mirror of https://github.com/GNOME/gimp.git
Bit of a large checkin this - it's basically three things: 1 - GimpModules
Sun Jan 11 00:24:21 GMT 1999 Austin Donnelly <austin@greenend.org.uk> Bit of a large checkin this - it's basically three things: 1 - GimpModules using gmodules to dynamically load and initialise modules at gimp start of day. 2 - Color selectors now register themselves with a color notebook. 3 - progress bars have been cleaned up a bit, so now have progress indictations on all transform tool and gradient fill operations. Not done bucket fill, but that seems to be the next candidate. New directories: * modules/: new directory for dynamically loadable modules. New files: * modules/.cvsignore * modules/Makefile.am * modules/colorsel_gtk.c: GTK color selector wrapped up as a color selector the gimp can use. * app/gimpprogress.[ch]: progress bars within gimp core, either as popups, or in the status bar. This is mainly code moved out of plug-in.c * app/color_notebook.[ch]: color selector notebook, implementing very similar interface to color_select.h so it can be used as a drop-in replacement for it. * libgimp/color_selector.h: API color selectors need to implement to become a page in the color_notebook. * libgimp/gimpmodule.h: API gimp modules need to implement to be initialised by gimp at start of day. Modified files: * Makefile.am: add modules/ to SUBDIRS * libgimp/Makefile.am: install gimpmodule.h and color_selector.h * app/gimprc.[ch]: recognise module-path variable. * gimprc.in: set module-path variable to something sensible (currently "${gimp_dir}/modules:${gimp_plugin_dir}/modules"). * app/Makefile.am: build color notebook and gimpprogress * app/app_procs.c: register internal GIMP color selector with color notebook. * app/asupsample.c: call progress function less frequently for better performance. * app/asupsample.h: progress_func_t typedef moved to gimpprogress.h * app/blend.c: make callbacks to a progress function * app/color_area.c: use a color notebook rather than a color selector * app/color_panel.c: ditto * app/color_select.c: export color selector interface for notebook * app/color_select.h: color_select_init() prototype * app/flip_tool.c: flip the image every time, rather than every second click. * app/interface.c: move progress bar stuff out to gimpprogress.c. Make the code actually work while we're at it. * app/interface.h: move prototypes for progress functions out to gimpprogress.h * app/plug_in.c: load and initialise modules (if possible). Move progress bar handling code out to gimpprogress.c * app/plug_in.h: keep only a gimp_progress * for each plugin, not a whole bunch of GtkWidgets. * app/scale_tool.c * app/rotate_tool.c * app/shear_tool.c * app/perspective_tool.c: progress bar during operation. De-sensitise the dialog to discourage the user from running two transforms in parallel. * app/transform_core.c: recalculate grid coords when bounding box changes. Only initialise the action area of the dialog once, to avoid multiple "ok" / "reset" buttons appearing. Undraw transform tool with correct matrix to get rid of handle remains on screen. Call a progress function as we apply the transform matrix. A few new i18n markups. Invalidate floating selection marching ants after applying matrix. * app/transform_core.h: transform_core_do() takes an optional progress callback argument (and data). * plug-ins/oilify/oilify.c: send progress bar updates after every pixel region, not only if they processed a multiple of 5 pixels (which was quite unlikely, and therefore gave a jerky progress indication).
This commit is contained in:
parent
bf0dbb2018
commit
d8be79f036
82
ChangeLog
82
ChangeLog
|
@ -1,3 +1,85 @@
|
|||
Sun Jan 11 00:24:21 GMT 1999 Austin Donnelly <austin@greenend.org.uk>
|
||||
|
||||
Bit of a large checkin this - it's basically three things:
|
||||
1 - GimpModules using gmodules to dynamically load and
|
||||
initialise modules at gimp start of day.
|
||||
2 - Color selectors now register themselves with a color
|
||||
notebook.
|
||||
3 - progress bars have been cleaned up a bit, so now have
|
||||
progress indictations on all transform tool and gradient
|
||||
fill operations. Not done bucket fill, but that seems to
|
||||
be the next candidate.
|
||||
|
||||
New directories:
|
||||
* modules/: new directory for dynamically loadable modules.
|
||||
|
||||
New files:
|
||||
* modules/.cvsignore
|
||||
* modules/Makefile.am
|
||||
* modules/colorsel_gtk.c: GTK color selector wrapped up as a
|
||||
color selector the gimp can use.
|
||||
|
||||
* app/gimpprogress.[ch]: progress bars within gimp core, either as
|
||||
popups, or in the status bar. This is mainly code moved out
|
||||
of plug-in.c
|
||||
|
||||
* app/color_notebook.[ch]: color selector notebook, implementing
|
||||
very similar interface to color_select.h so it can be used as
|
||||
a drop-in replacement for it.
|
||||
|
||||
* libgimp/color_selector.h: API color selectors need to implement
|
||||
to become a page in the color_notebook.
|
||||
|
||||
* libgimp/gimpmodule.h: API gimp modules need to implement to be
|
||||
initialised by gimp at start of day.
|
||||
|
||||
Modified files:
|
||||
* Makefile.am: add modules/ to SUBDIRS
|
||||
* libgimp/Makefile.am: install gimpmodule.h and color_selector.h
|
||||
* app/gimprc.[ch]: recognise module-path variable.
|
||||
* gimprc.in: set module-path variable to something sensible
|
||||
(currently "${gimp_dir}/modules:${gimp_plugin_dir}/modules").
|
||||
* app/Makefile.am: build color notebook and gimpprogress
|
||||
* app/app_procs.c: register internal GIMP color selector with
|
||||
color notebook.
|
||||
* app/asupsample.c: call progress function less frequently for
|
||||
better performance.
|
||||
* app/asupsample.h: progress_func_t typedef moved to gimpprogress.h
|
||||
* app/blend.c: make callbacks to a progress function
|
||||
* app/color_area.c: use a color notebook rather than a color selector
|
||||
* app/color_panel.c: ditto
|
||||
* app/color_select.c: export color selector interface for notebook
|
||||
* app/color_select.h: color_select_init() prototype
|
||||
* app/flip_tool.c: flip the image every time, rather than every
|
||||
second click.
|
||||
* app/interface.c: move progress bar stuff out to
|
||||
gimpprogress.c. Make the code actually work while we're at it.
|
||||
* app/interface.h: move prototypes for progress functions out to
|
||||
gimpprogress.h
|
||||
* app/plug_in.c: load and initialise modules (if possible). Move
|
||||
progress bar handling code out to gimpprogress.c
|
||||
* app/plug_in.h: keep only a gimp_progress * for each plugin, not
|
||||
a whole bunch of GtkWidgets.
|
||||
* app/scale_tool.c
|
||||
* app/rotate_tool.c
|
||||
* app/shear_tool.c
|
||||
* app/perspective_tool.c: progress bar during operation.
|
||||
De-sensitise the dialog to discourage the user from running
|
||||
two transforms in parallel.
|
||||
* app/transform_core.c: recalculate grid coords when bounding box
|
||||
changes. Only initialise the action area of the dialog once,
|
||||
to avoid multiple "ok" / "reset" buttons appearing. Undraw
|
||||
transform tool with correct matrix to get rid of handle
|
||||
remains on screen. Call a progress function as we apply the
|
||||
transform matrix. A few new i18n markups. Invalidate
|
||||
floating selection marching ants after applying matrix.
|
||||
* app/transform_core.h: transform_core_do() takes an optional
|
||||
progress callback argument (and data).
|
||||
* plug-ins/oilify/oilify.c: send progress bar updates after every
|
||||
pixel region, not only if they processed a multiple of 5
|
||||
pixels (which was quite unlikely, and therefore gave a jerky
|
||||
progress indication).
|
||||
|
||||
Sun Jan 10 23:31:45 GMT 1999 Adam D. Moss <adam@gimp.org>
|
||||
|
||||
* app/blend.c app/bucket_fill.c app/convert.c app/crop.c
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
SUBDIRS = po intl @GCG_SUBDIRS@ libgimp app plug-ins data @GIMPDOCS@
|
||||
SUBDIRS = po intl @GCG_SUBDIRS@ libgimp app plug-ins modules data @GIMPDOCS@
|
||||
|
||||
bin_SCRIPTS = gimptool
|
||||
|
||||
|
|
|
@ -77,6 +77,8 @@ gimp_SOURCES = \
|
|||
color_area.h \
|
||||
color_balance.c \
|
||||
color_balance.h \
|
||||
color_notebook.c \
|
||||
color_notebook.h \
|
||||
color_panel.c \
|
||||
color_panel.h \
|
||||
color_picker.c \
|
||||
|
@ -186,6 +188,8 @@ gimp_SOURCES = \
|
|||
gimplistP.h \
|
||||
gimpparasite.c \
|
||||
gimpparasite.h \
|
||||
gimpprogress.c \
|
||||
gimpprogress.h \
|
||||
gimprc.c \
|
||||
gimprc.h \
|
||||
global_edit.c \
|
||||
|
@ -370,8 +374,8 @@ LDADD = \
|
|||
libgimpim.a \
|
||||
$(top_builddir)/libgimp/libgimpi.a \
|
||||
$(GTK_LIBS) \
|
||||
$(GIMP_THREAD_LIBS) \
|
||||
$(INTLLIBS)
|
||||
$(GIMP_THREAD_LIBS) # \
|
||||
# $(INTLLIBS)
|
||||
|
||||
DEPS = \
|
||||
libgimpim.a \
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <unistd.h>
|
||||
#include "libgimp/parasite.h"
|
||||
#include "libgimp/parasiteP.h" /* ick */
|
||||
#include "libgimp/gimpmodule.h"
|
||||
|
||||
#ifdef HAVE_IPC_H
|
||||
#include <sys/ipc.h>
|
||||
|
@ -62,7 +63,7 @@
|
|||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#define SEPARATE_PROGRESS_BAR
|
||||
|
||||
|
||||
|
||||
typedef struct _PlugInBlocked PlugInBlocked;
|
||||
|
@ -126,8 +127,6 @@ static void plug_in_args_destroy (Argument *args,
|
|||
int nargs,
|
||||
int full_destroy);
|
||||
|
||||
static void plug_in_disconnect_cancel (PlugIn *plug_in);
|
||||
|
||||
static Argument* progress_init_invoker (Argument *args);
|
||||
static Argument* progress_update_invoker (Argument *args);
|
||||
|
||||
|
@ -138,6 +137,8 @@ static Argument* message_handler_set_invoker (Argument *args);
|
|||
|
||||
static Argument* plugin_temp_PDB_name_invoker (Argument *args);
|
||||
|
||||
static void module_initialize (char *filename);
|
||||
|
||||
|
||||
static GSList *plug_in_defs = NULL;
|
||||
static GSList *gimprc_proc_defs = NULL;
|
||||
|
@ -481,8 +482,79 @@ plug_in_init ()
|
|||
g_free (plug_in_def);
|
||||
}
|
||||
g_slist_free (plug_in_defs);
|
||||
|
||||
|
||||
/* Load and initialize gimp modules */
|
||||
|
||||
if (g_module_supported ())
|
||||
datafiles_read_directories (module_path,
|
||||
module_initialize, 0 /* no flags */);
|
||||
}
|
||||
|
||||
|
||||
/* name must be of the form lib*.so */
|
||||
/* TODO: need support for WIN32-style dll names. Maybe this function
|
||||
* should live in libgmodule? */
|
||||
static gboolean
|
||||
valid_module_name (const char *filename)
|
||||
{
|
||||
const char *basename;
|
||||
int len;
|
||||
|
||||
basename = strrchr (filename, '/');
|
||||
if (basename)
|
||||
basename++;
|
||||
else
|
||||
basename = filename;
|
||||
|
||||
len = strlen (basename);
|
||||
|
||||
if (len < 3 + 1 + 3)
|
||||
return FALSE;
|
||||
|
||||
if (strncmp (basename, "lib", 3))
|
||||
return FALSE;
|
||||
|
||||
if (strcmp (basename + len - 3, ".so"))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
module_initialize (char *filename)
|
||||
{
|
||||
GModule *mod;
|
||||
GimpModuleInitFunc init;
|
||||
gpointer symbol;
|
||||
|
||||
if (!valid_module_name (filename))
|
||||
return;
|
||||
|
||||
if ((be_verbose == TRUE) || (no_splash == TRUE))
|
||||
g_print (_("load module: \"%s\"\n"), filename);
|
||||
|
||||
mod = g_module_open (filename, G_MODULE_BIND_LAZY);
|
||||
if (!mod)
|
||||
{
|
||||
g_warning (_("module load error: %s: %s"), filename, g_module_error ());
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_module_symbol (mod, "module_init", &symbol))
|
||||
{
|
||||
init = symbol;
|
||||
if (init () == GIMP_MODULE_UNLOAD)
|
||||
g_module_close (mod);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning (_("%s: module_init() symbol not found"), filename);
|
||||
g_module_close (mod);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
plug_in_kill ()
|
||||
{
|
||||
|
@ -818,9 +890,6 @@ plug_in_new (char *name)
|
|||
plug_in->write_buffer_index = 0;
|
||||
plug_in->temp_proc_defs = NULL;
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
plug_in->progress_gdisp_ID = -1;
|
||||
plug_in->user_data = NULL;
|
||||
|
||||
return plug_in;
|
||||
|
@ -829,9 +898,6 @@ plug_in_new (char *name)
|
|||
void
|
||||
plug_in_destroy (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
guint c_id;
|
||||
|
||||
if (plug_in)
|
||||
{
|
||||
plug_in_close (plug_in, TRUE);
|
||||
|
@ -849,18 +915,9 @@ plug_in_destroy (PlugIn *plug_in)
|
|||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
c_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), c_id);
|
||||
gtk_progress_bar_update(GTK_PROGRESS_BAR(gdisp->progressbar), 0.0);
|
||||
|
||||
plug_in_disconnect_cancel (plug_in);
|
||||
|
||||
gdisp->progressid = 0;
|
||||
}
|
||||
if (plug_in->progress)
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
|
@ -1011,23 +1068,9 @@ plug_in_close (PlugIn *plug_in,
|
|||
|
||||
/* Destroy the progress dialog if it exists
|
||||
*/
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (plug_in->progress)
|
||||
{
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (plug_in->progress), plug_in);
|
||||
gtk_widget_destroy (plug_in->progress);
|
||||
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
}
|
||||
#else
|
||||
if (plug_in->progress)
|
||||
{
|
||||
progress_end ();
|
||||
plug_in->progress = NULL;
|
||||
}
|
||||
#endif
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
/* Set the fields to null values.
|
||||
*/
|
||||
|
@ -3089,32 +3132,15 @@ static void
|
|||
plug_in_progress_cancel (GtkWidget *widget,
|
||||
PlugIn *plug_in)
|
||||
{
|
||||
plug_in->progress = NULL;
|
||||
plug_in_destroy (plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_disconnect_cancel (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp = NULL;
|
||||
|
||||
gdisp = gdisplay_get_ID (plug_in->progress_gdisp_ID);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, FALSE);
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (gdisp->cancelbutton),
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_init (PlugIn *plug_in,
|
||||
char *message,
|
||||
gint gdisp_ID)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *button;
|
||||
GDisplay *gdisp = NULL;
|
||||
guint context_id;
|
||||
|
||||
if (!message)
|
||||
message = plug_in->args[0];
|
||||
|
@ -3122,100 +3148,22 @@ plug_in_progress_init (PlugIn *plug_in,
|
|||
if (gdisp_ID > 0)
|
||||
gdisp = gdisplay_get_ID(gdisp_ID);
|
||||
|
||||
if (gdisp_ID > 0 && GTK_WIDGET_VISIBLE (gdisp->statusarea)
|
||||
&& (gdisp->progressid == 0 || plug_in->progress_gdisp_ID > 0))
|
||||
{
|
||||
context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), context_id);
|
||||
|
||||
gdisp->progressid = gtk_statusbar_push(GTK_STATUSBAR(gdisp->statusbar),
|
||||
context_id, message);
|
||||
plug_in->progress_gdisp_ID = gdisp_ID;
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (gdisp->cancelbutton), "clicked",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, TRUE);
|
||||
}
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = gtk_dialog_new ();
|
||||
gtk_window_set_wmclass (GTK_WINDOW (plug_in->progress), "plug_in_progress", "Gimp");
|
||||
gtk_window_set_title (GTK_WINDOW (plug_in->progress), prune_filename (plug_in->args[0]));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (plug_in->progress), "destroy",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (plug_in->progress)->action_area), 2);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->vbox), vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
plug_in->progress_label = gtk_label_new (message);
|
||||
gtk_misc_set_alignment (GTK_MISC (plug_in->progress_label), 0.0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_label, FALSE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_label);
|
||||
|
||||
plug_in->progress_bar = gtk_progress_bar_new ();
|
||||
gtk_widget_set_usize (plug_in->progress_bar, 150, 20);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_bar, TRUE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_bar);
|
||||
|
||||
button = gtk_button_new_with_label (_("Cancel"));
|
||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) gtk_widget_destroy,
|
||||
GTK_OBJECT (plug_in->progress));
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->action_area), button, TRUE, TRUE, 0);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gtk_widget_show (plug_in->progress);
|
||||
}
|
||||
if (plug_in->progress)
|
||||
plug_in->progress = progress_restart (plug_in->progress, message,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
else
|
||||
{
|
||||
gtk_label_set (GTK_LABEL (plug_in->progress_label), message);
|
||||
}
|
||||
#else
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = 0x1;
|
||||
progress_update (0.0);
|
||||
progress_start ();
|
||||
}
|
||||
#endif
|
||||
plug_in->progress = progress_start (gdisp, message, TRUE,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_update (PlugIn *plug_in,
|
||||
double percentage)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update( GTK_PROGRESS_BAR (gdisp->progressbar), percentage);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (plug_in->progress_bar), percentage);
|
||||
#else
|
||||
progress_update (percentage);
|
||||
#endif
|
||||
}
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
progress_update (plug_in->progress, percentage);
|
||||
}
|
||||
|
||||
static Argument*
|
||||
|
|
|
@ -67,6 +67,9 @@
|
|||
#include "docindex.h"
|
||||
#include "colormap_dialog.h"
|
||||
|
||||
#include "color_notebook.h"
|
||||
#include "color_select.h"
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
@ -554,6 +557,9 @@ app_init (void)
|
|||
get_active_pattern ();
|
||||
paint_funcs_setup ();
|
||||
|
||||
/* register internal color selectors */
|
||||
color_select_init ();
|
||||
|
||||
if (no_interface == FALSE)
|
||||
{
|
||||
devices_restore(); /* Must be done AFTER get_active_{brush|pattern}
|
||||
|
|
|
@ -193,7 +193,7 @@ adaptive_supersample_area(int x1, int y1, int x2, int y2, int max_depth, double
|
|||
|
||||
/* Call progress display function */
|
||||
|
||||
if (progress_func)
|
||||
if (progress_func && !(y & 0xf))
|
||||
(*progress_func)(y1, y2, y, progress_data);
|
||||
} /* for */
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#ifndef __ASUPSAMPLE_H__
|
||||
#define __ASUPSAMPLE_H__
|
||||
|
||||
#include "gimpprogress.h"
|
||||
|
||||
/***** Types *****/
|
||||
|
||||
|
@ -33,7 +34,6 @@ typedef struct {
|
|||
|
||||
typedef void (*render_func_t) (double x, double y, color_t *color, void *render_data);
|
||||
typedef void (*put_pixel_func_t) (int x, int y, color_t color, void *put_pixel_data);
|
||||
typedef void (*progress_func_t) (int y1, int y2, int curr_y, void *progress_data);
|
||||
|
||||
|
||||
/***** Functions *****/
|
||||
|
|
124
app/blend.c
124
app/blend.c
|
@ -161,7 +161,9 @@ static void blend (GImage *gimage, GimpDrawable *drawa
|
|||
RepeatMode repeat,
|
||||
int supersample, int max_depth, double threshold,
|
||||
double startx, double starty,
|
||||
double endx, double endy);
|
||||
double endx, double endy,
|
||||
progress_func_t progress_callback,
|
||||
void *progress_data);
|
||||
|
||||
static double gradient_calc_conical_sym_factor (double dist, double *axis, double offset,
|
||||
double x, double y);
|
||||
|
@ -195,7 +197,9 @@ static void gradient_fill_region (GImage *gimage, GimpDrawable *drawa
|
|||
BlendMode blend_mode, GradientType gradient_type,
|
||||
double offset, RepeatMode repeat,
|
||||
int supersample, int max_depth, double threshold,
|
||||
double sx, double sy, double ex, double ey);
|
||||
double sx, double sy, double ex, double ey,
|
||||
progress_func_t progress_callback,
|
||||
void *progress_data);
|
||||
|
||||
static void calc_rgb_to_hsv(double *r, double *g, double *b);
|
||||
static void calc_hsv_to_rgb(double *h, double *s, double *v);
|
||||
|
@ -606,8 +610,12 @@ blend_button_release (Tool *tool,
|
|||
GDisplay * gdisp;
|
||||
GImage * gimage;
|
||||
BlendTool * blend_tool;
|
||||
#ifdef BLEND_UI_CALLS_VIA_PDB
|
||||
Argument *return_vals;
|
||||
int nreturn_vals;
|
||||
#else
|
||||
gimp_progress *progress;
|
||||
#endif
|
||||
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
gimage = gdisp->gimage;
|
||||
|
@ -626,6 +634,9 @@ blend_button_release (Tool *tool,
|
|||
((blend_tool->startx != blend_tool->endx) ||
|
||||
(blend_tool->starty != blend_tool->endy)))
|
||||
{
|
||||
/* we can't do callbacks easily with the PDB, so this UI/backend
|
||||
* separation (though good) is ignored for the moment */
|
||||
#ifdef BLEND_UI_CALLS_VIA_PDB
|
||||
return_vals = procedural_db_run_proc ("gimp_blend",
|
||||
&nreturn_vals,
|
||||
PDB_DRAWABLE, drawable_ID (gimage_active_drawable (gimage)),
|
||||
|
@ -650,6 +661,33 @@ blend_button_release (Tool *tool,
|
|||
g_message (_("Blend operation failed."));
|
||||
|
||||
procedural_db_destroy_args (return_vals, nreturn_vals);
|
||||
|
||||
#else /* ! BLEND_UI_CALLS_VIA_PDB */
|
||||
|
||||
progress = progress_start (gdisp, _("Blending..."), FALSE, NULL, NULL);
|
||||
|
||||
blend (gimage,
|
||||
gimage_active_drawable (gimage),
|
||||
blend_options->blend_mode,
|
||||
blend_options->paint_mode,
|
||||
blend_options->gradient_type,
|
||||
blend_options->opacity,
|
||||
blend_options->offset,
|
||||
blend_options->repeat,
|
||||
blend_options->supersample,
|
||||
blend_options->max_depth,
|
||||
blend_options->threshold,
|
||||
blend_tool->startx,
|
||||
blend_tool->starty,
|
||||
blend_tool->endx,
|
||||
blend_tool->endy,
|
||||
progress? progress_update_and_flush : NULL, progress);
|
||||
|
||||
if (progress)
|
||||
progress_end (progress);
|
||||
|
||||
gdisplays_flush ();
|
||||
#endif /* ! BLEND_UI_CALLS_VIA_PDB */
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -766,21 +804,23 @@ blend_control (Tool *tool,
|
|||
|
||||
/* The actual blending procedure */
|
||||
static void
|
||||
blend (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
BlendMode blend_mode,
|
||||
int paint_mode,
|
||||
GradientType gradient_type,
|
||||
double opacity,
|
||||
double offset,
|
||||
RepeatMode repeat,
|
||||
int supersample,
|
||||
int max_depth,
|
||||
double threshold,
|
||||
double startx,
|
||||
double starty,
|
||||
double endx,
|
||||
double endy)
|
||||
blend (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
BlendMode blend_mode,
|
||||
int paint_mode,
|
||||
GradientType gradient_type,
|
||||
double opacity,
|
||||
double offset,
|
||||
RepeatMode repeat,
|
||||
int supersample,
|
||||
int max_depth,
|
||||
double threshold,
|
||||
double startx,
|
||||
double starty,
|
||||
double endx,
|
||||
double endy,
|
||||
progress_func_t progress_callback,
|
||||
void *progress_data)
|
||||
{
|
||||
TileManager *buf_tiles;
|
||||
PixelRegion bufPR;
|
||||
|
@ -811,7 +851,8 @@ blend (GImage *gimage,
|
|||
blend_mode, gradient_type, offset, repeat,
|
||||
supersample, max_depth, threshold,
|
||||
(startx - x1), (starty - y1),
|
||||
(endx - x1), (endy - y1));
|
||||
(endx - x1), (endy - y1),
|
||||
progress_callback, progress_data);
|
||||
|
||||
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), FALSE);
|
||||
gimage_apply_image (gimage, drawable, &bufPR, TRUE,
|
||||
|
@ -1375,23 +1416,26 @@ gradient_put_pixel(int x, int y, color_t color, void *put_pixel_data)
|
|||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
gradient_fill_region (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
PixelRegion *PR,
|
||||
int width,
|
||||
int height,
|
||||
BlendMode blend_mode,
|
||||
GradientType gradient_type,
|
||||
double offset,
|
||||
RepeatMode repeat,
|
||||
int supersample,
|
||||
int max_depth,
|
||||
double threshold,
|
||||
double sx,
|
||||
double sy,
|
||||
double ex,
|
||||
double ey)
|
||||
gradient_fill_region (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
PixelRegion *PR,
|
||||
int width,
|
||||
int height,
|
||||
BlendMode blend_mode,
|
||||
GradientType gradient_type,
|
||||
double offset,
|
||||
RepeatMode repeat,
|
||||
int supersample,
|
||||
int max_depth,
|
||||
double threshold,
|
||||
double sx,
|
||||
double sy,
|
||||
double ex,
|
||||
double ey,
|
||||
progress_func_t progress_callback,
|
||||
void *progress_data)
|
||||
{
|
||||
RenderBlendData rbd;
|
||||
PutPixelData ppd;
|
||||
|
@ -1536,7 +1580,7 @@ gradient_fill_region (GImage *gimage,
|
|||
max_depth, threshold,
|
||||
gradient_render_pixel, &rbd,
|
||||
gradient_put_pixel, &ppd,
|
||||
NULL, NULL);
|
||||
progress_callback, progress_data);
|
||||
|
||||
/* Clean up */
|
||||
|
||||
|
@ -1544,6 +1588,9 @@ gradient_fill_region (GImage *gimage,
|
|||
}
|
||||
else
|
||||
{
|
||||
int max_progress = PR->w * PR->h;
|
||||
int progress = 0;
|
||||
|
||||
for (pr = pixel_regions_register(1, PR); pr != NULL; pr = pixel_regions_process(pr))
|
||||
{
|
||||
data = PR->data;
|
||||
|
@ -1572,6 +1619,10 @@ gradient_fill_region (GImage *gimage,
|
|||
*data++ = color.a * 255.0;
|
||||
}
|
||||
}
|
||||
|
||||
progress += PR->w * PR->h;
|
||||
if (progress_callback)
|
||||
(*progress_callback) (0, max_progress, progress, progress_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1992,7 +2043,8 @@ blend_invoker (Argument *args)
|
|||
if (success)
|
||||
{
|
||||
blend (gimage, drawable, blend_mode, paint_mode, gradient_type,
|
||||
opacity, offset, repeat, supersample, max_depth, threshold, x1, y1, x2, y2);
|
||||
opacity, offset, repeat, supersample, max_depth, threshold,
|
||||
x1, y1, x2, y2, NULL, NULL);
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&blend_proc, success);
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <stdlib.h>
|
||||
#include "appenv.h"
|
||||
#include "color_area.h"
|
||||
#include "color_select.h"
|
||||
#include "color_notebook.h"
|
||||
#include "colormaps.h"
|
||||
#include "palette.h"
|
||||
|
||||
|
@ -37,8 +37,8 @@ static GtkWidget *color_area = NULL;
|
|||
static GdkPixmap *color_area_pixmap = NULL;
|
||||
static GdkPixmap *default_pixmap = NULL;
|
||||
static GdkPixmap *swap_pixmap = NULL;
|
||||
static ColorSelectP color_select = NULL;
|
||||
static int color_select_active = 0;
|
||||
static ColorNotebookP color_notebook = NULL;
|
||||
static int color_notebook_active = 0;
|
||||
static int edit_color;
|
||||
static unsigned char revert_fg_r, revert_fg_g, revert_fg_b;
|
||||
static unsigned char revert_bg_r, revert_bg_g, revert_bg_b;
|
||||
|
@ -195,25 +195,25 @@ static void
|
|||
color_area_select_callback (int r,
|
||||
int g,
|
||||
int b,
|
||||
ColorSelectState state,
|
||||
ColorNotebookState state,
|
||||
void *client_data)
|
||||
{
|
||||
if (color_select)
|
||||
if (color_notebook)
|
||||
{
|
||||
switch (state) {
|
||||
case COLOR_SELECT_OK:
|
||||
color_select_hide (color_select);
|
||||
color_select_active = 0;
|
||||
case COLOR_NOTEBOOK_OK:
|
||||
color_notebook_hide (color_notebook);
|
||||
color_notebook_active = 0;
|
||||
/* Fallthrough */
|
||||
case COLOR_SELECT_UPDATE:
|
||||
case COLOR_NOTEBOOK_UPDATE:
|
||||
if (edit_color == FOREGROUND)
|
||||
palette_set_foreground (r, g, b);
|
||||
else
|
||||
palette_set_background (r, g, b);
|
||||
break;
|
||||
case COLOR_SELECT_CANCEL:
|
||||
color_select_hide (color_select);
|
||||
color_select_active = 0;
|
||||
case COLOR_NOTEBOOK_CANCEL:
|
||||
color_notebook_hide (color_notebook);
|
||||
color_notebook_active = 0;
|
||||
palette_set_foreground (revert_fg_r, revert_fg_g, revert_fg_b);
|
||||
palette_set_background (revert_bg_r, revert_bg_g, revert_bg_b);
|
||||
}
|
||||
|
@ -225,7 +225,7 @@ color_area_edit (void)
|
|||
{
|
||||
unsigned char r, g, b;
|
||||
|
||||
if (!color_select_active)
|
||||
if (!color_notebook_active)
|
||||
{
|
||||
palette_get_foreground (&revert_fg_r, &revert_fg_g, &revert_fg_b);
|
||||
palette_get_background (&revert_bg_r, &revert_bg_g, &revert_bg_b);
|
||||
|
@ -241,19 +241,19 @@ color_area_edit (void)
|
|||
edit_color = BACKGROUND;
|
||||
}
|
||||
|
||||
if (! color_select)
|
||||
if (! color_notebook)
|
||||
{
|
||||
color_select = color_select_new (r, g, b, color_area_select_callback, NULL, TRUE);
|
||||
color_select_active = 1;
|
||||
color_notebook = color_notebook_new (r, g, b, color_area_select_callback, NULL, TRUE);
|
||||
color_notebook_active = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! color_select_active)
|
||||
color_select_show (color_select);
|
||||
if (! color_notebook_active)
|
||||
color_notebook_show (color_notebook);
|
||||
else
|
||||
gdk_window_raise (color_select->shell->window);
|
||||
gdk_window_raise (color_notebook->shell->window);
|
||||
|
||||
color_select_set_color (color_select, r, g, b, 1);
|
||||
color_notebook_set_color (color_notebook, r, g, b, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,459 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* color_notebook module (C) 1998 Austin Donnelly <austin@greenend.org.uk>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "appenv.h"
|
||||
#include "actionarea.h"
|
||||
#include "color_notebook.h"
|
||||
|
||||
#include "libgimp/color_selector.h"
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
|
||||
static void color_notebook_ok_callback (GtkWidget *, gpointer);
|
||||
static void color_notebook_cancel_callback (GtkWidget *, gpointer);
|
||||
static gint color_notebook_delete_callback (GtkWidget *, GdkEvent *, gpointer);
|
||||
static void color_notebook_update_callback (void *, int, int, int);
|
||||
static void color_notebook_page_switch (GtkWidget *, GtkNotebookPage *, guint);
|
||||
|
||||
|
||||
static ActionAreaItem action_items[2] =
|
||||
{
|
||||
{ N_("OK"), color_notebook_ok_callback, NULL, NULL },
|
||||
{ N_("Cancel"), color_notebook_cancel_callback, NULL, NULL },
|
||||
};
|
||||
|
||||
|
||||
/* information we keep on each registered colour selector */
|
||||
typedef struct _ColorSelectorInfo {
|
||||
char *name; /* label used in notebook tab */
|
||||
GimpColorSelectorMethods m;
|
||||
int refs; /* number of instances around */
|
||||
gboolean active;
|
||||
void (*death_callback) (void *data);
|
||||
void *death_data;
|
||||
struct _ColorSelectorInfo *next;
|
||||
} ColorSelectorInfo;
|
||||
|
||||
typedef struct _ColorSelectorInstance {
|
||||
_ColorNotebook *color_notebook;
|
||||
ColorSelectorInfo *info;
|
||||
GtkWidget *frame; /* main widget */
|
||||
gpointer selector_data;
|
||||
struct _ColorSelectorInstance *next;
|
||||
} ColorSelectorInstance;
|
||||
|
||||
static void selector_death (ColorSelectorInfo *info);
|
||||
|
||||
|
||||
/* master list of all registered colour selectors */
|
||||
static ColorSelectorInfo *selector_info = NULL;
|
||||
|
||||
|
||||
#define RED 0
|
||||
#define GREEN 1
|
||||
#define BLUE 2
|
||||
#define NUM_COLORS 3
|
||||
|
||||
|
||||
ColorNotebookP
|
||||
color_notebook_new (int r,
|
||||
int g,
|
||||
int b,
|
||||
ColorNotebookCallback callback,
|
||||
void *client_data,
|
||||
int wants_updates)
|
||||
{
|
||||
ColorNotebookP cnp;
|
||||
GtkWidget *label;
|
||||
ColorSelectorInfo *info;
|
||||
ColorSelectorInstance *csel;
|
||||
|
||||
g_return_val_if_fail (selector_info != NULL, NULL);
|
||||
|
||||
cnp = g_malloc (sizeof (_ColorNotebook));
|
||||
|
||||
cnp->callback = callback;
|
||||
cnp->client_data = client_data;
|
||||
cnp->wants_updates = wants_updates;
|
||||
cnp->selectors = NULL;
|
||||
cnp->cur_page = NULL;
|
||||
|
||||
cnp->values[RED] = cnp->orig_values[RED] = r & 0xff;
|
||||
cnp->values[GREEN] = cnp->orig_values[GREEN] = g & 0xff;
|
||||
cnp->values[BLUE] = cnp->orig_values[BLUE] = b & 0xff;
|
||||
|
||||
/* window hints need to stay the same, so people's window manager
|
||||
* setups still work */
|
||||
cnp->shell = gtk_dialog_new ();
|
||||
gtk_window_set_wmclass (GTK_WINDOW (cnp->shell), "color_selection", "Gimp");
|
||||
gtk_window_set_title (GTK_WINDOW (cnp->shell), _("Color Selection"));
|
||||
gtk_window_set_policy (GTK_WINDOW (cnp->shell), FALSE, FALSE, FALSE);
|
||||
|
||||
/* handle the wm close signal */
|
||||
gtk_signal_connect (GTK_OBJECT (cnp->shell), "delete_event",
|
||||
(GtkSignalFunc) color_notebook_delete_callback, cnp);
|
||||
|
||||
/* do we actually need a notebook? */
|
||||
if (selector_info->next)
|
||||
{
|
||||
cnp->notebook = gtk_notebook_new ();
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (cnp->shell)->vbox),
|
||||
cnp->notebook, TRUE, TRUE, 1);
|
||||
gtk_widget_show (cnp->notebook);
|
||||
}
|
||||
else /* only one selector */
|
||||
{
|
||||
cnp->notebook = NULL;
|
||||
}
|
||||
|
||||
/* create each registered colour selector */
|
||||
info = selector_info;
|
||||
while (info)
|
||||
{
|
||||
if (info->active)
|
||||
{
|
||||
|
||||
csel = g_malloc (sizeof (ColorSelectorInstance));
|
||||
csel->color_notebook = cnp;
|
||||
csel->info = info;
|
||||
info->refs++;
|
||||
csel->frame = info->m.new (r, g, b,
|
||||
color_notebook_update_callback, csel,
|
||||
&csel->selector_data);
|
||||
gtk_object_set_data (GTK_OBJECT (csel->frame), "gimp_color_notebook",
|
||||
csel);
|
||||
|
||||
if (cnp->notebook)
|
||||
{
|
||||
label = gtk_label_new (info->name);
|
||||
gtk_widget_show (label);
|
||||
gtk_notebook_append_page (GTK_NOTEBOOK (cnp->notebook),
|
||||
csel->frame, label);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (cnp->shell)->vbox),
|
||||
csel->frame, TRUE, TRUE, 1);
|
||||
}
|
||||
|
||||
gtk_widget_show (csel->frame);
|
||||
|
||||
if (!cnp->cur_page)
|
||||
cnp->cur_page = csel;
|
||||
|
||||
/* link into list of all selectors hanging off the new notebook */
|
||||
csel->next = cnp->selectors;
|
||||
cnp->selectors = csel;
|
||||
}
|
||||
|
||||
info = info->next;
|
||||
}
|
||||
|
||||
/* The action area */
|
||||
action_items[0].user_data = cnp;
|
||||
action_items[1].user_data = cnp;
|
||||
if (cnp->wants_updates)
|
||||
{
|
||||
action_items[0].label = _("Close");
|
||||
action_items[1].label = _("Revert to Old Color");
|
||||
}
|
||||
else
|
||||
{
|
||||
action_items[0].label = _("OK");
|
||||
action_items[1].label = _("Cancel");
|
||||
}
|
||||
build_action_area (GTK_DIALOG (cnp->shell), action_items, 2, 0);
|
||||
|
||||
gtk_widget_show (cnp->shell);
|
||||
|
||||
/* this must come after showing the widget, otherwise we get a
|
||||
* switch_page signal for a non-visible color selector, which is bad
|
||||
* news. */
|
||||
if (cnp->notebook)
|
||||
{
|
||||
gtk_object_set_user_data (GTK_OBJECT (cnp->notebook), cnp);
|
||||
gtk_signal_connect (GTK_OBJECT (cnp->notebook), "switch_page",
|
||||
(GtkSignalFunc)color_notebook_page_switch, NULL);
|
||||
}
|
||||
|
||||
return cnp;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
color_notebook_show (ColorNotebookP cnp)
|
||||
{
|
||||
g_return_if_fail (cnp != NULL);
|
||||
gtk_widget_show (cnp->shell);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
color_notebook_hide (ColorNotebookP cnp)
|
||||
{
|
||||
g_return_if_fail (cnp != NULL);
|
||||
gtk_widget_hide (cnp->shell);
|
||||
}
|
||||
|
||||
void
|
||||
color_notebook_free (ColorNotebookP cnp)
|
||||
{
|
||||
ColorSelectorInstance *csel, *next;
|
||||
|
||||
g_return_if_fail (cnp != NULL);
|
||||
|
||||
gtk_widget_destroy (cnp->shell);
|
||||
|
||||
/* call the free functions for all the colour selectors */
|
||||
csel = cnp->selectors;
|
||||
while (csel)
|
||||
{
|
||||
next = csel->next;
|
||||
|
||||
csel->info->m.free (csel->selector_data);
|
||||
|
||||
csel->info->refs--;
|
||||
if (csel->info->refs == 0 && !csel->info->active)
|
||||
selector_death (csel->info);
|
||||
|
||||
g_free (csel);
|
||||
csel = next;
|
||||
}
|
||||
|
||||
g_free (cnp);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
color_notebook_set_color (ColorNotebookP cnp,
|
||||
int r,
|
||||
int g,
|
||||
int b,
|
||||
int set_current)
|
||||
{
|
||||
ColorSelectorInstance *csel;
|
||||
g_return_if_fail (cnp != NULL);
|
||||
|
||||
cnp->orig_values[RED] = r;
|
||||
cnp->orig_values[GREEN] = g;
|
||||
cnp->orig_values[BLUE] = b;
|
||||
|
||||
if (set_current)
|
||||
{
|
||||
cnp->values[RED] = r;
|
||||
cnp->values[GREEN] = g;
|
||||
cnp->values[BLUE] = b;
|
||||
}
|
||||
|
||||
csel = cnp->cur_page;
|
||||
csel->info->m.setcolor (csel->selector_data, r, g, b, set_current);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Called by a colour selector on user selection of a colour */
|
||||
static void
|
||||
color_notebook_update_callback (void *data, int r, int g, int b)
|
||||
{
|
||||
ColorSelectorInstance *csel;
|
||||
ColorNotebookP cnp;
|
||||
|
||||
g_return_if_fail (data != NULL);
|
||||
|
||||
csel = (ColorSelectorInstance *) data;
|
||||
cnp = csel->color_notebook;
|
||||
|
||||
cnp->values[RED] = r;
|
||||
cnp->values[GREEN] = g;
|
||||
cnp->values[BLUE] = b;
|
||||
|
||||
if (cnp->wants_updates && cnp->callback)
|
||||
{
|
||||
(* cnp->callback) (cnp->values[RED],
|
||||
cnp->values[GREEN],
|
||||
cnp->values[BLUE],
|
||||
COLOR_NOTEBOOK_UPDATE,
|
||||
cnp->client_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void
|
||||
color_notebook_ok_callback (GtkWidget *w,
|
||||
gpointer client_data)
|
||||
{
|
||||
ColorNotebookP cnp;
|
||||
|
||||
cnp = (ColorNotebookP) client_data;
|
||||
|
||||
if (cnp->callback)
|
||||
(* cnp->callback) (cnp->values[RED],
|
||||
cnp->values[GREEN],
|
||||
cnp->values[BLUE],
|
||||
COLOR_NOTEBOOK_OK,
|
||||
cnp->client_data);
|
||||
}
|
||||
|
||||
|
||||
static gint
|
||||
color_notebook_delete_callback (GtkWidget *w,
|
||||
GdkEvent *e,
|
||||
gpointer client_data)
|
||||
{
|
||||
color_notebook_cancel_callback (w, client_data);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
color_notebook_cancel_callback (GtkWidget *w,
|
||||
gpointer client_data)
|
||||
{
|
||||
ColorNotebookP cnp;
|
||||
|
||||
cnp = (ColorNotebookP) client_data;
|
||||
|
||||
if (cnp->callback)
|
||||
(* cnp->callback) (cnp->orig_values[RED],
|
||||
cnp->orig_values[GREEN],
|
||||
cnp->orig_values[BLUE],
|
||||
COLOR_NOTEBOOK_CANCEL,
|
||||
cnp->client_data);
|
||||
}
|
||||
|
||||
static void
|
||||
color_notebook_page_switch (GtkWidget *w,
|
||||
GtkNotebookPage *page,
|
||||
guint page_num)
|
||||
{
|
||||
ColorNotebookP cnp;
|
||||
ColorSelectorInstance *csel;
|
||||
|
||||
cnp = gtk_object_get_user_data (GTK_OBJECT (w));
|
||||
csel = gtk_object_get_data (GTK_OBJECT(page->child), "gimp_color_notebook");
|
||||
|
||||
g_return_if_fail (cnp != NULL && csel != NULL);
|
||||
|
||||
cnp->cur_page = csel;
|
||||
csel->info->m.setcolor (csel->selector_data,
|
||||
cnp->values[RED],
|
||||
cnp->values[GREEN],
|
||||
cnp->values[BLUE],
|
||||
TRUE);
|
||||
}
|
||||
|
||||
/**************************************************************/
|
||||
/* Registration functions */
|
||||
|
||||
|
||||
GimpColorSelectorID
|
||||
gimp_color_selector_register (const char *name,
|
||||
GimpColorSelectorMethods *methods)
|
||||
{
|
||||
ColorSelectorInfo *info;
|
||||
|
||||
/* check the name is unique */
|
||||
info = selector_info;
|
||||
while (info)
|
||||
{
|
||||
if (!strcmp (info->name, name))
|
||||
return NULL;
|
||||
info = info->next;
|
||||
}
|
||||
|
||||
info = g_malloc (sizeof (ColorSelectorInfo));
|
||||
|
||||
info->name = g_strdup (name);
|
||||
info->m = *methods;
|
||||
info->refs = 0;
|
||||
info->active = TRUE;
|
||||
|
||||
info->next = selector_info;
|
||||
selector_info = info;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
gimp_color_selector_unregister (GimpColorSelectorID id,
|
||||
void (*callback)(void *data),
|
||||
void *data)
|
||||
{
|
||||
ColorSelectorInfo *info;
|
||||
|
||||
info = selector_info;
|
||||
while (info)
|
||||
{
|
||||
if (info == id)
|
||||
{
|
||||
info->active = FALSE;
|
||||
info->death_callback = callback;
|
||||
info->death_data = data;
|
||||
if (info->refs == 0)
|
||||
selector_death (info);
|
||||
return TRUE;
|
||||
}
|
||||
info = info->next;
|
||||
}
|
||||
|
||||
g_warning ("unknown color selector id %p", id);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
selector_death (ColorSelectorInfo *info)
|
||||
{
|
||||
ColorSelectorInfo *here, *prev;
|
||||
|
||||
here = selector_info;
|
||||
prev = NULL;
|
||||
while (here)
|
||||
{
|
||||
if (here == info)
|
||||
{
|
||||
if (prev)
|
||||
prev->next = info->next;
|
||||
else
|
||||
selector_info = info->next;
|
||||
|
||||
if (info->death_callback)
|
||||
(*info->death_callback) (info->death_data);
|
||||
|
||||
g_free (info->name);
|
||||
g_free (info);
|
||||
|
||||
return;
|
||||
}
|
||||
prev = here;
|
||||
here = here->next;
|
||||
}
|
||||
|
||||
g_warning ("color selector %p not found, can't happen!", info);
|
||||
}
|
||||
|
||||
|
||||
/* End of color_notebook.c */
|
|
@ -0,0 +1,53 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __COLOR_NOTEBOOK_H__
|
||||
#define __COLOR_NOTEBOOK_H__
|
||||
|
||||
typedef enum {
|
||||
COLOR_NOTEBOOK_OK,
|
||||
COLOR_NOTEBOOK_CANCEL,
|
||||
COLOR_NOTEBOOK_UPDATE
|
||||
} ColorNotebookState;
|
||||
|
||||
typedef struct _ColorNotebook _ColorNotebook, *ColorNotebookP;
|
||||
typedef void (*ColorNotebookCallback) (int, int, int, ColorNotebookState,
|
||||
void *);
|
||||
|
||||
struct _ColorSelectorInstance;
|
||||
|
||||
struct _ColorNotebook {
|
||||
GtkWidget *shell;
|
||||
GtkWidget *notebook;
|
||||
int values[3];
|
||||
int orig_values[3];
|
||||
ColorNotebookCallback callback;
|
||||
void *client_data;
|
||||
int wants_updates;
|
||||
struct _ColorSelectorInstance *selectors;
|
||||
struct _ColorSelectorInstance *cur_page;
|
||||
};
|
||||
|
||||
ColorNotebookP color_notebook_new (int, int, int, ColorNotebookCallback, void *, int);
|
||||
void color_notebook_show (ColorNotebookP);
|
||||
void color_notebook_hide (ColorNotebookP);
|
||||
void color_notebook_free (ColorNotebookP);
|
||||
void color_notebook_set_color (ColorNotebookP, int, int, int, int);
|
||||
|
||||
|
||||
#endif /* __COLOR_NOTEBOOK_H__ */
|
|
@ -20,7 +20,7 @@
|
|||
#include <stdlib.h>
|
||||
#include "appenv.h"
|
||||
#include "color_panel.h"
|
||||
#include "color_select.h"
|
||||
#include "color_notebook.h"
|
||||
#include "colormaps.h"
|
||||
|
||||
#define EVENT_MASK GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK
|
||||
|
@ -32,13 +32,13 @@ struct _ColorPanelPrivate
|
|||
GtkWidget *drawing_area;
|
||||
GdkGC *gc;
|
||||
|
||||
ColorSelectP color_select;
|
||||
int color_select_active;
|
||||
ColorNotebookP color_notebook;
|
||||
int color_notebook_active;
|
||||
};
|
||||
|
||||
static void color_panel_draw (ColorPanel *);
|
||||
static gint color_panel_events (GtkWidget *area, GdkEvent *event);
|
||||
static void color_panel_select_callback (int, int, int, ColorSelectState, void *);
|
||||
static void color_panel_select_callback (int, int, int, ColorNotebookState, void *);
|
||||
|
||||
|
||||
ColorPanel *
|
||||
|
@ -52,8 +52,8 @@ color_panel_new (unsigned char *initial,
|
|||
|
||||
color_panel = g_new (ColorPanel, 1);
|
||||
private = g_new (ColorPanelPrivate, 1);
|
||||
private->color_select = NULL;
|
||||
private->color_select_active = 0;
|
||||
private->color_notebook = NULL;
|
||||
private->color_notebook_active = 0;
|
||||
private->gc = NULL;
|
||||
color_panel->private_part = private;
|
||||
|
||||
|
@ -85,11 +85,11 @@ color_panel_free (ColorPanel *color_panel)
|
|||
|
||||
private = (ColorPanelPrivate *) color_panel->private_part;
|
||||
|
||||
/* make sure we hide and free color_select */
|
||||
if (private->color_select)
|
||||
/* make sure we hide and free color_notebook */
|
||||
if (private->color_notebook)
|
||||
{
|
||||
color_select_hide (private->color_select);
|
||||
color_select_free (private->color_select);
|
||||
color_notebook_hide (private->color_notebook);
|
||||
color_notebook_free (private->color_notebook);
|
||||
}
|
||||
|
||||
if (private->gc)
|
||||
|
@ -144,24 +144,24 @@ color_panel_events (GtkWidget *widget,
|
|||
|
||||
if (bevent->button == 1)
|
||||
{
|
||||
if (! private->color_select)
|
||||
if (! private->color_notebook)
|
||||
{
|
||||
private->color_select = color_select_new (color_panel->color[0],
|
||||
private->color_notebook = color_notebook_new (color_panel->color[0],
|
||||
color_panel->color[1],
|
||||
color_panel->color[2],
|
||||
color_panel_select_callback,
|
||||
color_panel,
|
||||
FALSE);
|
||||
private->color_select_active = 1;
|
||||
private->color_notebook_active = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! private->color_select_active)
|
||||
color_select_show (private->color_select);
|
||||
color_select_set_color (private->color_select,
|
||||
color_panel->color[0],
|
||||
color_panel->color[1],
|
||||
color_panel->color[2], 1);
|
||||
if (! private->color_notebook_active)
|
||||
color_notebook_show (private->color_notebook);
|
||||
color_notebook_set_color (private->color_notebook,
|
||||
color_panel->color[0],
|
||||
color_panel->color[1],
|
||||
color_panel->color[2], 1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -177,7 +177,7 @@ static void
|
|||
color_panel_select_callback (int r,
|
||||
int g,
|
||||
int b,
|
||||
ColorSelectState state,
|
||||
ColorNotebookState state,
|
||||
void *client_data)
|
||||
{
|
||||
ColorPanel *color_panel;
|
||||
|
@ -186,21 +186,21 @@ color_panel_select_callback (int r,
|
|||
color_panel = (ColorPanel *) client_data;
|
||||
private = (ColorPanelPrivate *) color_panel->private_part;
|
||||
|
||||
if (private->color_select)
|
||||
if (private->color_notebook)
|
||||
{
|
||||
switch (state) {
|
||||
case COLOR_SELECT_UPDATE:
|
||||
case COLOR_NOTEBOOK_UPDATE:
|
||||
break;
|
||||
case COLOR_SELECT_OK:
|
||||
case COLOR_NOTEBOOK_OK:
|
||||
color_panel->color[0] = r;
|
||||
color_panel->color[1] = g;
|
||||
color_panel->color[2] = b;
|
||||
|
||||
color_panel_draw (color_panel);
|
||||
/* Fallthrough */
|
||||
case COLOR_SELECT_CANCEL:
|
||||
color_select_hide (private->color_select);
|
||||
private->color_select_active = 0;
|
||||
case COLOR_NOTEBOOK_CANCEL:
|
||||
color_notebook_hide (private->color_notebook);
|
||||
private->color_notebook_active = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "appenv.h"
|
||||
#include "actionarea.h"
|
||||
#include "color_select.h"
|
||||
#include "libgimp/color_selector.h"
|
||||
#include "colormaps.h"
|
||||
#include "errors.h"
|
||||
#include "gimprc.h"
|
||||
|
@ -76,6 +77,8 @@ struct _ColorSelectFill {
|
|||
ColorSelectFillUpdateProc update;
|
||||
};
|
||||
|
||||
static GtkWidget * color_select_widget_new (ColorSelectP, int, int, int);
|
||||
|
||||
static void color_select_update (ColorSelectP, ColorSelectUpdateType);
|
||||
static void color_select_update_caller (ColorSelectP);
|
||||
static void color_select_update_values (ColorSelectP);
|
||||
|
@ -117,6 +120,18 @@ static void color_select_update_hue_saturation (ColorSelectFill *);
|
|||
static void color_select_update_hue_value (ColorSelectFill *);
|
||||
static void color_select_update_saturation_value (ColorSelectFill *);
|
||||
|
||||
static GtkWidget * color_select_notebook_new (int, int, int,
|
||||
GimpColorSelector_Callback,
|
||||
void *, void **);
|
||||
static void color_select_notebook_free (void *);
|
||||
static void color_select_notebook_setcolor (void *, int, int, int, int);
|
||||
static void color_select_notebook_update_callback (int, int, int,
|
||||
ColorSelectState, void *);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static ColorSelectFillUpdateProc update_procs[] =
|
||||
{
|
||||
color_select_update_hue,
|
||||
|
@ -147,26 +162,8 @@ color_select_new (int r,
|
|||
void *client_data,
|
||||
int wants_updates)
|
||||
{
|
||||
/* static char *toggle_titles[6] = { "Hue", "Saturation", "Value", "Red", "Green", "Blue" }; */
|
||||
static char *toggle_titles[6] = { "H", "S", "V", "R", "G", "B" };
|
||||
static gfloat slider_max_vals[6] = { 360, 100, 100, 255, 255, 255 };
|
||||
static gfloat slider_incs[6] = { 0.1, 0.1, 0.1, 1.0, 1.0, 1.0 };
|
||||
|
||||
ColorSelectP csp;
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *main_hbox;
|
||||
GtkWidget *xy_frame;
|
||||
GtkWidget *z_frame;
|
||||
GtkWidget *colors_frame;
|
||||
GtkWidget *colors_hbox;
|
||||
GtkWidget *right_vbox;
|
||||
GtkWidget *table;
|
||||
GtkWidget *slider;
|
||||
GtkWidget *hex_hbox;
|
||||
GtkWidget *label;
|
||||
GSList *group;
|
||||
char buffer[16];
|
||||
int i;
|
||||
|
||||
csp = g_malloc (sizeof (_ColorSelect));
|
||||
|
||||
|
@ -193,10 +190,58 @@ color_select_new (int r,
|
|||
gtk_signal_connect (GTK_OBJECT (csp->shell), "delete_event",
|
||||
(GtkSignalFunc) color_select_delete_callback, csp);
|
||||
|
||||
main_vbox = color_select_widget_new (csp, r, g, b);
|
||||
gtk_widget_show (main_vbox);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (csp->shell)->vbox), main_vbox, TRUE, TRUE, 0);
|
||||
|
||||
/* The action area */
|
||||
action_items[0].user_data = csp;
|
||||
action_items[1].user_data = csp;
|
||||
if (csp->wants_updates)
|
||||
{
|
||||
action_items[0].label = _("Close");
|
||||
action_items[1].label = _("Revert to Old Color");
|
||||
}
|
||||
else
|
||||
{
|
||||
action_items[0].label = _("OK");
|
||||
action_items[1].label = _("Cancel");
|
||||
}
|
||||
build_action_area (GTK_DIALOG (csp->shell), action_items, 2, 0);
|
||||
|
||||
color_select_image_fill (csp->z_color, csp->z_color_fill, csp->values);
|
||||
color_select_image_fill (csp->xy_color, csp->xy_color_fill, csp->values);
|
||||
|
||||
gtk_widget_show (csp->shell);
|
||||
|
||||
return csp;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
color_select_widget_new (ColorSelectP csp, int r, int g, int b)
|
||||
{
|
||||
static char *toggle_titles[6] = { "H", "S", "V", "R", "G", "B" };
|
||||
static gfloat slider_max_vals[6] = { 360, 100, 100, 255, 255, 255 };
|
||||
static gfloat slider_incs[6] = { 0.1, 0.1, 0.1, 1.0, 1.0, 1.0 };
|
||||
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *main_hbox;
|
||||
GtkWidget *xy_frame;
|
||||
GtkWidget *z_frame;
|
||||
GtkWidget *colors_frame;
|
||||
GtkWidget *colors_hbox;
|
||||
GtkWidget *right_vbox;
|
||||
GtkWidget *table;
|
||||
GtkWidget *slider;
|
||||
GtkWidget *hex_hbox;
|
||||
GtkWidget *label;
|
||||
GSList *group;
|
||||
char buffer[16];
|
||||
int i;
|
||||
|
||||
main_vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 2);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (csp->shell)->vbox), main_vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (main_vbox);
|
||||
|
||||
main_hbox = gtk_hbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (main_hbox), 0);
|
||||
|
@ -341,29 +386,25 @@ color_select_new (int r,
|
|||
gtk_box_pack_end (GTK_BOX (hex_hbox), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
/* The action area */
|
||||
action_items[0].user_data = csp;
|
||||
action_items[1].user_data = csp;
|
||||
if (csp->wants_updates)
|
||||
{
|
||||
action_items[0].label = _("Close");
|
||||
action_items[1].label = _("Revert to Old Color");
|
||||
}
|
||||
else
|
||||
{
|
||||
action_items[0].label = _("OK");
|
||||
action_items[1].label = _("Cancel");
|
||||
}
|
||||
build_action_area (GTK_DIALOG (csp->shell), action_items, 2, 0);
|
||||
|
||||
color_select_image_fill (csp->z_color, csp->z_color_fill, csp->values);
|
||||
color_select_image_fill (csp->xy_color, csp->xy_color_fill, csp->values);
|
||||
|
||||
gtk_widget_show (csp->shell);
|
||||
|
||||
return csp;
|
||||
return main_vbox;
|
||||
}
|
||||
|
||||
|
||||
/* Register the GIMP colour selector with the color notebook */
|
||||
void
|
||||
color_select_init (void)
|
||||
{
|
||||
GimpColorSelectorMethods methods =
|
||||
{
|
||||
color_select_notebook_new,
|
||||
color_select_notebook_free,
|
||||
color_select_notebook_setcolor
|
||||
};
|
||||
|
||||
gimp_color_selector_register ("GIMP", &methods);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
color_select_show (ColorSelectP csp)
|
||||
{
|
||||
|
@ -383,7 +424,8 @@ color_select_free (ColorSelectP csp)
|
|||
{
|
||||
if (csp)
|
||||
{
|
||||
gtk_widget_destroy (csp->shell);
|
||||
if (csp->shell)
|
||||
gtk_widget_destroy (csp->shell);
|
||||
gdk_gc_destroy (csp->gc);
|
||||
g_free (csp);
|
||||
}
|
||||
|
@ -1973,3 +2015,96 @@ color_select_update_saturation_value (ColorSelectFill *csf)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*****************************/
|
||||
/* Colour notebook glue */
|
||||
|
||||
typedef struct {
|
||||
GimpColorSelector_Callback callback;
|
||||
void *client_data;
|
||||
ColorSelectP csp;
|
||||
GtkWidget *main_vbox;
|
||||
} notebook_glue;
|
||||
|
||||
|
||||
static GtkWidget *
|
||||
color_select_notebook_new (int r, int g, int b,
|
||||
GimpColorSelector_Callback callback, void *client_data,
|
||||
/* RETURNS: */
|
||||
void **selector_data)
|
||||
{
|
||||
ColorSelectP csp;
|
||||
notebook_glue *glue;
|
||||
|
||||
glue = g_malloc (sizeof (notebook_glue));
|
||||
|
||||
csp = g_malloc (sizeof (_ColorSelect));
|
||||
|
||||
glue->csp = csp;
|
||||
glue->callback = callback;
|
||||
glue->client_data = client_data;
|
||||
|
||||
csp->callback = color_select_notebook_update_callback;
|
||||
csp->client_data = glue;
|
||||
csp->z_color_fill = HUE;
|
||||
csp->xy_color_fill = SATURATION_VALUE;
|
||||
csp->gc = NULL;
|
||||
csp->wants_updates = TRUE;
|
||||
|
||||
csp->values[RED] = csp->orig_values[0] = r;
|
||||
csp->values[GREEN] = csp->orig_values[1] = g;
|
||||
csp->values[BLUE] = csp->orig_values[2] = b;
|
||||
color_select_update_hsv_values (csp);
|
||||
color_select_update_pos (csp);
|
||||
|
||||
glue->main_vbox = color_select_widget_new (csp, r, g, b);
|
||||
|
||||
/* the shell is provided by the notebook */
|
||||
csp->shell = NULL;
|
||||
|
||||
color_select_image_fill (csp->z_color, csp->z_color_fill, csp->values);
|
||||
color_select_image_fill (csp->xy_color, csp->xy_color_fill, csp->values);
|
||||
|
||||
(*selector_data) = glue;
|
||||
return glue->main_vbox;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
color_select_notebook_free (void *data)
|
||||
{
|
||||
notebook_glue *glue = data;
|
||||
|
||||
color_select_free (glue->csp);
|
||||
/* don't need to destroy the widget, since it's done by the caller
|
||||
* of this function */
|
||||
g_free (glue);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
color_select_notebook_setcolor (void *data,
|
||||
int r, int g, int b, int set_current)
|
||||
{
|
||||
notebook_glue *glue = data;
|
||||
|
||||
color_select_set_color (glue->csp, r, g, b, set_current);
|
||||
}
|
||||
|
||||
static void
|
||||
color_select_notebook_update_callback (int r, int g, int b,
|
||||
ColorSelectState state, void *data)
|
||||
{
|
||||
notebook_glue *glue = data;
|
||||
|
||||
switch (state) {
|
||||
case COLOR_SELECT_UPDATE:
|
||||
glue->callback (glue->client_data, r, g, b);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_warning ("state %d can't happen!", state);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,8 @@ struct _ColorSelect {
|
|||
GdkGC *gc;
|
||||
};
|
||||
|
||||
void color_select_init (void);
|
||||
|
||||
ColorSelectP color_select_new (int, int, int, ColorSelectCallback, void *, int);
|
||||
void color_select_show (ColorSelectP);
|
||||
void color_select_hide (ColorSelectP);
|
||||
|
|
|
@ -161,7 +161,9 @@ static void blend (GImage *gimage, GimpDrawable *drawa
|
|||
RepeatMode repeat,
|
||||
int supersample, int max_depth, double threshold,
|
||||
double startx, double starty,
|
||||
double endx, double endy);
|
||||
double endx, double endy,
|
||||
progress_func_t progress_callback,
|
||||
void *progress_data);
|
||||
|
||||
static double gradient_calc_conical_sym_factor (double dist, double *axis, double offset,
|
||||
double x, double y);
|
||||
|
@ -195,7 +197,9 @@ static void gradient_fill_region (GImage *gimage, GimpDrawable *drawa
|
|||
BlendMode blend_mode, GradientType gradient_type,
|
||||
double offset, RepeatMode repeat,
|
||||
int supersample, int max_depth, double threshold,
|
||||
double sx, double sy, double ex, double ey);
|
||||
double sx, double sy, double ex, double ey,
|
||||
progress_func_t progress_callback,
|
||||
void *progress_data);
|
||||
|
||||
static void calc_rgb_to_hsv(double *r, double *g, double *b);
|
||||
static void calc_hsv_to_rgb(double *h, double *s, double *v);
|
||||
|
@ -606,8 +610,12 @@ blend_button_release (Tool *tool,
|
|||
GDisplay * gdisp;
|
||||
GImage * gimage;
|
||||
BlendTool * blend_tool;
|
||||
#ifdef BLEND_UI_CALLS_VIA_PDB
|
||||
Argument *return_vals;
|
||||
int nreturn_vals;
|
||||
#else
|
||||
gimp_progress *progress;
|
||||
#endif
|
||||
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
gimage = gdisp->gimage;
|
||||
|
@ -626,6 +634,9 @@ blend_button_release (Tool *tool,
|
|||
((blend_tool->startx != blend_tool->endx) ||
|
||||
(blend_tool->starty != blend_tool->endy)))
|
||||
{
|
||||
/* we can't do callbacks easily with the PDB, so this UI/backend
|
||||
* separation (though good) is ignored for the moment */
|
||||
#ifdef BLEND_UI_CALLS_VIA_PDB
|
||||
return_vals = procedural_db_run_proc ("gimp_blend",
|
||||
&nreturn_vals,
|
||||
PDB_DRAWABLE, drawable_ID (gimage_active_drawable (gimage)),
|
||||
|
@ -650,6 +661,33 @@ blend_button_release (Tool *tool,
|
|||
g_message (_("Blend operation failed."));
|
||||
|
||||
procedural_db_destroy_args (return_vals, nreturn_vals);
|
||||
|
||||
#else /* ! BLEND_UI_CALLS_VIA_PDB */
|
||||
|
||||
progress = progress_start (gdisp, _("Blending..."), FALSE, NULL, NULL);
|
||||
|
||||
blend (gimage,
|
||||
gimage_active_drawable (gimage),
|
||||
blend_options->blend_mode,
|
||||
blend_options->paint_mode,
|
||||
blend_options->gradient_type,
|
||||
blend_options->opacity,
|
||||
blend_options->offset,
|
||||
blend_options->repeat,
|
||||
blend_options->supersample,
|
||||
blend_options->max_depth,
|
||||
blend_options->threshold,
|
||||
blend_tool->startx,
|
||||
blend_tool->starty,
|
||||
blend_tool->endx,
|
||||
blend_tool->endy,
|
||||
progress? progress_update_and_flush : NULL, progress);
|
||||
|
||||
if (progress)
|
||||
progress_end (progress);
|
||||
|
||||
gdisplays_flush ();
|
||||
#endif /* ! BLEND_UI_CALLS_VIA_PDB */
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -766,21 +804,23 @@ blend_control (Tool *tool,
|
|||
|
||||
/* The actual blending procedure */
|
||||
static void
|
||||
blend (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
BlendMode blend_mode,
|
||||
int paint_mode,
|
||||
GradientType gradient_type,
|
||||
double opacity,
|
||||
double offset,
|
||||
RepeatMode repeat,
|
||||
int supersample,
|
||||
int max_depth,
|
||||
double threshold,
|
||||
double startx,
|
||||
double starty,
|
||||
double endx,
|
||||
double endy)
|
||||
blend (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
BlendMode blend_mode,
|
||||
int paint_mode,
|
||||
GradientType gradient_type,
|
||||
double opacity,
|
||||
double offset,
|
||||
RepeatMode repeat,
|
||||
int supersample,
|
||||
int max_depth,
|
||||
double threshold,
|
||||
double startx,
|
||||
double starty,
|
||||
double endx,
|
||||
double endy,
|
||||
progress_func_t progress_callback,
|
||||
void *progress_data)
|
||||
{
|
||||
TileManager *buf_tiles;
|
||||
PixelRegion bufPR;
|
||||
|
@ -811,7 +851,8 @@ blend (GImage *gimage,
|
|||
blend_mode, gradient_type, offset, repeat,
|
||||
supersample, max_depth, threshold,
|
||||
(startx - x1), (starty - y1),
|
||||
(endx - x1), (endy - y1));
|
||||
(endx - x1), (endy - y1),
|
||||
progress_callback, progress_data);
|
||||
|
||||
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), FALSE);
|
||||
gimage_apply_image (gimage, drawable, &bufPR, TRUE,
|
||||
|
@ -1375,23 +1416,26 @@ gradient_put_pixel(int x, int y, color_t color, void *put_pixel_data)
|
|||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
gradient_fill_region (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
PixelRegion *PR,
|
||||
int width,
|
||||
int height,
|
||||
BlendMode blend_mode,
|
||||
GradientType gradient_type,
|
||||
double offset,
|
||||
RepeatMode repeat,
|
||||
int supersample,
|
||||
int max_depth,
|
||||
double threshold,
|
||||
double sx,
|
||||
double sy,
|
||||
double ex,
|
||||
double ey)
|
||||
gradient_fill_region (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
PixelRegion *PR,
|
||||
int width,
|
||||
int height,
|
||||
BlendMode blend_mode,
|
||||
GradientType gradient_type,
|
||||
double offset,
|
||||
RepeatMode repeat,
|
||||
int supersample,
|
||||
int max_depth,
|
||||
double threshold,
|
||||
double sx,
|
||||
double sy,
|
||||
double ex,
|
||||
double ey,
|
||||
progress_func_t progress_callback,
|
||||
void *progress_data)
|
||||
{
|
||||
RenderBlendData rbd;
|
||||
PutPixelData ppd;
|
||||
|
@ -1536,7 +1580,7 @@ gradient_fill_region (GImage *gimage,
|
|||
max_depth, threshold,
|
||||
gradient_render_pixel, &rbd,
|
||||
gradient_put_pixel, &ppd,
|
||||
NULL, NULL);
|
||||
progress_callback, progress_data);
|
||||
|
||||
/* Clean up */
|
||||
|
||||
|
@ -1544,6 +1588,9 @@ gradient_fill_region (GImage *gimage,
|
|||
}
|
||||
else
|
||||
{
|
||||
int max_progress = PR->w * PR->h;
|
||||
int progress = 0;
|
||||
|
||||
for (pr = pixel_regions_register(1, PR); pr != NULL; pr = pixel_regions_process(pr))
|
||||
{
|
||||
data = PR->data;
|
||||
|
@ -1572,6 +1619,10 @@ gradient_fill_region (GImage *gimage,
|
|||
*data++ = color.a * 255.0;
|
||||
}
|
||||
}
|
||||
|
||||
progress += PR->w * PR->h;
|
||||
if (progress_callback)
|
||||
(*progress_callback) (0, max_progress, progress, progress_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1992,7 +2043,8 @@ blend_invoker (Argument *args)
|
|||
if (success)
|
||||
{
|
||||
blend (gimage, drawable, blend_mode, paint_mode, gradient_type,
|
||||
opacity, offset, repeat, supersample, max_depth, threshold, x1, y1, x2, y2);
|
||||
opacity, offset, repeat, supersample, max_depth, threshold,
|
||||
x1, y1, x2, y2, NULL, NULL);
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&blend_proc, success);
|
||||
|
|
|
@ -0,0 +1,459 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* color_notebook module (C) 1998 Austin Donnelly <austin@greenend.org.uk>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "appenv.h"
|
||||
#include "actionarea.h"
|
||||
#include "color_notebook.h"
|
||||
|
||||
#include "libgimp/color_selector.h"
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
|
||||
static void color_notebook_ok_callback (GtkWidget *, gpointer);
|
||||
static void color_notebook_cancel_callback (GtkWidget *, gpointer);
|
||||
static gint color_notebook_delete_callback (GtkWidget *, GdkEvent *, gpointer);
|
||||
static void color_notebook_update_callback (void *, int, int, int);
|
||||
static void color_notebook_page_switch (GtkWidget *, GtkNotebookPage *, guint);
|
||||
|
||||
|
||||
static ActionAreaItem action_items[2] =
|
||||
{
|
||||
{ N_("OK"), color_notebook_ok_callback, NULL, NULL },
|
||||
{ N_("Cancel"), color_notebook_cancel_callback, NULL, NULL },
|
||||
};
|
||||
|
||||
|
||||
/* information we keep on each registered colour selector */
|
||||
typedef struct _ColorSelectorInfo {
|
||||
char *name; /* label used in notebook tab */
|
||||
GimpColorSelectorMethods m;
|
||||
int refs; /* number of instances around */
|
||||
gboolean active;
|
||||
void (*death_callback) (void *data);
|
||||
void *death_data;
|
||||
struct _ColorSelectorInfo *next;
|
||||
} ColorSelectorInfo;
|
||||
|
||||
typedef struct _ColorSelectorInstance {
|
||||
_ColorNotebook *color_notebook;
|
||||
ColorSelectorInfo *info;
|
||||
GtkWidget *frame; /* main widget */
|
||||
gpointer selector_data;
|
||||
struct _ColorSelectorInstance *next;
|
||||
} ColorSelectorInstance;
|
||||
|
||||
static void selector_death (ColorSelectorInfo *info);
|
||||
|
||||
|
||||
/* master list of all registered colour selectors */
|
||||
static ColorSelectorInfo *selector_info = NULL;
|
||||
|
||||
|
||||
#define RED 0
|
||||
#define GREEN 1
|
||||
#define BLUE 2
|
||||
#define NUM_COLORS 3
|
||||
|
||||
|
||||
ColorNotebookP
|
||||
color_notebook_new (int r,
|
||||
int g,
|
||||
int b,
|
||||
ColorNotebookCallback callback,
|
||||
void *client_data,
|
||||
int wants_updates)
|
||||
{
|
||||
ColorNotebookP cnp;
|
||||
GtkWidget *label;
|
||||
ColorSelectorInfo *info;
|
||||
ColorSelectorInstance *csel;
|
||||
|
||||
g_return_val_if_fail (selector_info != NULL, NULL);
|
||||
|
||||
cnp = g_malloc (sizeof (_ColorNotebook));
|
||||
|
||||
cnp->callback = callback;
|
||||
cnp->client_data = client_data;
|
||||
cnp->wants_updates = wants_updates;
|
||||
cnp->selectors = NULL;
|
||||
cnp->cur_page = NULL;
|
||||
|
||||
cnp->values[RED] = cnp->orig_values[RED] = r & 0xff;
|
||||
cnp->values[GREEN] = cnp->orig_values[GREEN] = g & 0xff;
|
||||
cnp->values[BLUE] = cnp->orig_values[BLUE] = b & 0xff;
|
||||
|
||||
/* window hints need to stay the same, so people's window manager
|
||||
* setups still work */
|
||||
cnp->shell = gtk_dialog_new ();
|
||||
gtk_window_set_wmclass (GTK_WINDOW (cnp->shell), "color_selection", "Gimp");
|
||||
gtk_window_set_title (GTK_WINDOW (cnp->shell), _("Color Selection"));
|
||||
gtk_window_set_policy (GTK_WINDOW (cnp->shell), FALSE, FALSE, FALSE);
|
||||
|
||||
/* handle the wm close signal */
|
||||
gtk_signal_connect (GTK_OBJECT (cnp->shell), "delete_event",
|
||||
(GtkSignalFunc) color_notebook_delete_callback, cnp);
|
||||
|
||||
/* do we actually need a notebook? */
|
||||
if (selector_info->next)
|
||||
{
|
||||
cnp->notebook = gtk_notebook_new ();
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (cnp->shell)->vbox),
|
||||
cnp->notebook, TRUE, TRUE, 1);
|
||||
gtk_widget_show (cnp->notebook);
|
||||
}
|
||||
else /* only one selector */
|
||||
{
|
||||
cnp->notebook = NULL;
|
||||
}
|
||||
|
||||
/* create each registered colour selector */
|
||||
info = selector_info;
|
||||
while (info)
|
||||
{
|
||||
if (info->active)
|
||||
{
|
||||
|
||||
csel = g_malloc (sizeof (ColorSelectorInstance));
|
||||
csel->color_notebook = cnp;
|
||||
csel->info = info;
|
||||
info->refs++;
|
||||
csel->frame = info->m.new (r, g, b,
|
||||
color_notebook_update_callback, csel,
|
||||
&csel->selector_data);
|
||||
gtk_object_set_data (GTK_OBJECT (csel->frame), "gimp_color_notebook",
|
||||
csel);
|
||||
|
||||
if (cnp->notebook)
|
||||
{
|
||||
label = gtk_label_new (info->name);
|
||||
gtk_widget_show (label);
|
||||
gtk_notebook_append_page (GTK_NOTEBOOK (cnp->notebook),
|
||||
csel->frame, label);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (cnp->shell)->vbox),
|
||||
csel->frame, TRUE, TRUE, 1);
|
||||
}
|
||||
|
||||
gtk_widget_show (csel->frame);
|
||||
|
||||
if (!cnp->cur_page)
|
||||
cnp->cur_page = csel;
|
||||
|
||||
/* link into list of all selectors hanging off the new notebook */
|
||||
csel->next = cnp->selectors;
|
||||
cnp->selectors = csel;
|
||||
}
|
||||
|
||||
info = info->next;
|
||||
}
|
||||
|
||||
/* The action area */
|
||||
action_items[0].user_data = cnp;
|
||||
action_items[1].user_data = cnp;
|
||||
if (cnp->wants_updates)
|
||||
{
|
||||
action_items[0].label = _("Close");
|
||||
action_items[1].label = _("Revert to Old Color");
|
||||
}
|
||||
else
|
||||
{
|
||||
action_items[0].label = _("OK");
|
||||
action_items[1].label = _("Cancel");
|
||||
}
|
||||
build_action_area (GTK_DIALOG (cnp->shell), action_items, 2, 0);
|
||||
|
||||
gtk_widget_show (cnp->shell);
|
||||
|
||||
/* this must come after showing the widget, otherwise we get a
|
||||
* switch_page signal for a non-visible color selector, which is bad
|
||||
* news. */
|
||||
if (cnp->notebook)
|
||||
{
|
||||
gtk_object_set_user_data (GTK_OBJECT (cnp->notebook), cnp);
|
||||
gtk_signal_connect (GTK_OBJECT (cnp->notebook), "switch_page",
|
||||
(GtkSignalFunc)color_notebook_page_switch, NULL);
|
||||
}
|
||||
|
||||
return cnp;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
color_notebook_show (ColorNotebookP cnp)
|
||||
{
|
||||
g_return_if_fail (cnp != NULL);
|
||||
gtk_widget_show (cnp->shell);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
color_notebook_hide (ColorNotebookP cnp)
|
||||
{
|
||||
g_return_if_fail (cnp != NULL);
|
||||
gtk_widget_hide (cnp->shell);
|
||||
}
|
||||
|
||||
void
|
||||
color_notebook_free (ColorNotebookP cnp)
|
||||
{
|
||||
ColorSelectorInstance *csel, *next;
|
||||
|
||||
g_return_if_fail (cnp != NULL);
|
||||
|
||||
gtk_widget_destroy (cnp->shell);
|
||||
|
||||
/* call the free functions for all the colour selectors */
|
||||
csel = cnp->selectors;
|
||||
while (csel)
|
||||
{
|
||||
next = csel->next;
|
||||
|
||||
csel->info->m.free (csel->selector_data);
|
||||
|
||||
csel->info->refs--;
|
||||
if (csel->info->refs == 0 && !csel->info->active)
|
||||
selector_death (csel->info);
|
||||
|
||||
g_free (csel);
|
||||
csel = next;
|
||||
}
|
||||
|
||||
g_free (cnp);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
color_notebook_set_color (ColorNotebookP cnp,
|
||||
int r,
|
||||
int g,
|
||||
int b,
|
||||
int set_current)
|
||||
{
|
||||
ColorSelectorInstance *csel;
|
||||
g_return_if_fail (cnp != NULL);
|
||||
|
||||
cnp->orig_values[RED] = r;
|
||||
cnp->orig_values[GREEN] = g;
|
||||
cnp->orig_values[BLUE] = b;
|
||||
|
||||
if (set_current)
|
||||
{
|
||||
cnp->values[RED] = r;
|
||||
cnp->values[GREEN] = g;
|
||||
cnp->values[BLUE] = b;
|
||||
}
|
||||
|
||||
csel = cnp->cur_page;
|
||||
csel->info->m.setcolor (csel->selector_data, r, g, b, set_current);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Called by a colour selector on user selection of a colour */
|
||||
static void
|
||||
color_notebook_update_callback (void *data, int r, int g, int b)
|
||||
{
|
||||
ColorSelectorInstance *csel;
|
||||
ColorNotebookP cnp;
|
||||
|
||||
g_return_if_fail (data != NULL);
|
||||
|
||||
csel = (ColorSelectorInstance *) data;
|
||||
cnp = csel->color_notebook;
|
||||
|
||||
cnp->values[RED] = r;
|
||||
cnp->values[GREEN] = g;
|
||||
cnp->values[BLUE] = b;
|
||||
|
||||
if (cnp->wants_updates && cnp->callback)
|
||||
{
|
||||
(* cnp->callback) (cnp->values[RED],
|
||||
cnp->values[GREEN],
|
||||
cnp->values[BLUE],
|
||||
COLOR_NOTEBOOK_UPDATE,
|
||||
cnp->client_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void
|
||||
color_notebook_ok_callback (GtkWidget *w,
|
||||
gpointer client_data)
|
||||
{
|
||||
ColorNotebookP cnp;
|
||||
|
||||
cnp = (ColorNotebookP) client_data;
|
||||
|
||||
if (cnp->callback)
|
||||
(* cnp->callback) (cnp->values[RED],
|
||||
cnp->values[GREEN],
|
||||
cnp->values[BLUE],
|
||||
COLOR_NOTEBOOK_OK,
|
||||
cnp->client_data);
|
||||
}
|
||||
|
||||
|
||||
static gint
|
||||
color_notebook_delete_callback (GtkWidget *w,
|
||||
GdkEvent *e,
|
||||
gpointer client_data)
|
||||
{
|
||||
color_notebook_cancel_callback (w, client_data);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
color_notebook_cancel_callback (GtkWidget *w,
|
||||
gpointer client_data)
|
||||
{
|
||||
ColorNotebookP cnp;
|
||||
|
||||
cnp = (ColorNotebookP) client_data;
|
||||
|
||||
if (cnp->callback)
|
||||
(* cnp->callback) (cnp->orig_values[RED],
|
||||
cnp->orig_values[GREEN],
|
||||
cnp->orig_values[BLUE],
|
||||
COLOR_NOTEBOOK_CANCEL,
|
||||
cnp->client_data);
|
||||
}
|
||||
|
||||
static void
|
||||
color_notebook_page_switch (GtkWidget *w,
|
||||
GtkNotebookPage *page,
|
||||
guint page_num)
|
||||
{
|
||||
ColorNotebookP cnp;
|
||||
ColorSelectorInstance *csel;
|
||||
|
||||
cnp = gtk_object_get_user_data (GTK_OBJECT (w));
|
||||
csel = gtk_object_get_data (GTK_OBJECT(page->child), "gimp_color_notebook");
|
||||
|
||||
g_return_if_fail (cnp != NULL && csel != NULL);
|
||||
|
||||
cnp->cur_page = csel;
|
||||
csel->info->m.setcolor (csel->selector_data,
|
||||
cnp->values[RED],
|
||||
cnp->values[GREEN],
|
||||
cnp->values[BLUE],
|
||||
TRUE);
|
||||
}
|
||||
|
||||
/**************************************************************/
|
||||
/* Registration functions */
|
||||
|
||||
|
||||
GimpColorSelectorID
|
||||
gimp_color_selector_register (const char *name,
|
||||
GimpColorSelectorMethods *methods)
|
||||
{
|
||||
ColorSelectorInfo *info;
|
||||
|
||||
/* check the name is unique */
|
||||
info = selector_info;
|
||||
while (info)
|
||||
{
|
||||
if (!strcmp (info->name, name))
|
||||
return NULL;
|
||||
info = info->next;
|
||||
}
|
||||
|
||||
info = g_malloc (sizeof (ColorSelectorInfo));
|
||||
|
||||
info->name = g_strdup (name);
|
||||
info->m = *methods;
|
||||
info->refs = 0;
|
||||
info->active = TRUE;
|
||||
|
||||
info->next = selector_info;
|
||||
selector_info = info;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
gimp_color_selector_unregister (GimpColorSelectorID id,
|
||||
void (*callback)(void *data),
|
||||
void *data)
|
||||
{
|
||||
ColorSelectorInfo *info;
|
||||
|
||||
info = selector_info;
|
||||
while (info)
|
||||
{
|
||||
if (info == id)
|
||||
{
|
||||
info->active = FALSE;
|
||||
info->death_callback = callback;
|
||||
info->death_data = data;
|
||||
if (info->refs == 0)
|
||||
selector_death (info);
|
||||
return TRUE;
|
||||
}
|
||||
info = info->next;
|
||||
}
|
||||
|
||||
g_warning ("unknown color selector id %p", id);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
selector_death (ColorSelectorInfo *info)
|
||||
{
|
||||
ColorSelectorInfo *here, *prev;
|
||||
|
||||
here = selector_info;
|
||||
prev = NULL;
|
||||
while (here)
|
||||
{
|
||||
if (here == info)
|
||||
{
|
||||
if (prev)
|
||||
prev->next = info->next;
|
||||
else
|
||||
selector_info = info->next;
|
||||
|
||||
if (info->death_callback)
|
||||
(*info->death_callback) (info->death_data);
|
||||
|
||||
g_free (info->name);
|
||||
g_free (info);
|
||||
|
||||
return;
|
||||
}
|
||||
prev = here;
|
||||
here = here->next;
|
||||
}
|
||||
|
||||
g_warning ("color selector %p not found, can't happen!", info);
|
||||
}
|
||||
|
||||
|
||||
/* End of color_notebook.c */
|
|
@ -0,0 +1,53 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __COLOR_NOTEBOOK_H__
|
||||
#define __COLOR_NOTEBOOK_H__
|
||||
|
||||
typedef enum {
|
||||
COLOR_NOTEBOOK_OK,
|
||||
COLOR_NOTEBOOK_CANCEL,
|
||||
COLOR_NOTEBOOK_UPDATE
|
||||
} ColorNotebookState;
|
||||
|
||||
typedef struct _ColorNotebook _ColorNotebook, *ColorNotebookP;
|
||||
typedef void (*ColorNotebookCallback) (int, int, int, ColorNotebookState,
|
||||
void *);
|
||||
|
||||
struct _ColorSelectorInstance;
|
||||
|
||||
struct _ColorNotebook {
|
||||
GtkWidget *shell;
|
||||
GtkWidget *notebook;
|
||||
int values[3];
|
||||
int orig_values[3];
|
||||
ColorNotebookCallback callback;
|
||||
void *client_data;
|
||||
int wants_updates;
|
||||
struct _ColorSelectorInstance *selectors;
|
||||
struct _ColorSelectorInstance *cur_page;
|
||||
};
|
||||
|
||||
ColorNotebookP color_notebook_new (int, int, int, ColorNotebookCallback, void *, int);
|
||||
void color_notebook_show (ColorNotebookP);
|
||||
void color_notebook_hide (ColorNotebookP);
|
||||
void color_notebook_free (ColorNotebookP);
|
||||
void color_notebook_set_color (ColorNotebookP, int, int, int, int);
|
||||
|
||||
|
||||
#endif /* __COLOR_NOTEBOOK_H__ */
|
|
@ -98,8 +98,6 @@ GtkTooltips *tool_tips;
|
|||
GtkWidget *popup_shell = NULL;
|
||||
|
||||
|
||||
static GtkWidget *tool_label_area = NULL;
|
||||
static GtkWidget *progress_area = NULL;
|
||||
static GdkColor colors[12];
|
||||
static GtkWidget *toolbox_shell = NULL;
|
||||
|
||||
|
@ -1040,58 +1038,3 @@ message_box_close_callback (GtkWidget *w,
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
progress_start ()
|
||||
{
|
||||
if (!GTK_WIDGET_VISIBLE (progress_area))
|
||||
{
|
||||
gtk_widget_set_usize (progress_area,
|
||||
tool_label_area->allocation.width,
|
||||
tool_label_area->allocation.height);
|
||||
|
||||
gtk_widget_hide (tool_label_area);
|
||||
gtk_widget_show (progress_area);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
progress_update (float percentage)
|
||||
{
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (progress_area), percentage);
|
||||
|
||||
if (GTK_WIDGET_VISIBLE (progress_area))
|
||||
gdk_flush ();
|
||||
}
|
||||
|
||||
void
|
||||
progress_step ()
|
||||
{
|
||||
float val;
|
||||
|
||||
if (GTK_WIDGET_VISIBLE (progress_area))
|
||||
{
|
||||
val = gtk_progress_get_current_percentage(GTK_PROGRESS(progress_area))
|
||||
+ 0.01;
|
||||
/*
|
||||
val = GTK_PROGRESS_BAR (progress_area)->percentage + 0.01;
|
||||
*/
|
||||
if (val > 1.0)
|
||||
val = 0.0;
|
||||
|
||||
progress_update (val);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
progress_end ()
|
||||
{
|
||||
if (GTK_WIDGET_VISIBLE (progress_area))
|
||||
{
|
||||
gtk_widget_hide (progress_area);
|
||||
gtk_widget_show (tool_label_area);
|
||||
|
||||
gdk_flush ();
|
||||
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (progress_area), 0.0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,9 +44,4 @@ GtkWidget * message_box (char *, GtkCallback, gpointer);
|
|||
void tools_push_label (char *label);
|
||||
void tools_pop_label (void);
|
||||
|
||||
void progress_start (void);
|
||||
void progress_update (float);
|
||||
void progress_step (void);
|
||||
void progress_end (void);
|
||||
|
||||
#endif /* INTERFACE_H */
|
||||
|
|
|
@ -98,8 +98,6 @@ GtkTooltips *tool_tips;
|
|||
GtkWidget *popup_shell = NULL;
|
||||
|
||||
|
||||
static GtkWidget *tool_label_area = NULL;
|
||||
static GtkWidget *progress_area = NULL;
|
||||
static GdkColor colors[12];
|
||||
static GtkWidget *toolbox_shell = NULL;
|
||||
|
||||
|
@ -1040,58 +1038,3 @@ message_box_close_callback (GtkWidget *w,
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
progress_start ()
|
||||
{
|
||||
if (!GTK_WIDGET_VISIBLE (progress_area))
|
||||
{
|
||||
gtk_widget_set_usize (progress_area,
|
||||
tool_label_area->allocation.width,
|
||||
tool_label_area->allocation.height);
|
||||
|
||||
gtk_widget_hide (tool_label_area);
|
||||
gtk_widget_show (progress_area);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
progress_update (float percentage)
|
||||
{
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (progress_area), percentage);
|
||||
|
||||
if (GTK_WIDGET_VISIBLE (progress_area))
|
||||
gdk_flush ();
|
||||
}
|
||||
|
||||
void
|
||||
progress_step ()
|
||||
{
|
||||
float val;
|
||||
|
||||
if (GTK_WIDGET_VISIBLE (progress_area))
|
||||
{
|
||||
val = gtk_progress_get_current_percentage(GTK_PROGRESS(progress_area))
|
||||
+ 0.01;
|
||||
/*
|
||||
val = GTK_PROGRESS_BAR (progress_area)->percentage + 0.01;
|
||||
*/
|
||||
if (val > 1.0)
|
||||
val = 0.0;
|
||||
|
||||
progress_update (val);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
progress_end ()
|
||||
{
|
||||
if (GTK_WIDGET_VISIBLE (progress_area))
|
||||
{
|
||||
gtk_widget_hide (progress_area);
|
||||
gtk_widget_show (tool_label_area);
|
||||
|
||||
gdk_flush ();
|
||||
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (progress_area), 0.0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,9 +44,4 @@ GtkWidget * message_box (char *, GtkCallback, gpointer);
|
|||
void tools_push_label (char *label);
|
||||
void tools_pop_label (void);
|
||||
|
||||
void progress_start (void);
|
||||
void progress_update (float);
|
||||
void progress_step (void);
|
||||
void progress_end (void);
|
||||
|
||||
#endif /* INTERFACE_H */
|
||||
|
|
|
@ -0,0 +1,332 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
|
||||
#include "appenv.h"
|
||||
#include "gdisplay.h"
|
||||
#include "libgimp/gimpintl.h"
|
||||
#include "gimpprogress.h"
|
||||
|
||||
|
||||
struct gimp_progress_pvt {
|
||||
GDisplay *gdisp; /* gdisp in use, or NULL*/
|
||||
|
||||
/* next four fields are only valid if gdisp is NULL */
|
||||
GtkWidget *dialog; /* progress dialog, NULL if using gdisp */
|
||||
GtkWidget *dialog_label;
|
||||
GtkWidget *progressbar;
|
||||
GtkWidget *cancelbutton;
|
||||
|
||||
GtkSignalFunc cancel_callback; /* callback to remove, or NULL */
|
||||
gpointer cancel_data;
|
||||
};
|
||||
|
||||
#define DEFAULT_PROGRESS_MESSAGE _("Please wait...")
|
||||
|
||||
|
||||
/* prototypes */
|
||||
static void progress_signal_setup (gimp_progress *, GtkSignalFunc, gpointer);
|
||||
|
||||
|
||||
/* These progress bar routines are re-entrant, and so should be
|
||||
* thread-safe. */
|
||||
|
||||
|
||||
/* Start a progress bar on "gdisp" with reason "message". If "gdisp"
|
||||
* is NULL, the progress bar is presented in a new dialog box. If
|
||||
* "message" is NULL, then no message is used.
|
||||
*
|
||||
* If "cancel_callback" is not NULL, it is attached to the progress
|
||||
* bar cancel button's "clicked" signal, with data "cancel_data". The
|
||||
* cancel button is only made sensitive if the callback is set.
|
||||
*
|
||||
* It is an error to progress_start() a bar on a "gdisp" for which
|
||||
* there is already a progress bar active.
|
||||
*
|
||||
* Progress bars with "important" set to TRUE will be shown to the
|
||||
* user in any possible way. Unimportant progress bars will not be
|
||||
* shown to the user if it would mean creating a new window.
|
||||
*/
|
||||
gimp_progress *
|
||||
progress_start (GDisplay *gdisp, const char *message, gboolean important,
|
||||
GtkSignalFunc cancel_callback, gpointer cancel_data)
|
||||
{
|
||||
gimp_progress *p;
|
||||
guint cid;
|
||||
GtkWidget *vbox;
|
||||
|
||||
p = g_malloc (sizeof (*p));
|
||||
|
||||
p->gdisp = gdisp;
|
||||
p->dialog = NULL;
|
||||
p->cancel_callback = NULL;
|
||||
p->cancel_data = NULL;
|
||||
|
||||
/* do we have a useful gdisplay and statusarea? */
|
||||
if (gdisp && GTK_WIDGET_VISIBLE (gdisp->statusarea))
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar),
|
||||
"progress");
|
||||
|
||||
gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), cid, message);
|
||||
}
|
||||
|
||||
/* really need image locking to stop multiple people going at
|
||||
* the image */
|
||||
if (gdisp->progressid)
|
||||
g_warning("%d progress bars already active for display %p\n",
|
||||
gdisp->progressid, gdisp);
|
||||
gdisp->progressid++;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* unimporant progress indications are occasionally failed */
|
||||
if (!important)
|
||||
{
|
||||
g_free (p);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
p->gdisp = NULL;
|
||||
p->dialog = gtk_dialog_new ();
|
||||
|
||||
/* not strictly true anymore, but needed in case anyone's window
|
||||
* manager knows about WMCLASS "plug_in_progress" */
|
||||
gtk_window_set_wmclass (GTK_WINDOW (p->dialog),
|
||||
"plug_in_progress", "Gimp");
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (p->dialog), _("Progress"));
|
||||
|
||||
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (p->dialog)->action_area), 2);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (p->dialog)->vbox), vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
p->dialog_label = gtk_label_new (message? message :
|
||||
DEFAULT_PROGRESS_MESSAGE);
|
||||
gtk_misc_set_alignment (GTK_MISC (p->dialog_label), 0.0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), p->dialog_label, FALSE, TRUE, 0);
|
||||
gtk_widget_show (p->dialog_label);
|
||||
|
||||
p->progressbar = gtk_progress_bar_new ();
|
||||
gtk_widget_set_usize (p->progressbar, 150, 20);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), p->progressbar, TRUE, TRUE, 0);
|
||||
gtk_widget_show (p->progressbar);
|
||||
|
||||
p->cancelbutton = gtk_button_new_with_label (_("Cancel"));
|
||||
GTK_WIDGET_SET_FLAGS (p->cancelbutton, GTK_CAN_DEFAULT);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (p->dialog)->action_area),
|
||||
p->cancelbutton, TRUE, TRUE, 0);
|
||||
gtk_widget_grab_default (p->cancelbutton);
|
||||
gtk_widget_show (p->cancelbutton);
|
||||
|
||||
gtk_widget_show (p->dialog);
|
||||
}
|
||||
|
||||
progress_signal_setup (p, cancel_callback, cancel_data);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
/* Update the message and/or the callbacks for a progress and reset
|
||||
* the bar to zero, with the minimum of disturbance to the user. */
|
||||
gimp_progress *
|
||||
progress_restart (gimp_progress *p, const char *message,
|
||||
GtkSignalFunc cancel_callback, gpointer cancel_data)
|
||||
{
|
||||
int cid;
|
||||
GtkWidget *bar;
|
||||
|
||||
g_return_val_if_fail (p != NULL, p);
|
||||
|
||||
/* change the message */
|
||||
if (p->gdisp)
|
||||
{
|
||||
cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (p->gdisp->statusbar),
|
||||
"progress");
|
||||
gtk_statusbar_pop (GTK_STATUSBAR (p->gdisp->statusbar), cid);
|
||||
|
||||
if (message)
|
||||
gtk_statusbar_push (GTK_STATUSBAR (p->gdisp->statusbar), cid, message);
|
||||
|
||||
bar = p->gdisp->progressbar;
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_label_set_text (GTK_LABEL (p->dialog_label),
|
||||
message? message : DEFAULT_PROGRESS_MESSAGE);
|
||||
bar = p->progressbar;
|
||||
}
|
||||
|
||||
/* reset the progress bar */
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (bar), 0.0);
|
||||
|
||||
/* do we need to change the callbacks? */
|
||||
progress_signal_setup (p, cancel_callback, cancel_data);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
progress_update (gimp_progress *progress, float percentage)
|
||||
{
|
||||
GtkWidget *bar;
|
||||
|
||||
g_return_if_fail (progress != NULL);
|
||||
|
||||
if (!(percentage >= 0.0 && percentage <= 1.0))
|
||||
return;
|
||||
|
||||
/* do we have a dialog box, or are we using the statusbar? */
|
||||
if (progress->gdisp)
|
||||
bar = progress->gdisp->progressbar;
|
||||
else
|
||||
bar = progress->progressbar;
|
||||
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (bar), percentage);
|
||||
}
|
||||
|
||||
|
||||
/* This function's prototype is conveniently the same as progress_func_t */
|
||||
void
|
||||
progress_update_and_flush (int ymin, int ymax, int curr_y, gpointer data)
|
||||
{
|
||||
progress_update ((gimp_progress *)data,
|
||||
(float)(curr_y - ymin) / (float)(ymax - ymin));
|
||||
|
||||
/* HACK until we do long-running operations in the gtk idle thread */
|
||||
while (gtk_events_pending())
|
||||
gtk_main_iteration();
|
||||
}
|
||||
|
||||
|
||||
/* Step the progress bar by one percent, wrapping at 100% */
|
||||
void
|
||||
progress_step (gimp_progress *progress)
|
||||
{
|
||||
GtkWidget *bar;
|
||||
float val;
|
||||
|
||||
g_return_if_fail (progress != NULL);
|
||||
|
||||
if (progress->gdisp)
|
||||
bar = progress->gdisp->progressbar;
|
||||
else
|
||||
bar = progress->progressbar;
|
||||
|
||||
val = gtk_progress_get_current_percentage (GTK_PROGRESS (bar)) + 0.01;
|
||||
if (val > 1.0)
|
||||
val = 0.0;
|
||||
|
||||
progress_update (progress, val);
|
||||
}
|
||||
|
||||
|
||||
/* Finish using the progress bar "p" */
|
||||
void
|
||||
progress_end (gimp_progress *p)
|
||||
{
|
||||
int cid;
|
||||
|
||||
g_return_if_fail (p != NULL);
|
||||
|
||||
/* remove all callbacks so they don't get called while we're
|
||||
* destroying widgets */
|
||||
progress_signal_setup (p, NULL, NULL);
|
||||
|
||||
if (p->gdisp)
|
||||
{
|
||||
cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (p->gdisp->statusbar),
|
||||
"progress");
|
||||
gtk_statusbar_pop (GTK_STATUSBAR (p->gdisp->statusbar), cid);
|
||||
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (p->gdisp->progressbar), 0.0);
|
||||
|
||||
if (p->gdisp->progressid > 0)
|
||||
p->gdisp->progressid--;
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_destroy (p->dialog);
|
||||
}
|
||||
|
||||
g_free (p);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Helper function to add or remove signals */
|
||||
static void
|
||||
progress_signal_setup (gimp_progress *p,
|
||||
GtkSignalFunc cancel_callback,
|
||||
gpointer cancel_data)
|
||||
{
|
||||
GtkWidget *button;
|
||||
GtkWidget *dialog;
|
||||
|
||||
if (p->cancel_callback == cancel_callback && p->cancel_data == cancel_data)
|
||||
return;
|
||||
|
||||
/* are we using the statusbar or a freestanding dialog? */
|
||||
if (p->gdisp)
|
||||
{
|
||||
dialog = NULL;
|
||||
button = p->gdisp->cancelbutton;
|
||||
}
|
||||
else
|
||||
{
|
||||
dialog = p->dialog;
|
||||
button = p->cancelbutton;
|
||||
}
|
||||
|
||||
/* remove any existing signal handlers */
|
||||
if (p->cancel_callback)
|
||||
{
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (button),
|
||||
p->cancel_callback, p->cancel_data);
|
||||
if (dialog)
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (dialog),
|
||||
p->cancel_callback, p->cancel_data);
|
||||
}
|
||||
|
||||
/* add the new handlers */
|
||||
if (cancel_callback)
|
||||
{
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
cancel_callback, cancel_data);
|
||||
|
||||
if (dialog)
|
||||
gtk_signal_connect (GTK_OBJECT (dialog), "destroy",
|
||||
cancel_callback, cancel_data);
|
||||
}
|
||||
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (button),
|
||||
cancel_callback? TRUE : FALSE);
|
||||
|
||||
p->cancel_callback = cancel_callback;
|
||||
p->cancel_data = cancel_data;
|
||||
}
|
||||
|
||||
|
||||
/* End of gimpprogress.c */
|
|
@ -0,0 +1,47 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __GIMPPROGRESS_H__
|
||||
#define __GIMPPROGRESS_H__
|
||||
|
||||
#include "gdisplayF.h"
|
||||
|
||||
|
||||
/* Progress bars for use internally by the main GIMP application. */
|
||||
|
||||
|
||||
/* structures */
|
||||
struct gimp_progress_pvt;
|
||||
|
||||
/* typedefs */
|
||||
typedef struct gimp_progress_pvt gimp_progress;
|
||||
typedef void (*progress_func_t) (int ymin, int ymax, int curr_y,
|
||||
gpointer progress_data);
|
||||
|
||||
/* functions */
|
||||
gimp_progress * progress_start (GDisplay *, const char *, gboolean,
|
||||
GtkSignalFunc, gpointer);
|
||||
gimp_progress * progress_restart (gimp_progress *, const char *,
|
||||
GtkSignalFunc, gpointer);
|
||||
void progress_update (gimp_progress *, float);
|
||||
void progress_step (gimp_progress *);
|
||||
void progress_end (gimp_progress *);
|
||||
|
||||
void progress_update_and_flush (int, int, int, gpointer);
|
||||
|
||||
|
||||
#endif /* __GIMPPROGRESS_H__ */
|
|
@ -133,7 +133,7 @@ flip_tool_transform_horz (Tool *tool,
|
|||
break;
|
||||
|
||||
case FINISH :
|
||||
transform_core->trans_info[FLIP] *= -1.0;
|
||||
/* transform_core->trans_info[FLIP] *= -1.0;*/
|
||||
return flip_tool_flip_horz (gdisp->gimage, gimage_active_drawable (gdisp->gimage),
|
||||
transform_core->original, transform_core->trans_info[FLIP]);
|
||||
break;
|
||||
|
@ -166,7 +166,7 @@ flip_tool_transform_vert (Tool *tool,
|
|||
break;
|
||||
|
||||
case FINISH :
|
||||
transform_core->trans_info[FLIP] *= -1.0;
|
||||
/*transform_core->trans_info[FLIP] *= -1.0;*/
|
||||
return flip_tool_flip_vert (gdisp->gimage, gimage_active_drawable (gdisp->gimage),
|
||||
transform_core->original, transform_core->trans_info[FLIP]);
|
||||
break;
|
||||
|
@ -213,7 +213,7 @@ tools_new_flip_horz ()
|
|||
|
||||
/* set the rotation specific transformation attributes */
|
||||
private->trans_func = flip_tool_transform_horz;
|
||||
private->trans_info[FLIP] = 1.0;
|
||||
private->trans_info[FLIP] = -1.0;
|
||||
|
||||
return tool;
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ tools_new_flip_vert ()
|
|||
|
||||
/* set the rotation specific transformation attributes */
|
||||
private->trans_func = flip_tool_transform_vert;
|
||||
private->trans_info[FLIP] = 1.0;
|
||||
private->trans_info[FLIP] = -1.0;
|
||||
|
||||
return tool;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,332 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
|
||||
#include "appenv.h"
|
||||
#include "gdisplay.h"
|
||||
#include "libgimp/gimpintl.h"
|
||||
#include "gimpprogress.h"
|
||||
|
||||
|
||||
struct gimp_progress_pvt {
|
||||
GDisplay *gdisp; /* gdisp in use, or NULL*/
|
||||
|
||||
/* next four fields are only valid if gdisp is NULL */
|
||||
GtkWidget *dialog; /* progress dialog, NULL if using gdisp */
|
||||
GtkWidget *dialog_label;
|
||||
GtkWidget *progressbar;
|
||||
GtkWidget *cancelbutton;
|
||||
|
||||
GtkSignalFunc cancel_callback; /* callback to remove, or NULL */
|
||||
gpointer cancel_data;
|
||||
};
|
||||
|
||||
#define DEFAULT_PROGRESS_MESSAGE _("Please wait...")
|
||||
|
||||
|
||||
/* prototypes */
|
||||
static void progress_signal_setup (gimp_progress *, GtkSignalFunc, gpointer);
|
||||
|
||||
|
||||
/* These progress bar routines are re-entrant, and so should be
|
||||
* thread-safe. */
|
||||
|
||||
|
||||
/* Start a progress bar on "gdisp" with reason "message". If "gdisp"
|
||||
* is NULL, the progress bar is presented in a new dialog box. If
|
||||
* "message" is NULL, then no message is used.
|
||||
*
|
||||
* If "cancel_callback" is not NULL, it is attached to the progress
|
||||
* bar cancel button's "clicked" signal, with data "cancel_data". The
|
||||
* cancel button is only made sensitive if the callback is set.
|
||||
*
|
||||
* It is an error to progress_start() a bar on a "gdisp" for which
|
||||
* there is already a progress bar active.
|
||||
*
|
||||
* Progress bars with "important" set to TRUE will be shown to the
|
||||
* user in any possible way. Unimportant progress bars will not be
|
||||
* shown to the user if it would mean creating a new window.
|
||||
*/
|
||||
gimp_progress *
|
||||
progress_start (GDisplay *gdisp, const char *message, gboolean important,
|
||||
GtkSignalFunc cancel_callback, gpointer cancel_data)
|
||||
{
|
||||
gimp_progress *p;
|
||||
guint cid;
|
||||
GtkWidget *vbox;
|
||||
|
||||
p = g_malloc (sizeof (*p));
|
||||
|
||||
p->gdisp = gdisp;
|
||||
p->dialog = NULL;
|
||||
p->cancel_callback = NULL;
|
||||
p->cancel_data = NULL;
|
||||
|
||||
/* do we have a useful gdisplay and statusarea? */
|
||||
if (gdisp && GTK_WIDGET_VISIBLE (gdisp->statusarea))
|
||||
{
|
||||
if (message)
|
||||
{
|
||||
cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (gdisp->statusbar),
|
||||
"progress");
|
||||
|
||||
gtk_statusbar_push (GTK_STATUSBAR (gdisp->statusbar), cid, message);
|
||||
}
|
||||
|
||||
/* really need image locking to stop multiple people going at
|
||||
* the image */
|
||||
if (gdisp->progressid)
|
||||
g_warning("%d progress bars already active for display %p\n",
|
||||
gdisp->progressid, gdisp);
|
||||
gdisp->progressid++;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* unimporant progress indications are occasionally failed */
|
||||
if (!important)
|
||||
{
|
||||
g_free (p);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
p->gdisp = NULL;
|
||||
p->dialog = gtk_dialog_new ();
|
||||
|
||||
/* not strictly true anymore, but needed in case anyone's window
|
||||
* manager knows about WMCLASS "plug_in_progress" */
|
||||
gtk_window_set_wmclass (GTK_WINDOW (p->dialog),
|
||||
"plug_in_progress", "Gimp");
|
||||
|
||||
gtk_window_set_title (GTK_WINDOW (p->dialog), _("Progress"));
|
||||
|
||||
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (p->dialog)->action_area), 2);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (p->dialog)->vbox), vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
p->dialog_label = gtk_label_new (message? message :
|
||||
DEFAULT_PROGRESS_MESSAGE);
|
||||
gtk_misc_set_alignment (GTK_MISC (p->dialog_label), 0.0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), p->dialog_label, FALSE, TRUE, 0);
|
||||
gtk_widget_show (p->dialog_label);
|
||||
|
||||
p->progressbar = gtk_progress_bar_new ();
|
||||
gtk_widget_set_usize (p->progressbar, 150, 20);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), p->progressbar, TRUE, TRUE, 0);
|
||||
gtk_widget_show (p->progressbar);
|
||||
|
||||
p->cancelbutton = gtk_button_new_with_label (_("Cancel"));
|
||||
GTK_WIDGET_SET_FLAGS (p->cancelbutton, GTK_CAN_DEFAULT);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (p->dialog)->action_area),
|
||||
p->cancelbutton, TRUE, TRUE, 0);
|
||||
gtk_widget_grab_default (p->cancelbutton);
|
||||
gtk_widget_show (p->cancelbutton);
|
||||
|
||||
gtk_widget_show (p->dialog);
|
||||
}
|
||||
|
||||
progress_signal_setup (p, cancel_callback, cancel_data);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
/* Update the message and/or the callbacks for a progress and reset
|
||||
* the bar to zero, with the minimum of disturbance to the user. */
|
||||
gimp_progress *
|
||||
progress_restart (gimp_progress *p, const char *message,
|
||||
GtkSignalFunc cancel_callback, gpointer cancel_data)
|
||||
{
|
||||
int cid;
|
||||
GtkWidget *bar;
|
||||
|
||||
g_return_val_if_fail (p != NULL, p);
|
||||
|
||||
/* change the message */
|
||||
if (p->gdisp)
|
||||
{
|
||||
cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (p->gdisp->statusbar),
|
||||
"progress");
|
||||
gtk_statusbar_pop (GTK_STATUSBAR (p->gdisp->statusbar), cid);
|
||||
|
||||
if (message)
|
||||
gtk_statusbar_push (GTK_STATUSBAR (p->gdisp->statusbar), cid, message);
|
||||
|
||||
bar = p->gdisp->progressbar;
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_label_set_text (GTK_LABEL (p->dialog_label),
|
||||
message? message : DEFAULT_PROGRESS_MESSAGE);
|
||||
bar = p->progressbar;
|
||||
}
|
||||
|
||||
/* reset the progress bar */
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (bar), 0.0);
|
||||
|
||||
/* do we need to change the callbacks? */
|
||||
progress_signal_setup (p, cancel_callback, cancel_data);
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
progress_update (gimp_progress *progress, float percentage)
|
||||
{
|
||||
GtkWidget *bar;
|
||||
|
||||
g_return_if_fail (progress != NULL);
|
||||
|
||||
if (!(percentage >= 0.0 && percentage <= 1.0))
|
||||
return;
|
||||
|
||||
/* do we have a dialog box, or are we using the statusbar? */
|
||||
if (progress->gdisp)
|
||||
bar = progress->gdisp->progressbar;
|
||||
else
|
||||
bar = progress->progressbar;
|
||||
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (bar), percentage);
|
||||
}
|
||||
|
||||
|
||||
/* This function's prototype is conveniently the same as progress_func_t */
|
||||
void
|
||||
progress_update_and_flush (int ymin, int ymax, int curr_y, gpointer data)
|
||||
{
|
||||
progress_update ((gimp_progress *)data,
|
||||
(float)(curr_y - ymin) / (float)(ymax - ymin));
|
||||
|
||||
/* HACK until we do long-running operations in the gtk idle thread */
|
||||
while (gtk_events_pending())
|
||||
gtk_main_iteration();
|
||||
}
|
||||
|
||||
|
||||
/* Step the progress bar by one percent, wrapping at 100% */
|
||||
void
|
||||
progress_step (gimp_progress *progress)
|
||||
{
|
||||
GtkWidget *bar;
|
||||
float val;
|
||||
|
||||
g_return_if_fail (progress != NULL);
|
||||
|
||||
if (progress->gdisp)
|
||||
bar = progress->gdisp->progressbar;
|
||||
else
|
||||
bar = progress->progressbar;
|
||||
|
||||
val = gtk_progress_get_current_percentage (GTK_PROGRESS (bar)) + 0.01;
|
||||
if (val > 1.0)
|
||||
val = 0.0;
|
||||
|
||||
progress_update (progress, val);
|
||||
}
|
||||
|
||||
|
||||
/* Finish using the progress bar "p" */
|
||||
void
|
||||
progress_end (gimp_progress *p)
|
||||
{
|
||||
int cid;
|
||||
|
||||
g_return_if_fail (p != NULL);
|
||||
|
||||
/* remove all callbacks so they don't get called while we're
|
||||
* destroying widgets */
|
||||
progress_signal_setup (p, NULL, NULL);
|
||||
|
||||
if (p->gdisp)
|
||||
{
|
||||
cid = gtk_statusbar_get_context_id (GTK_STATUSBAR (p->gdisp->statusbar),
|
||||
"progress");
|
||||
gtk_statusbar_pop (GTK_STATUSBAR (p->gdisp->statusbar), cid);
|
||||
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (p->gdisp->progressbar), 0.0);
|
||||
|
||||
if (p->gdisp->progressid > 0)
|
||||
p->gdisp->progressid--;
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_widget_destroy (p->dialog);
|
||||
}
|
||||
|
||||
g_free (p);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Helper function to add or remove signals */
|
||||
static void
|
||||
progress_signal_setup (gimp_progress *p,
|
||||
GtkSignalFunc cancel_callback,
|
||||
gpointer cancel_data)
|
||||
{
|
||||
GtkWidget *button;
|
||||
GtkWidget *dialog;
|
||||
|
||||
if (p->cancel_callback == cancel_callback && p->cancel_data == cancel_data)
|
||||
return;
|
||||
|
||||
/* are we using the statusbar or a freestanding dialog? */
|
||||
if (p->gdisp)
|
||||
{
|
||||
dialog = NULL;
|
||||
button = p->gdisp->cancelbutton;
|
||||
}
|
||||
else
|
||||
{
|
||||
dialog = p->dialog;
|
||||
button = p->cancelbutton;
|
||||
}
|
||||
|
||||
/* remove any existing signal handlers */
|
||||
if (p->cancel_callback)
|
||||
{
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (button),
|
||||
p->cancel_callback, p->cancel_data);
|
||||
if (dialog)
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (dialog),
|
||||
p->cancel_callback, p->cancel_data);
|
||||
}
|
||||
|
||||
/* add the new handlers */
|
||||
if (cancel_callback)
|
||||
{
|
||||
gtk_signal_connect (GTK_OBJECT (button), "clicked",
|
||||
cancel_callback, cancel_data);
|
||||
|
||||
if (dialog)
|
||||
gtk_signal_connect (GTK_OBJECT (dialog), "destroy",
|
||||
cancel_callback, cancel_data);
|
||||
}
|
||||
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (button),
|
||||
cancel_callback? TRUE : FALSE);
|
||||
|
||||
p->cancel_callback = cancel_callback;
|
||||
p->cancel_data = cancel_data;
|
||||
}
|
||||
|
||||
|
||||
/* End of gimpprogress.c */
|
|
@ -0,0 +1,47 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
#ifndef __GIMPPROGRESS_H__
|
||||
#define __GIMPPROGRESS_H__
|
||||
|
||||
#include "gdisplayF.h"
|
||||
|
||||
|
||||
/* Progress bars for use internally by the main GIMP application. */
|
||||
|
||||
|
||||
/* structures */
|
||||
struct gimp_progress_pvt;
|
||||
|
||||
/* typedefs */
|
||||
typedef struct gimp_progress_pvt gimp_progress;
|
||||
typedef void (*progress_func_t) (int ymin, int ymax, int curr_y,
|
||||
gpointer progress_data);
|
||||
|
||||
/* functions */
|
||||
gimp_progress * progress_start (GDisplay *, const char *, gboolean,
|
||||
GtkSignalFunc, gpointer);
|
||||
gimp_progress * progress_restart (gimp_progress *, const char *,
|
||||
GtkSignalFunc, gpointer);
|
||||
void progress_update (gimp_progress *, float);
|
||||
void progress_step (gimp_progress *);
|
||||
void progress_end (gimp_progress *);
|
||||
|
||||
void progress_update_and_flush (int, int, int, gpointer);
|
||||
|
||||
|
||||
#endif /* __GIMPPROGRESS_H__ */
|
|
@ -95,6 +95,7 @@ char * default_palette = NULL;
|
|||
char * gradient_path = NULL;
|
||||
char * default_gradient = NULL;
|
||||
char * pluginrc_path = NULL;
|
||||
char * module_path = NULL;
|
||||
int tile_cache_size = 4194304; /* 4 MB */
|
||||
int marching_speed = 150; /* 150 ms */
|
||||
double gamma_val = 1.0;
|
||||
|
@ -200,6 +201,7 @@ static ParseFunc funcs[] =
|
|||
{ "palette-path", TT_PATH, &palette_path, NULL },
|
||||
{ "gradient-path", TT_PATH, &gradient_path, NULL },
|
||||
{ "pluginrc-path", TT_PATH, &pluginrc_path, NULL },
|
||||
{ "module-path", TT_PATH, &module_path, NULL },
|
||||
{ "default-brush", TT_STRING, &default_brush, NULL },
|
||||
{ "default-pattern", TT_STRING, &default_pattern, NULL },
|
||||
{ "default-palette", TT_STRING, &default_palette, NULL },
|
||||
|
|
|
@ -34,6 +34,7 @@ extern char * default_palette;
|
|||
extern char * gradient_path;
|
||||
extern char * default_gradient;
|
||||
extern char * pluginrc_path;
|
||||
extern char * module_path;
|
||||
extern int tile_cache_size;
|
||||
extern int marching_speed;
|
||||
extern int last_opened_size;
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <stdlib.h>
|
||||
#include "appenv.h"
|
||||
#include "color_area.h"
|
||||
#include "color_select.h"
|
||||
#include "color_notebook.h"
|
||||
#include "colormaps.h"
|
||||
#include "palette.h"
|
||||
|
||||
|
@ -37,8 +37,8 @@ static GtkWidget *color_area = NULL;
|
|||
static GdkPixmap *color_area_pixmap = NULL;
|
||||
static GdkPixmap *default_pixmap = NULL;
|
||||
static GdkPixmap *swap_pixmap = NULL;
|
||||
static ColorSelectP color_select = NULL;
|
||||
static int color_select_active = 0;
|
||||
static ColorNotebookP color_notebook = NULL;
|
||||
static int color_notebook_active = 0;
|
||||
static int edit_color;
|
||||
static unsigned char revert_fg_r, revert_fg_g, revert_fg_b;
|
||||
static unsigned char revert_bg_r, revert_bg_g, revert_bg_b;
|
||||
|
@ -195,25 +195,25 @@ static void
|
|||
color_area_select_callback (int r,
|
||||
int g,
|
||||
int b,
|
||||
ColorSelectState state,
|
||||
ColorNotebookState state,
|
||||
void *client_data)
|
||||
{
|
||||
if (color_select)
|
||||
if (color_notebook)
|
||||
{
|
||||
switch (state) {
|
||||
case COLOR_SELECT_OK:
|
||||
color_select_hide (color_select);
|
||||
color_select_active = 0;
|
||||
case COLOR_NOTEBOOK_OK:
|
||||
color_notebook_hide (color_notebook);
|
||||
color_notebook_active = 0;
|
||||
/* Fallthrough */
|
||||
case COLOR_SELECT_UPDATE:
|
||||
case COLOR_NOTEBOOK_UPDATE:
|
||||
if (edit_color == FOREGROUND)
|
||||
palette_set_foreground (r, g, b);
|
||||
else
|
||||
palette_set_background (r, g, b);
|
||||
break;
|
||||
case COLOR_SELECT_CANCEL:
|
||||
color_select_hide (color_select);
|
||||
color_select_active = 0;
|
||||
case COLOR_NOTEBOOK_CANCEL:
|
||||
color_notebook_hide (color_notebook);
|
||||
color_notebook_active = 0;
|
||||
palette_set_foreground (revert_fg_r, revert_fg_g, revert_fg_b);
|
||||
palette_set_background (revert_bg_r, revert_bg_g, revert_bg_b);
|
||||
}
|
||||
|
@ -225,7 +225,7 @@ color_area_edit (void)
|
|||
{
|
||||
unsigned char r, g, b;
|
||||
|
||||
if (!color_select_active)
|
||||
if (!color_notebook_active)
|
||||
{
|
||||
palette_get_foreground (&revert_fg_r, &revert_fg_g, &revert_fg_b);
|
||||
palette_get_background (&revert_bg_r, &revert_bg_g, &revert_bg_b);
|
||||
|
@ -241,19 +241,19 @@ color_area_edit (void)
|
|||
edit_color = BACKGROUND;
|
||||
}
|
||||
|
||||
if (! color_select)
|
||||
if (! color_notebook)
|
||||
{
|
||||
color_select = color_select_new (r, g, b, color_area_select_callback, NULL, TRUE);
|
||||
color_select_active = 1;
|
||||
color_notebook = color_notebook_new (r, g, b, color_area_select_callback, NULL, TRUE);
|
||||
color_notebook_active = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! color_select_active)
|
||||
color_select_show (color_select);
|
||||
if (! color_notebook_active)
|
||||
color_notebook_show (color_notebook);
|
||||
else
|
||||
gdk_window_raise (color_select->shell->window);
|
||||
gdk_window_raise (color_notebook->shell->window);
|
||||
|
||||
color_select_set_color (color_select, r, g, b, 1);
|
||||
color_notebook_set_color (color_notebook, r, g, b, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,459 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* color_notebook module (C) 1998 Austin Donnelly <austin@greenend.org.uk>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "appenv.h"
|
||||
#include "actionarea.h"
|
||||
#include "color_notebook.h"
|
||||
|
||||
#include "libgimp/color_selector.h"
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
|
||||
static void color_notebook_ok_callback (GtkWidget *, gpointer);
|
||||
static void color_notebook_cancel_callback (GtkWidget *, gpointer);
|
||||
static gint color_notebook_delete_callback (GtkWidget *, GdkEvent *, gpointer);
|
||||
static void color_notebook_update_callback (void *, int, int, int);
|
||||
static void color_notebook_page_switch (GtkWidget *, GtkNotebookPage *, guint);
|
||||
|
||||
|
||||
static ActionAreaItem action_items[2] =
|
||||
{
|
||||
{ N_("OK"), color_notebook_ok_callback, NULL, NULL },
|
||||
{ N_("Cancel"), color_notebook_cancel_callback, NULL, NULL },
|
||||
};
|
||||
|
||||
|
||||
/* information we keep on each registered colour selector */
|
||||
typedef struct _ColorSelectorInfo {
|
||||
char *name; /* label used in notebook tab */
|
||||
GimpColorSelectorMethods m;
|
||||
int refs; /* number of instances around */
|
||||
gboolean active;
|
||||
void (*death_callback) (void *data);
|
||||
void *death_data;
|
||||
struct _ColorSelectorInfo *next;
|
||||
} ColorSelectorInfo;
|
||||
|
||||
typedef struct _ColorSelectorInstance {
|
||||
_ColorNotebook *color_notebook;
|
||||
ColorSelectorInfo *info;
|
||||
GtkWidget *frame; /* main widget */
|
||||
gpointer selector_data;
|
||||
struct _ColorSelectorInstance *next;
|
||||
} ColorSelectorInstance;
|
||||
|
||||
static void selector_death (ColorSelectorInfo *info);
|
||||
|
||||
|
||||
/* master list of all registered colour selectors */
|
||||
static ColorSelectorInfo *selector_info = NULL;
|
||||
|
||||
|
||||
#define RED 0
|
||||
#define GREEN 1
|
||||
#define BLUE 2
|
||||
#define NUM_COLORS 3
|
||||
|
||||
|
||||
ColorNotebookP
|
||||
color_notebook_new (int r,
|
||||
int g,
|
||||
int b,
|
||||
ColorNotebookCallback callback,
|
||||
void *client_data,
|
||||
int wants_updates)
|
||||
{
|
||||
ColorNotebookP cnp;
|
||||
GtkWidget *label;
|
||||
ColorSelectorInfo *info;
|
||||
ColorSelectorInstance *csel;
|
||||
|
||||
g_return_val_if_fail (selector_info != NULL, NULL);
|
||||
|
||||
cnp = g_malloc (sizeof (_ColorNotebook));
|
||||
|
||||
cnp->callback = callback;
|
||||
cnp->client_data = client_data;
|
||||
cnp->wants_updates = wants_updates;
|
||||
cnp->selectors = NULL;
|
||||
cnp->cur_page = NULL;
|
||||
|
||||
cnp->values[RED] = cnp->orig_values[RED] = r & 0xff;
|
||||
cnp->values[GREEN] = cnp->orig_values[GREEN] = g & 0xff;
|
||||
cnp->values[BLUE] = cnp->orig_values[BLUE] = b & 0xff;
|
||||
|
||||
/* window hints need to stay the same, so people's window manager
|
||||
* setups still work */
|
||||
cnp->shell = gtk_dialog_new ();
|
||||
gtk_window_set_wmclass (GTK_WINDOW (cnp->shell), "color_selection", "Gimp");
|
||||
gtk_window_set_title (GTK_WINDOW (cnp->shell), _("Color Selection"));
|
||||
gtk_window_set_policy (GTK_WINDOW (cnp->shell), FALSE, FALSE, FALSE);
|
||||
|
||||
/* handle the wm close signal */
|
||||
gtk_signal_connect (GTK_OBJECT (cnp->shell), "delete_event",
|
||||
(GtkSignalFunc) color_notebook_delete_callback, cnp);
|
||||
|
||||
/* do we actually need a notebook? */
|
||||
if (selector_info->next)
|
||||
{
|
||||
cnp->notebook = gtk_notebook_new ();
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (cnp->shell)->vbox),
|
||||
cnp->notebook, TRUE, TRUE, 1);
|
||||
gtk_widget_show (cnp->notebook);
|
||||
}
|
||||
else /* only one selector */
|
||||
{
|
||||
cnp->notebook = NULL;
|
||||
}
|
||||
|
||||
/* create each registered colour selector */
|
||||
info = selector_info;
|
||||
while (info)
|
||||
{
|
||||
if (info->active)
|
||||
{
|
||||
|
||||
csel = g_malloc (sizeof (ColorSelectorInstance));
|
||||
csel->color_notebook = cnp;
|
||||
csel->info = info;
|
||||
info->refs++;
|
||||
csel->frame = info->m.new (r, g, b,
|
||||
color_notebook_update_callback, csel,
|
||||
&csel->selector_data);
|
||||
gtk_object_set_data (GTK_OBJECT (csel->frame), "gimp_color_notebook",
|
||||
csel);
|
||||
|
||||
if (cnp->notebook)
|
||||
{
|
||||
label = gtk_label_new (info->name);
|
||||
gtk_widget_show (label);
|
||||
gtk_notebook_append_page (GTK_NOTEBOOK (cnp->notebook),
|
||||
csel->frame, label);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (cnp->shell)->vbox),
|
||||
csel->frame, TRUE, TRUE, 1);
|
||||
}
|
||||
|
||||
gtk_widget_show (csel->frame);
|
||||
|
||||
if (!cnp->cur_page)
|
||||
cnp->cur_page = csel;
|
||||
|
||||
/* link into list of all selectors hanging off the new notebook */
|
||||
csel->next = cnp->selectors;
|
||||
cnp->selectors = csel;
|
||||
}
|
||||
|
||||
info = info->next;
|
||||
}
|
||||
|
||||
/* The action area */
|
||||
action_items[0].user_data = cnp;
|
||||
action_items[1].user_data = cnp;
|
||||
if (cnp->wants_updates)
|
||||
{
|
||||
action_items[0].label = _("Close");
|
||||
action_items[1].label = _("Revert to Old Color");
|
||||
}
|
||||
else
|
||||
{
|
||||
action_items[0].label = _("OK");
|
||||
action_items[1].label = _("Cancel");
|
||||
}
|
||||
build_action_area (GTK_DIALOG (cnp->shell), action_items, 2, 0);
|
||||
|
||||
gtk_widget_show (cnp->shell);
|
||||
|
||||
/* this must come after showing the widget, otherwise we get a
|
||||
* switch_page signal for a non-visible color selector, which is bad
|
||||
* news. */
|
||||
if (cnp->notebook)
|
||||
{
|
||||
gtk_object_set_user_data (GTK_OBJECT (cnp->notebook), cnp);
|
||||
gtk_signal_connect (GTK_OBJECT (cnp->notebook), "switch_page",
|
||||
(GtkSignalFunc)color_notebook_page_switch, NULL);
|
||||
}
|
||||
|
||||
return cnp;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
color_notebook_show (ColorNotebookP cnp)
|
||||
{
|
||||
g_return_if_fail (cnp != NULL);
|
||||
gtk_widget_show (cnp->shell);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
color_notebook_hide (ColorNotebookP cnp)
|
||||
{
|
||||
g_return_if_fail (cnp != NULL);
|
||||
gtk_widget_hide (cnp->shell);
|
||||
}
|
||||
|
||||
void
|
||||
color_notebook_free (ColorNotebookP cnp)
|
||||
{
|
||||
ColorSelectorInstance *csel, *next;
|
||||
|
||||
g_return_if_fail (cnp != NULL);
|
||||
|
||||
gtk_widget_destroy (cnp->shell);
|
||||
|
||||
/* call the free functions for all the colour selectors */
|
||||
csel = cnp->selectors;
|
||||
while (csel)
|
||||
{
|
||||
next = csel->next;
|
||||
|
||||
csel->info->m.free (csel->selector_data);
|
||||
|
||||
csel->info->refs--;
|
||||
if (csel->info->refs == 0 && !csel->info->active)
|
||||
selector_death (csel->info);
|
||||
|
||||
g_free (csel);
|
||||
csel = next;
|
||||
}
|
||||
|
||||
g_free (cnp);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
color_notebook_set_color (ColorNotebookP cnp,
|
||||
int r,
|
||||
int g,
|
||||
int b,
|
||||
int set_current)
|
||||
{
|
||||
ColorSelectorInstance *csel;
|
||||
g_return_if_fail (cnp != NULL);
|
||||
|
||||
cnp->orig_values[RED] = r;
|
||||
cnp->orig_values[GREEN] = g;
|
||||
cnp->orig_values[BLUE] = b;
|
||||
|
||||
if (set_current)
|
||||
{
|
||||
cnp->values[RED] = r;
|
||||
cnp->values[GREEN] = g;
|
||||
cnp->values[BLUE] = b;
|
||||
}
|
||||
|
||||
csel = cnp->cur_page;
|
||||
csel->info->m.setcolor (csel->selector_data, r, g, b, set_current);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Called by a colour selector on user selection of a colour */
|
||||
static void
|
||||
color_notebook_update_callback (void *data, int r, int g, int b)
|
||||
{
|
||||
ColorSelectorInstance *csel;
|
||||
ColorNotebookP cnp;
|
||||
|
||||
g_return_if_fail (data != NULL);
|
||||
|
||||
csel = (ColorSelectorInstance *) data;
|
||||
cnp = csel->color_notebook;
|
||||
|
||||
cnp->values[RED] = r;
|
||||
cnp->values[GREEN] = g;
|
||||
cnp->values[BLUE] = b;
|
||||
|
||||
if (cnp->wants_updates && cnp->callback)
|
||||
{
|
||||
(* cnp->callback) (cnp->values[RED],
|
||||
cnp->values[GREEN],
|
||||
cnp->values[BLUE],
|
||||
COLOR_NOTEBOOK_UPDATE,
|
||||
cnp->client_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void
|
||||
color_notebook_ok_callback (GtkWidget *w,
|
||||
gpointer client_data)
|
||||
{
|
||||
ColorNotebookP cnp;
|
||||
|
||||
cnp = (ColorNotebookP) client_data;
|
||||
|
||||
if (cnp->callback)
|
||||
(* cnp->callback) (cnp->values[RED],
|
||||
cnp->values[GREEN],
|
||||
cnp->values[BLUE],
|
||||
COLOR_NOTEBOOK_OK,
|
||||
cnp->client_data);
|
||||
}
|
||||
|
||||
|
||||
static gint
|
||||
color_notebook_delete_callback (GtkWidget *w,
|
||||
GdkEvent *e,
|
||||
gpointer client_data)
|
||||
{
|
||||
color_notebook_cancel_callback (w, client_data);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
color_notebook_cancel_callback (GtkWidget *w,
|
||||
gpointer client_data)
|
||||
{
|
||||
ColorNotebookP cnp;
|
||||
|
||||
cnp = (ColorNotebookP) client_data;
|
||||
|
||||
if (cnp->callback)
|
||||
(* cnp->callback) (cnp->orig_values[RED],
|
||||
cnp->orig_values[GREEN],
|
||||
cnp->orig_values[BLUE],
|
||||
COLOR_NOTEBOOK_CANCEL,
|
||||
cnp->client_data);
|
||||
}
|
||||
|
||||
static void
|
||||
color_notebook_page_switch (GtkWidget *w,
|
||||
GtkNotebookPage *page,
|
||||
guint page_num)
|
||||
{
|
||||
ColorNotebookP cnp;
|
||||
ColorSelectorInstance *csel;
|
||||
|
||||
cnp = gtk_object_get_user_data (GTK_OBJECT (w));
|
||||
csel = gtk_object_get_data (GTK_OBJECT(page->child), "gimp_color_notebook");
|
||||
|
||||
g_return_if_fail (cnp != NULL && csel != NULL);
|
||||
|
||||
cnp->cur_page = csel;
|
||||
csel->info->m.setcolor (csel->selector_data,
|
||||
cnp->values[RED],
|
||||
cnp->values[GREEN],
|
||||
cnp->values[BLUE],
|
||||
TRUE);
|
||||
}
|
||||
|
||||
/**************************************************************/
|
||||
/* Registration functions */
|
||||
|
||||
|
||||
GimpColorSelectorID
|
||||
gimp_color_selector_register (const char *name,
|
||||
GimpColorSelectorMethods *methods)
|
||||
{
|
||||
ColorSelectorInfo *info;
|
||||
|
||||
/* check the name is unique */
|
||||
info = selector_info;
|
||||
while (info)
|
||||
{
|
||||
if (!strcmp (info->name, name))
|
||||
return NULL;
|
||||
info = info->next;
|
||||
}
|
||||
|
||||
info = g_malloc (sizeof (ColorSelectorInfo));
|
||||
|
||||
info->name = g_strdup (name);
|
||||
info->m = *methods;
|
||||
info->refs = 0;
|
||||
info->active = TRUE;
|
||||
|
||||
info->next = selector_info;
|
||||
selector_info = info;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
gimp_color_selector_unregister (GimpColorSelectorID id,
|
||||
void (*callback)(void *data),
|
||||
void *data)
|
||||
{
|
||||
ColorSelectorInfo *info;
|
||||
|
||||
info = selector_info;
|
||||
while (info)
|
||||
{
|
||||
if (info == id)
|
||||
{
|
||||
info->active = FALSE;
|
||||
info->death_callback = callback;
|
||||
info->death_data = data;
|
||||
if (info->refs == 0)
|
||||
selector_death (info);
|
||||
return TRUE;
|
||||
}
|
||||
info = info->next;
|
||||
}
|
||||
|
||||
g_warning ("unknown color selector id %p", id);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
selector_death (ColorSelectorInfo *info)
|
||||
{
|
||||
ColorSelectorInfo *here, *prev;
|
||||
|
||||
here = selector_info;
|
||||
prev = NULL;
|
||||
while (here)
|
||||
{
|
||||
if (here == info)
|
||||
{
|
||||
if (prev)
|
||||
prev->next = info->next;
|
||||
else
|
||||
selector_info = info->next;
|
||||
|
||||
if (info->death_callback)
|
||||
(*info->death_callback) (info->death_data);
|
||||
|
||||
g_free (info->name);
|
||||
g_free (info);
|
||||
|
||||
return;
|
||||
}
|
||||
prev = here;
|
||||
here = here->next;
|
||||
}
|
||||
|
||||
g_warning ("color selector %p not found, can't happen!", info);
|
||||
}
|
||||
|
||||
|
||||
/* End of color_notebook.c */
|
|
@ -0,0 +1,53 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __COLOR_NOTEBOOK_H__
|
||||
#define __COLOR_NOTEBOOK_H__
|
||||
|
||||
typedef enum {
|
||||
COLOR_NOTEBOOK_OK,
|
||||
COLOR_NOTEBOOK_CANCEL,
|
||||
COLOR_NOTEBOOK_UPDATE
|
||||
} ColorNotebookState;
|
||||
|
||||
typedef struct _ColorNotebook _ColorNotebook, *ColorNotebookP;
|
||||
typedef void (*ColorNotebookCallback) (int, int, int, ColorNotebookState,
|
||||
void *);
|
||||
|
||||
struct _ColorSelectorInstance;
|
||||
|
||||
struct _ColorNotebook {
|
||||
GtkWidget *shell;
|
||||
GtkWidget *notebook;
|
||||
int values[3];
|
||||
int orig_values[3];
|
||||
ColorNotebookCallback callback;
|
||||
void *client_data;
|
||||
int wants_updates;
|
||||
struct _ColorSelectorInstance *selectors;
|
||||
struct _ColorSelectorInstance *cur_page;
|
||||
};
|
||||
|
||||
ColorNotebookP color_notebook_new (int, int, int, ColorNotebookCallback, void *, int);
|
||||
void color_notebook_show (ColorNotebookP);
|
||||
void color_notebook_hide (ColorNotebookP);
|
||||
void color_notebook_free (ColorNotebookP);
|
||||
void color_notebook_set_color (ColorNotebookP, int, int, int, int);
|
||||
|
||||
|
||||
#endif /* __COLOR_NOTEBOOK_H__ */
|
|
@ -20,6 +20,7 @@
|
|||
#include "appenv.h"
|
||||
#include "actionarea.h"
|
||||
#include "color_select.h"
|
||||
#include "libgimp/color_selector.h"
|
||||
#include "colormaps.h"
|
||||
#include "errors.h"
|
||||
#include "gimprc.h"
|
||||
|
@ -76,6 +77,8 @@ struct _ColorSelectFill {
|
|||
ColorSelectFillUpdateProc update;
|
||||
};
|
||||
|
||||
static GtkWidget * color_select_widget_new (ColorSelectP, int, int, int);
|
||||
|
||||
static void color_select_update (ColorSelectP, ColorSelectUpdateType);
|
||||
static void color_select_update_caller (ColorSelectP);
|
||||
static void color_select_update_values (ColorSelectP);
|
||||
|
@ -117,6 +120,18 @@ static void color_select_update_hue_saturation (ColorSelectFill *);
|
|||
static void color_select_update_hue_value (ColorSelectFill *);
|
||||
static void color_select_update_saturation_value (ColorSelectFill *);
|
||||
|
||||
static GtkWidget * color_select_notebook_new (int, int, int,
|
||||
GimpColorSelector_Callback,
|
||||
void *, void **);
|
||||
static void color_select_notebook_free (void *);
|
||||
static void color_select_notebook_setcolor (void *, int, int, int, int);
|
||||
static void color_select_notebook_update_callback (int, int, int,
|
||||
ColorSelectState, void *);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static ColorSelectFillUpdateProc update_procs[] =
|
||||
{
|
||||
color_select_update_hue,
|
||||
|
@ -147,26 +162,8 @@ color_select_new (int r,
|
|||
void *client_data,
|
||||
int wants_updates)
|
||||
{
|
||||
/* static char *toggle_titles[6] = { "Hue", "Saturation", "Value", "Red", "Green", "Blue" }; */
|
||||
static char *toggle_titles[6] = { "H", "S", "V", "R", "G", "B" };
|
||||
static gfloat slider_max_vals[6] = { 360, 100, 100, 255, 255, 255 };
|
||||
static gfloat slider_incs[6] = { 0.1, 0.1, 0.1, 1.0, 1.0, 1.0 };
|
||||
|
||||
ColorSelectP csp;
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *main_hbox;
|
||||
GtkWidget *xy_frame;
|
||||
GtkWidget *z_frame;
|
||||
GtkWidget *colors_frame;
|
||||
GtkWidget *colors_hbox;
|
||||
GtkWidget *right_vbox;
|
||||
GtkWidget *table;
|
||||
GtkWidget *slider;
|
||||
GtkWidget *hex_hbox;
|
||||
GtkWidget *label;
|
||||
GSList *group;
|
||||
char buffer[16];
|
||||
int i;
|
||||
|
||||
csp = g_malloc (sizeof (_ColorSelect));
|
||||
|
||||
|
@ -193,10 +190,58 @@ color_select_new (int r,
|
|||
gtk_signal_connect (GTK_OBJECT (csp->shell), "delete_event",
|
||||
(GtkSignalFunc) color_select_delete_callback, csp);
|
||||
|
||||
main_vbox = color_select_widget_new (csp, r, g, b);
|
||||
gtk_widget_show (main_vbox);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (csp->shell)->vbox), main_vbox, TRUE, TRUE, 0);
|
||||
|
||||
/* The action area */
|
||||
action_items[0].user_data = csp;
|
||||
action_items[1].user_data = csp;
|
||||
if (csp->wants_updates)
|
||||
{
|
||||
action_items[0].label = _("Close");
|
||||
action_items[1].label = _("Revert to Old Color");
|
||||
}
|
||||
else
|
||||
{
|
||||
action_items[0].label = _("OK");
|
||||
action_items[1].label = _("Cancel");
|
||||
}
|
||||
build_action_area (GTK_DIALOG (csp->shell), action_items, 2, 0);
|
||||
|
||||
color_select_image_fill (csp->z_color, csp->z_color_fill, csp->values);
|
||||
color_select_image_fill (csp->xy_color, csp->xy_color_fill, csp->values);
|
||||
|
||||
gtk_widget_show (csp->shell);
|
||||
|
||||
return csp;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
color_select_widget_new (ColorSelectP csp, int r, int g, int b)
|
||||
{
|
||||
static char *toggle_titles[6] = { "H", "S", "V", "R", "G", "B" };
|
||||
static gfloat slider_max_vals[6] = { 360, 100, 100, 255, 255, 255 };
|
||||
static gfloat slider_incs[6] = { 0.1, 0.1, 0.1, 1.0, 1.0, 1.0 };
|
||||
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *main_hbox;
|
||||
GtkWidget *xy_frame;
|
||||
GtkWidget *z_frame;
|
||||
GtkWidget *colors_frame;
|
||||
GtkWidget *colors_hbox;
|
||||
GtkWidget *right_vbox;
|
||||
GtkWidget *table;
|
||||
GtkWidget *slider;
|
||||
GtkWidget *hex_hbox;
|
||||
GtkWidget *label;
|
||||
GSList *group;
|
||||
char buffer[16];
|
||||
int i;
|
||||
|
||||
main_vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 2);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (csp->shell)->vbox), main_vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (main_vbox);
|
||||
|
||||
main_hbox = gtk_hbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (main_hbox), 0);
|
||||
|
@ -341,29 +386,25 @@ color_select_new (int r,
|
|||
gtk_box_pack_end (GTK_BOX (hex_hbox), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
/* The action area */
|
||||
action_items[0].user_data = csp;
|
||||
action_items[1].user_data = csp;
|
||||
if (csp->wants_updates)
|
||||
{
|
||||
action_items[0].label = _("Close");
|
||||
action_items[1].label = _("Revert to Old Color");
|
||||
}
|
||||
else
|
||||
{
|
||||
action_items[0].label = _("OK");
|
||||
action_items[1].label = _("Cancel");
|
||||
}
|
||||
build_action_area (GTK_DIALOG (csp->shell), action_items, 2, 0);
|
||||
|
||||
color_select_image_fill (csp->z_color, csp->z_color_fill, csp->values);
|
||||
color_select_image_fill (csp->xy_color, csp->xy_color_fill, csp->values);
|
||||
|
||||
gtk_widget_show (csp->shell);
|
||||
|
||||
return csp;
|
||||
return main_vbox;
|
||||
}
|
||||
|
||||
|
||||
/* Register the GIMP colour selector with the color notebook */
|
||||
void
|
||||
color_select_init (void)
|
||||
{
|
||||
GimpColorSelectorMethods methods =
|
||||
{
|
||||
color_select_notebook_new,
|
||||
color_select_notebook_free,
|
||||
color_select_notebook_setcolor
|
||||
};
|
||||
|
||||
gimp_color_selector_register ("GIMP", &methods);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
color_select_show (ColorSelectP csp)
|
||||
{
|
||||
|
@ -383,7 +424,8 @@ color_select_free (ColorSelectP csp)
|
|||
{
|
||||
if (csp)
|
||||
{
|
||||
gtk_widget_destroy (csp->shell);
|
||||
if (csp->shell)
|
||||
gtk_widget_destroy (csp->shell);
|
||||
gdk_gc_destroy (csp->gc);
|
||||
g_free (csp);
|
||||
}
|
||||
|
@ -1973,3 +2015,96 @@ color_select_update_saturation_value (ColorSelectFill *csf)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*****************************/
|
||||
/* Colour notebook glue */
|
||||
|
||||
typedef struct {
|
||||
GimpColorSelector_Callback callback;
|
||||
void *client_data;
|
||||
ColorSelectP csp;
|
||||
GtkWidget *main_vbox;
|
||||
} notebook_glue;
|
||||
|
||||
|
||||
static GtkWidget *
|
||||
color_select_notebook_new (int r, int g, int b,
|
||||
GimpColorSelector_Callback callback, void *client_data,
|
||||
/* RETURNS: */
|
||||
void **selector_data)
|
||||
{
|
||||
ColorSelectP csp;
|
||||
notebook_glue *glue;
|
||||
|
||||
glue = g_malloc (sizeof (notebook_glue));
|
||||
|
||||
csp = g_malloc (sizeof (_ColorSelect));
|
||||
|
||||
glue->csp = csp;
|
||||
glue->callback = callback;
|
||||
glue->client_data = client_data;
|
||||
|
||||
csp->callback = color_select_notebook_update_callback;
|
||||
csp->client_data = glue;
|
||||
csp->z_color_fill = HUE;
|
||||
csp->xy_color_fill = SATURATION_VALUE;
|
||||
csp->gc = NULL;
|
||||
csp->wants_updates = TRUE;
|
||||
|
||||
csp->values[RED] = csp->orig_values[0] = r;
|
||||
csp->values[GREEN] = csp->orig_values[1] = g;
|
||||
csp->values[BLUE] = csp->orig_values[2] = b;
|
||||
color_select_update_hsv_values (csp);
|
||||
color_select_update_pos (csp);
|
||||
|
||||
glue->main_vbox = color_select_widget_new (csp, r, g, b);
|
||||
|
||||
/* the shell is provided by the notebook */
|
||||
csp->shell = NULL;
|
||||
|
||||
color_select_image_fill (csp->z_color, csp->z_color_fill, csp->values);
|
||||
color_select_image_fill (csp->xy_color, csp->xy_color_fill, csp->values);
|
||||
|
||||
(*selector_data) = glue;
|
||||
return glue->main_vbox;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
color_select_notebook_free (void *data)
|
||||
{
|
||||
notebook_glue *glue = data;
|
||||
|
||||
color_select_free (glue->csp);
|
||||
/* don't need to destroy the widget, since it's done by the caller
|
||||
* of this function */
|
||||
g_free (glue);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
color_select_notebook_setcolor (void *data,
|
||||
int r, int g, int b, int set_current)
|
||||
{
|
||||
notebook_glue *glue = data;
|
||||
|
||||
color_select_set_color (glue->csp, r, g, b, set_current);
|
||||
}
|
||||
|
||||
static void
|
||||
color_select_notebook_update_callback (int r, int g, int b,
|
||||
ColorSelectState state, void *data)
|
||||
{
|
||||
notebook_glue *glue = data;
|
||||
|
||||
switch (state) {
|
||||
case COLOR_SELECT_UPDATE:
|
||||
glue->callback (glue->client_data, r, g, b);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_warning ("state %d can't happen!", state);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,6 +48,8 @@ struct _ColorSelect {
|
|||
GdkGC *gc;
|
||||
};
|
||||
|
||||
void color_select_init (void);
|
||||
|
||||
ColorSelectP color_select_new (int, int, int, ColorSelectCallback, void *, int);
|
||||
void color_select_show (ColorSelectP);
|
||||
void color_select_hide (ColorSelectP);
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <unistd.h>
|
||||
#include "libgimp/parasite.h"
|
||||
#include "libgimp/parasiteP.h" /* ick */
|
||||
#include "libgimp/gimpmodule.h"
|
||||
|
||||
#ifdef HAVE_IPC_H
|
||||
#include <sys/ipc.h>
|
||||
|
@ -62,7 +63,7 @@
|
|||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#define SEPARATE_PROGRESS_BAR
|
||||
|
||||
|
||||
|
||||
typedef struct _PlugInBlocked PlugInBlocked;
|
||||
|
@ -126,8 +127,6 @@ static void plug_in_args_destroy (Argument *args,
|
|||
int nargs,
|
||||
int full_destroy);
|
||||
|
||||
static void plug_in_disconnect_cancel (PlugIn *plug_in);
|
||||
|
||||
static Argument* progress_init_invoker (Argument *args);
|
||||
static Argument* progress_update_invoker (Argument *args);
|
||||
|
||||
|
@ -138,6 +137,8 @@ static Argument* message_handler_set_invoker (Argument *args);
|
|||
|
||||
static Argument* plugin_temp_PDB_name_invoker (Argument *args);
|
||||
|
||||
static void module_initialize (char *filename);
|
||||
|
||||
|
||||
static GSList *plug_in_defs = NULL;
|
||||
static GSList *gimprc_proc_defs = NULL;
|
||||
|
@ -481,8 +482,79 @@ plug_in_init ()
|
|||
g_free (plug_in_def);
|
||||
}
|
||||
g_slist_free (plug_in_defs);
|
||||
|
||||
|
||||
/* Load and initialize gimp modules */
|
||||
|
||||
if (g_module_supported ())
|
||||
datafiles_read_directories (module_path,
|
||||
module_initialize, 0 /* no flags */);
|
||||
}
|
||||
|
||||
|
||||
/* name must be of the form lib*.so */
|
||||
/* TODO: need support for WIN32-style dll names. Maybe this function
|
||||
* should live in libgmodule? */
|
||||
static gboolean
|
||||
valid_module_name (const char *filename)
|
||||
{
|
||||
const char *basename;
|
||||
int len;
|
||||
|
||||
basename = strrchr (filename, '/');
|
||||
if (basename)
|
||||
basename++;
|
||||
else
|
||||
basename = filename;
|
||||
|
||||
len = strlen (basename);
|
||||
|
||||
if (len < 3 + 1 + 3)
|
||||
return FALSE;
|
||||
|
||||
if (strncmp (basename, "lib", 3))
|
||||
return FALSE;
|
||||
|
||||
if (strcmp (basename + len - 3, ".so"))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
module_initialize (char *filename)
|
||||
{
|
||||
GModule *mod;
|
||||
GimpModuleInitFunc init;
|
||||
gpointer symbol;
|
||||
|
||||
if (!valid_module_name (filename))
|
||||
return;
|
||||
|
||||
if ((be_verbose == TRUE) || (no_splash == TRUE))
|
||||
g_print (_("load module: \"%s\"\n"), filename);
|
||||
|
||||
mod = g_module_open (filename, G_MODULE_BIND_LAZY);
|
||||
if (!mod)
|
||||
{
|
||||
g_warning (_("module load error: %s: %s"), filename, g_module_error ());
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_module_symbol (mod, "module_init", &symbol))
|
||||
{
|
||||
init = symbol;
|
||||
if (init () == GIMP_MODULE_UNLOAD)
|
||||
g_module_close (mod);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning (_("%s: module_init() symbol not found"), filename);
|
||||
g_module_close (mod);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
plug_in_kill ()
|
||||
{
|
||||
|
@ -818,9 +890,6 @@ plug_in_new (char *name)
|
|||
plug_in->write_buffer_index = 0;
|
||||
plug_in->temp_proc_defs = NULL;
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
plug_in->progress_gdisp_ID = -1;
|
||||
plug_in->user_data = NULL;
|
||||
|
||||
return plug_in;
|
||||
|
@ -829,9 +898,6 @@ plug_in_new (char *name)
|
|||
void
|
||||
plug_in_destroy (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
guint c_id;
|
||||
|
||||
if (plug_in)
|
||||
{
|
||||
plug_in_close (plug_in, TRUE);
|
||||
|
@ -849,18 +915,9 @@ plug_in_destroy (PlugIn *plug_in)
|
|||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
c_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), c_id);
|
||||
gtk_progress_bar_update(GTK_PROGRESS_BAR(gdisp->progressbar), 0.0);
|
||||
|
||||
plug_in_disconnect_cancel (plug_in);
|
||||
|
||||
gdisp->progressid = 0;
|
||||
}
|
||||
if (plug_in->progress)
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
|
@ -1011,23 +1068,9 @@ plug_in_close (PlugIn *plug_in,
|
|||
|
||||
/* Destroy the progress dialog if it exists
|
||||
*/
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (plug_in->progress)
|
||||
{
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (plug_in->progress), plug_in);
|
||||
gtk_widget_destroy (plug_in->progress);
|
||||
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
}
|
||||
#else
|
||||
if (plug_in->progress)
|
||||
{
|
||||
progress_end ();
|
||||
plug_in->progress = NULL;
|
||||
}
|
||||
#endif
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
/* Set the fields to null values.
|
||||
*/
|
||||
|
@ -3089,32 +3132,15 @@ static void
|
|||
plug_in_progress_cancel (GtkWidget *widget,
|
||||
PlugIn *plug_in)
|
||||
{
|
||||
plug_in->progress = NULL;
|
||||
plug_in_destroy (plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_disconnect_cancel (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp = NULL;
|
||||
|
||||
gdisp = gdisplay_get_ID (plug_in->progress_gdisp_ID);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, FALSE);
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (gdisp->cancelbutton),
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_init (PlugIn *plug_in,
|
||||
char *message,
|
||||
gint gdisp_ID)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *button;
|
||||
GDisplay *gdisp = NULL;
|
||||
guint context_id;
|
||||
|
||||
if (!message)
|
||||
message = plug_in->args[0];
|
||||
|
@ -3122,100 +3148,22 @@ plug_in_progress_init (PlugIn *plug_in,
|
|||
if (gdisp_ID > 0)
|
||||
gdisp = gdisplay_get_ID(gdisp_ID);
|
||||
|
||||
if (gdisp_ID > 0 && GTK_WIDGET_VISIBLE (gdisp->statusarea)
|
||||
&& (gdisp->progressid == 0 || plug_in->progress_gdisp_ID > 0))
|
||||
{
|
||||
context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), context_id);
|
||||
|
||||
gdisp->progressid = gtk_statusbar_push(GTK_STATUSBAR(gdisp->statusbar),
|
||||
context_id, message);
|
||||
plug_in->progress_gdisp_ID = gdisp_ID;
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (gdisp->cancelbutton), "clicked",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, TRUE);
|
||||
}
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = gtk_dialog_new ();
|
||||
gtk_window_set_wmclass (GTK_WINDOW (plug_in->progress), "plug_in_progress", "Gimp");
|
||||
gtk_window_set_title (GTK_WINDOW (plug_in->progress), prune_filename (plug_in->args[0]));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (plug_in->progress), "destroy",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (plug_in->progress)->action_area), 2);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->vbox), vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
plug_in->progress_label = gtk_label_new (message);
|
||||
gtk_misc_set_alignment (GTK_MISC (plug_in->progress_label), 0.0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_label, FALSE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_label);
|
||||
|
||||
plug_in->progress_bar = gtk_progress_bar_new ();
|
||||
gtk_widget_set_usize (plug_in->progress_bar, 150, 20);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_bar, TRUE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_bar);
|
||||
|
||||
button = gtk_button_new_with_label (_("Cancel"));
|
||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) gtk_widget_destroy,
|
||||
GTK_OBJECT (plug_in->progress));
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->action_area), button, TRUE, TRUE, 0);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gtk_widget_show (plug_in->progress);
|
||||
}
|
||||
if (plug_in->progress)
|
||||
plug_in->progress = progress_restart (plug_in->progress, message,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
else
|
||||
{
|
||||
gtk_label_set (GTK_LABEL (plug_in->progress_label), message);
|
||||
}
|
||||
#else
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = 0x1;
|
||||
progress_update (0.0);
|
||||
progress_start ();
|
||||
}
|
||||
#endif
|
||||
plug_in->progress = progress_start (gdisp, message, TRUE,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_update (PlugIn *plug_in,
|
||||
double percentage)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update( GTK_PROGRESS_BAR (gdisp->progressbar), percentage);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (plug_in->progress_bar), percentage);
|
||||
#else
|
||||
progress_update (percentage);
|
||||
#endif
|
||||
}
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
progress_update (plug_in->progress, percentage);
|
||||
}
|
||||
|
||||
static Argument*
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <unistd.h>
|
||||
#include "libgimp/parasite.h"
|
||||
#include "libgimp/parasiteP.h" /* ick */
|
||||
#include "libgimp/gimpmodule.h"
|
||||
|
||||
#ifdef HAVE_IPC_H
|
||||
#include <sys/ipc.h>
|
||||
|
@ -62,7 +63,7 @@
|
|||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#define SEPARATE_PROGRESS_BAR
|
||||
|
||||
|
||||
|
||||
typedef struct _PlugInBlocked PlugInBlocked;
|
||||
|
@ -126,8 +127,6 @@ static void plug_in_args_destroy (Argument *args,
|
|||
int nargs,
|
||||
int full_destroy);
|
||||
|
||||
static void plug_in_disconnect_cancel (PlugIn *plug_in);
|
||||
|
||||
static Argument* progress_init_invoker (Argument *args);
|
||||
static Argument* progress_update_invoker (Argument *args);
|
||||
|
||||
|
@ -138,6 +137,8 @@ static Argument* message_handler_set_invoker (Argument *args);
|
|||
|
||||
static Argument* plugin_temp_PDB_name_invoker (Argument *args);
|
||||
|
||||
static void module_initialize (char *filename);
|
||||
|
||||
|
||||
static GSList *plug_in_defs = NULL;
|
||||
static GSList *gimprc_proc_defs = NULL;
|
||||
|
@ -481,8 +482,79 @@ plug_in_init ()
|
|||
g_free (plug_in_def);
|
||||
}
|
||||
g_slist_free (plug_in_defs);
|
||||
|
||||
|
||||
/* Load and initialize gimp modules */
|
||||
|
||||
if (g_module_supported ())
|
||||
datafiles_read_directories (module_path,
|
||||
module_initialize, 0 /* no flags */);
|
||||
}
|
||||
|
||||
|
||||
/* name must be of the form lib*.so */
|
||||
/* TODO: need support for WIN32-style dll names. Maybe this function
|
||||
* should live in libgmodule? */
|
||||
static gboolean
|
||||
valid_module_name (const char *filename)
|
||||
{
|
||||
const char *basename;
|
||||
int len;
|
||||
|
||||
basename = strrchr (filename, '/');
|
||||
if (basename)
|
||||
basename++;
|
||||
else
|
||||
basename = filename;
|
||||
|
||||
len = strlen (basename);
|
||||
|
||||
if (len < 3 + 1 + 3)
|
||||
return FALSE;
|
||||
|
||||
if (strncmp (basename, "lib", 3))
|
||||
return FALSE;
|
||||
|
||||
if (strcmp (basename + len - 3, ".so"))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
module_initialize (char *filename)
|
||||
{
|
||||
GModule *mod;
|
||||
GimpModuleInitFunc init;
|
||||
gpointer symbol;
|
||||
|
||||
if (!valid_module_name (filename))
|
||||
return;
|
||||
|
||||
if ((be_verbose == TRUE) || (no_splash == TRUE))
|
||||
g_print (_("load module: \"%s\"\n"), filename);
|
||||
|
||||
mod = g_module_open (filename, G_MODULE_BIND_LAZY);
|
||||
if (!mod)
|
||||
{
|
||||
g_warning (_("module load error: %s: %s"), filename, g_module_error ());
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_module_symbol (mod, "module_init", &symbol))
|
||||
{
|
||||
init = symbol;
|
||||
if (init () == GIMP_MODULE_UNLOAD)
|
||||
g_module_close (mod);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning (_("%s: module_init() symbol not found"), filename);
|
||||
g_module_close (mod);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
plug_in_kill ()
|
||||
{
|
||||
|
@ -818,9 +890,6 @@ plug_in_new (char *name)
|
|||
plug_in->write_buffer_index = 0;
|
||||
plug_in->temp_proc_defs = NULL;
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
plug_in->progress_gdisp_ID = -1;
|
||||
plug_in->user_data = NULL;
|
||||
|
||||
return plug_in;
|
||||
|
@ -829,9 +898,6 @@ plug_in_new (char *name)
|
|||
void
|
||||
plug_in_destroy (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
guint c_id;
|
||||
|
||||
if (plug_in)
|
||||
{
|
||||
plug_in_close (plug_in, TRUE);
|
||||
|
@ -849,18 +915,9 @@ plug_in_destroy (PlugIn *plug_in)
|
|||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
c_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), c_id);
|
||||
gtk_progress_bar_update(GTK_PROGRESS_BAR(gdisp->progressbar), 0.0);
|
||||
|
||||
plug_in_disconnect_cancel (plug_in);
|
||||
|
||||
gdisp->progressid = 0;
|
||||
}
|
||||
if (plug_in->progress)
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
|
@ -1011,23 +1068,9 @@ plug_in_close (PlugIn *plug_in,
|
|||
|
||||
/* Destroy the progress dialog if it exists
|
||||
*/
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (plug_in->progress)
|
||||
{
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (plug_in->progress), plug_in);
|
||||
gtk_widget_destroy (plug_in->progress);
|
||||
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
}
|
||||
#else
|
||||
if (plug_in->progress)
|
||||
{
|
||||
progress_end ();
|
||||
plug_in->progress = NULL;
|
||||
}
|
||||
#endif
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
/* Set the fields to null values.
|
||||
*/
|
||||
|
@ -3089,32 +3132,15 @@ static void
|
|||
plug_in_progress_cancel (GtkWidget *widget,
|
||||
PlugIn *plug_in)
|
||||
{
|
||||
plug_in->progress = NULL;
|
||||
plug_in_destroy (plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_disconnect_cancel (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp = NULL;
|
||||
|
||||
gdisp = gdisplay_get_ID (plug_in->progress_gdisp_ID);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, FALSE);
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (gdisp->cancelbutton),
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_init (PlugIn *plug_in,
|
||||
char *message,
|
||||
gint gdisp_ID)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *button;
|
||||
GDisplay *gdisp = NULL;
|
||||
guint context_id;
|
||||
|
||||
if (!message)
|
||||
message = plug_in->args[0];
|
||||
|
@ -3122,100 +3148,22 @@ plug_in_progress_init (PlugIn *plug_in,
|
|||
if (gdisp_ID > 0)
|
||||
gdisp = gdisplay_get_ID(gdisp_ID);
|
||||
|
||||
if (gdisp_ID > 0 && GTK_WIDGET_VISIBLE (gdisp->statusarea)
|
||||
&& (gdisp->progressid == 0 || plug_in->progress_gdisp_ID > 0))
|
||||
{
|
||||
context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), context_id);
|
||||
|
||||
gdisp->progressid = gtk_statusbar_push(GTK_STATUSBAR(gdisp->statusbar),
|
||||
context_id, message);
|
||||
plug_in->progress_gdisp_ID = gdisp_ID;
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (gdisp->cancelbutton), "clicked",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, TRUE);
|
||||
}
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = gtk_dialog_new ();
|
||||
gtk_window_set_wmclass (GTK_WINDOW (plug_in->progress), "plug_in_progress", "Gimp");
|
||||
gtk_window_set_title (GTK_WINDOW (plug_in->progress), prune_filename (plug_in->args[0]));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (plug_in->progress), "destroy",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (plug_in->progress)->action_area), 2);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->vbox), vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
plug_in->progress_label = gtk_label_new (message);
|
||||
gtk_misc_set_alignment (GTK_MISC (plug_in->progress_label), 0.0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_label, FALSE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_label);
|
||||
|
||||
plug_in->progress_bar = gtk_progress_bar_new ();
|
||||
gtk_widget_set_usize (plug_in->progress_bar, 150, 20);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_bar, TRUE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_bar);
|
||||
|
||||
button = gtk_button_new_with_label (_("Cancel"));
|
||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) gtk_widget_destroy,
|
||||
GTK_OBJECT (plug_in->progress));
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->action_area), button, TRUE, TRUE, 0);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gtk_widget_show (plug_in->progress);
|
||||
}
|
||||
if (plug_in->progress)
|
||||
plug_in->progress = progress_restart (plug_in->progress, message,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
else
|
||||
{
|
||||
gtk_label_set (GTK_LABEL (plug_in->progress_label), message);
|
||||
}
|
||||
#else
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = 0x1;
|
||||
progress_update (0.0);
|
||||
progress_start ();
|
||||
}
|
||||
#endif
|
||||
plug_in->progress = progress_start (gdisp, message, TRUE,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_update (PlugIn *plug_in,
|
||||
double percentage)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update( GTK_PROGRESS_BAR (gdisp->progressbar), percentage);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (plug_in->progress_bar), percentage);
|
||||
#else
|
||||
progress_update (percentage);
|
||||
#endif
|
||||
}
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
progress_update (plug_in->progress, percentage);
|
||||
}
|
||||
|
||||
static Argument*
|
||||
|
|
|
@ -98,8 +98,6 @@ GtkTooltips *tool_tips;
|
|||
GtkWidget *popup_shell = NULL;
|
||||
|
||||
|
||||
static GtkWidget *tool_label_area = NULL;
|
||||
static GtkWidget *progress_area = NULL;
|
||||
static GdkColor colors[12];
|
||||
static GtkWidget *toolbox_shell = NULL;
|
||||
|
||||
|
@ -1040,58 +1038,3 @@ message_box_close_callback (GtkWidget *w,
|
|||
}
|
||||
|
||||
|
||||
void
|
||||
progress_start ()
|
||||
{
|
||||
if (!GTK_WIDGET_VISIBLE (progress_area))
|
||||
{
|
||||
gtk_widget_set_usize (progress_area,
|
||||
tool_label_area->allocation.width,
|
||||
tool_label_area->allocation.height);
|
||||
|
||||
gtk_widget_hide (tool_label_area);
|
||||
gtk_widget_show (progress_area);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
progress_update (float percentage)
|
||||
{
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (progress_area), percentage);
|
||||
|
||||
if (GTK_WIDGET_VISIBLE (progress_area))
|
||||
gdk_flush ();
|
||||
}
|
||||
|
||||
void
|
||||
progress_step ()
|
||||
{
|
||||
float val;
|
||||
|
||||
if (GTK_WIDGET_VISIBLE (progress_area))
|
||||
{
|
||||
val = gtk_progress_get_current_percentage(GTK_PROGRESS(progress_area))
|
||||
+ 0.01;
|
||||
/*
|
||||
val = GTK_PROGRESS_BAR (progress_area)->percentage + 0.01;
|
||||
*/
|
||||
if (val > 1.0)
|
||||
val = 0.0;
|
||||
|
||||
progress_update (val);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
progress_end ()
|
||||
{
|
||||
if (GTK_WIDGET_VISIBLE (progress_area))
|
||||
{
|
||||
gtk_widget_hide (progress_area);
|
||||
gtk_widget_show (tool_label_area);
|
||||
|
||||
gdk_flush ();
|
||||
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (progress_area), 0.0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,9 +44,4 @@ GtkWidget * message_box (char *, GtkCallback, gpointer);
|
|||
void tools_push_label (char *label);
|
||||
void tools_pop_label (void);
|
||||
|
||||
void progress_start (void);
|
||||
void progress_update (float);
|
||||
void progress_step (void);
|
||||
void progress_end (void);
|
||||
|
||||
#endif /* INTERFACE_H */
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <unistd.h>
|
||||
#include "libgimp/parasite.h"
|
||||
#include "libgimp/parasiteP.h" /* ick */
|
||||
#include "libgimp/gimpmodule.h"
|
||||
|
||||
#ifdef HAVE_IPC_H
|
||||
#include <sys/ipc.h>
|
||||
|
@ -62,7 +63,7 @@
|
|||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#define SEPARATE_PROGRESS_BAR
|
||||
|
||||
|
||||
|
||||
typedef struct _PlugInBlocked PlugInBlocked;
|
||||
|
@ -126,8 +127,6 @@ static void plug_in_args_destroy (Argument *args,
|
|||
int nargs,
|
||||
int full_destroy);
|
||||
|
||||
static void plug_in_disconnect_cancel (PlugIn *plug_in);
|
||||
|
||||
static Argument* progress_init_invoker (Argument *args);
|
||||
static Argument* progress_update_invoker (Argument *args);
|
||||
|
||||
|
@ -138,6 +137,8 @@ static Argument* message_handler_set_invoker (Argument *args);
|
|||
|
||||
static Argument* plugin_temp_PDB_name_invoker (Argument *args);
|
||||
|
||||
static void module_initialize (char *filename);
|
||||
|
||||
|
||||
static GSList *plug_in_defs = NULL;
|
||||
static GSList *gimprc_proc_defs = NULL;
|
||||
|
@ -481,8 +482,79 @@ plug_in_init ()
|
|||
g_free (plug_in_def);
|
||||
}
|
||||
g_slist_free (plug_in_defs);
|
||||
|
||||
|
||||
/* Load and initialize gimp modules */
|
||||
|
||||
if (g_module_supported ())
|
||||
datafiles_read_directories (module_path,
|
||||
module_initialize, 0 /* no flags */);
|
||||
}
|
||||
|
||||
|
||||
/* name must be of the form lib*.so */
|
||||
/* TODO: need support for WIN32-style dll names. Maybe this function
|
||||
* should live in libgmodule? */
|
||||
static gboolean
|
||||
valid_module_name (const char *filename)
|
||||
{
|
||||
const char *basename;
|
||||
int len;
|
||||
|
||||
basename = strrchr (filename, '/');
|
||||
if (basename)
|
||||
basename++;
|
||||
else
|
||||
basename = filename;
|
||||
|
||||
len = strlen (basename);
|
||||
|
||||
if (len < 3 + 1 + 3)
|
||||
return FALSE;
|
||||
|
||||
if (strncmp (basename, "lib", 3))
|
||||
return FALSE;
|
||||
|
||||
if (strcmp (basename + len - 3, ".so"))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
module_initialize (char *filename)
|
||||
{
|
||||
GModule *mod;
|
||||
GimpModuleInitFunc init;
|
||||
gpointer symbol;
|
||||
|
||||
if (!valid_module_name (filename))
|
||||
return;
|
||||
|
||||
if ((be_verbose == TRUE) || (no_splash == TRUE))
|
||||
g_print (_("load module: \"%s\"\n"), filename);
|
||||
|
||||
mod = g_module_open (filename, G_MODULE_BIND_LAZY);
|
||||
if (!mod)
|
||||
{
|
||||
g_warning (_("module load error: %s: %s"), filename, g_module_error ());
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_module_symbol (mod, "module_init", &symbol))
|
||||
{
|
||||
init = symbol;
|
||||
if (init () == GIMP_MODULE_UNLOAD)
|
||||
g_module_close (mod);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning (_("%s: module_init() symbol not found"), filename);
|
||||
g_module_close (mod);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
plug_in_kill ()
|
||||
{
|
||||
|
@ -818,9 +890,6 @@ plug_in_new (char *name)
|
|||
plug_in->write_buffer_index = 0;
|
||||
plug_in->temp_proc_defs = NULL;
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
plug_in->progress_gdisp_ID = -1;
|
||||
plug_in->user_data = NULL;
|
||||
|
||||
return plug_in;
|
||||
|
@ -829,9 +898,6 @@ plug_in_new (char *name)
|
|||
void
|
||||
plug_in_destroy (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
guint c_id;
|
||||
|
||||
if (plug_in)
|
||||
{
|
||||
plug_in_close (plug_in, TRUE);
|
||||
|
@ -849,18 +915,9 @@ plug_in_destroy (PlugIn *plug_in)
|
|||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
c_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), c_id);
|
||||
gtk_progress_bar_update(GTK_PROGRESS_BAR(gdisp->progressbar), 0.0);
|
||||
|
||||
plug_in_disconnect_cancel (plug_in);
|
||||
|
||||
gdisp->progressid = 0;
|
||||
}
|
||||
if (plug_in->progress)
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
|
@ -1011,23 +1068,9 @@ plug_in_close (PlugIn *plug_in,
|
|||
|
||||
/* Destroy the progress dialog if it exists
|
||||
*/
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (plug_in->progress)
|
||||
{
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (plug_in->progress), plug_in);
|
||||
gtk_widget_destroy (plug_in->progress);
|
||||
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
}
|
||||
#else
|
||||
if (plug_in->progress)
|
||||
{
|
||||
progress_end ();
|
||||
plug_in->progress = NULL;
|
||||
}
|
||||
#endif
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
/* Set the fields to null values.
|
||||
*/
|
||||
|
@ -3089,32 +3132,15 @@ static void
|
|||
plug_in_progress_cancel (GtkWidget *widget,
|
||||
PlugIn *plug_in)
|
||||
{
|
||||
plug_in->progress = NULL;
|
||||
plug_in_destroy (plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_disconnect_cancel (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp = NULL;
|
||||
|
||||
gdisp = gdisplay_get_ID (plug_in->progress_gdisp_ID);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, FALSE);
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (gdisp->cancelbutton),
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_init (PlugIn *plug_in,
|
||||
char *message,
|
||||
gint gdisp_ID)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *button;
|
||||
GDisplay *gdisp = NULL;
|
||||
guint context_id;
|
||||
|
||||
if (!message)
|
||||
message = plug_in->args[0];
|
||||
|
@ -3122,100 +3148,22 @@ plug_in_progress_init (PlugIn *plug_in,
|
|||
if (gdisp_ID > 0)
|
||||
gdisp = gdisplay_get_ID(gdisp_ID);
|
||||
|
||||
if (gdisp_ID > 0 && GTK_WIDGET_VISIBLE (gdisp->statusarea)
|
||||
&& (gdisp->progressid == 0 || plug_in->progress_gdisp_ID > 0))
|
||||
{
|
||||
context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), context_id);
|
||||
|
||||
gdisp->progressid = gtk_statusbar_push(GTK_STATUSBAR(gdisp->statusbar),
|
||||
context_id, message);
|
||||
plug_in->progress_gdisp_ID = gdisp_ID;
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (gdisp->cancelbutton), "clicked",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, TRUE);
|
||||
}
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = gtk_dialog_new ();
|
||||
gtk_window_set_wmclass (GTK_WINDOW (plug_in->progress), "plug_in_progress", "Gimp");
|
||||
gtk_window_set_title (GTK_WINDOW (plug_in->progress), prune_filename (plug_in->args[0]));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (plug_in->progress), "destroy",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (plug_in->progress)->action_area), 2);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->vbox), vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
plug_in->progress_label = gtk_label_new (message);
|
||||
gtk_misc_set_alignment (GTK_MISC (plug_in->progress_label), 0.0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_label, FALSE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_label);
|
||||
|
||||
plug_in->progress_bar = gtk_progress_bar_new ();
|
||||
gtk_widget_set_usize (plug_in->progress_bar, 150, 20);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_bar, TRUE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_bar);
|
||||
|
||||
button = gtk_button_new_with_label (_("Cancel"));
|
||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) gtk_widget_destroy,
|
||||
GTK_OBJECT (plug_in->progress));
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->action_area), button, TRUE, TRUE, 0);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gtk_widget_show (plug_in->progress);
|
||||
}
|
||||
if (plug_in->progress)
|
||||
plug_in->progress = progress_restart (plug_in->progress, message,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
else
|
||||
{
|
||||
gtk_label_set (GTK_LABEL (plug_in->progress_label), message);
|
||||
}
|
||||
#else
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = 0x1;
|
||||
progress_update (0.0);
|
||||
progress_start ();
|
||||
}
|
||||
#endif
|
||||
plug_in->progress = progress_start (gdisp, message, TRUE,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_update (PlugIn *plug_in,
|
||||
double percentage)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update( GTK_PROGRESS_BAR (gdisp->progressbar), percentage);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (plug_in->progress_bar), percentage);
|
||||
#else
|
||||
progress_update (percentage);
|
||||
#endif
|
||||
}
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
progress_update (plug_in->progress, percentage);
|
||||
}
|
||||
|
||||
static Argument*
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
static char matrix_row_buf [3][MAX_INFO_BUF];
|
||||
|
||||
/* forward function declarations */
|
||||
static void * perspective_tool_perspective (GImage *, GimpDrawable *, TileManager *, int, GimpMatrix);
|
||||
static void * perspective_tool_perspective (GImage *, GimpDrawable *, GDisplay *, TileManager *, int, GimpMatrix);
|
||||
static void perspective_find_transform (double *, GimpMatrix);
|
||||
static void * perspective_tool_recalc (Tool *, void *);
|
||||
static void perspective_tool_motion (Tool *, void *);
|
||||
|
@ -78,6 +78,7 @@ perspective_tool_transform (tool, gdisp_ptr, state)
|
|||
info_dialog_add_field (transform_info, " ",
|
||||
matrix_row_buf[2], NULL, NULL);
|
||||
}
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), TRUE);
|
||||
|
||||
transform_core->trans_info [X0] = (double) transform_core->x1;
|
||||
transform_core->trans_info [Y0] = (double) transform_core->y1;
|
||||
|
@ -103,7 +104,8 @@ perspective_tool_transform (tool, gdisp_ptr, state)
|
|||
|
||||
case FINISH :
|
||||
/* Let the transform core handle the inverse mapping */
|
||||
return perspective_tool_perspective (gdisp->gimage, gimage_active_drawable (gdisp->gimage),
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), FALSE);
|
||||
return perspective_tool_perspective (gdisp->gimage, gimage_active_drawable (gdisp->gimage), gdisp,
|
||||
transform_core->original, transform_tool_smoothing (),
|
||||
transform_core->transform);
|
||||
break;
|
||||
|
@ -309,14 +311,26 @@ perspective_find_transform (coords, m)
|
|||
|
||||
|
||||
static void *
|
||||
perspective_tool_perspective (gimage, drawable, float_tiles, interpolation, matrix)
|
||||
perspective_tool_perspective (gimage, drawable, gdisp, float_tiles, interpolation, matrix)
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
GDisplay *gdisp;
|
||||
TileManager *float_tiles;
|
||||
int interpolation;
|
||||
GimpMatrix matrix;
|
||||
{
|
||||
return transform_core_do (gimage, drawable, float_tiles, interpolation, matrix);
|
||||
void *ret;
|
||||
gimp_progress *progress;
|
||||
|
||||
progress = progress_start (gdisp, _("Perspective..."), FALSE, NULL, NULL);
|
||||
|
||||
ret = transform_core_do (gimage, drawable, float_tiles,
|
||||
interpolation, matrix,
|
||||
progress? progress_update_and_flush:NULL, progress);
|
||||
if (progress)
|
||||
progress_end (progress);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -479,7 +493,7 @@ perspective_invoker (args)
|
|||
gimp_matrix_mult (m, matrix);
|
||||
|
||||
/* perspective the buffer */
|
||||
new_tiles = perspective_tool_perspective (gimage, drawable, float_tiles, interpolation, matrix);
|
||||
new_tiles = perspective_tool_perspective (gimage, drawable, NULL, float_tiles, interpolation, matrix);
|
||||
|
||||
/* free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <unistd.h>
|
||||
#include "libgimp/parasite.h"
|
||||
#include "libgimp/parasiteP.h" /* ick */
|
||||
#include "libgimp/gimpmodule.h"
|
||||
|
||||
#ifdef HAVE_IPC_H
|
||||
#include <sys/ipc.h>
|
||||
|
@ -62,7 +63,7 @@
|
|||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#define SEPARATE_PROGRESS_BAR
|
||||
|
||||
|
||||
|
||||
typedef struct _PlugInBlocked PlugInBlocked;
|
||||
|
@ -126,8 +127,6 @@ static void plug_in_args_destroy (Argument *args,
|
|||
int nargs,
|
||||
int full_destroy);
|
||||
|
||||
static void plug_in_disconnect_cancel (PlugIn *plug_in);
|
||||
|
||||
static Argument* progress_init_invoker (Argument *args);
|
||||
static Argument* progress_update_invoker (Argument *args);
|
||||
|
||||
|
@ -138,6 +137,8 @@ static Argument* message_handler_set_invoker (Argument *args);
|
|||
|
||||
static Argument* plugin_temp_PDB_name_invoker (Argument *args);
|
||||
|
||||
static void module_initialize (char *filename);
|
||||
|
||||
|
||||
static GSList *plug_in_defs = NULL;
|
||||
static GSList *gimprc_proc_defs = NULL;
|
||||
|
@ -481,8 +482,79 @@ plug_in_init ()
|
|||
g_free (plug_in_def);
|
||||
}
|
||||
g_slist_free (plug_in_defs);
|
||||
|
||||
|
||||
/* Load and initialize gimp modules */
|
||||
|
||||
if (g_module_supported ())
|
||||
datafiles_read_directories (module_path,
|
||||
module_initialize, 0 /* no flags */);
|
||||
}
|
||||
|
||||
|
||||
/* name must be of the form lib*.so */
|
||||
/* TODO: need support for WIN32-style dll names. Maybe this function
|
||||
* should live in libgmodule? */
|
||||
static gboolean
|
||||
valid_module_name (const char *filename)
|
||||
{
|
||||
const char *basename;
|
||||
int len;
|
||||
|
||||
basename = strrchr (filename, '/');
|
||||
if (basename)
|
||||
basename++;
|
||||
else
|
||||
basename = filename;
|
||||
|
||||
len = strlen (basename);
|
||||
|
||||
if (len < 3 + 1 + 3)
|
||||
return FALSE;
|
||||
|
||||
if (strncmp (basename, "lib", 3))
|
||||
return FALSE;
|
||||
|
||||
if (strcmp (basename + len - 3, ".so"))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
module_initialize (char *filename)
|
||||
{
|
||||
GModule *mod;
|
||||
GimpModuleInitFunc init;
|
||||
gpointer symbol;
|
||||
|
||||
if (!valid_module_name (filename))
|
||||
return;
|
||||
|
||||
if ((be_verbose == TRUE) || (no_splash == TRUE))
|
||||
g_print (_("load module: \"%s\"\n"), filename);
|
||||
|
||||
mod = g_module_open (filename, G_MODULE_BIND_LAZY);
|
||||
if (!mod)
|
||||
{
|
||||
g_warning (_("module load error: %s: %s"), filename, g_module_error ());
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_module_symbol (mod, "module_init", &symbol))
|
||||
{
|
||||
init = symbol;
|
||||
if (init () == GIMP_MODULE_UNLOAD)
|
||||
g_module_close (mod);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning (_("%s: module_init() symbol not found"), filename);
|
||||
g_module_close (mod);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
plug_in_kill ()
|
||||
{
|
||||
|
@ -818,9 +890,6 @@ plug_in_new (char *name)
|
|||
plug_in->write_buffer_index = 0;
|
||||
plug_in->temp_proc_defs = NULL;
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
plug_in->progress_gdisp_ID = -1;
|
||||
plug_in->user_data = NULL;
|
||||
|
||||
return plug_in;
|
||||
|
@ -829,9 +898,6 @@ plug_in_new (char *name)
|
|||
void
|
||||
plug_in_destroy (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
guint c_id;
|
||||
|
||||
if (plug_in)
|
||||
{
|
||||
plug_in_close (plug_in, TRUE);
|
||||
|
@ -849,18 +915,9 @@ plug_in_destroy (PlugIn *plug_in)
|
|||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
c_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), c_id);
|
||||
gtk_progress_bar_update(GTK_PROGRESS_BAR(gdisp->progressbar), 0.0);
|
||||
|
||||
plug_in_disconnect_cancel (plug_in);
|
||||
|
||||
gdisp->progressid = 0;
|
||||
}
|
||||
if (plug_in->progress)
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
|
@ -1011,23 +1068,9 @@ plug_in_close (PlugIn *plug_in,
|
|||
|
||||
/* Destroy the progress dialog if it exists
|
||||
*/
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (plug_in->progress)
|
||||
{
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (plug_in->progress), plug_in);
|
||||
gtk_widget_destroy (plug_in->progress);
|
||||
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
}
|
||||
#else
|
||||
if (plug_in->progress)
|
||||
{
|
||||
progress_end ();
|
||||
plug_in->progress = NULL;
|
||||
}
|
||||
#endif
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
/* Set the fields to null values.
|
||||
*/
|
||||
|
@ -3089,32 +3132,15 @@ static void
|
|||
plug_in_progress_cancel (GtkWidget *widget,
|
||||
PlugIn *plug_in)
|
||||
{
|
||||
plug_in->progress = NULL;
|
||||
plug_in_destroy (plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_disconnect_cancel (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp = NULL;
|
||||
|
||||
gdisp = gdisplay_get_ID (plug_in->progress_gdisp_ID);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, FALSE);
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (gdisp->cancelbutton),
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_init (PlugIn *plug_in,
|
||||
char *message,
|
||||
gint gdisp_ID)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *button;
|
||||
GDisplay *gdisp = NULL;
|
||||
guint context_id;
|
||||
|
||||
if (!message)
|
||||
message = plug_in->args[0];
|
||||
|
@ -3122,100 +3148,22 @@ plug_in_progress_init (PlugIn *plug_in,
|
|||
if (gdisp_ID > 0)
|
||||
gdisp = gdisplay_get_ID(gdisp_ID);
|
||||
|
||||
if (gdisp_ID > 0 && GTK_WIDGET_VISIBLE (gdisp->statusarea)
|
||||
&& (gdisp->progressid == 0 || plug_in->progress_gdisp_ID > 0))
|
||||
{
|
||||
context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), context_id);
|
||||
|
||||
gdisp->progressid = gtk_statusbar_push(GTK_STATUSBAR(gdisp->statusbar),
|
||||
context_id, message);
|
||||
plug_in->progress_gdisp_ID = gdisp_ID;
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (gdisp->cancelbutton), "clicked",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, TRUE);
|
||||
}
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = gtk_dialog_new ();
|
||||
gtk_window_set_wmclass (GTK_WINDOW (plug_in->progress), "plug_in_progress", "Gimp");
|
||||
gtk_window_set_title (GTK_WINDOW (plug_in->progress), prune_filename (plug_in->args[0]));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (plug_in->progress), "destroy",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (plug_in->progress)->action_area), 2);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->vbox), vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
plug_in->progress_label = gtk_label_new (message);
|
||||
gtk_misc_set_alignment (GTK_MISC (plug_in->progress_label), 0.0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_label, FALSE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_label);
|
||||
|
||||
plug_in->progress_bar = gtk_progress_bar_new ();
|
||||
gtk_widget_set_usize (plug_in->progress_bar, 150, 20);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_bar, TRUE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_bar);
|
||||
|
||||
button = gtk_button_new_with_label (_("Cancel"));
|
||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) gtk_widget_destroy,
|
||||
GTK_OBJECT (plug_in->progress));
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->action_area), button, TRUE, TRUE, 0);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gtk_widget_show (plug_in->progress);
|
||||
}
|
||||
if (plug_in->progress)
|
||||
plug_in->progress = progress_restart (plug_in->progress, message,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
else
|
||||
{
|
||||
gtk_label_set (GTK_LABEL (plug_in->progress_label), message);
|
||||
}
|
||||
#else
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = 0x1;
|
||||
progress_update (0.0);
|
||||
progress_start ();
|
||||
}
|
||||
#endif
|
||||
plug_in->progress = progress_start (gdisp, message, TRUE,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_update (PlugIn *plug_in,
|
||||
double percentage)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update( GTK_PROGRESS_BAR (gdisp->progressbar), percentage);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (plug_in->progress_bar), percentage);
|
||||
#else
|
||||
progress_update (percentage);
|
||||
#endif
|
||||
}
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
progress_update (plug_in->progress, percentage);
|
||||
}
|
||||
|
||||
static Argument*
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <unistd.h>
|
||||
#include "libgimp/parasite.h"
|
||||
#include "libgimp/parasiteP.h" /* ick */
|
||||
#include "libgimp/gimpmodule.h"
|
||||
|
||||
#ifdef HAVE_IPC_H
|
||||
#include <sys/ipc.h>
|
||||
|
@ -62,7 +63,7 @@
|
|||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#define SEPARATE_PROGRESS_BAR
|
||||
|
||||
|
||||
|
||||
typedef struct _PlugInBlocked PlugInBlocked;
|
||||
|
@ -126,8 +127,6 @@ static void plug_in_args_destroy (Argument *args,
|
|||
int nargs,
|
||||
int full_destroy);
|
||||
|
||||
static void plug_in_disconnect_cancel (PlugIn *plug_in);
|
||||
|
||||
static Argument* progress_init_invoker (Argument *args);
|
||||
static Argument* progress_update_invoker (Argument *args);
|
||||
|
||||
|
@ -138,6 +137,8 @@ static Argument* message_handler_set_invoker (Argument *args);
|
|||
|
||||
static Argument* plugin_temp_PDB_name_invoker (Argument *args);
|
||||
|
||||
static void module_initialize (char *filename);
|
||||
|
||||
|
||||
static GSList *plug_in_defs = NULL;
|
||||
static GSList *gimprc_proc_defs = NULL;
|
||||
|
@ -481,8 +482,79 @@ plug_in_init ()
|
|||
g_free (plug_in_def);
|
||||
}
|
||||
g_slist_free (plug_in_defs);
|
||||
|
||||
|
||||
/* Load and initialize gimp modules */
|
||||
|
||||
if (g_module_supported ())
|
||||
datafiles_read_directories (module_path,
|
||||
module_initialize, 0 /* no flags */);
|
||||
}
|
||||
|
||||
|
||||
/* name must be of the form lib*.so */
|
||||
/* TODO: need support for WIN32-style dll names. Maybe this function
|
||||
* should live in libgmodule? */
|
||||
static gboolean
|
||||
valid_module_name (const char *filename)
|
||||
{
|
||||
const char *basename;
|
||||
int len;
|
||||
|
||||
basename = strrchr (filename, '/');
|
||||
if (basename)
|
||||
basename++;
|
||||
else
|
||||
basename = filename;
|
||||
|
||||
len = strlen (basename);
|
||||
|
||||
if (len < 3 + 1 + 3)
|
||||
return FALSE;
|
||||
|
||||
if (strncmp (basename, "lib", 3))
|
||||
return FALSE;
|
||||
|
||||
if (strcmp (basename + len - 3, ".so"))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
module_initialize (char *filename)
|
||||
{
|
||||
GModule *mod;
|
||||
GimpModuleInitFunc init;
|
||||
gpointer symbol;
|
||||
|
||||
if (!valid_module_name (filename))
|
||||
return;
|
||||
|
||||
if ((be_verbose == TRUE) || (no_splash == TRUE))
|
||||
g_print (_("load module: \"%s\"\n"), filename);
|
||||
|
||||
mod = g_module_open (filename, G_MODULE_BIND_LAZY);
|
||||
if (!mod)
|
||||
{
|
||||
g_warning (_("module load error: %s: %s"), filename, g_module_error ());
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_module_symbol (mod, "module_init", &symbol))
|
||||
{
|
||||
init = symbol;
|
||||
if (init () == GIMP_MODULE_UNLOAD)
|
||||
g_module_close (mod);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning (_("%s: module_init() symbol not found"), filename);
|
||||
g_module_close (mod);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
plug_in_kill ()
|
||||
{
|
||||
|
@ -818,9 +890,6 @@ plug_in_new (char *name)
|
|||
plug_in->write_buffer_index = 0;
|
||||
plug_in->temp_proc_defs = NULL;
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
plug_in->progress_gdisp_ID = -1;
|
||||
plug_in->user_data = NULL;
|
||||
|
||||
return plug_in;
|
||||
|
@ -829,9 +898,6 @@ plug_in_new (char *name)
|
|||
void
|
||||
plug_in_destroy (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
guint c_id;
|
||||
|
||||
if (plug_in)
|
||||
{
|
||||
plug_in_close (plug_in, TRUE);
|
||||
|
@ -849,18 +915,9 @@ plug_in_destroy (PlugIn *plug_in)
|
|||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
c_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), c_id);
|
||||
gtk_progress_bar_update(GTK_PROGRESS_BAR(gdisp->progressbar), 0.0);
|
||||
|
||||
plug_in_disconnect_cancel (plug_in);
|
||||
|
||||
gdisp->progressid = 0;
|
||||
}
|
||||
if (plug_in->progress)
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
|
@ -1011,23 +1068,9 @@ plug_in_close (PlugIn *plug_in,
|
|||
|
||||
/* Destroy the progress dialog if it exists
|
||||
*/
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (plug_in->progress)
|
||||
{
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (plug_in->progress), plug_in);
|
||||
gtk_widget_destroy (plug_in->progress);
|
||||
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
}
|
||||
#else
|
||||
if (plug_in->progress)
|
||||
{
|
||||
progress_end ();
|
||||
plug_in->progress = NULL;
|
||||
}
|
||||
#endif
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
/* Set the fields to null values.
|
||||
*/
|
||||
|
@ -3089,32 +3132,15 @@ static void
|
|||
plug_in_progress_cancel (GtkWidget *widget,
|
||||
PlugIn *plug_in)
|
||||
{
|
||||
plug_in->progress = NULL;
|
||||
plug_in_destroy (plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_disconnect_cancel (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp = NULL;
|
||||
|
||||
gdisp = gdisplay_get_ID (plug_in->progress_gdisp_ID);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, FALSE);
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (gdisp->cancelbutton),
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_init (PlugIn *plug_in,
|
||||
char *message,
|
||||
gint gdisp_ID)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *button;
|
||||
GDisplay *gdisp = NULL;
|
||||
guint context_id;
|
||||
|
||||
if (!message)
|
||||
message = plug_in->args[0];
|
||||
|
@ -3122,100 +3148,22 @@ plug_in_progress_init (PlugIn *plug_in,
|
|||
if (gdisp_ID > 0)
|
||||
gdisp = gdisplay_get_ID(gdisp_ID);
|
||||
|
||||
if (gdisp_ID > 0 && GTK_WIDGET_VISIBLE (gdisp->statusarea)
|
||||
&& (gdisp->progressid == 0 || plug_in->progress_gdisp_ID > 0))
|
||||
{
|
||||
context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), context_id);
|
||||
|
||||
gdisp->progressid = gtk_statusbar_push(GTK_STATUSBAR(gdisp->statusbar),
|
||||
context_id, message);
|
||||
plug_in->progress_gdisp_ID = gdisp_ID;
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (gdisp->cancelbutton), "clicked",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, TRUE);
|
||||
}
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = gtk_dialog_new ();
|
||||
gtk_window_set_wmclass (GTK_WINDOW (plug_in->progress), "plug_in_progress", "Gimp");
|
||||
gtk_window_set_title (GTK_WINDOW (plug_in->progress), prune_filename (plug_in->args[0]));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (plug_in->progress), "destroy",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (plug_in->progress)->action_area), 2);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->vbox), vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
plug_in->progress_label = gtk_label_new (message);
|
||||
gtk_misc_set_alignment (GTK_MISC (plug_in->progress_label), 0.0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_label, FALSE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_label);
|
||||
|
||||
plug_in->progress_bar = gtk_progress_bar_new ();
|
||||
gtk_widget_set_usize (plug_in->progress_bar, 150, 20);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_bar, TRUE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_bar);
|
||||
|
||||
button = gtk_button_new_with_label (_("Cancel"));
|
||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) gtk_widget_destroy,
|
||||
GTK_OBJECT (plug_in->progress));
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->action_area), button, TRUE, TRUE, 0);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gtk_widget_show (plug_in->progress);
|
||||
}
|
||||
if (plug_in->progress)
|
||||
plug_in->progress = progress_restart (plug_in->progress, message,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
else
|
||||
{
|
||||
gtk_label_set (GTK_LABEL (plug_in->progress_label), message);
|
||||
}
|
||||
#else
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = 0x1;
|
||||
progress_update (0.0);
|
||||
progress_start ();
|
||||
}
|
||||
#endif
|
||||
plug_in->progress = progress_start (gdisp, message, TRUE,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_update (PlugIn *plug_in,
|
||||
double percentage)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update( GTK_PROGRESS_BAR (gdisp->progressbar), percentage);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (plug_in->progress_bar), percentage);
|
||||
#else
|
||||
progress_update (percentage);
|
||||
#endif
|
||||
}
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
progress_update (plug_in->progress, percentage);
|
||||
}
|
||||
|
||||
static Argument*
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "gtk/gtk.h"
|
||||
#include "procedural_db.h"
|
||||
#include "gimpprogress.h"
|
||||
|
||||
|
||||
#define WRITE_BUFFER_SIZE 512
|
||||
|
@ -58,11 +59,7 @@ struct _PlugIn
|
|||
|
||||
GSList *temp_proc_defs; /* Temporary procedures */
|
||||
|
||||
GtkWidget *progress; /* Progress dialog */
|
||||
GtkWidget *progress_label;
|
||||
GtkWidget *progress_bar;
|
||||
|
||||
gint8 progress_gdisp_ID; /* gdisp_ID of progress */
|
||||
gimp_progress *progress; /* Progress dialog */
|
||||
|
||||
gpointer user_data; /* Handle for hanging data onto */
|
||||
};
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <unistd.h>
|
||||
#include "libgimp/parasite.h"
|
||||
#include "libgimp/parasiteP.h" /* ick */
|
||||
#include "libgimp/gimpmodule.h"
|
||||
|
||||
#ifdef HAVE_IPC_H
|
||||
#include <sys/ipc.h>
|
||||
|
@ -62,7 +63,7 @@
|
|||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#define SEPARATE_PROGRESS_BAR
|
||||
|
||||
|
||||
|
||||
typedef struct _PlugInBlocked PlugInBlocked;
|
||||
|
@ -126,8 +127,6 @@ static void plug_in_args_destroy (Argument *args,
|
|||
int nargs,
|
||||
int full_destroy);
|
||||
|
||||
static void plug_in_disconnect_cancel (PlugIn *plug_in);
|
||||
|
||||
static Argument* progress_init_invoker (Argument *args);
|
||||
static Argument* progress_update_invoker (Argument *args);
|
||||
|
||||
|
@ -138,6 +137,8 @@ static Argument* message_handler_set_invoker (Argument *args);
|
|||
|
||||
static Argument* plugin_temp_PDB_name_invoker (Argument *args);
|
||||
|
||||
static void module_initialize (char *filename);
|
||||
|
||||
|
||||
static GSList *plug_in_defs = NULL;
|
||||
static GSList *gimprc_proc_defs = NULL;
|
||||
|
@ -481,8 +482,79 @@ plug_in_init ()
|
|||
g_free (plug_in_def);
|
||||
}
|
||||
g_slist_free (plug_in_defs);
|
||||
|
||||
|
||||
/* Load and initialize gimp modules */
|
||||
|
||||
if (g_module_supported ())
|
||||
datafiles_read_directories (module_path,
|
||||
module_initialize, 0 /* no flags */);
|
||||
}
|
||||
|
||||
|
||||
/* name must be of the form lib*.so */
|
||||
/* TODO: need support for WIN32-style dll names. Maybe this function
|
||||
* should live in libgmodule? */
|
||||
static gboolean
|
||||
valid_module_name (const char *filename)
|
||||
{
|
||||
const char *basename;
|
||||
int len;
|
||||
|
||||
basename = strrchr (filename, '/');
|
||||
if (basename)
|
||||
basename++;
|
||||
else
|
||||
basename = filename;
|
||||
|
||||
len = strlen (basename);
|
||||
|
||||
if (len < 3 + 1 + 3)
|
||||
return FALSE;
|
||||
|
||||
if (strncmp (basename, "lib", 3))
|
||||
return FALSE;
|
||||
|
||||
if (strcmp (basename + len - 3, ".so"))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
module_initialize (char *filename)
|
||||
{
|
||||
GModule *mod;
|
||||
GimpModuleInitFunc init;
|
||||
gpointer symbol;
|
||||
|
||||
if (!valid_module_name (filename))
|
||||
return;
|
||||
|
||||
if ((be_verbose == TRUE) || (no_splash == TRUE))
|
||||
g_print (_("load module: \"%s\"\n"), filename);
|
||||
|
||||
mod = g_module_open (filename, G_MODULE_BIND_LAZY);
|
||||
if (!mod)
|
||||
{
|
||||
g_warning (_("module load error: %s: %s"), filename, g_module_error ());
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_module_symbol (mod, "module_init", &symbol))
|
||||
{
|
||||
init = symbol;
|
||||
if (init () == GIMP_MODULE_UNLOAD)
|
||||
g_module_close (mod);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning (_("%s: module_init() symbol not found"), filename);
|
||||
g_module_close (mod);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
plug_in_kill ()
|
||||
{
|
||||
|
@ -818,9 +890,6 @@ plug_in_new (char *name)
|
|||
plug_in->write_buffer_index = 0;
|
||||
plug_in->temp_proc_defs = NULL;
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
plug_in->progress_gdisp_ID = -1;
|
||||
plug_in->user_data = NULL;
|
||||
|
||||
return plug_in;
|
||||
|
@ -829,9 +898,6 @@ plug_in_new (char *name)
|
|||
void
|
||||
plug_in_destroy (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
guint c_id;
|
||||
|
||||
if (plug_in)
|
||||
{
|
||||
plug_in_close (plug_in, TRUE);
|
||||
|
@ -849,18 +915,9 @@ plug_in_destroy (PlugIn *plug_in)
|
|||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
c_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), c_id);
|
||||
gtk_progress_bar_update(GTK_PROGRESS_BAR(gdisp->progressbar), 0.0);
|
||||
|
||||
plug_in_disconnect_cancel (plug_in);
|
||||
|
||||
gdisp->progressid = 0;
|
||||
}
|
||||
if (plug_in->progress)
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
|
@ -1011,23 +1068,9 @@ plug_in_close (PlugIn *plug_in,
|
|||
|
||||
/* Destroy the progress dialog if it exists
|
||||
*/
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (plug_in->progress)
|
||||
{
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (plug_in->progress), plug_in);
|
||||
gtk_widget_destroy (plug_in->progress);
|
||||
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
}
|
||||
#else
|
||||
if (plug_in->progress)
|
||||
{
|
||||
progress_end ();
|
||||
plug_in->progress = NULL;
|
||||
}
|
||||
#endif
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
/* Set the fields to null values.
|
||||
*/
|
||||
|
@ -3089,32 +3132,15 @@ static void
|
|||
plug_in_progress_cancel (GtkWidget *widget,
|
||||
PlugIn *plug_in)
|
||||
{
|
||||
plug_in->progress = NULL;
|
||||
plug_in_destroy (plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_disconnect_cancel (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp = NULL;
|
||||
|
||||
gdisp = gdisplay_get_ID (plug_in->progress_gdisp_ID);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, FALSE);
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (gdisp->cancelbutton),
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_init (PlugIn *plug_in,
|
||||
char *message,
|
||||
gint gdisp_ID)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *button;
|
||||
GDisplay *gdisp = NULL;
|
||||
guint context_id;
|
||||
|
||||
if (!message)
|
||||
message = plug_in->args[0];
|
||||
|
@ -3122,100 +3148,22 @@ plug_in_progress_init (PlugIn *plug_in,
|
|||
if (gdisp_ID > 0)
|
||||
gdisp = gdisplay_get_ID(gdisp_ID);
|
||||
|
||||
if (gdisp_ID > 0 && GTK_WIDGET_VISIBLE (gdisp->statusarea)
|
||||
&& (gdisp->progressid == 0 || plug_in->progress_gdisp_ID > 0))
|
||||
{
|
||||
context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), context_id);
|
||||
|
||||
gdisp->progressid = gtk_statusbar_push(GTK_STATUSBAR(gdisp->statusbar),
|
||||
context_id, message);
|
||||
plug_in->progress_gdisp_ID = gdisp_ID;
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (gdisp->cancelbutton), "clicked",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, TRUE);
|
||||
}
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = gtk_dialog_new ();
|
||||
gtk_window_set_wmclass (GTK_WINDOW (plug_in->progress), "plug_in_progress", "Gimp");
|
||||
gtk_window_set_title (GTK_WINDOW (plug_in->progress), prune_filename (plug_in->args[0]));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (plug_in->progress), "destroy",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (plug_in->progress)->action_area), 2);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->vbox), vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
plug_in->progress_label = gtk_label_new (message);
|
||||
gtk_misc_set_alignment (GTK_MISC (plug_in->progress_label), 0.0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_label, FALSE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_label);
|
||||
|
||||
plug_in->progress_bar = gtk_progress_bar_new ();
|
||||
gtk_widget_set_usize (plug_in->progress_bar, 150, 20);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_bar, TRUE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_bar);
|
||||
|
||||
button = gtk_button_new_with_label (_("Cancel"));
|
||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) gtk_widget_destroy,
|
||||
GTK_OBJECT (plug_in->progress));
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->action_area), button, TRUE, TRUE, 0);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gtk_widget_show (plug_in->progress);
|
||||
}
|
||||
if (plug_in->progress)
|
||||
plug_in->progress = progress_restart (plug_in->progress, message,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
else
|
||||
{
|
||||
gtk_label_set (GTK_LABEL (plug_in->progress_label), message);
|
||||
}
|
||||
#else
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = 0x1;
|
||||
progress_update (0.0);
|
||||
progress_start ();
|
||||
}
|
||||
#endif
|
||||
plug_in->progress = progress_start (gdisp, message, TRUE,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_update (PlugIn *plug_in,
|
||||
double percentage)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update( GTK_PROGRESS_BAR (gdisp->progressbar), percentage);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (plug_in->progress_bar), percentage);
|
||||
#else
|
||||
progress_update (percentage);
|
||||
#endif
|
||||
}
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
progress_update (plug_in->progress, percentage);
|
||||
}
|
||||
|
||||
static Argument*
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "gtk/gtk.h"
|
||||
#include "procedural_db.h"
|
||||
#include "gimpprogress.h"
|
||||
|
||||
|
||||
#define WRITE_BUFFER_SIZE 512
|
||||
|
@ -58,11 +59,7 @@ struct _PlugIn
|
|||
|
||||
GSList *temp_proc_defs; /* Temporary procedures */
|
||||
|
||||
GtkWidget *progress; /* Progress dialog */
|
||||
GtkWidget *progress_label;
|
||||
GtkWidget *progress_bar;
|
||||
|
||||
gint8 progress_gdisp_ID; /* gdisp_ID of progress */
|
||||
gimp_progress *progress; /* Progress dialog */
|
||||
|
||||
gpointer user_data; /* Handle for hanging data onto */
|
||||
};
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <unistd.h>
|
||||
#include "libgimp/parasite.h"
|
||||
#include "libgimp/parasiteP.h" /* ick */
|
||||
#include "libgimp/gimpmodule.h"
|
||||
|
||||
#ifdef HAVE_IPC_H
|
||||
#include <sys/ipc.h>
|
||||
|
@ -62,7 +63,7 @@
|
|||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#define SEPARATE_PROGRESS_BAR
|
||||
|
||||
|
||||
|
||||
typedef struct _PlugInBlocked PlugInBlocked;
|
||||
|
@ -126,8 +127,6 @@ static void plug_in_args_destroy (Argument *args,
|
|||
int nargs,
|
||||
int full_destroy);
|
||||
|
||||
static void plug_in_disconnect_cancel (PlugIn *plug_in);
|
||||
|
||||
static Argument* progress_init_invoker (Argument *args);
|
||||
static Argument* progress_update_invoker (Argument *args);
|
||||
|
||||
|
@ -138,6 +137,8 @@ static Argument* message_handler_set_invoker (Argument *args);
|
|||
|
||||
static Argument* plugin_temp_PDB_name_invoker (Argument *args);
|
||||
|
||||
static void module_initialize (char *filename);
|
||||
|
||||
|
||||
static GSList *plug_in_defs = NULL;
|
||||
static GSList *gimprc_proc_defs = NULL;
|
||||
|
@ -481,8 +482,79 @@ plug_in_init ()
|
|||
g_free (plug_in_def);
|
||||
}
|
||||
g_slist_free (plug_in_defs);
|
||||
|
||||
|
||||
/* Load and initialize gimp modules */
|
||||
|
||||
if (g_module_supported ())
|
||||
datafiles_read_directories (module_path,
|
||||
module_initialize, 0 /* no flags */);
|
||||
}
|
||||
|
||||
|
||||
/* name must be of the form lib*.so */
|
||||
/* TODO: need support for WIN32-style dll names. Maybe this function
|
||||
* should live in libgmodule? */
|
||||
static gboolean
|
||||
valid_module_name (const char *filename)
|
||||
{
|
||||
const char *basename;
|
||||
int len;
|
||||
|
||||
basename = strrchr (filename, '/');
|
||||
if (basename)
|
||||
basename++;
|
||||
else
|
||||
basename = filename;
|
||||
|
||||
len = strlen (basename);
|
||||
|
||||
if (len < 3 + 1 + 3)
|
||||
return FALSE;
|
||||
|
||||
if (strncmp (basename, "lib", 3))
|
||||
return FALSE;
|
||||
|
||||
if (strcmp (basename + len - 3, ".so"))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
module_initialize (char *filename)
|
||||
{
|
||||
GModule *mod;
|
||||
GimpModuleInitFunc init;
|
||||
gpointer symbol;
|
||||
|
||||
if (!valid_module_name (filename))
|
||||
return;
|
||||
|
||||
if ((be_verbose == TRUE) || (no_splash == TRUE))
|
||||
g_print (_("load module: \"%s\"\n"), filename);
|
||||
|
||||
mod = g_module_open (filename, G_MODULE_BIND_LAZY);
|
||||
if (!mod)
|
||||
{
|
||||
g_warning (_("module load error: %s: %s"), filename, g_module_error ());
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_module_symbol (mod, "module_init", &symbol))
|
||||
{
|
||||
init = symbol;
|
||||
if (init () == GIMP_MODULE_UNLOAD)
|
||||
g_module_close (mod);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning (_("%s: module_init() symbol not found"), filename);
|
||||
g_module_close (mod);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
plug_in_kill ()
|
||||
{
|
||||
|
@ -818,9 +890,6 @@ plug_in_new (char *name)
|
|||
plug_in->write_buffer_index = 0;
|
||||
plug_in->temp_proc_defs = NULL;
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
plug_in->progress_gdisp_ID = -1;
|
||||
plug_in->user_data = NULL;
|
||||
|
||||
return plug_in;
|
||||
|
@ -829,9 +898,6 @@ plug_in_new (char *name)
|
|||
void
|
||||
plug_in_destroy (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
guint c_id;
|
||||
|
||||
if (plug_in)
|
||||
{
|
||||
plug_in_close (plug_in, TRUE);
|
||||
|
@ -849,18 +915,9 @@ plug_in_destroy (PlugIn *plug_in)
|
|||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
c_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), c_id);
|
||||
gtk_progress_bar_update(GTK_PROGRESS_BAR(gdisp->progressbar), 0.0);
|
||||
|
||||
plug_in_disconnect_cancel (plug_in);
|
||||
|
||||
gdisp->progressid = 0;
|
||||
}
|
||||
if (plug_in->progress)
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
|
@ -1011,23 +1068,9 @@ plug_in_close (PlugIn *plug_in,
|
|||
|
||||
/* Destroy the progress dialog if it exists
|
||||
*/
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (plug_in->progress)
|
||||
{
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (plug_in->progress), plug_in);
|
||||
gtk_widget_destroy (plug_in->progress);
|
||||
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
}
|
||||
#else
|
||||
if (plug_in->progress)
|
||||
{
|
||||
progress_end ();
|
||||
plug_in->progress = NULL;
|
||||
}
|
||||
#endif
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
/* Set the fields to null values.
|
||||
*/
|
||||
|
@ -3089,32 +3132,15 @@ static void
|
|||
plug_in_progress_cancel (GtkWidget *widget,
|
||||
PlugIn *plug_in)
|
||||
{
|
||||
plug_in->progress = NULL;
|
||||
plug_in_destroy (plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_disconnect_cancel (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp = NULL;
|
||||
|
||||
gdisp = gdisplay_get_ID (plug_in->progress_gdisp_ID);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, FALSE);
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (gdisp->cancelbutton),
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_init (PlugIn *plug_in,
|
||||
char *message,
|
||||
gint gdisp_ID)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *button;
|
||||
GDisplay *gdisp = NULL;
|
||||
guint context_id;
|
||||
|
||||
if (!message)
|
||||
message = plug_in->args[0];
|
||||
|
@ -3122,100 +3148,22 @@ plug_in_progress_init (PlugIn *plug_in,
|
|||
if (gdisp_ID > 0)
|
||||
gdisp = gdisplay_get_ID(gdisp_ID);
|
||||
|
||||
if (gdisp_ID > 0 && GTK_WIDGET_VISIBLE (gdisp->statusarea)
|
||||
&& (gdisp->progressid == 0 || plug_in->progress_gdisp_ID > 0))
|
||||
{
|
||||
context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), context_id);
|
||||
|
||||
gdisp->progressid = gtk_statusbar_push(GTK_STATUSBAR(gdisp->statusbar),
|
||||
context_id, message);
|
||||
plug_in->progress_gdisp_ID = gdisp_ID;
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (gdisp->cancelbutton), "clicked",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, TRUE);
|
||||
}
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = gtk_dialog_new ();
|
||||
gtk_window_set_wmclass (GTK_WINDOW (plug_in->progress), "plug_in_progress", "Gimp");
|
||||
gtk_window_set_title (GTK_WINDOW (plug_in->progress), prune_filename (plug_in->args[0]));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (plug_in->progress), "destroy",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (plug_in->progress)->action_area), 2);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->vbox), vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
plug_in->progress_label = gtk_label_new (message);
|
||||
gtk_misc_set_alignment (GTK_MISC (plug_in->progress_label), 0.0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_label, FALSE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_label);
|
||||
|
||||
plug_in->progress_bar = gtk_progress_bar_new ();
|
||||
gtk_widget_set_usize (plug_in->progress_bar, 150, 20);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_bar, TRUE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_bar);
|
||||
|
||||
button = gtk_button_new_with_label (_("Cancel"));
|
||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) gtk_widget_destroy,
|
||||
GTK_OBJECT (plug_in->progress));
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->action_area), button, TRUE, TRUE, 0);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gtk_widget_show (plug_in->progress);
|
||||
}
|
||||
if (plug_in->progress)
|
||||
plug_in->progress = progress_restart (plug_in->progress, message,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
else
|
||||
{
|
||||
gtk_label_set (GTK_LABEL (plug_in->progress_label), message);
|
||||
}
|
||||
#else
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = 0x1;
|
||||
progress_update (0.0);
|
||||
progress_start ();
|
||||
}
|
||||
#endif
|
||||
plug_in->progress = progress_start (gdisp, message, TRUE,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_update (PlugIn *plug_in,
|
||||
double percentage)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update( GTK_PROGRESS_BAR (gdisp->progressbar), percentage);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (plug_in->progress_bar), percentage);
|
||||
#else
|
||||
progress_update (percentage);
|
||||
#endif
|
||||
}
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
progress_update (plug_in->progress, percentage);
|
||||
}
|
||||
|
||||
static Argument*
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <unistd.h>
|
||||
#include "libgimp/parasite.h"
|
||||
#include "libgimp/parasiteP.h" /* ick */
|
||||
#include "libgimp/gimpmodule.h"
|
||||
|
||||
#ifdef HAVE_IPC_H
|
||||
#include <sys/ipc.h>
|
||||
|
@ -62,7 +63,7 @@
|
|||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#define SEPARATE_PROGRESS_BAR
|
||||
|
||||
|
||||
|
||||
typedef struct _PlugInBlocked PlugInBlocked;
|
||||
|
@ -126,8 +127,6 @@ static void plug_in_args_destroy (Argument *args,
|
|||
int nargs,
|
||||
int full_destroy);
|
||||
|
||||
static void plug_in_disconnect_cancel (PlugIn *plug_in);
|
||||
|
||||
static Argument* progress_init_invoker (Argument *args);
|
||||
static Argument* progress_update_invoker (Argument *args);
|
||||
|
||||
|
@ -138,6 +137,8 @@ static Argument* message_handler_set_invoker (Argument *args);
|
|||
|
||||
static Argument* plugin_temp_PDB_name_invoker (Argument *args);
|
||||
|
||||
static void module_initialize (char *filename);
|
||||
|
||||
|
||||
static GSList *plug_in_defs = NULL;
|
||||
static GSList *gimprc_proc_defs = NULL;
|
||||
|
@ -481,8 +482,79 @@ plug_in_init ()
|
|||
g_free (plug_in_def);
|
||||
}
|
||||
g_slist_free (plug_in_defs);
|
||||
|
||||
|
||||
/* Load and initialize gimp modules */
|
||||
|
||||
if (g_module_supported ())
|
||||
datafiles_read_directories (module_path,
|
||||
module_initialize, 0 /* no flags */);
|
||||
}
|
||||
|
||||
|
||||
/* name must be of the form lib*.so */
|
||||
/* TODO: need support for WIN32-style dll names. Maybe this function
|
||||
* should live in libgmodule? */
|
||||
static gboolean
|
||||
valid_module_name (const char *filename)
|
||||
{
|
||||
const char *basename;
|
||||
int len;
|
||||
|
||||
basename = strrchr (filename, '/');
|
||||
if (basename)
|
||||
basename++;
|
||||
else
|
||||
basename = filename;
|
||||
|
||||
len = strlen (basename);
|
||||
|
||||
if (len < 3 + 1 + 3)
|
||||
return FALSE;
|
||||
|
||||
if (strncmp (basename, "lib", 3))
|
||||
return FALSE;
|
||||
|
||||
if (strcmp (basename + len - 3, ".so"))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
module_initialize (char *filename)
|
||||
{
|
||||
GModule *mod;
|
||||
GimpModuleInitFunc init;
|
||||
gpointer symbol;
|
||||
|
||||
if (!valid_module_name (filename))
|
||||
return;
|
||||
|
||||
if ((be_verbose == TRUE) || (no_splash == TRUE))
|
||||
g_print (_("load module: \"%s\"\n"), filename);
|
||||
|
||||
mod = g_module_open (filename, G_MODULE_BIND_LAZY);
|
||||
if (!mod)
|
||||
{
|
||||
g_warning (_("module load error: %s: %s"), filename, g_module_error ());
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_module_symbol (mod, "module_init", &symbol))
|
||||
{
|
||||
init = symbol;
|
||||
if (init () == GIMP_MODULE_UNLOAD)
|
||||
g_module_close (mod);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning (_("%s: module_init() symbol not found"), filename);
|
||||
g_module_close (mod);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
plug_in_kill ()
|
||||
{
|
||||
|
@ -818,9 +890,6 @@ plug_in_new (char *name)
|
|||
plug_in->write_buffer_index = 0;
|
||||
plug_in->temp_proc_defs = NULL;
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
plug_in->progress_gdisp_ID = -1;
|
||||
plug_in->user_data = NULL;
|
||||
|
||||
return plug_in;
|
||||
|
@ -829,9 +898,6 @@ plug_in_new (char *name)
|
|||
void
|
||||
plug_in_destroy (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
guint c_id;
|
||||
|
||||
if (plug_in)
|
||||
{
|
||||
plug_in_close (plug_in, TRUE);
|
||||
|
@ -849,18 +915,9 @@ plug_in_destroy (PlugIn *plug_in)
|
|||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
c_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), c_id);
|
||||
gtk_progress_bar_update(GTK_PROGRESS_BAR(gdisp->progressbar), 0.0);
|
||||
|
||||
plug_in_disconnect_cancel (plug_in);
|
||||
|
||||
gdisp->progressid = 0;
|
||||
}
|
||||
if (plug_in->progress)
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
|
@ -1011,23 +1068,9 @@ plug_in_close (PlugIn *plug_in,
|
|||
|
||||
/* Destroy the progress dialog if it exists
|
||||
*/
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (plug_in->progress)
|
||||
{
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (plug_in->progress), plug_in);
|
||||
gtk_widget_destroy (plug_in->progress);
|
||||
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
}
|
||||
#else
|
||||
if (plug_in->progress)
|
||||
{
|
||||
progress_end ();
|
||||
plug_in->progress = NULL;
|
||||
}
|
||||
#endif
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
/* Set the fields to null values.
|
||||
*/
|
||||
|
@ -3089,32 +3132,15 @@ static void
|
|||
plug_in_progress_cancel (GtkWidget *widget,
|
||||
PlugIn *plug_in)
|
||||
{
|
||||
plug_in->progress = NULL;
|
||||
plug_in_destroy (plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_disconnect_cancel (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp = NULL;
|
||||
|
||||
gdisp = gdisplay_get_ID (plug_in->progress_gdisp_ID);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, FALSE);
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (gdisp->cancelbutton),
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_init (PlugIn *plug_in,
|
||||
char *message,
|
||||
gint gdisp_ID)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *button;
|
||||
GDisplay *gdisp = NULL;
|
||||
guint context_id;
|
||||
|
||||
if (!message)
|
||||
message = plug_in->args[0];
|
||||
|
@ -3122,100 +3148,22 @@ plug_in_progress_init (PlugIn *plug_in,
|
|||
if (gdisp_ID > 0)
|
||||
gdisp = gdisplay_get_ID(gdisp_ID);
|
||||
|
||||
if (gdisp_ID > 0 && GTK_WIDGET_VISIBLE (gdisp->statusarea)
|
||||
&& (gdisp->progressid == 0 || plug_in->progress_gdisp_ID > 0))
|
||||
{
|
||||
context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), context_id);
|
||||
|
||||
gdisp->progressid = gtk_statusbar_push(GTK_STATUSBAR(gdisp->statusbar),
|
||||
context_id, message);
|
||||
plug_in->progress_gdisp_ID = gdisp_ID;
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (gdisp->cancelbutton), "clicked",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, TRUE);
|
||||
}
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = gtk_dialog_new ();
|
||||
gtk_window_set_wmclass (GTK_WINDOW (plug_in->progress), "plug_in_progress", "Gimp");
|
||||
gtk_window_set_title (GTK_WINDOW (plug_in->progress), prune_filename (plug_in->args[0]));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (plug_in->progress), "destroy",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (plug_in->progress)->action_area), 2);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->vbox), vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
plug_in->progress_label = gtk_label_new (message);
|
||||
gtk_misc_set_alignment (GTK_MISC (plug_in->progress_label), 0.0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_label, FALSE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_label);
|
||||
|
||||
plug_in->progress_bar = gtk_progress_bar_new ();
|
||||
gtk_widget_set_usize (plug_in->progress_bar, 150, 20);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_bar, TRUE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_bar);
|
||||
|
||||
button = gtk_button_new_with_label (_("Cancel"));
|
||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) gtk_widget_destroy,
|
||||
GTK_OBJECT (plug_in->progress));
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->action_area), button, TRUE, TRUE, 0);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gtk_widget_show (plug_in->progress);
|
||||
}
|
||||
if (plug_in->progress)
|
||||
plug_in->progress = progress_restart (plug_in->progress, message,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
else
|
||||
{
|
||||
gtk_label_set (GTK_LABEL (plug_in->progress_label), message);
|
||||
}
|
||||
#else
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = 0x1;
|
||||
progress_update (0.0);
|
||||
progress_start ();
|
||||
}
|
||||
#endif
|
||||
plug_in->progress = progress_start (gdisp, message, TRUE,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_update (PlugIn *plug_in,
|
||||
double percentage)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update( GTK_PROGRESS_BAR (gdisp->progressbar), percentage);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (plug_in->progress_bar), percentage);
|
||||
#else
|
||||
progress_update (percentage);
|
||||
#endif
|
||||
}
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
progress_update (plug_in->progress, percentage);
|
||||
}
|
||||
|
||||
static Argument*
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <unistd.h>
|
||||
#include "libgimp/parasite.h"
|
||||
#include "libgimp/parasiteP.h" /* ick */
|
||||
#include "libgimp/gimpmodule.h"
|
||||
|
||||
#ifdef HAVE_IPC_H
|
||||
#include <sys/ipc.h>
|
||||
|
@ -62,7 +63,7 @@
|
|||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#define SEPARATE_PROGRESS_BAR
|
||||
|
||||
|
||||
|
||||
typedef struct _PlugInBlocked PlugInBlocked;
|
||||
|
@ -126,8 +127,6 @@ static void plug_in_args_destroy (Argument *args,
|
|||
int nargs,
|
||||
int full_destroy);
|
||||
|
||||
static void plug_in_disconnect_cancel (PlugIn *plug_in);
|
||||
|
||||
static Argument* progress_init_invoker (Argument *args);
|
||||
static Argument* progress_update_invoker (Argument *args);
|
||||
|
||||
|
@ -138,6 +137,8 @@ static Argument* message_handler_set_invoker (Argument *args);
|
|||
|
||||
static Argument* plugin_temp_PDB_name_invoker (Argument *args);
|
||||
|
||||
static void module_initialize (char *filename);
|
||||
|
||||
|
||||
static GSList *plug_in_defs = NULL;
|
||||
static GSList *gimprc_proc_defs = NULL;
|
||||
|
@ -481,8 +482,79 @@ plug_in_init ()
|
|||
g_free (plug_in_def);
|
||||
}
|
||||
g_slist_free (plug_in_defs);
|
||||
|
||||
|
||||
/* Load and initialize gimp modules */
|
||||
|
||||
if (g_module_supported ())
|
||||
datafiles_read_directories (module_path,
|
||||
module_initialize, 0 /* no flags */);
|
||||
}
|
||||
|
||||
|
||||
/* name must be of the form lib*.so */
|
||||
/* TODO: need support for WIN32-style dll names. Maybe this function
|
||||
* should live in libgmodule? */
|
||||
static gboolean
|
||||
valid_module_name (const char *filename)
|
||||
{
|
||||
const char *basename;
|
||||
int len;
|
||||
|
||||
basename = strrchr (filename, '/');
|
||||
if (basename)
|
||||
basename++;
|
||||
else
|
||||
basename = filename;
|
||||
|
||||
len = strlen (basename);
|
||||
|
||||
if (len < 3 + 1 + 3)
|
||||
return FALSE;
|
||||
|
||||
if (strncmp (basename, "lib", 3))
|
||||
return FALSE;
|
||||
|
||||
if (strcmp (basename + len - 3, ".so"))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
module_initialize (char *filename)
|
||||
{
|
||||
GModule *mod;
|
||||
GimpModuleInitFunc init;
|
||||
gpointer symbol;
|
||||
|
||||
if (!valid_module_name (filename))
|
||||
return;
|
||||
|
||||
if ((be_verbose == TRUE) || (no_splash == TRUE))
|
||||
g_print (_("load module: \"%s\"\n"), filename);
|
||||
|
||||
mod = g_module_open (filename, G_MODULE_BIND_LAZY);
|
||||
if (!mod)
|
||||
{
|
||||
g_warning (_("module load error: %s: %s"), filename, g_module_error ());
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_module_symbol (mod, "module_init", &symbol))
|
||||
{
|
||||
init = symbol;
|
||||
if (init () == GIMP_MODULE_UNLOAD)
|
||||
g_module_close (mod);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning (_("%s: module_init() symbol not found"), filename);
|
||||
g_module_close (mod);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
plug_in_kill ()
|
||||
{
|
||||
|
@ -818,9 +890,6 @@ plug_in_new (char *name)
|
|||
plug_in->write_buffer_index = 0;
|
||||
plug_in->temp_proc_defs = NULL;
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
plug_in->progress_gdisp_ID = -1;
|
||||
plug_in->user_data = NULL;
|
||||
|
||||
return plug_in;
|
||||
|
@ -829,9 +898,6 @@ plug_in_new (char *name)
|
|||
void
|
||||
plug_in_destroy (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
guint c_id;
|
||||
|
||||
if (plug_in)
|
||||
{
|
||||
plug_in_close (plug_in, TRUE);
|
||||
|
@ -849,18 +915,9 @@ plug_in_destroy (PlugIn *plug_in)
|
|||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
c_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), c_id);
|
||||
gtk_progress_bar_update(GTK_PROGRESS_BAR(gdisp->progressbar), 0.0);
|
||||
|
||||
plug_in_disconnect_cancel (plug_in);
|
||||
|
||||
gdisp->progressid = 0;
|
||||
}
|
||||
if (plug_in->progress)
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
|
@ -1011,23 +1068,9 @@ plug_in_close (PlugIn *plug_in,
|
|||
|
||||
/* Destroy the progress dialog if it exists
|
||||
*/
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (plug_in->progress)
|
||||
{
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (plug_in->progress), plug_in);
|
||||
gtk_widget_destroy (plug_in->progress);
|
||||
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
}
|
||||
#else
|
||||
if (plug_in->progress)
|
||||
{
|
||||
progress_end ();
|
||||
plug_in->progress = NULL;
|
||||
}
|
||||
#endif
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
/* Set the fields to null values.
|
||||
*/
|
||||
|
@ -3089,32 +3132,15 @@ static void
|
|||
plug_in_progress_cancel (GtkWidget *widget,
|
||||
PlugIn *plug_in)
|
||||
{
|
||||
plug_in->progress = NULL;
|
||||
plug_in_destroy (plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_disconnect_cancel (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp = NULL;
|
||||
|
||||
gdisp = gdisplay_get_ID (plug_in->progress_gdisp_ID);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, FALSE);
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (gdisp->cancelbutton),
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_init (PlugIn *plug_in,
|
||||
char *message,
|
||||
gint gdisp_ID)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *button;
|
||||
GDisplay *gdisp = NULL;
|
||||
guint context_id;
|
||||
|
||||
if (!message)
|
||||
message = plug_in->args[0];
|
||||
|
@ -3122,100 +3148,22 @@ plug_in_progress_init (PlugIn *plug_in,
|
|||
if (gdisp_ID > 0)
|
||||
gdisp = gdisplay_get_ID(gdisp_ID);
|
||||
|
||||
if (gdisp_ID > 0 && GTK_WIDGET_VISIBLE (gdisp->statusarea)
|
||||
&& (gdisp->progressid == 0 || plug_in->progress_gdisp_ID > 0))
|
||||
{
|
||||
context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), context_id);
|
||||
|
||||
gdisp->progressid = gtk_statusbar_push(GTK_STATUSBAR(gdisp->statusbar),
|
||||
context_id, message);
|
||||
plug_in->progress_gdisp_ID = gdisp_ID;
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (gdisp->cancelbutton), "clicked",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, TRUE);
|
||||
}
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = gtk_dialog_new ();
|
||||
gtk_window_set_wmclass (GTK_WINDOW (plug_in->progress), "plug_in_progress", "Gimp");
|
||||
gtk_window_set_title (GTK_WINDOW (plug_in->progress), prune_filename (plug_in->args[0]));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (plug_in->progress), "destroy",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (plug_in->progress)->action_area), 2);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->vbox), vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
plug_in->progress_label = gtk_label_new (message);
|
||||
gtk_misc_set_alignment (GTK_MISC (plug_in->progress_label), 0.0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_label, FALSE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_label);
|
||||
|
||||
plug_in->progress_bar = gtk_progress_bar_new ();
|
||||
gtk_widget_set_usize (plug_in->progress_bar, 150, 20);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_bar, TRUE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_bar);
|
||||
|
||||
button = gtk_button_new_with_label (_("Cancel"));
|
||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) gtk_widget_destroy,
|
||||
GTK_OBJECT (plug_in->progress));
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->action_area), button, TRUE, TRUE, 0);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gtk_widget_show (plug_in->progress);
|
||||
}
|
||||
if (plug_in->progress)
|
||||
plug_in->progress = progress_restart (plug_in->progress, message,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
else
|
||||
{
|
||||
gtk_label_set (GTK_LABEL (plug_in->progress_label), message);
|
||||
}
|
||||
#else
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = 0x1;
|
||||
progress_update (0.0);
|
||||
progress_start ();
|
||||
}
|
||||
#endif
|
||||
plug_in->progress = progress_start (gdisp, message, TRUE,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_update (PlugIn *plug_in,
|
||||
double percentage)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update( GTK_PROGRESS_BAR (gdisp->progressbar), percentage);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (plug_in->progress_bar), percentage);
|
||||
#else
|
||||
progress_update (percentage);
|
||||
#endif
|
||||
}
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
progress_update (plug_in->progress, percentage);
|
||||
}
|
||||
|
||||
static Argument*
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "gtk/gtk.h"
|
||||
#include "procedural_db.h"
|
||||
#include "gimpprogress.h"
|
||||
|
||||
|
||||
#define WRITE_BUFFER_SIZE 512
|
||||
|
@ -58,11 +59,7 @@ struct _PlugIn
|
|||
|
||||
GSList *temp_proc_defs; /* Temporary procedures */
|
||||
|
||||
GtkWidget *progress; /* Progress dialog */
|
||||
GtkWidget *progress_label;
|
||||
GtkWidget *progress_bar;
|
||||
|
||||
gint8 progress_gdisp_ID; /* gdisp_ID of progress */
|
||||
gimp_progress *progress; /* Progress dialog */
|
||||
|
||||
gpointer user_data; /* Handle for hanging data onto */
|
||||
};
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <unistd.h>
|
||||
#include "libgimp/parasite.h"
|
||||
#include "libgimp/parasiteP.h" /* ick */
|
||||
#include "libgimp/gimpmodule.h"
|
||||
|
||||
#ifdef HAVE_IPC_H
|
||||
#include <sys/ipc.h>
|
||||
|
@ -62,7 +63,7 @@
|
|||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#define SEPARATE_PROGRESS_BAR
|
||||
|
||||
|
||||
|
||||
typedef struct _PlugInBlocked PlugInBlocked;
|
||||
|
@ -126,8 +127,6 @@ static void plug_in_args_destroy (Argument *args,
|
|||
int nargs,
|
||||
int full_destroy);
|
||||
|
||||
static void plug_in_disconnect_cancel (PlugIn *plug_in);
|
||||
|
||||
static Argument* progress_init_invoker (Argument *args);
|
||||
static Argument* progress_update_invoker (Argument *args);
|
||||
|
||||
|
@ -138,6 +137,8 @@ static Argument* message_handler_set_invoker (Argument *args);
|
|||
|
||||
static Argument* plugin_temp_PDB_name_invoker (Argument *args);
|
||||
|
||||
static void module_initialize (char *filename);
|
||||
|
||||
|
||||
static GSList *plug_in_defs = NULL;
|
||||
static GSList *gimprc_proc_defs = NULL;
|
||||
|
@ -481,8 +482,79 @@ plug_in_init ()
|
|||
g_free (plug_in_def);
|
||||
}
|
||||
g_slist_free (plug_in_defs);
|
||||
|
||||
|
||||
/* Load and initialize gimp modules */
|
||||
|
||||
if (g_module_supported ())
|
||||
datafiles_read_directories (module_path,
|
||||
module_initialize, 0 /* no flags */);
|
||||
}
|
||||
|
||||
|
||||
/* name must be of the form lib*.so */
|
||||
/* TODO: need support for WIN32-style dll names. Maybe this function
|
||||
* should live in libgmodule? */
|
||||
static gboolean
|
||||
valid_module_name (const char *filename)
|
||||
{
|
||||
const char *basename;
|
||||
int len;
|
||||
|
||||
basename = strrchr (filename, '/');
|
||||
if (basename)
|
||||
basename++;
|
||||
else
|
||||
basename = filename;
|
||||
|
||||
len = strlen (basename);
|
||||
|
||||
if (len < 3 + 1 + 3)
|
||||
return FALSE;
|
||||
|
||||
if (strncmp (basename, "lib", 3))
|
||||
return FALSE;
|
||||
|
||||
if (strcmp (basename + len - 3, ".so"))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
module_initialize (char *filename)
|
||||
{
|
||||
GModule *mod;
|
||||
GimpModuleInitFunc init;
|
||||
gpointer symbol;
|
||||
|
||||
if (!valid_module_name (filename))
|
||||
return;
|
||||
|
||||
if ((be_verbose == TRUE) || (no_splash == TRUE))
|
||||
g_print (_("load module: \"%s\"\n"), filename);
|
||||
|
||||
mod = g_module_open (filename, G_MODULE_BIND_LAZY);
|
||||
if (!mod)
|
||||
{
|
||||
g_warning (_("module load error: %s: %s"), filename, g_module_error ());
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_module_symbol (mod, "module_init", &symbol))
|
||||
{
|
||||
init = symbol;
|
||||
if (init () == GIMP_MODULE_UNLOAD)
|
||||
g_module_close (mod);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning (_("%s: module_init() symbol not found"), filename);
|
||||
g_module_close (mod);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
plug_in_kill ()
|
||||
{
|
||||
|
@ -818,9 +890,6 @@ plug_in_new (char *name)
|
|||
plug_in->write_buffer_index = 0;
|
||||
plug_in->temp_proc_defs = NULL;
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
plug_in->progress_gdisp_ID = -1;
|
||||
plug_in->user_data = NULL;
|
||||
|
||||
return plug_in;
|
||||
|
@ -829,9 +898,6 @@ plug_in_new (char *name)
|
|||
void
|
||||
plug_in_destroy (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
guint c_id;
|
||||
|
||||
if (plug_in)
|
||||
{
|
||||
plug_in_close (plug_in, TRUE);
|
||||
|
@ -849,18 +915,9 @@ plug_in_destroy (PlugIn *plug_in)
|
|||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
c_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), c_id);
|
||||
gtk_progress_bar_update(GTK_PROGRESS_BAR(gdisp->progressbar), 0.0);
|
||||
|
||||
plug_in_disconnect_cancel (plug_in);
|
||||
|
||||
gdisp->progressid = 0;
|
||||
}
|
||||
if (plug_in->progress)
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
|
@ -1011,23 +1068,9 @@ plug_in_close (PlugIn *plug_in,
|
|||
|
||||
/* Destroy the progress dialog if it exists
|
||||
*/
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (plug_in->progress)
|
||||
{
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (plug_in->progress), plug_in);
|
||||
gtk_widget_destroy (plug_in->progress);
|
||||
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
}
|
||||
#else
|
||||
if (plug_in->progress)
|
||||
{
|
||||
progress_end ();
|
||||
plug_in->progress = NULL;
|
||||
}
|
||||
#endif
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
/* Set the fields to null values.
|
||||
*/
|
||||
|
@ -3089,32 +3132,15 @@ static void
|
|||
plug_in_progress_cancel (GtkWidget *widget,
|
||||
PlugIn *plug_in)
|
||||
{
|
||||
plug_in->progress = NULL;
|
||||
plug_in_destroy (plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_disconnect_cancel (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp = NULL;
|
||||
|
||||
gdisp = gdisplay_get_ID (plug_in->progress_gdisp_ID);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, FALSE);
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (gdisp->cancelbutton),
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_init (PlugIn *plug_in,
|
||||
char *message,
|
||||
gint gdisp_ID)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *button;
|
||||
GDisplay *gdisp = NULL;
|
||||
guint context_id;
|
||||
|
||||
if (!message)
|
||||
message = plug_in->args[0];
|
||||
|
@ -3122,100 +3148,22 @@ plug_in_progress_init (PlugIn *plug_in,
|
|||
if (gdisp_ID > 0)
|
||||
gdisp = gdisplay_get_ID(gdisp_ID);
|
||||
|
||||
if (gdisp_ID > 0 && GTK_WIDGET_VISIBLE (gdisp->statusarea)
|
||||
&& (gdisp->progressid == 0 || plug_in->progress_gdisp_ID > 0))
|
||||
{
|
||||
context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), context_id);
|
||||
|
||||
gdisp->progressid = gtk_statusbar_push(GTK_STATUSBAR(gdisp->statusbar),
|
||||
context_id, message);
|
||||
plug_in->progress_gdisp_ID = gdisp_ID;
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (gdisp->cancelbutton), "clicked",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, TRUE);
|
||||
}
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = gtk_dialog_new ();
|
||||
gtk_window_set_wmclass (GTK_WINDOW (plug_in->progress), "plug_in_progress", "Gimp");
|
||||
gtk_window_set_title (GTK_WINDOW (plug_in->progress), prune_filename (plug_in->args[0]));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (plug_in->progress), "destroy",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (plug_in->progress)->action_area), 2);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->vbox), vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
plug_in->progress_label = gtk_label_new (message);
|
||||
gtk_misc_set_alignment (GTK_MISC (plug_in->progress_label), 0.0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_label, FALSE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_label);
|
||||
|
||||
plug_in->progress_bar = gtk_progress_bar_new ();
|
||||
gtk_widget_set_usize (plug_in->progress_bar, 150, 20);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_bar, TRUE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_bar);
|
||||
|
||||
button = gtk_button_new_with_label (_("Cancel"));
|
||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) gtk_widget_destroy,
|
||||
GTK_OBJECT (plug_in->progress));
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->action_area), button, TRUE, TRUE, 0);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gtk_widget_show (plug_in->progress);
|
||||
}
|
||||
if (plug_in->progress)
|
||||
plug_in->progress = progress_restart (plug_in->progress, message,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
else
|
||||
{
|
||||
gtk_label_set (GTK_LABEL (plug_in->progress_label), message);
|
||||
}
|
||||
#else
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = 0x1;
|
||||
progress_update (0.0);
|
||||
progress_start ();
|
||||
}
|
||||
#endif
|
||||
plug_in->progress = progress_start (gdisp, message, TRUE,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_update (PlugIn *plug_in,
|
||||
double percentage)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update( GTK_PROGRESS_BAR (gdisp->progressbar), percentage);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (plug_in->progress_bar), percentage);
|
||||
#else
|
||||
progress_update (percentage);
|
||||
#endif
|
||||
}
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
progress_update (plug_in->progress, percentage);
|
||||
}
|
||||
|
||||
static Argument*
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <unistd.h>
|
||||
#include "libgimp/parasite.h"
|
||||
#include "libgimp/parasiteP.h" /* ick */
|
||||
#include "libgimp/gimpmodule.h"
|
||||
|
||||
#ifdef HAVE_IPC_H
|
||||
#include <sys/ipc.h>
|
||||
|
@ -62,7 +63,7 @@
|
|||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#define SEPARATE_PROGRESS_BAR
|
||||
|
||||
|
||||
|
||||
typedef struct _PlugInBlocked PlugInBlocked;
|
||||
|
@ -126,8 +127,6 @@ static void plug_in_args_destroy (Argument *args,
|
|||
int nargs,
|
||||
int full_destroy);
|
||||
|
||||
static void plug_in_disconnect_cancel (PlugIn *plug_in);
|
||||
|
||||
static Argument* progress_init_invoker (Argument *args);
|
||||
static Argument* progress_update_invoker (Argument *args);
|
||||
|
||||
|
@ -138,6 +137,8 @@ static Argument* message_handler_set_invoker (Argument *args);
|
|||
|
||||
static Argument* plugin_temp_PDB_name_invoker (Argument *args);
|
||||
|
||||
static void module_initialize (char *filename);
|
||||
|
||||
|
||||
static GSList *plug_in_defs = NULL;
|
||||
static GSList *gimprc_proc_defs = NULL;
|
||||
|
@ -481,8 +482,79 @@ plug_in_init ()
|
|||
g_free (plug_in_def);
|
||||
}
|
||||
g_slist_free (plug_in_defs);
|
||||
|
||||
|
||||
/* Load and initialize gimp modules */
|
||||
|
||||
if (g_module_supported ())
|
||||
datafiles_read_directories (module_path,
|
||||
module_initialize, 0 /* no flags */);
|
||||
}
|
||||
|
||||
|
||||
/* name must be of the form lib*.so */
|
||||
/* TODO: need support for WIN32-style dll names. Maybe this function
|
||||
* should live in libgmodule? */
|
||||
static gboolean
|
||||
valid_module_name (const char *filename)
|
||||
{
|
||||
const char *basename;
|
||||
int len;
|
||||
|
||||
basename = strrchr (filename, '/');
|
||||
if (basename)
|
||||
basename++;
|
||||
else
|
||||
basename = filename;
|
||||
|
||||
len = strlen (basename);
|
||||
|
||||
if (len < 3 + 1 + 3)
|
||||
return FALSE;
|
||||
|
||||
if (strncmp (basename, "lib", 3))
|
||||
return FALSE;
|
||||
|
||||
if (strcmp (basename + len - 3, ".so"))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
module_initialize (char *filename)
|
||||
{
|
||||
GModule *mod;
|
||||
GimpModuleInitFunc init;
|
||||
gpointer symbol;
|
||||
|
||||
if (!valid_module_name (filename))
|
||||
return;
|
||||
|
||||
if ((be_verbose == TRUE) || (no_splash == TRUE))
|
||||
g_print (_("load module: \"%s\"\n"), filename);
|
||||
|
||||
mod = g_module_open (filename, G_MODULE_BIND_LAZY);
|
||||
if (!mod)
|
||||
{
|
||||
g_warning (_("module load error: %s: %s"), filename, g_module_error ());
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_module_symbol (mod, "module_init", &symbol))
|
||||
{
|
||||
init = symbol;
|
||||
if (init () == GIMP_MODULE_UNLOAD)
|
||||
g_module_close (mod);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning (_("%s: module_init() symbol not found"), filename);
|
||||
g_module_close (mod);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
plug_in_kill ()
|
||||
{
|
||||
|
@ -818,9 +890,6 @@ plug_in_new (char *name)
|
|||
plug_in->write_buffer_index = 0;
|
||||
plug_in->temp_proc_defs = NULL;
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
plug_in->progress_gdisp_ID = -1;
|
||||
plug_in->user_data = NULL;
|
||||
|
||||
return plug_in;
|
||||
|
@ -829,9 +898,6 @@ plug_in_new (char *name)
|
|||
void
|
||||
plug_in_destroy (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
guint c_id;
|
||||
|
||||
if (plug_in)
|
||||
{
|
||||
plug_in_close (plug_in, TRUE);
|
||||
|
@ -849,18 +915,9 @@ plug_in_destroy (PlugIn *plug_in)
|
|||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
c_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), c_id);
|
||||
gtk_progress_bar_update(GTK_PROGRESS_BAR(gdisp->progressbar), 0.0);
|
||||
|
||||
plug_in_disconnect_cancel (plug_in);
|
||||
|
||||
gdisp->progressid = 0;
|
||||
}
|
||||
if (plug_in->progress)
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
|
@ -1011,23 +1068,9 @@ plug_in_close (PlugIn *plug_in,
|
|||
|
||||
/* Destroy the progress dialog if it exists
|
||||
*/
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (plug_in->progress)
|
||||
{
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (plug_in->progress), plug_in);
|
||||
gtk_widget_destroy (plug_in->progress);
|
||||
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
}
|
||||
#else
|
||||
if (plug_in->progress)
|
||||
{
|
||||
progress_end ();
|
||||
plug_in->progress = NULL;
|
||||
}
|
||||
#endif
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
/* Set the fields to null values.
|
||||
*/
|
||||
|
@ -3089,32 +3132,15 @@ static void
|
|||
plug_in_progress_cancel (GtkWidget *widget,
|
||||
PlugIn *plug_in)
|
||||
{
|
||||
plug_in->progress = NULL;
|
||||
plug_in_destroy (plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_disconnect_cancel (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp = NULL;
|
||||
|
||||
gdisp = gdisplay_get_ID (plug_in->progress_gdisp_ID);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, FALSE);
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (gdisp->cancelbutton),
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_init (PlugIn *plug_in,
|
||||
char *message,
|
||||
gint gdisp_ID)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *button;
|
||||
GDisplay *gdisp = NULL;
|
||||
guint context_id;
|
||||
|
||||
if (!message)
|
||||
message = plug_in->args[0];
|
||||
|
@ -3122,100 +3148,22 @@ plug_in_progress_init (PlugIn *plug_in,
|
|||
if (gdisp_ID > 0)
|
||||
gdisp = gdisplay_get_ID(gdisp_ID);
|
||||
|
||||
if (gdisp_ID > 0 && GTK_WIDGET_VISIBLE (gdisp->statusarea)
|
||||
&& (gdisp->progressid == 0 || plug_in->progress_gdisp_ID > 0))
|
||||
{
|
||||
context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), context_id);
|
||||
|
||||
gdisp->progressid = gtk_statusbar_push(GTK_STATUSBAR(gdisp->statusbar),
|
||||
context_id, message);
|
||||
plug_in->progress_gdisp_ID = gdisp_ID;
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (gdisp->cancelbutton), "clicked",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, TRUE);
|
||||
}
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = gtk_dialog_new ();
|
||||
gtk_window_set_wmclass (GTK_WINDOW (plug_in->progress), "plug_in_progress", "Gimp");
|
||||
gtk_window_set_title (GTK_WINDOW (plug_in->progress), prune_filename (plug_in->args[0]));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (plug_in->progress), "destroy",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (plug_in->progress)->action_area), 2);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->vbox), vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
plug_in->progress_label = gtk_label_new (message);
|
||||
gtk_misc_set_alignment (GTK_MISC (plug_in->progress_label), 0.0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_label, FALSE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_label);
|
||||
|
||||
plug_in->progress_bar = gtk_progress_bar_new ();
|
||||
gtk_widget_set_usize (plug_in->progress_bar, 150, 20);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_bar, TRUE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_bar);
|
||||
|
||||
button = gtk_button_new_with_label (_("Cancel"));
|
||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) gtk_widget_destroy,
|
||||
GTK_OBJECT (plug_in->progress));
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->action_area), button, TRUE, TRUE, 0);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gtk_widget_show (plug_in->progress);
|
||||
}
|
||||
if (plug_in->progress)
|
||||
plug_in->progress = progress_restart (plug_in->progress, message,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
else
|
||||
{
|
||||
gtk_label_set (GTK_LABEL (plug_in->progress_label), message);
|
||||
}
|
||||
#else
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = 0x1;
|
||||
progress_update (0.0);
|
||||
progress_start ();
|
||||
}
|
||||
#endif
|
||||
plug_in->progress = progress_start (gdisp, message, TRUE,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_update (PlugIn *plug_in,
|
||||
double percentage)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update( GTK_PROGRESS_BAR (gdisp->progressbar), percentage);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (plug_in->progress_bar), percentage);
|
||||
#else
|
||||
progress_update (percentage);
|
||||
#endif
|
||||
}
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
progress_update (plug_in->progress, percentage);
|
||||
}
|
||||
|
||||
static Argument*
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "gtk/gtk.h"
|
||||
#include "procedural_db.h"
|
||||
#include "gimpprogress.h"
|
||||
|
||||
|
||||
#define WRITE_BUFFER_SIZE 512
|
||||
|
@ -58,11 +59,7 @@ struct _PlugIn
|
|||
|
||||
GSList *temp_proc_defs; /* Temporary procedures */
|
||||
|
||||
GtkWidget *progress; /* Progress dialog */
|
||||
GtkWidget *progress_label;
|
||||
GtkWidget *progress_bar;
|
||||
|
||||
gint8 progress_gdisp_ID; /* gdisp_ID of progress */
|
||||
gimp_progress *progress; /* Progress dialog */
|
||||
|
||||
gpointer user_data; /* Handle for hanging data onto */
|
||||
};
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <unistd.h>
|
||||
#include "libgimp/parasite.h"
|
||||
#include "libgimp/parasiteP.h" /* ick */
|
||||
#include "libgimp/gimpmodule.h"
|
||||
|
||||
#ifdef HAVE_IPC_H
|
||||
#include <sys/ipc.h>
|
||||
|
@ -62,7 +63,7 @@
|
|||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#define SEPARATE_PROGRESS_BAR
|
||||
|
||||
|
||||
|
||||
typedef struct _PlugInBlocked PlugInBlocked;
|
||||
|
@ -126,8 +127,6 @@ static void plug_in_args_destroy (Argument *args,
|
|||
int nargs,
|
||||
int full_destroy);
|
||||
|
||||
static void plug_in_disconnect_cancel (PlugIn *plug_in);
|
||||
|
||||
static Argument* progress_init_invoker (Argument *args);
|
||||
static Argument* progress_update_invoker (Argument *args);
|
||||
|
||||
|
@ -138,6 +137,8 @@ static Argument* message_handler_set_invoker (Argument *args);
|
|||
|
||||
static Argument* plugin_temp_PDB_name_invoker (Argument *args);
|
||||
|
||||
static void module_initialize (char *filename);
|
||||
|
||||
|
||||
static GSList *plug_in_defs = NULL;
|
||||
static GSList *gimprc_proc_defs = NULL;
|
||||
|
@ -481,8 +482,79 @@ plug_in_init ()
|
|||
g_free (plug_in_def);
|
||||
}
|
||||
g_slist_free (plug_in_defs);
|
||||
|
||||
|
||||
/* Load and initialize gimp modules */
|
||||
|
||||
if (g_module_supported ())
|
||||
datafiles_read_directories (module_path,
|
||||
module_initialize, 0 /* no flags */);
|
||||
}
|
||||
|
||||
|
||||
/* name must be of the form lib*.so */
|
||||
/* TODO: need support for WIN32-style dll names. Maybe this function
|
||||
* should live in libgmodule? */
|
||||
static gboolean
|
||||
valid_module_name (const char *filename)
|
||||
{
|
||||
const char *basename;
|
||||
int len;
|
||||
|
||||
basename = strrchr (filename, '/');
|
||||
if (basename)
|
||||
basename++;
|
||||
else
|
||||
basename = filename;
|
||||
|
||||
len = strlen (basename);
|
||||
|
||||
if (len < 3 + 1 + 3)
|
||||
return FALSE;
|
||||
|
||||
if (strncmp (basename, "lib", 3))
|
||||
return FALSE;
|
||||
|
||||
if (strcmp (basename + len - 3, ".so"))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
module_initialize (char *filename)
|
||||
{
|
||||
GModule *mod;
|
||||
GimpModuleInitFunc init;
|
||||
gpointer symbol;
|
||||
|
||||
if (!valid_module_name (filename))
|
||||
return;
|
||||
|
||||
if ((be_verbose == TRUE) || (no_splash == TRUE))
|
||||
g_print (_("load module: \"%s\"\n"), filename);
|
||||
|
||||
mod = g_module_open (filename, G_MODULE_BIND_LAZY);
|
||||
if (!mod)
|
||||
{
|
||||
g_warning (_("module load error: %s: %s"), filename, g_module_error ());
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_module_symbol (mod, "module_init", &symbol))
|
||||
{
|
||||
init = symbol;
|
||||
if (init () == GIMP_MODULE_UNLOAD)
|
||||
g_module_close (mod);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning (_("%s: module_init() symbol not found"), filename);
|
||||
g_module_close (mod);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
plug_in_kill ()
|
||||
{
|
||||
|
@ -818,9 +890,6 @@ plug_in_new (char *name)
|
|||
plug_in->write_buffer_index = 0;
|
||||
plug_in->temp_proc_defs = NULL;
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
plug_in->progress_gdisp_ID = -1;
|
||||
plug_in->user_data = NULL;
|
||||
|
||||
return plug_in;
|
||||
|
@ -829,9 +898,6 @@ plug_in_new (char *name)
|
|||
void
|
||||
plug_in_destroy (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
guint c_id;
|
||||
|
||||
if (plug_in)
|
||||
{
|
||||
plug_in_close (plug_in, TRUE);
|
||||
|
@ -849,18 +915,9 @@ plug_in_destroy (PlugIn *plug_in)
|
|||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
c_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), c_id);
|
||||
gtk_progress_bar_update(GTK_PROGRESS_BAR(gdisp->progressbar), 0.0);
|
||||
|
||||
plug_in_disconnect_cancel (plug_in);
|
||||
|
||||
gdisp->progressid = 0;
|
||||
}
|
||||
if (plug_in->progress)
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
|
@ -1011,23 +1068,9 @@ plug_in_close (PlugIn *plug_in,
|
|||
|
||||
/* Destroy the progress dialog if it exists
|
||||
*/
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (plug_in->progress)
|
||||
{
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (plug_in->progress), plug_in);
|
||||
gtk_widget_destroy (plug_in->progress);
|
||||
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
}
|
||||
#else
|
||||
if (plug_in->progress)
|
||||
{
|
||||
progress_end ();
|
||||
plug_in->progress = NULL;
|
||||
}
|
||||
#endif
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
/* Set the fields to null values.
|
||||
*/
|
||||
|
@ -3089,32 +3132,15 @@ static void
|
|||
plug_in_progress_cancel (GtkWidget *widget,
|
||||
PlugIn *plug_in)
|
||||
{
|
||||
plug_in->progress = NULL;
|
||||
plug_in_destroy (plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_disconnect_cancel (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp = NULL;
|
||||
|
||||
gdisp = gdisplay_get_ID (plug_in->progress_gdisp_ID);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, FALSE);
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (gdisp->cancelbutton),
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_init (PlugIn *plug_in,
|
||||
char *message,
|
||||
gint gdisp_ID)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *button;
|
||||
GDisplay *gdisp = NULL;
|
||||
guint context_id;
|
||||
|
||||
if (!message)
|
||||
message = plug_in->args[0];
|
||||
|
@ -3122,100 +3148,22 @@ plug_in_progress_init (PlugIn *plug_in,
|
|||
if (gdisp_ID > 0)
|
||||
gdisp = gdisplay_get_ID(gdisp_ID);
|
||||
|
||||
if (gdisp_ID > 0 && GTK_WIDGET_VISIBLE (gdisp->statusarea)
|
||||
&& (gdisp->progressid == 0 || plug_in->progress_gdisp_ID > 0))
|
||||
{
|
||||
context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), context_id);
|
||||
|
||||
gdisp->progressid = gtk_statusbar_push(GTK_STATUSBAR(gdisp->statusbar),
|
||||
context_id, message);
|
||||
plug_in->progress_gdisp_ID = gdisp_ID;
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (gdisp->cancelbutton), "clicked",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, TRUE);
|
||||
}
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = gtk_dialog_new ();
|
||||
gtk_window_set_wmclass (GTK_WINDOW (plug_in->progress), "plug_in_progress", "Gimp");
|
||||
gtk_window_set_title (GTK_WINDOW (plug_in->progress), prune_filename (plug_in->args[0]));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (plug_in->progress), "destroy",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (plug_in->progress)->action_area), 2);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->vbox), vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
plug_in->progress_label = gtk_label_new (message);
|
||||
gtk_misc_set_alignment (GTK_MISC (plug_in->progress_label), 0.0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_label, FALSE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_label);
|
||||
|
||||
plug_in->progress_bar = gtk_progress_bar_new ();
|
||||
gtk_widget_set_usize (plug_in->progress_bar, 150, 20);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_bar, TRUE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_bar);
|
||||
|
||||
button = gtk_button_new_with_label (_("Cancel"));
|
||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) gtk_widget_destroy,
|
||||
GTK_OBJECT (plug_in->progress));
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->action_area), button, TRUE, TRUE, 0);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gtk_widget_show (plug_in->progress);
|
||||
}
|
||||
if (plug_in->progress)
|
||||
plug_in->progress = progress_restart (plug_in->progress, message,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
else
|
||||
{
|
||||
gtk_label_set (GTK_LABEL (plug_in->progress_label), message);
|
||||
}
|
||||
#else
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = 0x1;
|
||||
progress_update (0.0);
|
||||
progress_start ();
|
||||
}
|
||||
#endif
|
||||
plug_in->progress = progress_start (gdisp, message, TRUE,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_update (PlugIn *plug_in,
|
||||
double percentage)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update( GTK_PROGRESS_BAR (gdisp->progressbar), percentage);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (plug_in->progress_bar), percentage);
|
||||
#else
|
||||
progress_update (percentage);
|
||||
#endif
|
||||
}
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
progress_update (plug_in->progress, percentage);
|
||||
}
|
||||
|
||||
static Argument*
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <unistd.h>
|
||||
#include "libgimp/parasite.h"
|
||||
#include "libgimp/parasiteP.h" /* ick */
|
||||
#include "libgimp/gimpmodule.h"
|
||||
|
||||
#ifdef HAVE_IPC_H
|
||||
#include <sys/ipc.h>
|
||||
|
@ -62,7 +63,7 @@
|
|||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#define SEPARATE_PROGRESS_BAR
|
||||
|
||||
|
||||
|
||||
typedef struct _PlugInBlocked PlugInBlocked;
|
||||
|
@ -126,8 +127,6 @@ static void plug_in_args_destroy (Argument *args,
|
|||
int nargs,
|
||||
int full_destroy);
|
||||
|
||||
static void plug_in_disconnect_cancel (PlugIn *plug_in);
|
||||
|
||||
static Argument* progress_init_invoker (Argument *args);
|
||||
static Argument* progress_update_invoker (Argument *args);
|
||||
|
||||
|
@ -138,6 +137,8 @@ static Argument* message_handler_set_invoker (Argument *args);
|
|||
|
||||
static Argument* plugin_temp_PDB_name_invoker (Argument *args);
|
||||
|
||||
static void module_initialize (char *filename);
|
||||
|
||||
|
||||
static GSList *plug_in_defs = NULL;
|
||||
static GSList *gimprc_proc_defs = NULL;
|
||||
|
@ -481,8 +482,79 @@ plug_in_init ()
|
|||
g_free (plug_in_def);
|
||||
}
|
||||
g_slist_free (plug_in_defs);
|
||||
|
||||
|
||||
/* Load and initialize gimp modules */
|
||||
|
||||
if (g_module_supported ())
|
||||
datafiles_read_directories (module_path,
|
||||
module_initialize, 0 /* no flags */);
|
||||
}
|
||||
|
||||
|
||||
/* name must be of the form lib*.so */
|
||||
/* TODO: need support for WIN32-style dll names. Maybe this function
|
||||
* should live in libgmodule? */
|
||||
static gboolean
|
||||
valid_module_name (const char *filename)
|
||||
{
|
||||
const char *basename;
|
||||
int len;
|
||||
|
||||
basename = strrchr (filename, '/');
|
||||
if (basename)
|
||||
basename++;
|
||||
else
|
||||
basename = filename;
|
||||
|
||||
len = strlen (basename);
|
||||
|
||||
if (len < 3 + 1 + 3)
|
||||
return FALSE;
|
||||
|
||||
if (strncmp (basename, "lib", 3))
|
||||
return FALSE;
|
||||
|
||||
if (strcmp (basename + len - 3, ".so"))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
module_initialize (char *filename)
|
||||
{
|
||||
GModule *mod;
|
||||
GimpModuleInitFunc init;
|
||||
gpointer symbol;
|
||||
|
||||
if (!valid_module_name (filename))
|
||||
return;
|
||||
|
||||
if ((be_verbose == TRUE) || (no_splash == TRUE))
|
||||
g_print (_("load module: \"%s\"\n"), filename);
|
||||
|
||||
mod = g_module_open (filename, G_MODULE_BIND_LAZY);
|
||||
if (!mod)
|
||||
{
|
||||
g_warning (_("module load error: %s: %s"), filename, g_module_error ());
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_module_symbol (mod, "module_init", &symbol))
|
||||
{
|
||||
init = symbol;
|
||||
if (init () == GIMP_MODULE_UNLOAD)
|
||||
g_module_close (mod);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning (_("%s: module_init() symbol not found"), filename);
|
||||
g_module_close (mod);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
plug_in_kill ()
|
||||
{
|
||||
|
@ -818,9 +890,6 @@ plug_in_new (char *name)
|
|||
plug_in->write_buffer_index = 0;
|
||||
plug_in->temp_proc_defs = NULL;
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
plug_in->progress_gdisp_ID = -1;
|
||||
plug_in->user_data = NULL;
|
||||
|
||||
return plug_in;
|
||||
|
@ -829,9 +898,6 @@ plug_in_new (char *name)
|
|||
void
|
||||
plug_in_destroy (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
guint c_id;
|
||||
|
||||
if (plug_in)
|
||||
{
|
||||
plug_in_close (plug_in, TRUE);
|
||||
|
@ -849,18 +915,9 @@ plug_in_destroy (PlugIn *plug_in)
|
|||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
c_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), c_id);
|
||||
gtk_progress_bar_update(GTK_PROGRESS_BAR(gdisp->progressbar), 0.0);
|
||||
|
||||
plug_in_disconnect_cancel (plug_in);
|
||||
|
||||
gdisp->progressid = 0;
|
||||
}
|
||||
if (plug_in->progress)
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
|
@ -1011,23 +1068,9 @@ plug_in_close (PlugIn *plug_in,
|
|||
|
||||
/* Destroy the progress dialog if it exists
|
||||
*/
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (plug_in->progress)
|
||||
{
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (plug_in->progress), plug_in);
|
||||
gtk_widget_destroy (plug_in->progress);
|
||||
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
}
|
||||
#else
|
||||
if (plug_in->progress)
|
||||
{
|
||||
progress_end ();
|
||||
plug_in->progress = NULL;
|
||||
}
|
||||
#endif
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
/* Set the fields to null values.
|
||||
*/
|
||||
|
@ -3089,32 +3132,15 @@ static void
|
|||
plug_in_progress_cancel (GtkWidget *widget,
|
||||
PlugIn *plug_in)
|
||||
{
|
||||
plug_in->progress = NULL;
|
||||
plug_in_destroy (plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_disconnect_cancel (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp = NULL;
|
||||
|
||||
gdisp = gdisplay_get_ID (plug_in->progress_gdisp_ID);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, FALSE);
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (gdisp->cancelbutton),
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_init (PlugIn *plug_in,
|
||||
char *message,
|
||||
gint gdisp_ID)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *button;
|
||||
GDisplay *gdisp = NULL;
|
||||
guint context_id;
|
||||
|
||||
if (!message)
|
||||
message = plug_in->args[0];
|
||||
|
@ -3122,100 +3148,22 @@ plug_in_progress_init (PlugIn *plug_in,
|
|||
if (gdisp_ID > 0)
|
||||
gdisp = gdisplay_get_ID(gdisp_ID);
|
||||
|
||||
if (gdisp_ID > 0 && GTK_WIDGET_VISIBLE (gdisp->statusarea)
|
||||
&& (gdisp->progressid == 0 || plug_in->progress_gdisp_ID > 0))
|
||||
{
|
||||
context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), context_id);
|
||||
|
||||
gdisp->progressid = gtk_statusbar_push(GTK_STATUSBAR(gdisp->statusbar),
|
||||
context_id, message);
|
||||
plug_in->progress_gdisp_ID = gdisp_ID;
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (gdisp->cancelbutton), "clicked",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, TRUE);
|
||||
}
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = gtk_dialog_new ();
|
||||
gtk_window_set_wmclass (GTK_WINDOW (plug_in->progress), "plug_in_progress", "Gimp");
|
||||
gtk_window_set_title (GTK_WINDOW (plug_in->progress), prune_filename (plug_in->args[0]));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (plug_in->progress), "destroy",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (plug_in->progress)->action_area), 2);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->vbox), vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
plug_in->progress_label = gtk_label_new (message);
|
||||
gtk_misc_set_alignment (GTK_MISC (plug_in->progress_label), 0.0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_label, FALSE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_label);
|
||||
|
||||
plug_in->progress_bar = gtk_progress_bar_new ();
|
||||
gtk_widget_set_usize (plug_in->progress_bar, 150, 20);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_bar, TRUE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_bar);
|
||||
|
||||
button = gtk_button_new_with_label (_("Cancel"));
|
||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) gtk_widget_destroy,
|
||||
GTK_OBJECT (plug_in->progress));
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->action_area), button, TRUE, TRUE, 0);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gtk_widget_show (plug_in->progress);
|
||||
}
|
||||
if (plug_in->progress)
|
||||
plug_in->progress = progress_restart (plug_in->progress, message,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
else
|
||||
{
|
||||
gtk_label_set (GTK_LABEL (plug_in->progress_label), message);
|
||||
}
|
||||
#else
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = 0x1;
|
||||
progress_update (0.0);
|
||||
progress_start ();
|
||||
}
|
||||
#endif
|
||||
plug_in->progress = progress_start (gdisp, message, TRUE,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_update (PlugIn *plug_in,
|
||||
double percentage)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update( GTK_PROGRESS_BAR (gdisp->progressbar), percentage);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (plug_in->progress_bar), percentage);
|
||||
#else
|
||||
progress_update (percentage);
|
||||
#endif
|
||||
}
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
progress_update (plug_in->progress, percentage);
|
||||
}
|
||||
|
||||
static Argument*
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "gtk/gtk.h"
|
||||
#include "procedural_db.h"
|
||||
#include "gimpprogress.h"
|
||||
|
||||
|
||||
#define WRITE_BUFFER_SIZE 512
|
||||
|
@ -58,11 +59,7 @@ struct _PlugIn
|
|||
|
||||
GSList *temp_proc_defs; /* Temporary procedures */
|
||||
|
||||
GtkWidget *progress; /* Progress dialog */
|
||||
GtkWidget *progress_label;
|
||||
GtkWidget *progress_bar;
|
||||
|
||||
gint8 progress_gdisp_ID; /* gdisp_ID of progress */
|
||||
gimp_progress *progress; /* Progress dialog */
|
||||
|
||||
gpointer user_data; /* Handle for hanging data onto */
|
||||
};
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <unistd.h>
|
||||
#include "libgimp/parasite.h"
|
||||
#include "libgimp/parasiteP.h" /* ick */
|
||||
#include "libgimp/gimpmodule.h"
|
||||
|
||||
#ifdef HAVE_IPC_H
|
||||
#include <sys/ipc.h>
|
||||
|
@ -62,7 +63,7 @@
|
|||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#define SEPARATE_PROGRESS_BAR
|
||||
|
||||
|
||||
|
||||
typedef struct _PlugInBlocked PlugInBlocked;
|
||||
|
@ -126,8 +127,6 @@ static void plug_in_args_destroy (Argument *args,
|
|||
int nargs,
|
||||
int full_destroy);
|
||||
|
||||
static void plug_in_disconnect_cancel (PlugIn *plug_in);
|
||||
|
||||
static Argument* progress_init_invoker (Argument *args);
|
||||
static Argument* progress_update_invoker (Argument *args);
|
||||
|
||||
|
@ -138,6 +137,8 @@ static Argument* message_handler_set_invoker (Argument *args);
|
|||
|
||||
static Argument* plugin_temp_PDB_name_invoker (Argument *args);
|
||||
|
||||
static void module_initialize (char *filename);
|
||||
|
||||
|
||||
static GSList *plug_in_defs = NULL;
|
||||
static GSList *gimprc_proc_defs = NULL;
|
||||
|
@ -481,8 +482,79 @@ plug_in_init ()
|
|||
g_free (plug_in_def);
|
||||
}
|
||||
g_slist_free (plug_in_defs);
|
||||
|
||||
|
||||
/* Load and initialize gimp modules */
|
||||
|
||||
if (g_module_supported ())
|
||||
datafiles_read_directories (module_path,
|
||||
module_initialize, 0 /* no flags */);
|
||||
}
|
||||
|
||||
|
||||
/* name must be of the form lib*.so */
|
||||
/* TODO: need support for WIN32-style dll names. Maybe this function
|
||||
* should live in libgmodule? */
|
||||
static gboolean
|
||||
valid_module_name (const char *filename)
|
||||
{
|
||||
const char *basename;
|
||||
int len;
|
||||
|
||||
basename = strrchr (filename, '/');
|
||||
if (basename)
|
||||
basename++;
|
||||
else
|
||||
basename = filename;
|
||||
|
||||
len = strlen (basename);
|
||||
|
||||
if (len < 3 + 1 + 3)
|
||||
return FALSE;
|
||||
|
||||
if (strncmp (basename, "lib", 3))
|
||||
return FALSE;
|
||||
|
||||
if (strcmp (basename + len - 3, ".so"))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
module_initialize (char *filename)
|
||||
{
|
||||
GModule *mod;
|
||||
GimpModuleInitFunc init;
|
||||
gpointer symbol;
|
||||
|
||||
if (!valid_module_name (filename))
|
||||
return;
|
||||
|
||||
if ((be_verbose == TRUE) || (no_splash == TRUE))
|
||||
g_print (_("load module: \"%s\"\n"), filename);
|
||||
|
||||
mod = g_module_open (filename, G_MODULE_BIND_LAZY);
|
||||
if (!mod)
|
||||
{
|
||||
g_warning (_("module load error: %s: %s"), filename, g_module_error ());
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_module_symbol (mod, "module_init", &symbol))
|
||||
{
|
||||
init = symbol;
|
||||
if (init () == GIMP_MODULE_UNLOAD)
|
||||
g_module_close (mod);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning (_("%s: module_init() symbol not found"), filename);
|
||||
g_module_close (mod);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
plug_in_kill ()
|
||||
{
|
||||
|
@ -818,9 +890,6 @@ plug_in_new (char *name)
|
|||
plug_in->write_buffer_index = 0;
|
||||
plug_in->temp_proc_defs = NULL;
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
plug_in->progress_gdisp_ID = -1;
|
||||
plug_in->user_data = NULL;
|
||||
|
||||
return plug_in;
|
||||
|
@ -829,9 +898,6 @@ plug_in_new (char *name)
|
|||
void
|
||||
plug_in_destroy (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
guint c_id;
|
||||
|
||||
if (plug_in)
|
||||
{
|
||||
plug_in_close (plug_in, TRUE);
|
||||
|
@ -849,18 +915,9 @@ plug_in_destroy (PlugIn *plug_in)
|
|||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
c_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), c_id);
|
||||
gtk_progress_bar_update(GTK_PROGRESS_BAR(gdisp->progressbar), 0.0);
|
||||
|
||||
plug_in_disconnect_cancel (plug_in);
|
||||
|
||||
gdisp->progressid = 0;
|
||||
}
|
||||
if (plug_in->progress)
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
|
@ -1011,23 +1068,9 @@ plug_in_close (PlugIn *plug_in,
|
|||
|
||||
/* Destroy the progress dialog if it exists
|
||||
*/
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (plug_in->progress)
|
||||
{
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (plug_in->progress), plug_in);
|
||||
gtk_widget_destroy (plug_in->progress);
|
||||
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
}
|
||||
#else
|
||||
if (plug_in->progress)
|
||||
{
|
||||
progress_end ();
|
||||
plug_in->progress = NULL;
|
||||
}
|
||||
#endif
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
/* Set the fields to null values.
|
||||
*/
|
||||
|
@ -3089,32 +3132,15 @@ static void
|
|||
plug_in_progress_cancel (GtkWidget *widget,
|
||||
PlugIn *plug_in)
|
||||
{
|
||||
plug_in->progress = NULL;
|
||||
plug_in_destroy (plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_disconnect_cancel (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp = NULL;
|
||||
|
||||
gdisp = gdisplay_get_ID (plug_in->progress_gdisp_ID);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, FALSE);
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (gdisp->cancelbutton),
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_init (PlugIn *plug_in,
|
||||
char *message,
|
||||
gint gdisp_ID)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *button;
|
||||
GDisplay *gdisp = NULL;
|
||||
guint context_id;
|
||||
|
||||
if (!message)
|
||||
message = plug_in->args[0];
|
||||
|
@ -3122,100 +3148,22 @@ plug_in_progress_init (PlugIn *plug_in,
|
|||
if (gdisp_ID > 0)
|
||||
gdisp = gdisplay_get_ID(gdisp_ID);
|
||||
|
||||
if (gdisp_ID > 0 && GTK_WIDGET_VISIBLE (gdisp->statusarea)
|
||||
&& (gdisp->progressid == 0 || plug_in->progress_gdisp_ID > 0))
|
||||
{
|
||||
context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), context_id);
|
||||
|
||||
gdisp->progressid = gtk_statusbar_push(GTK_STATUSBAR(gdisp->statusbar),
|
||||
context_id, message);
|
||||
plug_in->progress_gdisp_ID = gdisp_ID;
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (gdisp->cancelbutton), "clicked",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, TRUE);
|
||||
}
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = gtk_dialog_new ();
|
||||
gtk_window_set_wmclass (GTK_WINDOW (plug_in->progress), "plug_in_progress", "Gimp");
|
||||
gtk_window_set_title (GTK_WINDOW (plug_in->progress), prune_filename (plug_in->args[0]));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (plug_in->progress), "destroy",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (plug_in->progress)->action_area), 2);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->vbox), vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
plug_in->progress_label = gtk_label_new (message);
|
||||
gtk_misc_set_alignment (GTK_MISC (plug_in->progress_label), 0.0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_label, FALSE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_label);
|
||||
|
||||
plug_in->progress_bar = gtk_progress_bar_new ();
|
||||
gtk_widget_set_usize (plug_in->progress_bar, 150, 20);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_bar, TRUE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_bar);
|
||||
|
||||
button = gtk_button_new_with_label (_("Cancel"));
|
||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) gtk_widget_destroy,
|
||||
GTK_OBJECT (plug_in->progress));
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->action_area), button, TRUE, TRUE, 0);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gtk_widget_show (plug_in->progress);
|
||||
}
|
||||
if (plug_in->progress)
|
||||
plug_in->progress = progress_restart (plug_in->progress, message,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
else
|
||||
{
|
||||
gtk_label_set (GTK_LABEL (plug_in->progress_label), message);
|
||||
}
|
||||
#else
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = 0x1;
|
||||
progress_update (0.0);
|
||||
progress_start ();
|
||||
}
|
||||
#endif
|
||||
plug_in->progress = progress_start (gdisp, message, TRUE,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_update (PlugIn *plug_in,
|
||||
double percentage)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update( GTK_PROGRESS_BAR (gdisp->progressbar), percentage);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (plug_in->progress_bar), percentage);
|
||||
#else
|
||||
progress_update (percentage);
|
||||
#endif
|
||||
}
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
progress_update (plug_in->progress, percentage);
|
||||
}
|
||||
|
||||
static Argument*
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "gtk/gtk.h"
|
||||
#include "procedural_db.h"
|
||||
#include "gimpprogress.h"
|
||||
|
||||
|
||||
#define WRITE_BUFFER_SIZE 512
|
||||
|
@ -58,11 +59,7 @@ struct _PlugIn
|
|||
|
||||
GSList *temp_proc_defs; /* Temporary procedures */
|
||||
|
||||
GtkWidget *progress; /* Progress dialog */
|
||||
GtkWidget *progress_label;
|
||||
GtkWidget *progress_bar;
|
||||
|
||||
gint8 progress_gdisp_ID; /* gdisp_ID of progress */
|
||||
gimp_progress *progress; /* Progress dialog */
|
||||
|
||||
gpointer user_data; /* Handle for hanging data onto */
|
||||
};
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <unistd.h>
|
||||
#include "libgimp/parasite.h"
|
||||
#include "libgimp/parasiteP.h" /* ick */
|
||||
#include "libgimp/gimpmodule.h"
|
||||
|
||||
#ifdef HAVE_IPC_H
|
||||
#include <sys/ipc.h>
|
||||
|
@ -62,7 +63,7 @@
|
|||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#define SEPARATE_PROGRESS_BAR
|
||||
|
||||
|
||||
|
||||
typedef struct _PlugInBlocked PlugInBlocked;
|
||||
|
@ -126,8 +127,6 @@ static void plug_in_args_destroy (Argument *args,
|
|||
int nargs,
|
||||
int full_destroy);
|
||||
|
||||
static void plug_in_disconnect_cancel (PlugIn *plug_in);
|
||||
|
||||
static Argument* progress_init_invoker (Argument *args);
|
||||
static Argument* progress_update_invoker (Argument *args);
|
||||
|
||||
|
@ -138,6 +137,8 @@ static Argument* message_handler_set_invoker (Argument *args);
|
|||
|
||||
static Argument* plugin_temp_PDB_name_invoker (Argument *args);
|
||||
|
||||
static void module_initialize (char *filename);
|
||||
|
||||
|
||||
static GSList *plug_in_defs = NULL;
|
||||
static GSList *gimprc_proc_defs = NULL;
|
||||
|
@ -481,8 +482,79 @@ plug_in_init ()
|
|||
g_free (plug_in_def);
|
||||
}
|
||||
g_slist_free (plug_in_defs);
|
||||
|
||||
|
||||
/* Load and initialize gimp modules */
|
||||
|
||||
if (g_module_supported ())
|
||||
datafiles_read_directories (module_path,
|
||||
module_initialize, 0 /* no flags */);
|
||||
}
|
||||
|
||||
|
||||
/* name must be of the form lib*.so */
|
||||
/* TODO: need support for WIN32-style dll names. Maybe this function
|
||||
* should live in libgmodule? */
|
||||
static gboolean
|
||||
valid_module_name (const char *filename)
|
||||
{
|
||||
const char *basename;
|
||||
int len;
|
||||
|
||||
basename = strrchr (filename, '/');
|
||||
if (basename)
|
||||
basename++;
|
||||
else
|
||||
basename = filename;
|
||||
|
||||
len = strlen (basename);
|
||||
|
||||
if (len < 3 + 1 + 3)
|
||||
return FALSE;
|
||||
|
||||
if (strncmp (basename, "lib", 3))
|
||||
return FALSE;
|
||||
|
||||
if (strcmp (basename + len - 3, ".so"))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
module_initialize (char *filename)
|
||||
{
|
||||
GModule *mod;
|
||||
GimpModuleInitFunc init;
|
||||
gpointer symbol;
|
||||
|
||||
if (!valid_module_name (filename))
|
||||
return;
|
||||
|
||||
if ((be_verbose == TRUE) || (no_splash == TRUE))
|
||||
g_print (_("load module: \"%s\"\n"), filename);
|
||||
|
||||
mod = g_module_open (filename, G_MODULE_BIND_LAZY);
|
||||
if (!mod)
|
||||
{
|
||||
g_warning (_("module load error: %s: %s"), filename, g_module_error ());
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_module_symbol (mod, "module_init", &symbol))
|
||||
{
|
||||
init = symbol;
|
||||
if (init () == GIMP_MODULE_UNLOAD)
|
||||
g_module_close (mod);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning (_("%s: module_init() symbol not found"), filename);
|
||||
g_module_close (mod);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
plug_in_kill ()
|
||||
{
|
||||
|
@ -818,9 +890,6 @@ plug_in_new (char *name)
|
|||
plug_in->write_buffer_index = 0;
|
||||
plug_in->temp_proc_defs = NULL;
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
plug_in->progress_gdisp_ID = -1;
|
||||
plug_in->user_data = NULL;
|
||||
|
||||
return plug_in;
|
||||
|
@ -829,9 +898,6 @@ plug_in_new (char *name)
|
|||
void
|
||||
plug_in_destroy (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
guint c_id;
|
||||
|
||||
if (plug_in)
|
||||
{
|
||||
plug_in_close (plug_in, TRUE);
|
||||
|
@ -849,18 +915,9 @@ plug_in_destroy (PlugIn *plug_in)
|
|||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
c_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), c_id);
|
||||
gtk_progress_bar_update(GTK_PROGRESS_BAR(gdisp->progressbar), 0.0);
|
||||
|
||||
plug_in_disconnect_cancel (plug_in);
|
||||
|
||||
gdisp->progressid = 0;
|
||||
}
|
||||
if (plug_in->progress)
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
|
@ -1011,23 +1068,9 @@ plug_in_close (PlugIn *plug_in,
|
|||
|
||||
/* Destroy the progress dialog if it exists
|
||||
*/
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (plug_in->progress)
|
||||
{
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (plug_in->progress), plug_in);
|
||||
gtk_widget_destroy (plug_in->progress);
|
||||
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
}
|
||||
#else
|
||||
if (plug_in->progress)
|
||||
{
|
||||
progress_end ();
|
||||
plug_in->progress = NULL;
|
||||
}
|
||||
#endif
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
/* Set the fields to null values.
|
||||
*/
|
||||
|
@ -3089,32 +3132,15 @@ static void
|
|||
plug_in_progress_cancel (GtkWidget *widget,
|
||||
PlugIn *plug_in)
|
||||
{
|
||||
plug_in->progress = NULL;
|
||||
plug_in_destroy (plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_disconnect_cancel (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp = NULL;
|
||||
|
||||
gdisp = gdisplay_get_ID (plug_in->progress_gdisp_ID);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, FALSE);
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (gdisp->cancelbutton),
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_init (PlugIn *plug_in,
|
||||
char *message,
|
||||
gint gdisp_ID)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *button;
|
||||
GDisplay *gdisp = NULL;
|
||||
guint context_id;
|
||||
|
||||
if (!message)
|
||||
message = plug_in->args[0];
|
||||
|
@ -3122,100 +3148,22 @@ plug_in_progress_init (PlugIn *plug_in,
|
|||
if (gdisp_ID > 0)
|
||||
gdisp = gdisplay_get_ID(gdisp_ID);
|
||||
|
||||
if (gdisp_ID > 0 && GTK_WIDGET_VISIBLE (gdisp->statusarea)
|
||||
&& (gdisp->progressid == 0 || plug_in->progress_gdisp_ID > 0))
|
||||
{
|
||||
context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), context_id);
|
||||
|
||||
gdisp->progressid = gtk_statusbar_push(GTK_STATUSBAR(gdisp->statusbar),
|
||||
context_id, message);
|
||||
plug_in->progress_gdisp_ID = gdisp_ID;
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (gdisp->cancelbutton), "clicked",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, TRUE);
|
||||
}
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = gtk_dialog_new ();
|
||||
gtk_window_set_wmclass (GTK_WINDOW (plug_in->progress), "plug_in_progress", "Gimp");
|
||||
gtk_window_set_title (GTK_WINDOW (plug_in->progress), prune_filename (plug_in->args[0]));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (plug_in->progress), "destroy",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (plug_in->progress)->action_area), 2);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->vbox), vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
plug_in->progress_label = gtk_label_new (message);
|
||||
gtk_misc_set_alignment (GTK_MISC (plug_in->progress_label), 0.0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_label, FALSE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_label);
|
||||
|
||||
plug_in->progress_bar = gtk_progress_bar_new ();
|
||||
gtk_widget_set_usize (plug_in->progress_bar, 150, 20);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_bar, TRUE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_bar);
|
||||
|
||||
button = gtk_button_new_with_label (_("Cancel"));
|
||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) gtk_widget_destroy,
|
||||
GTK_OBJECT (plug_in->progress));
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->action_area), button, TRUE, TRUE, 0);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gtk_widget_show (plug_in->progress);
|
||||
}
|
||||
if (plug_in->progress)
|
||||
plug_in->progress = progress_restart (plug_in->progress, message,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
else
|
||||
{
|
||||
gtk_label_set (GTK_LABEL (plug_in->progress_label), message);
|
||||
}
|
||||
#else
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = 0x1;
|
||||
progress_update (0.0);
|
||||
progress_start ();
|
||||
}
|
||||
#endif
|
||||
plug_in->progress = progress_start (gdisp, message, TRUE,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_update (PlugIn *plug_in,
|
||||
double percentage)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update( GTK_PROGRESS_BAR (gdisp->progressbar), percentage);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (plug_in->progress_bar), percentage);
|
||||
#else
|
||||
progress_update (percentage);
|
||||
#endif
|
||||
}
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
progress_update (plug_in->progress, percentage);
|
||||
}
|
||||
|
||||
static Argument*
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <unistd.h>
|
||||
#include "libgimp/parasite.h"
|
||||
#include "libgimp/parasiteP.h" /* ick */
|
||||
#include "libgimp/gimpmodule.h"
|
||||
|
||||
#ifdef HAVE_IPC_H
|
||||
#include <sys/ipc.h>
|
||||
|
@ -62,7 +63,7 @@
|
|||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#define SEPARATE_PROGRESS_BAR
|
||||
|
||||
|
||||
|
||||
typedef struct _PlugInBlocked PlugInBlocked;
|
||||
|
@ -126,8 +127,6 @@ static void plug_in_args_destroy (Argument *args,
|
|||
int nargs,
|
||||
int full_destroy);
|
||||
|
||||
static void plug_in_disconnect_cancel (PlugIn *plug_in);
|
||||
|
||||
static Argument* progress_init_invoker (Argument *args);
|
||||
static Argument* progress_update_invoker (Argument *args);
|
||||
|
||||
|
@ -138,6 +137,8 @@ static Argument* message_handler_set_invoker (Argument *args);
|
|||
|
||||
static Argument* plugin_temp_PDB_name_invoker (Argument *args);
|
||||
|
||||
static void module_initialize (char *filename);
|
||||
|
||||
|
||||
static GSList *plug_in_defs = NULL;
|
||||
static GSList *gimprc_proc_defs = NULL;
|
||||
|
@ -481,8 +482,79 @@ plug_in_init ()
|
|||
g_free (plug_in_def);
|
||||
}
|
||||
g_slist_free (plug_in_defs);
|
||||
|
||||
|
||||
/* Load and initialize gimp modules */
|
||||
|
||||
if (g_module_supported ())
|
||||
datafiles_read_directories (module_path,
|
||||
module_initialize, 0 /* no flags */);
|
||||
}
|
||||
|
||||
|
||||
/* name must be of the form lib*.so */
|
||||
/* TODO: need support for WIN32-style dll names. Maybe this function
|
||||
* should live in libgmodule? */
|
||||
static gboolean
|
||||
valid_module_name (const char *filename)
|
||||
{
|
||||
const char *basename;
|
||||
int len;
|
||||
|
||||
basename = strrchr (filename, '/');
|
||||
if (basename)
|
||||
basename++;
|
||||
else
|
||||
basename = filename;
|
||||
|
||||
len = strlen (basename);
|
||||
|
||||
if (len < 3 + 1 + 3)
|
||||
return FALSE;
|
||||
|
||||
if (strncmp (basename, "lib", 3))
|
||||
return FALSE;
|
||||
|
||||
if (strcmp (basename + len - 3, ".so"))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
module_initialize (char *filename)
|
||||
{
|
||||
GModule *mod;
|
||||
GimpModuleInitFunc init;
|
||||
gpointer symbol;
|
||||
|
||||
if (!valid_module_name (filename))
|
||||
return;
|
||||
|
||||
if ((be_verbose == TRUE) || (no_splash == TRUE))
|
||||
g_print (_("load module: \"%s\"\n"), filename);
|
||||
|
||||
mod = g_module_open (filename, G_MODULE_BIND_LAZY);
|
||||
if (!mod)
|
||||
{
|
||||
g_warning (_("module load error: %s: %s"), filename, g_module_error ());
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_module_symbol (mod, "module_init", &symbol))
|
||||
{
|
||||
init = symbol;
|
||||
if (init () == GIMP_MODULE_UNLOAD)
|
||||
g_module_close (mod);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning (_("%s: module_init() symbol not found"), filename);
|
||||
g_module_close (mod);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
plug_in_kill ()
|
||||
{
|
||||
|
@ -818,9 +890,6 @@ plug_in_new (char *name)
|
|||
plug_in->write_buffer_index = 0;
|
||||
plug_in->temp_proc_defs = NULL;
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
plug_in->progress_gdisp_ID = -1;
|
||||
plug_in->user_data = NULL;
|
||||
|
||||
return plug_in;
|
||||
|
@ -829,9 +898,6 @@ plug_in_new (char *name)
|
|||
void
|
||||
plug_in_destroy (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
guint c_id;
|
||||
|
||||
if (plug_in)
|
||||
{
|
||||
plug_in_close (plug_in, TRUE);
|
||||
|
@ -849,18 +915,9 @@ plug_in_destroy (PlugIn *plug_in)
|
|||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
c_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), c_id);
|
||||
gtk_progress_bar_update(GTK_PROGRESS_BAR(gdisp->progressbar), 0.0);
|
||||
|
||||
plug_in_disconnect_cancel (plug_in);
|
||||
|
||||
gdisp->progressid = 0;
|
||||
}
|
||||
if (plug_in->progress)
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
|
@ -1011,23 +1068,9 @@ plug_in_close (PlugIn *plug_in,
|
|||
|
||||
/* Destroy the progress dialog if it exists
|
||||
*/
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (plug_in->progress)
|
||||
{
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (plug_in->progress), plug_in);
|
||||
gtk_widget_destroy (plug_in->progress);
|
||||
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
}
|
||||
#else
|
||||
if (plug_in->progress)
|
||||
{
|
||||
progress_end ();
|
||||
plug_in->progress = NULL;
|
||||
}
|
||||
#endif
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
/* Set the fields to null values.
|
||||
*/
|
||||
|
@ -3089,32 +3132,15 @@ static void
|
|||
plug_in_progress_cancel (GtkWidget *widget,
|
||||
PlugIn *plug_in)
|
||||
{
|
||||
plug_in->progress = NULL;
|
||||
plug_in_destroy (plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_disconnect_cancel (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp = NULL;
|
||||
|
||||
gdisp = gdisplay_get_ID (plug_in->progress_gdisp_ID);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, FALSE);
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (gdisp->cancelbutton),
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_init (PlugIn *plug_in,
|
||||
char *message,
|
||||
gint gdisp_ID)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *button;
|
||||
GDisplay *gdisp = NULL;
|
||||
guint context_id;
|
||||
|
||||
if (!message)
|
||||
message = plug_in->args[0];
|
||||
|
@ -3122,100 +3148,22 @@ plug_in_progress_init (PlugIn *plug_in,
|
|||
if (gdisp_ID > 0)
|
||||
gdisp = gdisplay_get_ID(gdisp_ID);
|
||||
|
||||
if (gdisp_ID > 0 && GTK_WIDGET_VISIBLE (gdisp->statusarea)
|
||||
&& (gdisp->progressid == 0 || plug_in->progress_gdisp_ID > 0))
|
||||
{
|
||||
context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), context_id);
|
||||
|
||||
gdisp->progressid = gtk_statusbar_push(GTK_STATUSBAR(gdisp->statusbar),
|
||||
context_id, message);
|
||||
plug_in->progress_gdisp_ID = gdisp_ID;
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (gdisp->cancelbutton), "clicked",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, TRUE);
|
||||
}
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = gtk_dialog_new ();
|
||||
gtk_window_set_wmclass (GTK_WINDOW (plug_in->progress), "plug_in_progress", "Gimp");
|
||||
gtk_window_set_title (GTK_WINDOW (plug_in->progress), prune_filename (plug_in->args[0]));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (plug_in->progress), "destroy",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (plug_in->progress)->action_area), 2);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->vbox), vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
plug_in->progress_label = gtk_label_new (message);
|
||||
gtk_misc_set_alignment (GTK_MISC (plug_in->progress_label), 0.0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_label, FALSE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_label);
|
||||
|
||||
plug_in->progress_bar = gtk_progress_bar_new ();
|
||||
gtk_widget_set_usize (plug_in->progress_bar, 150, 20);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_bar, TRUE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_bar);
|
||||
|
||||
button = gtk_button_new_with_label (_("Cancel"));
|
||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) gtk_widget_destroy,
|
||||
GTK_OBJECT (plug_in->progress));
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->action_area), button, TRUE, TRUE, 0);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gtk_widget_show (plug_in->progress);
|
||||
}
|
||||
if (plug_in->progress)
|
||||
plug_in->progress = progress_restart (plug_in->progress, message,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
else
|
||||
{
|
||||
gtk_label_set (GTK_LABEL (plug_in->progress_label), message);
|
||||
}
|
||||
#else
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = 0x1;
|
||||
progress_update (0.0);
|
||||
progress_start ();
|
||||
}
|
||||
#endif
|
||||
plug_in->progress = progress_start (gdisp, message, TRUE,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_update (PlugIn *plug_in,
|
||||
double percentage)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update( GTK_PROGRESS_BAR (gdisp->progressbar), percentage);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (plug_in->progress_bar), percentage);
|
||||
#else
|
||||
progress_update (percentage);
|
||||
#endif
|
||||
}
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
progress_update (plug_in->progress, percentage);
|
||||
}
|
||||
|
||||
static Argument*
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <unistd.h>
|
||||
#include "libgimp/parasite.h"
|
||||
#include "libgimp/parasiteP.h" /* ick */
|
||||
#include "libgimp/gimpmodule.h"
|
||||
|
||||
#ifdef HAVE_IPC_H
|
||||
#include <sys/ipc.h>
|
||||
|
@ -62,7 +63,7 @@
|
|||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#define SEPARATE_PROGRESS_BAR
|
||||
|
||||
|
||||
|
||||
typedef struct _PlugInBlocked PlugInBlocked;
|
||||
|
@ -126,8 +127,6 @@ static void plug_in_args_destroy (Argument *args,
|
|||
int nargs,
|
||||
int full_destroy);
|
||||
|
||||
static void plug_in_disconnect_cancel (PlugIn *plug_in);
|
||||
|
||||
static Argument* progress_init_invoker (Argument *args);
|
||||
static Argument* progress_update_invoker (Argument *args);
|
||||
|
||||
|
@ -138,6 +137,8 @@ static Argument* message_handler_set_invoker (Argument *args);
|
|||
|
||||
static Argument* plugin_temp_PDB_name_invoker (Argument *args);
|
||||
|
||||
static void module_initialize (char *filename);
|
||||
|
||||
|
||||
static GSList *plug_in_defs = NULL;
|
||||
static GSList *gimprc_proc_defs = NULL;
|
||||
|
@ -481,8 +482,79 @@ plug_in_init ()
|
|||
g_free (plug_in_def);
|
||||
}
|
||||
g_slist_free (plug_in_defs);
|
||||
|
||||
|
||||
/* Load and initialize gimp modules */
|
||||
|
||||
if (g_module_supported ())
|
||||
datafiles_read_directories (module_path,
|
||||
module_initialize, 0 /* no flags */);
|
||||
}
|
||||
|
||||
|
||||
/* name must be of the form lib*.so */
|
||||
/* TODO: need support for WIN32-style dll names. Maybe this function
|
||||
* should live in libgmodule? */
|
||||
static gboolean
|
||||
valid_module_name (const char *filename)
|
||||
{
|
||||
const char *basename;
|
||||
int len;
|
||||
|
||||
basename = strrchr (filename, '/');
|
||||
if (basename)
|
||||
basename++;
|
||||
else
|
||||
basename = filename;
|
||||
|
||||
len = strlen (basename);
|
||||
|
||||
if (len < 3 + 1 + 3)
|
||||
return FALSE;
|
||||
|
||||
if (strncmp (basename, "lib", 3))
|
||||
return FALSE;
|
||||
|
||||
if (strcmp (basename + len - 3, ".so"))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
module_initialize (char *filename)
|
||||
{
|
||||
GModule *mod;
|
||||
GimpModuleInitFunc init;
|
||||
gpointer symbol;
|
||||
|
||||
if (!valid_module_name (filename))
|
||||
return;
|
||||
|
||||
if ((be_verbose == TRUE) || (no_splash == TRUE))
|
||||
g_print (_("load module: \"%s\"\n"), filename);
|
||||
|
||||
mod = g_module_open (filename, G_MODULE_BIND_LAZY);
|
||||
if (!mod)
|
||||
{
|
||||
g_warning (_("module load error: %s: %s"), filename, g_module_error ());
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_module_symbol (mod, "module_init", &symbol))
|
||||
{
|
||||
init = symbol;
|
||||
if (init () == GIMP_MODULE_UNLOAD)
|
||||
g_module_close (mod);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning (_("%s: module_init() symbol not found"), filename);
|
||||
g_module_close (mod);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
plug_in_kill ()
|
||||
{
|
||||
|
@ -818,9 +890,6 @@ plug_in_new (char *name)
|
|||
plug_in->write_buffer_index = 0;
|
||||
plug_in->temp_proc_defs = NULL;
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
plug_in->progress_gdisp_ID = -1;
|
||||
plug_in->user_data = NULL;
|
||||
|
||||
return plug_in;
|
||||
|
@ -829,9 +898,6 @@ plug_in_new (char *name)
|
|||
void
|
||||
plug_in_destroy (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
guint c_id;
|
||||
|
||||
if (plug_in)
|
||||
{
|
||||
plug_in_close (plug_in, TRUE);
|
||||
|
@ -849,18 +915,9 @@ plug_in_destroy (PlugIn *plug_in)
|
|||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
c_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), c_id);
|
||||
gtk_progress_bar_update(GTK_PROGRESS_BAR(gdisp->progressbar), 0.0);
|
||||
|
||||
plug_in_disconnect_cancel (plug_in);
|
||||
|
||||
gdisp->progressid = 0;
|
||||
}
|
||||
if (plug_in->progress)
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
|
@ -1011,23 +1068,9 @@ plug_in_close (PlugIn *plug_in,
|
|||
|
||||
/* Destroy the progress dialog if it exists
|
||||
*/
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (plug_in->progress)
|
||||
{
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (plug_in->progress), plug_in);
|
||||
gtk_widget_destroy (plug_in->progress);
|
||||
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
}
|
||||
#else
|
||||
if (plug_in->progress)
|
||||
{
|
||||
progress_end ();
|
||||
plug_in->progress = NULL;
|
||||
}
|
||||
#endif
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
/* Set the fields to null values.
|
||||
*/
|
||||
|
@ -3089,32 +3132,15 @@ static void
|
|||
plug_in_progress_cancel (GtkWidget *widget,
|
||||
PlugIn *plug_in)
|
||||
{
|
||||
plug_in->progress = NULL;
|
||||
plug_in_destroy (plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_disconnect_cancel (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp = NULL;
|
||||
|
||||
gdisp = gdisplay_get_ID (plug_in->progress_gdisp_ID);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, FALSE);
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (gdisp->cancelbutton),
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_init (PlugIn *plug_in,
|
||||
char *message,
|
||||
gint gdisp_ID)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *button;
|
||||
GDisplay *gdisp = NULL;
|
||||
guint context_id;
|
||||
|
||||
if (!message)
|
||||
message = plug_in->args[0];
|
||||
|
@ -3122,100 +3148,22 @@ plug_in_progress_init (PlugIn *plug_in,
|
|||
if (gdisp_ID > 0)
|
||||
gdisp = gdisplay_get_ID(gdisp_ID);
|
||||
|
||||
if (gdisp_ID > 0 && GTK_WIDGET_VISIBLE (gdisp->statusarea)
|
||||
&& (gdisp->progressid == 0 || plug_in->progress_gdisp_ID > 0))
|
||||
{
|
||||
context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), context_id);
|
||||
|
||||
gdisp->progressid = gtk_statusbar_push(GTK_STATUSBAR(gdisp->statusbar),
|
||||
context_id, message);
|
||||
plug_in->progress_gdisp_ID = gdisp_ID;
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (gdisp->cancelbutton), "clicked",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, TRUE);
|
||||
}
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = gtk_dialog_new ();
|
||||
gtk_window_set_wmclass (GTK_WINDOW (plug_in->progress), "plug_in_progress", "Gimp");
|
||||
gtk_window_set_title (GTK_WINDOW (plug_in->progress), prune_filename (plug_in->args[0]));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (plug_in->progress), "destroy",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (plug_in->progress)->action_area), 2);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->vbox), vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
plug_in->progress_label = gtk_label_new (message);
|
||||
gtk_misc_set_alignment (GTK_MISC (plug_in->progress_label), 0.0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_label, FALSE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_label);
|
||||
|
||||
plug_in->progress_bar = gtk_progress_bar_new ();
|
||||
gtk_widget_set_usize (plug_in->progress_bar, 150, 20);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_bar, TRUE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_bar);
|
||||
|
||||
button = gtk_button_new_with_label (_("Cancel"));
|
||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) gtk_widget_destroy,
|
||||
GTK_OBJECT (plug_in->progress));
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->action_area), button, TRUE, TRUE, 0);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gtk_widget_show (plug_in->progress);
|
||||
}
|
||||
if (plug_in->progress)
|
||||
plug_in->progress = progress_restart (plug_in->progress, message,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
else
|
||||
{
|
||||
gtk_label_set (GTK_LABEL (plug_in->progress_label), message);
|
||||
}
|
||||
#else
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = 0x1;
|
||||
progress_update (0.0);
|
||||
progress_start ();
|
||||
}
|
||||
#endif
|
||||
plug_in->progress = progress_start (gdisp, message, TRUE,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_update (PlugIn *plug_in,
|
||||
double percentage)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update( GTK_PROGRESS_BAR (gdisp->progressbar), percentage);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (plug_in->progress_bar), percentage);
|
||||
#else
|
||||
progress_update (percentage);
|
||||
#endif
|
||||
}
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
progress_update (plug_in->progress, percentage);
|
||||
}
|
||||
|
||||
static Argument*
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "gtk/gtk.h"
|
||||
#include "procedural_db.h"
|
||||
#include "gimpprogress.h"
|
||||
|
||||
|
||||
#define WRITE_BUFFER_SIZE 512
|
||||
|
@ -58,11 +59,7 @@ struct _PlugIn
|
|||
|
||||
GSList *temp_proc_defs; /* Temporary procedures */
|
||||
|
||||
GtkWidget *progress; /* Progress dialog */
|
||||
GtkWidget *progress_label;
|
||||
GtkWidget *progress_bar;
|
||||
|
||||
gint8 progress_gdisp_ID; /* gdisp_ID of progress */
|
||||
gimp_progress *progress; /* Progress dialog */
|
||||
|
||||
gpointer user_data; /* Handle for hanging data onto */
|
||||
};
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include <unistd.h>
|
||||
#include "libgimp/parasite.h"
|
||||
#include "libgimp/parasiteP.h" /* ick */
|
||||
#include "libgimp/gimpmodule.h"
|
||||
|
||||
#ifdef HAVE_IPC_H
|
||||
#include <sys/ipc.h>
|
||||
|
@ -62,7 +63,7 @@
|
|||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#define SEPARATE_PROGRESS_BAR
|
||||
|
||||
|
||||
|
||||
typedef struct _PlugInBlocked PlugInBlocked;
|
||||
|
@ -126,8 +127,6 @@ static void plug_in_args_destroy (Argument *args,
|
|||
int nargs,
|
||||
int full_destroy);
|
||||
|
||||
static void plug_in_disconnect_cancel (PlugIn *plug_in);
|
||||
|
||||
static Argument* progress_init_invoker (Argument *args);
|
||||
static Argument* progress_update_invoker (Argument *args);
|
||||
|
||||
|
@ -138,6 +137,8 @@ static Argument* message_handler_set_invoker (Argument *args);
|
|||
|
||||
static Argument* plugin_temp_PDB_name_invoker (Argument *args);
|
||||
|
||||
static void module_initialize (char *filename);
|
||||
|
||||
|
||||
static GSList *plug_in_defs = NULL;
|
||||
static GSList *gimprc_proc_defs = NULL;
|
||||
|
@ -481,8 +482,79 @@ plug_in_init ()
|
|||
g_free (plug_in_def);
|
||||
}
|
||||
g_slist_free (plug_in_defs);
|
||||
|
||||
|
||||
/* Load and initialize gimp modules */
|
||||
|
||||
if (g_module_supported ())
|
||||
datafiles_read_directories (module_path,
|
||||
module_initialize, 0 /* no flags */);
|
||||
}
|
||||
|
||||
|
||||
/* name must be of the form lib*.so */
|
||||
/* TODO: need support for WIN32-style dll names. Maybe this function
|
||||
* should live in libgmodule? */
|
||||
static gboolean
|
||||
valid_module_name (const char *filename)
|
||||
{
|
||||
const char *basename;
|
||||
int len;
|
||||
|
||||
basename = strrchr (filename, '/');
|
||||
if (basename)
|
||||
basename++;
|
||||
else
|
||||
basename = filename;
|
||||
|
||||
len = strlen (basename);
|
||||
|
||||
if (len < 3 + 1 + 3)
|
||||
return FALSE;
|
||||
|
||||
if (strncmp (basename, "lib", 3))
|
||||
return FALSE;
|
||||
|
||||
if (strcmp (basename + len - 3, ".so"))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
module_initialize (char *filename)
|
||||
{
|
||||
GModule *mod;
|
||||
GimpModuleInitFunc init;
|
||||
gpointer symbol;
|
||||
|
||||
if (!valid_module_name (filename))
|
||||
return;
|
||||
|
||||
if ((be_verbose == TRUE) || (no_splash == TRUE))
|
||||
g_print (_("load module: \"%s\"\n"), filename);
|
||||
|
||||
mod = g_module_open (filename, G_MODULE_BIND_LAZY);
|
||||
if (!mod)
|
||||
{
|
||||
g_warning (_("module load error: %s: %s"), filename, g_module_error ());
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_module_symbol (mod, "module_init", &symbol))
|
||||
{
|
||||
init = symbol;
|
||||
if (init () == GIMP_MODULE_UNLOAD)
|
||||
g_module_close (mod);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning (_("%s: module_init() symbol not found"), filename);
|
||||
g_module_close (mod);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
plug_in_kill ()
|
||||
{
|
||||
|
@ -818,9 +890,6 @@ plug_in_new (char *name)
|
|||
plug_in->write_buffer_index = 0;
|
||||
plug_in->temp_proc_defs = NULL;
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
plug_in->progress_gdisp_ID = -1;
|
||||
plug_in->user_data = NULL;
|
||||
|
||||
return plug_in;
|
||||
|
@ -829,9 +898,6 @@ plug_in_new (char *name)
|
|||
void
|
||||
plug_in_destroy (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
guint c_id;
|
||||
|
||||
if (plug_in)
|
||||
{
|
||||
plug_in_close (plug_in, TRUE);
|
||||
|
@ -849,18 +915,9 @@ plug_in_destroy (PlugIn *plug_in)
|
|||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
c_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), c_id);
|
||||
gtk_progress_bar_update(GTK_PROGRESS_BAR(gdisp->progressbar), 0.0);
|
||||
|
||||
plug_in_disconnect_cancel (plug_in);
|
||||
|
||||
gdisp->progressid = 0;
|
||||
}
|
||||
if (plug_in->progress)
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
|
@ -1011,23 +1068,9 @@ plug_in_close (PlugIn *plug_in,
|
|||
|
||||
/* Destroy the progress dialog if it exists
|
||||
*/
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (plug_in->progress)
|
||||
{
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (plug_in->progress), plug_in);
|
||||
gtk_widget_destroy (plug_in->progress);
|
||||
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
}
|
||||
#else
|
||||
if (plug_in->progress)
|
||||
{
|
||||
progress_end ();
|
||||
plug_in->progress = NULL;
|
||||
}
|
||||
#endif
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
/* Set the fields to null values.
|
||||
*/
|
||||
|
@ -3089,32 +3132,15 @@ static void
|
|||
plug_in_progress_cancel (GtkWidget *widget,
|
||||
PlugIn *plug_in)
|
||||
{
|
||||
plug_in->progress = NULL;
|
||||
plug_in_destroy (plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_disconnect_cancel (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp = NULL;
|
||||
|
||||
gdisp = gdisplay_get_ID (plug_in->progress_gdisp_ID);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, FALSE);
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (gdisp->cancelbutton),
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_init (PlugIn *plug_in,
|
||||
char *message,
|
||||
gint gdisp_ID)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *button;
|
||||
GDisplay *gdisp = NULL;
|
||||
guint context_id;
|
||||
|
||||
if (!message)
|
||||
message = plug_in->args[0];
|
||||
|
@ -3122,100 +3148,22 @@ plug_in_progress_init (PlugIn *plug_in,
|
|||
if (gdisp_ID > 0)
|
||||
gdisp = gdisplay_get_ID(gdisp_ID);
|
||||
|
||||
if (gdisp_ID > 0 && GTK_WIDGET_VISIBLE (gdisp->statusarea)
|
||||
&& (gdisp->progressid == 0 || plug_in->progress_gdisp_ID > 0))
|
||||
{
|
||||
context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), context_id);
|
||||
|
||||
gdisp->progressid = gtk_statusbar_push(GTK_STATUSBAR(gdisp->statusbar),
|
||||
context_id, message);
|
||||
plug_in->progress_gdisp_ID = gdisp_ID;
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (gdisp->cancelbutton), "clicked",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, TRUE);
|
||||
}
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = gtk_dialog_new ();
|
||||
gtk_window_set_wmclass (GTK_WINDOW (plug_in->progress), "plug_in_progress", "Gimp");
|
||||
gtk_window_set_title (GTK_WINDOW (plug_in->progress), prune_filename (plug_in->args[0]));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (plug_in->progress), "destroy",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (plug_in->progress)->action_area), 2);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->vbox), vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
plug_in->progress_label = gtk_label_new (message);
|
||||
gtk_misc_set_alignment (GTK_MISC (plug_in->progress_label), 0.0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_label, FALSE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_label);
|
||||
|
||||
plug_in->progress_bar = gtk_progress_bar_new ();
|
||||
gtk_widget_set_usize (plug_in->progress_bar, 150, 20);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_bar, TRUE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_bar);
|
||||
|
||||
button = gtk_button_new_with_label (_("Cancel"));
|
||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) gtk_widget_destroy,
|
||||
GTK_OBJECT (plug_in->progress));
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->action_area), button, TRUE, TRUE, 0);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gtk_widget_show (plug_in->progress);
|
||||
}
|
||||
if (plug_in->progress)
|
||||
plug_in->progress = progress_restart (plug_in->progress, message,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
else
|
||||
{
|
||||
gtk_label_set (GTK_LABEL (plug_in->progress_label), message);
|
||||
}
|
||||
#else
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = 0x1;
|
||||
progress_update (0.0);
|
||||
progress_start ();
|
||||
}
|
||||
#endif
|
||||
plug_in->progress = progress_start (gdisp, message, TRUE,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_update (PlugIn *plug_in,
|
||||
double percentage)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update( GTK_PROGRESS_BAR (gdisp->progressbar), percentage);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (plug_in->progress_bar), percentage);
|
||||
#else
|
||||
progress_update (percentage);
|
||||
#endif
|
||||
}
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
progress_update (plug_in->progress, percentage);
|
||||
}
|
||||
|
||||
static Argument*
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "gtk/gtk.h"
|
||||
#include "procedural_db.h"
|
||||
#include "gimpprogress.h"
|
||||
|
||||
|
||||
#define WRITE_BUFFER_SIZE 512
|
||||
|
@ -58,11 +59,7 @@ struct _PlugIn
|
|||
|
||||
GSList *temp_proc_defs; /* Temporary procedures */
|
||||
|
||||
GtkWidget *progress; /* Progress dialog */
|
||||
GtkWidget *progress_label;
|
||||
GtkWidget *progress_bar;
|
||||
|
||||
gint8 progress_gdisp_ID; /* gdisp_ID of progress */
|
||||
gimp_progress *progress; /* Progress dialog */
|
||||
|
||||
gpointer user_data; /* Handle for hanging data onto */
|
||||
};
|
||||
|
|
230
app/plug_in.c
230
app/plug_in.c
|
@ -30,6 +30,7 @@
|
|||
#include <unistd.h>
|
||||
#include "libgimp/parasite.h"
|
||||
#include "libgimp/parasiteP.h" /* ick */
|
||||
#include "libgimp/gimpmodule.h"
|
||||
|
||||
#ifdef HAVE_IPC_H
|
||||
#include <sys/ipc.h>
|
||||
|
@ -62,7 +63,7 @@
|
|||
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
#define SEPARATE_PROGRESS_BAR
|
||||
|
||||
|
||||
|
||||
typedef struct _PlugInBlocked PlugInBlocked;
|
||||
|
@ -126,8 +127,6 @@ static void plug_in_args_destroy (Argument *args,
|
|||
int nargs,
|
||||
int full_destroy);
|
||||
|
||||
static void plug_in_disconnect_cancel (PlugIn *plug_in);
|
||||
|
||||
static Argument* progress_init_invoker (Argument *args);
|
||||
static Argument* progress_update_invoker (Argument *args);
|
||||
|
||||
|
@ -138,6 +137,8 @@ static Argument* message_handler_set_invoker (Argument *args);
|
|||
|
||||
static Argument* plugin_temp_PDB_name_invoker (Argument *args);
|
||||
|
||||
static void module_initialize (char *filename);
|
||||
|
||||
|
||||
static GSList *plug_in_defs = NULL;
|
||||
static GSList *gimprc_proc_defs = NULL;
|
||||
|
@ -481,8 +482,79 @@ plug_in_init ()
|
|||
g_free (plug_in_def);
|
||||
}
|
||||
g_slist_free (plug_in_defs);
|
||||
|
||||
|
||||
/* Load and initialize gimp modules */
|
||||
|
||||
if (g_module_supported ())
|
||||
datafiles_read_directories (module_path,
|
||||
module_initialize, 0 /* no flags */);
|
||||
}
|
||||
|
||||
|
||||
/* name must be of the form lib*.so */
|
||||
/* TODO: need support for WIN32-style dll names. Maybe this function
|
||||
* should live in libgmodule? */
|
||||
static gboolean
|
||||
valid_module_name (const char *filename)
|
||||
{
|
||||
const char *basename;
|
||||
int len;
|
||||
|
||||
basename = strrchr (filename, '/');
|
||||
if (basename)
|
||||
basename++;
|
||||
else
|
||||
basename = filename;
|
||||
|
||||
len = strlen (basename);
|
||||
|
||||
if (len < 3 + 1 + 3)
|
||||
return FALSE;
|
||||
|
||||
if (strncmp (basename, "lib", 3))
|
||||
return FALSE;
|
||||
|
||||
if (strcmp (basename + len - 3, ".so"))
|
||||
return FALSE;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
module_initialize (char *filename)
|
||||
{
|
||||
GModule *mod;
|
||||
GimpModuleInitFunc init;
|
||||
gpointer symbol;
|
||||
|
||||
if (!valid_module_name (filename))
|
||||
return;
|
||||
|
||||
if ((be_verbose == TRUE) || (no_splash == TRUE))
|
||||
g_print (_("load module: \"%s\"\n"), filename);
|
||||
|
||||
mod = g_module_open (filename, G_MODULE_BIND_LAZY);
|
||||
if (!mod)
|
||||
{
|
||||
g_warning (_("module load error: %s: %s"), filename, g_module_error ());
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_module_symbol (mod, "module_init", &symbol))
|
||||
{
|
||||
init = symbol;
|
||||
if (init () == GIMP_MODULE_UNLOAD)
|
||||
g_module_close (mod);
|
||||
}
|
||||
else
|
||||
{
|
||||
g_warning (_("%s: module_init() symbol not found"), filename);
|
||||
g_module_close (mod);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
plug_in_kill ()
|
||||
{
|
||||
|
@ -818,9 +890,6 @@ plug_in_new (char *name)
|
|||
plug_in->write_buffer_index = 0;
|
||||
plug_in->temp_proc_defs = NULL;
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
plug_in->progress_gdisp_ID = -1;
|
||||
plug_in->user_data = NULL;
|
||||
|
||||
return plug_in;
|
||||
|
@ -829,9 +898,6 @@ plug_in_new (char *name)
|
|||
void
|
||||
plug_in_destroy (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
guint c_id;
|
||||
|
||||
if (plug_in)
|
||||
{
|
||||
plug_in_close (plug_in, TRUE);
|
||||
|
@ -849,18 +915,9 @@ plug_in_destroy (PlugIn *plug_in)
|
|||
if (plug_in->args[5])
|
||||
g_free (plug_in->args[5]);
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
c_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), c_id);
|
||||
gtk_progress_bar_update(GTK_PROGRESS_BAR(gdisp->progressbar), 0.0);
|
||||
|
||||
plug_in_disconnect_cancel (plug_in);
|
||||
|
||||
gdisp->progressid = 0;
|
||||
}
|
||||
if (plug_in->progress)
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
if (plug_in == current_plug_in)
|
||||
plug_in_pop ();
|
||||
|
@ -1011,23 +1068,9 @@ plug_in_close (PlugIn *plug_in,
|
|||
|
||||
/* Destroy the progress dialog if it exists
|
||||
*/
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (plug_in->progress)
|
||||
{
|
||||
gtk_signal_disconnect_by_data (GTK_OBJECT (plug_in->progress), plug_in);
|
||||
gtk_widget_destroy (plug_in->progress);
|
||||
|
||||
plug_in->progress = NULL;
|
||||
plug_in->progress_label = NULL;
|
||||
plug_in->progress_bar = NULL;
|
||||
}
|
||||
#else
|
||||
if (plug_in->progress)
|
||||
{
|
||||
progress_end ();
|
||||
plug_in->progress = NULL;
|
||||
}
|
||||
#endif
|
||||
progress_end (plug_in->progress);
|
||||
plug_in->progress = NULL;
|
||||
|
||||
/* Set the fields to null values.
|
||||
*/
|
||||
|
@ -3089,32 +3132,15 @@ static void
|
|||
plug_in_progress_cancel (GtkWidget *widget,
|
||||
PlugIn *plug_in)
|
||||
{
|
||||
plug_in->progress = NULL;
|
||||
plug_in_destroy (plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_disconnect_cancel (PlugIn *plug_in)
|
||||
{
|
||||
GDisplay *gdisp = NULL;
|
||||
|
||||
gdisp = gdisplay_get_ID (plug_in->progress_gdisp_ID);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, FALSE);
|
||||
|
||||
gtk_signal_disconnect_by_func (GTK_OBJECT (gdisp->cancelbutton),
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_init (PlugIn *plug_in,
|
||||
char *message,
|
||||
gint gdisp_ID)
|
||||
{
|
||||
GtkWidget *vbox;
|
||||
GtkWidget *button;
|
||||
GDisplay *gdisp = NULL;
|
||||
guint context_id;
|
||||
|
||||
if (!message)
|
||||
message = plug_in->args[0];
|
||||
|
@ -3122,100 +3148,22 @@ plug_in_progress_init (PlugIn *plug_in,
|
|||
if (gdisp_ID > 0)
|
||||
gdisp = gdisplay_get_ID(gdisp_ID);
|
||||
|
||||
if (gdisp_ID > 0 && GTK_WIDGET_VISIBLE (gdisp->statusarea)
|
||||
&& (gdisp->progressid == 0 || plug_in->progress_gdisp_ID > 0))
|
||||
{
|
||||
context_id = gtk_statusbar_get_context_id(GTK_STATUSBAR(gdisp->statusbar),
|
||||
"progress");
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
gtk_statusbar_pop(GTK_STATUSBAR(gdisp->statusbar), context_id);
|
||||
|
||||
gdisp->progressid = gtk_statusbar_push(GTK_STATUSBAR(gdisp->statusbar),
|
||||
context_id, message);
|
||||
plug_in->progress_gdisp_ID = gdisp_ID;
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (gdisp->cancelbutton), "clicked",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_widget_set_sensitive (gdisp->cancelbutton, TRUE);
|
||||
}
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = gtk_dialog_new ();
|
||||
gtk_window_set_wmclass (GTK_WINDOW (plug_in->progress), "plug_in_progress", "Gimp");
|
||||
gtk_window_set_title (GTK_WINDOW (plug_in->progress), prune_filename (plug_in->args[0]));
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (plug_in->progress), "destroy",
|
||||
(GtkSignalFunc) plug_in_progress_cancel,
|
||||
plug_in);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (GTK_DIALOG (plug_in->progress)->action_area), 2);
|
||||
|
||||
vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (vbox), 2);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->vbox), vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (vbox);
|
||||
|
||||
plug_in->progress_label = gtk_label_new (message);
|
||||
gtk_misc_set_alignment (GTK_MISC (plug_in->progress_label), 0.0, 0.5);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_label, FALSE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_label);
|
||||
|
||||
plug_in->progress_bar = gtk_progress_bar_new ();
|
||||
gtk_widget_set_usize (plug_in->progress_bar, 150, 20);
|
||||
gtk_box_pack_start (GTK_BOX (vbox), plug_in->progress_bar, TRUE, TRUE, 0);
|
||||
gtk_widget_show (plug_in->progress_bar);
|
||||
|
||||
button = gtk_button_new_with_label (_("Cancel"));
|
||||
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
|
||||
(GtkSignalFunc) gtk_widget_destroy,
|
||||
GTK_OBJECT (plug_in->progress));
|
||||
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (plug_in->progress)->action_area), button, TRUE, TRUE, 0);
|
||||
gtk_widget_grab_default (button);
|
||||
gtk_widget_show (button);
|
||||
|
||||
gtk_widget_show (plug_in->progress);
|
||||
}
|
||||
if (plug_in->progress)
|
||||
plug_in->progress = progress_restart (plug_in->progress, message,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
else
|
||||
{
|
||||
gtk_label_set (GTK_LABEL (plug_in->progress_label), message);
|
||||
}
|
||||
#else
|
||||
else if (!plug_in->progress)
|
||||
{
|
||||
plug_in->progress = 0x1;
|
||||
progress_update (0.0);
|
||||
progress_start ();
|
||||
}
|
||||
#endif
|
||||
plug_in->progress = progress_start (gdisp, message, TRUE,
|
||||
plug_in_progress_cancel, plug_in);
|
||||
}
|
||||
|
||||
static void
|
||||
plug_in_progress_update (PlugIn *plug_in,
|
||||
double percentage)
|
||||
{
|
||||
GDisplay *gdisp;
|
||||
|
||||
if (plug_in->progress_gdisp_ID > 0)
|
||||
{
|
||||
gdisp = gdisplay_get_ID(plug_in->progress_gdisp_ID);
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update( GTK_PROGRESS_BAR (gdisp->progressbar), percentage);
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef SEPARATE_PROGRESS_BAR
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
if (percentage >= 0.0 && percentage <= 1.0)
|
||||
gtk_progress_bar_update (GTK_PROGRESS_BAR (plug_in->progress_bar), percentage);
|
||||
#else
|
||||
progress_update (percentage);
|
||||
#endif
|
||||
}
|
||||
if (!plug_in->progress)
|
||||
plug_in_progress_init (plug_in, NULL, -1);
|
||||
|
||||
progress_update (plug_in->progress, percentage);
|
||||
}
|
||||
|
||||
static Argument*
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
|
||||
#include "gtk/gtk.h"
|
||||
#include "procedural_db.h"
|
||||
#include "gimpprogress.h"
|
||||
|
||||
|
||||
#define WRITE_BUFFER_SIZE 512
|
||||
|
@ -58,11 +59,7 @@ struct _PlugIn
|
|||
|
||||
GSList *temp_proc_defs; /* Temporary procedures */
|
||||
|
||||
GtkWidget *progress; /* Progress dialog */
|
||||
GtkWidget *progress_label;
|
||||
GtkWidget *progress_bar;
|
||||
|
||||
gint8 progress_gdisp_ID; /* gdisp_ID of progress */
|
||||
gimp_progress *progress; /* Progress dialog */
|
||||
|
||||
gpointer user_data; /* Handle for hanging data onto */
|
||||
};
|
||||
|
|
|
@ -54,7 +54,7 @@ static char center_x_buf [MAX_INFO_BUF];
|
|||
static char center_y_buf [MAX_INFO_BUF];
|
||||
|
||||
/* forward function declarations */
|
||||
static void * rotate_tool_rotate (GImage *, GimpDrawable *, double, TileManager *, int, GimpMatrix);
|
||||
static void * rotate_tool_rotate (GImage *, GimpDrawable *, GDisplay *, double, TileManager *, int, GimpMatrix);
|
||||
static void * rotate_tool_recalc (Tool *, void *);
|
||||
static void rotate_tool_motion (Tool *, void *);
|
||||
static void rotate_info_update (Tool *);
|
||||
|
@ -88,6 +88,7 @@ rotate_tool_transform (tool, gdisp_ptr, state)
|
|||
info_dialog_add_field (transform_info, _("Center X: "), center_x_buf, (GtkSignalFunc) rotate_center_x_changed, tool);
|
||||
info_dialog_add_field (transform_info, _("Center Y: "), center_y_buf, (GtkSignalFunc) rotate_center_y_changed, tool);
|
||||
}
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), TRUE);
|
||||
|
||||
transform_core->trans_info[ANGLE] = 0.0;
|
||||
transform_core->trans_info[REAL_ANGLE] = 0.0;
|
||||
|
@ -110,7 +111,8 @@ rotate_tool_transform (tool, gdisp_ptr, state)
|
|||
break;
|
||||
|
||||
case FINISH :
|
||||
return rotate_tool_rotate (gdisp->gimage, gimage_active_drawable (gdisp->gimage),
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), FALSE);
|
||||
return rotate_tool_rotate (gdisp->gimage, gimage_active_drawable (gdisp->gimage), gdisp,
|
||||
transform_core->trans_info[ANGLE], transform_core->original,
|
||||
transform_tool_smoothing (), transform_core->transform);
|
||||
break;
|
||||
|
@ -361,15 +363,27 @@ rotate_tool_recalc (tool, gdisp_ptr)
|
|||
*/
|
||||
|
||||
static void *
|
||||
rotate_tool_rotate (gimage, drawable, angle, float_tiles, interpolation, matrix)
|
||||
rotate_tool_rotate (gimage, drawable, gdisp, angle, float_tiles, interpolation, matrix)
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
GDisplay *gdisp;
|
||||
double angle;
|
||||
TileManager *float_tiles;
|
||||
int interpolation;
|
||||
GimpMatrix matrix;
|
||||
{
|
||||
return transform_core_do (gimage, drawable, float_tiles, interpolation, matrix);
|
||||
void *ret;
|
||||
gimp_progress *progress;
|
||||
|
||||
progress = progress_start (gdisp, _("Rotating..."), FALSE, NULL, NULL);
|
||||
|
||||
ret = transform_core_do (gimage, drawable, float_tiles,
|
||||
interpolation, matrix,
|
||||
progress? progress_update_and_flush:NULL, progress);
|
||||
if (progress)
|
||||
progress_end (progress);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -482,7 +496,7 @@ rotate_invoker (args)
|
|||
gimp_matrix_translate (matrix, +cx, +cy);
|
||||
|
||||
/* rotate the buffer */
|
||||
new_tiles = rotate_tool_rotate (gimage, drawable, angle, float_tiles, interpolation, matrix);
|
||||
new_tiles = rotate_tool_rotate (gimage, drawable, NULL, angle, float_tiles, interpolation, matrix);
|
||||
|
||||
/* free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
|
|
@ -47,7 +47,7 @@ char x_ratio_buf [MAX_INFO_BUF];
|
|||
char y_ratio_buf [MAX_INFO_BUF];
|
||||
|
||||
/* forward function declarations */
|
||||
static void * scale_tool_scale (GImage *, GimpDrawable *, double *, TileManager *, int, GimpMatrix);
|
||||
static void * scale_tool_scale (GImage *, GimpDrawable *, GDisplay *, double *, TileManager *, int, GimpMatrix);
|
||||
static void * scale_tool_recalc (Tool *, void *);
|
||||
static void scale_tool_motion (Tool *, void *);
|
||||
static void scale_info_update (Tool *);
|
||||
|
@ -82,6 +82,7 @@ scale_tool_transform (tool, gdisp_ptr, state)
|
|||
info_dialog_add_field (transform_info, _("X Scale Ratio: "), x_ratio_buf, NULL, NULL);
|
||||
info_dialog_add_field (transform_info, _("Y Scale Ratio: "), y_ratio_buf, NULL, NULL);
|
||||
}
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), TRUE);
|
||||
|
||||
transform_core->trans_info [X1] = (double) transform_core->x1;
|
||||
transform_core->trans_info [Y1] = (double) transform_core->y1;
|
||||
|
@ -102,7 +103,8 @@ scale_tool_transform (tool, gdisp_ptr, state)
|
|||
break;
|
||||
|
||||
case FINISH :
|
||||
return scale_tool_scale (gdisp->gimage, gimage_active_drawable (gdisp->gimage),
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), FALSE);
|
||||
return scale_tool_scale (gdisp->gimage, gimage_active_drawable (gdisp->gimage), gdisp,
|
||||
transform_core->trans_info, transform_core->original,
|
||||
transform_tool_smoothing (), transform_core->transform);
|
||||
break;
|
||||
|
@ -423,15 +425,27 @@ scale_tool_recalc (tool, gdisp_ptr)
|
|||
}
|
||||
|
||||
static void *
|
||||
scale_tool_scale (gimage, drawable, trans_info, float_tiles, interpolation, matrix)
|
||||
scale_tool_scale (gimage, drawable, gdisp, trans_info, float_tiles, interpolation, matrix)
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
GDisplay *gdisp;
|
||||
double *trans_info;
|
||||
TileManager *float_tiles;
|
||||
int interpolation;
|
||||
GimpMatrix matrix;
|
||||
{
|
||||
return transform_core_do (gimage, drawable, float_tiles, interpolation, matrix);
|
||||
void *ret;
|
||||
gimp_progress *progress;
|
||||
|
||||
progress = progress_start (gdisp, _("Scaling..."), FALSE, NULL, NULL);
|
||||
|
||||
ret = transform_core_do (gimage, drawable, float_tiles,
|
||||
interpolation, matrix,
|
||||
progress? progress_update_and_flush:NULL, progress);
|
||||
if (progress)
|
||||
progress_end (progress);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -568,7 +582,7 @@ scale_invoker (args)
|
|||
gimp_matrix_translate (matrix, trans_info[X1], trans_info[Y1]);
|
||||
|
||||
/* scale the buffer */
|
||||
new_tiles = scale_tool_scale (gimage, drawable, trans_info,
|
||||
new_tiles = scale_tool_scale (gimage, drawable, NULL, trans_info,
|
||||
float_tiles, interpolation, matrix);
|
||||
|
||||
/* free the cut/copied buffer */
|
||||
|
|
|
@ -53,7 +53,7 @@ static char xshear_buf [MAX_INFO_BUF];
|
|||
static char yshear_buf [MAX_INFO_BUF];
|
||||
|
||||
/* forward function declarations */
|
||||
static void * shear_tool_shear (GImage *, GimpDrawable *, TileManager *, int, GimpMatrix);
|
||||
static void * shear_tool_shear (GImage *, GimpDrawable *, GDisplay *, TileManager *, int, GimpMatrix);
|
||||
static void * shear_tool_recalc (Tool *, void *);
|
||||
static void shear_tool_motion (Tool *, void *);
|
||||
static void shear_info_update (Tool *);
|
||||
|
@ -84,6 +84,7 @@ shear_tool_transform (tool, gdisp_ptr, state)
|
|||
info_dialog_add_field (transform_info, _("X Shear Magnitude: "), xshear_buf, shear_x_mag_changed, tool);
|
||||
info_dialog_add_field (transform_info, _("Y Shear Magnitude: "), yshear_buf, shear_y_mag_changed, tool);
|
||||
}
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), TRUE);
|
||||
direction_unknown = 1;
|
||||
transform_core->trans_info[HORZ_OR_VERT] = HORZ;
|
||||
transform_core->trans_info[XSHEAR] = 0.0;
|
||||
|
@ -103,8 +104,9 @@ shear_tool_transform (tool, gdisp_ptr, state)
|
|||
break;
|
||||
|
||||
case FINISH :
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), FALSE);
|
||||
direction_unknown = 1;
|
||||
return shear_tool_shear (gdisp->gimage, gimage_active_drawable (gdisp->gimage),
|
||||
return shear_tool_shear (gdisp->gimage, gimage_active_drawable (gdisp->gimage), gdisp,
|
||||
transform_core->original, transform_tool_smoothing (),
|
||||
transform_core->transform);
|
||||
break;
|
||||
|
@ -349,14 +351,26 @@ shear_tool_recalc (tool, gdisp_ptr)
|
|||
|
||||
|
||||
static void *
|
||||
shear_tool_shear (gimage, drawable, float_tiles, interpolation, matrix)
|
||||
shear_tool_shear (gimage, drawable, gdisp, float_tiles, interpolation, matrix)
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
GDisplay *gdisp;
|
||||
TileManager *float_tiles;
|
||||
int interpolation;
|
||||
GimpMatrix matrix;
|
||||
{
|
||||
return transform_core_do (gimage, drawable, float_tiles, interpolation, matrix);
|
||||
void *ret;
|
||||
gimp_progress *progress;
|
||||
|
||||
progress = progress_start (gdisp, _("Shearing..."), FALSE, NULL, NULL);
|
||||
|
||||
ret = transform_core_do (gimage, drawable, float_tiles,
|
||||
interpolation, matrix,
|
||||
progress? progress_update_and_flush:NULL, progress);
|
||||
if (progress)
|
||||
progress_end (progress);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -491,7 +505,7 @@ shear_invoker (args)
|
|||
gimp_matrix_translate (matrix, +cx, +cy);
|
||||
|
||||
/* shear the buffer */
|
||||
new_tiles = shear_tool_shear (gimage, drawable, float_tiles, interpolation, matrix);
|
||||
new_tiles = shear_tool_shear (gimage, drawable, NULL, float_tiles, interpolation, matrix);
|
||||
|
||||
/* free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
|
|
@ -161,7 +161,9 @@ static void blend (GImage *gimage, GimpDrawable *drawa
|
|||
RepeatMode repeat,
|
||||
int supersample, int max_depth, double threshold,
|
||||
double startx, double starty,
|
||||
double endx, double endy);
|
||||
double endx, double endy,
|
||||
progress_func_t progress_callback,
|
||||
void *progress_data);
|
||||
|
||||
static double gradient_calc_conical_sym_factor (double dist, double *axis, double offset,
|
||||
double x, double y);
|
||||
|
@ -195,7 +197,9 @@ static void gradient_fill_region (GImage *gimage, GimpDrawable *drawa
|
|||
BlendMode blend_mode, GradientType gradient_type,
|
||||
double offset, RepeatMode repeat,
|
||||
int supersample, int max_depth, double threshold,
|
||||
double sx, double sy, double ex, double ey);
|
||||
double sx, double sy, double ex, double ey,
|
||||
progress_func_t progress_callback,
|
||||
void *progress_data);
|
||||
|
||||
static void calc_rgb_to_hsv(double *r, double *g, double *b);
|
||||
static void calc_hsv_to_rgb(double *h, double *s, double *v);
|
||||
|
@ -606,8 +610,12 @@ blend_button_release (Tool *tool,
|
|||
GDisplay * gdisp;
|
||||
GImage * gimage;
|
||||
BlendTool * blend_tool;
|
||||
#ifdef BLEND_UI_CALLS_VIA_PDB
|
||||
Argument *return_vals;
|
||||
int nreturn_vals;
|
||||
#else
|
||||
gimp_progress *progress;
|
||||
#endif
|
||||
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
gimage = gdisp->gimage;
|
||||
|
@ -626,6 +634,9 @@ blend_button_release (Tool *tool,
|
|||
((blend_tool->startx != blend_tool->endx) ||
|
||||
(blend_tool->starty != blend_tool->endy)))
|
||||
{
|
||||
/* we can't do callbacks easily with the PDB, so this UI/backend
|
||||
* separation (though good) is ignored for the moment */
|
||||
#ifdef BLEND_UI_CALLS_VIA_PDB
|
||||
return_vals = procedural_db_run_proc ("gimp_blend",
|
||||
&nreturn_vals,
|
||||
PDB_DRAWABLE, drawable_ID (gimage_active_drawable (gimage)),
|
||||
|
@ -650,6 +661,33 @@ blend_button_release (Tool *tool,
|
|||
g_message (_("Blend operation failed."));
|
||||
|
||||
procedural_db_destroy_args (return_vals, nreturn_vals);
|
||||
|
||||
#else /* ! BLEND_UI_CALLS_VIA_PDB */
|
||||
|
||||
progress = progress_start (gdisp, _("Blending..."), FALSE, NULL, NULL);
|
||||
|
||||
blend (gimage,
|
||||
gimage_active_drawable (gimage),
|
||||
blend_options->blend_mode,
|
||||
blend_options->paint_mode,
|
||||
blend_options->gradient_type,
|
||||
blend_options->opacity,
|
||||
blend_options->offset,
|
||||
blend_options->repeat,
|
||||
blend_options->supersample,
|
||||
blend_options->max_depth,
|
||||
blend_options->threshold,
|
||||
blend_tool->startx,
|
||||
blend_tool->starty,
|
||||
blend_tool->endx,
|
||||
blend_tool->endy,
|
||||
progress? progress_update_and_flush : NULL, progress);
|
||||
|
||||
if (progress)
|
||||
progress_end (progress);
|
||||
|
||||
gdisplays_flush ();
|
||||
#endif /* ! BLEND_UI_CALLS_VIA_PDB */
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -766,21 +804,23 @@ blend_control (Tool *tool,
|
|||
|
||||
/* The actual blending procedure */
|
||||
static void
|
||||
blend (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
BlendMode blend_mode,
|
||||
int paint_mode,
|
||||
GradientType gradient_type,
|
||||
double opacity,
|
||||
double offset,
|
||||
RepeatMode repeat,
|
||||
int supersample,
|
||||
int max_depth,
|
||||
double threshold,
|
||||
double startx,
|
||||
double starty,
|
||||
double endx,
|
||||
double endy)
|
||||
blend (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
BlendMode blend_mode,
|
||||
int paint_mode,
|
||||
GradientType gradient_type,
|
||||
double opacity,
|
||||
double offset,
|
||||
RepeatMode repeat,
|
||||
int supersample,
|
||||
int max_depth,
|
||||
double threshold,
|
||||
double startx,
|
||||
double starty,
|
||||
double endx,
|
||||
double endy,
|
||||
progress_func_t progress_callback,
|
||||
void *progress_data)
|
||||
{
|
||||
TileManager *buf_tiles;
|
||||
PixelRegion bufPR;
|
||||
|
@ -811,7 +851,8 @@ blend (GImage *gimage,
|
|||
blend_mode, gradient_type, offset, repeat,
|
||||
supersample, max_depth, threshold,
|
||||
(startx - x1), (starty - y1),
|
||||
(endx - x1), (endy - y1));
|
||||
(endx - x1), (endy - y1),
|
||||
progress_callback, progress_data);
|
||||
|
||||
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), FALSE);
|
||||
gimage_apply_image (gimage, drawable, &bufPR, TRUE,
|
||||
|
@ -1375,23 +1416,26 @@ gradient_put_pixel(int x, int y, color_t color, void *put_pixel_data)
|
|||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
gradient_fill_region (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
PixelRegion *PR,
|
||||
int width,
|
||||
int height,
|
||||
BlendMode blend_mode,
|
||||
GradientType gradient_type,
|
||||
double offset,
|
||||
RepeatMode repeat,
|
||||
int supersample,
|
||||
int max_depth,
|
||||
double threshold,
|
||||
double sx,
|
||||
double sy,
|
||||
double ex,
|
||||
double ey)
|
||||
gradient_fill_region (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
PixelRegion *PR,
|
||||
int width,
|
||||
int height,
|
||||
BlendMode blend_mode,
|
||||
GradientType gradient_type,
|
||||
double offset,
|
||||
RepeatMode repeat,
|
||||
int supersample,
|
||||
int max_depth,
|
||||
double threshold,
|
||||
double sx,
|
||||
double sy,
|
||||
double ex,
|
||||
double ey,
|
||||
progress_func_t progress_callback,
|
||||
void *progress_data)
|
||||
{
|
||||
RenderBlendData rbd;
|
||||
PutPixelData ppd;
|
||||
|
@ -1536,7 +1580,7 @@ gradient_fill_region (GImage *gimage,
|
|||
max_depth, threshold,
|
||||
gradient_render_pixel, &rbd,
|
||||
gradient_put_pixel, &ppd,
|
||||
NULL, NULL);
|
||||
progress_callback, progress_data);
|
||||
|
||||
/* Clean up */
|
||||
|
||||
|
@ -1544,6 +1588,9 @@ gradient_fill_region (GImage *gimage,
|
|||
}
|
||||
else
|
||||
{
|
||||
int max_progress = PR->w * PR->h;
|
||||
int progress = 0;
|
||||
|
||||
for (pr = pixel_regions_register(1, PR); pr != NULL; pr = pixel_regions_process(pr))
|
||||
{
|
||||
data = PR->data;
|
||||
|
@ -1572,6 +1619,10 @@ gradient_fill_region (GImage *gimage,
|
|||
*data++ = color.a * 255.0;
|
||||
}
|
||||
}
|
||||
|
||||
progress += PR->w * PR->h;
|
||||
if (progress_callback)
|
||||
(*progress_callback) (0, max_progress, progress, progress_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1992,7 +2043,8 @@ blend_invoker (Argument *args)
|
|||
if (success)
|
||||
{
|
||||
blend (gimage, drawable, blend_mode, paint_mode, gradient_type,
|
||||
opacity, offset, repeat, supersample, max_depth, threshold, x1, y1, x2, y2);
|
||||
opacity, offset, repeat, supersample, max_depth, threshold,
|
||||
x1, y1, x2, y2, NULL, NULL);
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&blend_proc, success);
|
||||
|
|
|
@ -133,7 +133,7 @@ flip_tool_transform_horz (Tool *tool,
|
|||
break;
|
||||
|
||||
case FINISH :
|
||||
transform_core->trans_info[FLIP] *= -1.0;
|
||||
/* transform_core->trans_info[FLIP] *= -1.0;*/
|
||||
return flip_tool_flip_horz (gdisp->gimage, gimage_active_drawable (gdisp->gimage),
|
||||
transform_core->original, transform_core->trans_info[FLIP]);
|
||||
break;
|
||||
|
@ -166,7 +166,7 @@ flip_tool_transform_vert (Tool *tool,
|
|||
break;
|
||||
|
||||
case FINISH :
|
||||
transform_core->trans_info[FLIP] *= -1.0;
|
||||
/*transform_core->trans_info[FLIP] *= -1.0;*/
|
||||
return flip_tool_flip_vert (gdisp->gimage, gimage_active_drawable (gdisp->gimage),
|
||||
transform_core->original, transform_core->trans_info[FLIP]);
|
||||
break;
|
||||
|
@ -213,7 +213,7 @@ tools_new_flip_horz ()
|
|||
|
||||
/* set the rotation specific transformation attributes */
|
||||
private->trans_func = flip_tool_transform_horz;
|
||||
private->trans_info[FLIP] = 1.0;
|
||||
private->trans_info[FLIP] = -1.0;
|
||||
|
||||
return tool;
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ tools_new_flip_vert ()
|
|||
|
||||
/* set the rotation specific transformation attributes */
|
||||
private->trans_func = flip_tool_transform_vert;
|
||||
private->trans_info[FLIP] = 1.0;
|
||||
private->trans_info[FLIP] = -1.0;
|
||||
|
||||
return tool;
|
||||
}
|
||||
|
|
|
@ -161,7 +161,9 @@ static void blend (GImage *gimage, GimpDrawable *drawa
|
|||
RepeatMode repeat,
|
||||
int supersample, int max_depth, double threshold,
|
||||
double startx, double starty,
|
||||
double endx, double endy);
|
||||
double endx, double endy,
|
||||
progress_func_t progress_callback,
|
||||
void *progress_data);
|
||||
|
||||
static double gradient_calc_conical_sym_factor (double dist, double *axis, double offset,
|
||||
double x, double y);
|
||||
|
@ -195,7 +197,9 @@ static void gradient_fill_region (GImage *gimage, GimpDrawable *drawa
|
|||
BlendMode blend_mode, GradientType gradient_type,
|
||||
double offset, RepeatMode repeat,
|
||||
int supersample, int max_depth, double threshold,
|
||||
double sx, double sy, double ex, double ey);
|
||||
double sx, double sy, double ex, double ey,
|
||||
progress_func_t progress_callback,
|
||||
void *progress_data);
|
||||
|
||||
static void calc_rgb_to_hsv(double *r, double *g, double *b);
|
||||
static void calc_hsv_to_rgb(double *h, double *s, double *v);
|
||||
|
@ -606,8 +610,12 @@ blend_button_release (Tool *tool,
|
|||
GDisplay * gdisp;
|
||||
GImage * gimage;
|
||||
BlendTool * blend_tool;
|
||||
#ifdef BLEND_UI_CALLS_VIA_PDB
|
||||
Argument *return_vals;
|
||||
int nreturn_vals;
|
||||
#else
|
||||
gimp_progress *progress;
|
||||
#endif
|
||||
|
||||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
gimage = gdisp->gimage;
|
||||
|
@ -626,6 +634,9 @@ blend_button_release (Tool *tool,
|
|||
((blend_tool->startx != blend_tool->endx) ||
|
||||
(blend_tool->starty != blend_tool->endy)))
|
||||
{
|
||||
/* we can't do callbacks easily with the PDB, so this UI/backend
|
||||
* separation (though good) is ignored for the moment */
|
||||
#ifdef BLEND_UI_CALLS_VIA_PDB
|
||||
return_vals = procedural_db_run_proc ("gimp_blend",
|
||||
&nreturn_vals,
|
||||
PDB_DRAWABLE, drawable_ID (gimage_active_drawable (gimage)),
|
||||
|
@ -650,6 +661,33 @@ blend_button_release (Tool *tool,
|
|||
g_message (_("Blend operation failed."));
|
||||
|
||||
procedural_db_destroy_args (return_vals, nreturn_vals);
|
||||
|
||||
#else /* ! BLEND_UI_CALLS_VIA_PDB */
|
||||
|
||||
progress = progress_start (gdisp, _("Blending..."), FALSE, NULL, NULL);
|
||||
|
||||
blend (gimage,
|
||||
gimage_active_drawable (gimage),
|
||||
blend_options->blend_mode,
|
||||
blend_options->paint_mode,
|
||||
blend_options->gradient_type,
|
||||
blend_options->opacity,
|
||||
blend_options->offset,
|
||||
blend_options->repeat,
|
||||
blend_options->supersample,
|
||||
blend_options->max_depth,
|
||||
blend_options->threshold,
|
||||
blend_tool->startx,
|
||||
blend_tool->starty,
|
||||
blend_tool->endx,
|
||||
blend_tool->endy,
|
||||
progress? progress_update_and_flush : NULL, progress);
|
||||
|
||||
if (progress)
|
||||
progress_end (progress);
|
||||
|
||||
gdisplays_flush ();
|
||||
#endif /* ! BLEND_UI_CALLS_VIA_PDB */
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -766,21 +804,23 @@ blend_control (Tool *tool,
|
|||
|
||||
/* The actual blending procedure */
|
||||
static void
|
||||
blend (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
BlendMode blend_mode,
|
||||
int paint_mode,
|
||||
GradientType gradient_type,
|
||||
double opacity,
|
||||
double offset,
|
||||
RepeatMode repeat,
|
||||
int supersample,
|
||||
int max_depth,
|
||||
double threshold,
|
||||
double startx,
|
||||
double starty,
|
||||
double endx,
|
||||
double endy)
|
||||
blend (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
BlendMode blend_mode,
|
||||
int paint_mode,
|
||||
GradientType gradient_type,
|
||||
double opacity,
|
||||
double offset,
|
||||
RepeatMode repeat,
|
||||
int supersample,
|
||||
int max_depth,
|
||||
double threshold,
|
||||
double startx,
|
||||
double starty,
|
||||
double endx,
|
||||
double endy,
|
||||
progress_func_t progress_callback,
|
||||
void *progress_data)
|
||||
{
|
||||
TileManager *buf_tiles;
|
||||
PixelRegion bufPR;
|
||||
|
@ -811,7 +851,8 @@ blend (GImage *gimage,
|
|||
blend_mode, gradient_type, offset, repeat,
|
||||
supersample, max_depth, threshold,
|
||||
(startx - x1), (starty - y1),
|
||||
(endx - x1), (endy - y1));
|
||||
(endx - x1), (endy - y1),
|
||||
progress_callback, progress_data);
|
||||
|
||||
pixel_region_init (&bufPR, buf_tiles, 0, 0, (x2 - x1), (y2 - y1), FALSE);
|
||||
gimage_apply_image (gimage, drawable, &bufPR, TRUE,
|
||||
|
@ -1375,23 +1416,26 @@ gradient_put_pixel(int x, int y, color_t color, void *put_pixel_data)
|
|||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
gradient_fill_region (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
PixelRegion *PR,
|
||||
int width,
|
||||
int height,
|
||||
BlendMode blend_mode,
|
||||
GradientType gradient_type,
|
||||
double offset,
|
||||
RepeatMode repeat,
|
||||
int supersample,
|
||||
int max_depth,
|
||||
double threshold,
|
||||
double sx,
|
||||
double sy,
|
||||
double ex,
|
||||
double ey)
|
||||
gradient_fill_region (GImage *gimage,
|
||||
GimpDrawable *drawable,
|
||||
PixelRegion *PR,
|
||||
int width,
|
||||
int height,
|
||||
BlendMode blend_mode,
|
||||
GradientType gradient_type,
|
||||
double offset,
|
||||
RepeatMode repeat,
|
||||
int supersample,
|
||||
int max_depth,
|
||||
double threshold,
|
||||
double sx,
|
||||
double sy,
|
||||
double ex,
|
||||
double ey,
|
||||
progress_func_t progress_callback,
|
||||
void *progress_data)
|
||||
{
|
||||
RenderBlendData rbd;
|
||||
PutPixelData ppd;
|
||||
|
@ -1536,7 +1580,7 @@ gradient_fill_region (GImage *gimage,
|
|||
max_depth, threshold,
|
||||
gradient_render_pixel, &rbd,
|
||||
gradient_put_pixel, &ppd,
|
||||
NULL, NULL);
|
||||
progress_callback, progress_data);
|
||||
|
||||
/* Clean up */
|
||||
|
||||
|
@ -1544,6 +1588,9 @@ gradient_fill_region (GImage *gimage,
|
|||
}
|
||||
else
|
||||
{
|
||||
int max_progress = PR->w * PR->h;
|
||||
int progress = 0;
|
||||
|
||||
for (pr = pixel_regions_register(1, PR); pr != NULL; pr = pixel_regions_process(pr))
|
||||
{
|
||||
data = PR->data;
|
||||
|
@ -1572,6 +1619,10 @@ gradient_fill_region (GImage *gimage,
|
|||
*data++ = color.a * 255.0;
|
||||
}
|
||||
}
|
||||
|
||||
progress += PR->w * PR->h;
|
||||
if (progress_callback)
|
||||
(*progress_callback) (0, max_progress, progress, progress_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1992,7 +2043,8 @@ blend_invoker (Argument *args)
|
|||
if (success)
|
||||
{
|
||||
blend (gimage, drawable, blend_mode, paint_mode, gradient_type,
|
||||
opacity, offset, repeat, supersample, max_depth, threshold, x1, y1, x2, y2);
|
||||
opacity, offset, repeat, supersample, max_depth, threshold,
|
||||
x1, y1, x2, y2, NULL, NULL);
|
||||
}
|
||||
|
||||
return procedural_db_return_args (&blend_proc, success);
|
||||
|
|
|
@ -133,7 +133,7 @@ flip_tool_transform_horz (Tool *tool,
|
|||
break;
|
||||
|
||||
case FINISH :
|
||||
transform_core->trans_info[FLIP] *= -1.0;
|
||||
/* transform_core->trans_info[FLIP] *= -1.0;*/
|
||||
return flip_tool_flip_horz (gdisp->gimage, gimage_active_drawable (gdisp->gimage),
|
||||
transform_core->original, transform_core->trans_info[FLIP]);
|
||||
break;
|
||||
|
@ -166,7 +166,7 @@ flip_tool_transform_vert (Tool *tool,
|
|||
break;
|
||||
|
||||
case FINISH :
|
||||
transform_core->trans_info[FLIP] *= -1.0;
|
||||
/*transform_core->trans_info[FLIP] *= -1.0;*/
|
||||
return flip_tool_flip_vert (gdisp->gimage, gimage_active_drawable (gdisp->gimage),
|
||||
transform_core->original, transform_core->trans_info[FLIP]);
|
||||
break;
|
||||
|
@ -213,7 +213,7 @@ tools_new_flip_horz ()
|
|||
|
||||
/* set the rotation specific transformation attributes */
|
||||
private->trans_func = flip_tool_transform_horz;
|
||||
private->trans_info[FLIP] = 1.0;
|
||||
private->trans_info[FLIP] = -1.0;
|
||||
|
||||
return tool;
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ tools_new_flip_vert ()
|
|||
|
||||
/* set the rotation specific transformation attributes */
|
||||
private->trans_func = flip_tool_transform_vert;
|
||||
private->trans_info[FLIP] = 1.0;
|
||||
private->trans_info[FLIP] = -1.0;
|
||||
|
||||
return tool;
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
static char matrix_row_buf [3][MAX_INFO_BUF];
|
||||
|
||||
/* forward function declarations */
|
||||
static void * perspective_tool_perspective (GImage *, GimpDrawable *, TileManager *, int, GimpMatrix);
|
||||
static void * perspective_tool_perspective (GImage *, GimpDrawable *, GDisplay *, TileManager *, int, GimpMatrix);
|
||||
static void perspective_find_transform (double *, GimpMatrix);
|
||||
static void * perspective_tool_recalc (Tool *, void *);
|
||||
static void perspective_tool_motion (Tool *, void *);
|
||||
|
@ -78,6 +78,7 @@ perspective_tool_transform (tool, gdisp_ptr, state)
|
|||
info_dialog_add_field (transform_info, " ",
|
||||
matrix_row_buf[2], NULL, NULL);
|
||||
}
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), TRUE);
|
||||
|
||||
transform_core->trans_info [X0] = (double) transform_core->x1;
|
||||
transform_core->trans_info [Y0] = (double) transform_core->y1;
|
||||
|
@ -103,7 +104,8 @@ perspective_tool_transform (tool, gdisp_ptr, state)
|
|||
|
||||
case FINISH :
|
||||
/* Let the transform core handle the inverse mapping */
|
||||
return perspective_tool_perspective (gdisp->gimage, gimage_active_drawable (gdisp->gimage),
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), FALSE);
|
||||
return perspective_tool_perspective (gdisp->gimage, gimage_active_drawable (gdisp->gimage), gdisp,
|
||||
transform_core->original, transform_tool_smoothing (),
|
||||
transform_core->transform);
|
||||
break;
|
||||
|
@ -309,14 +311,26 @@ perspective_find_transform (coords, m)
|
|||
|
||||
|
||||
static void *
|
||||
perspective_tool_perspective (gimage, drawable, float_tiles, interpolation, matrix)
|
||||
perspective_tool_perspective (gimage, drawable, gdisp, float_tiles, interpolation, matrix)
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
GDisplay *gdisp;
|
||||
TileManager *float_tiles;
|
||||
int interpolation;
|
||||
GimpMatrix matrix;
|
||||
{
|
||||
return transform_core_do (gimage, drawable, float_tiles, interpolation, matrix);
|
||||
void *ret;
|
||||
gimp_progress *progress;
|
||||
|
||||
progress = progress_start (gdisp, _("Perspective..."), FALSE, NULL, NULL);
|
||||
|
||||
ret = transform_core_do (gimage, drawable, float_tiles,
|
||||
interpolation, matrix,
|
||||
progress? progress_update_and_flush:NULL, progress);
|
||||
if (progress)
|
||||
progress_end (progress);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -479,7 +493,7 @@ perspective_invoker (args)
|
|||
gimp_matrix_mult (m, matrix);
|
||||
|
||||
/* perspective the buffer */
|
||||
new_tiles = perspective_tool_perspective (gimage, drawable, float_tiles, interpolation, matrix);
|
||||
new_tiles = perspective_tool_perspective (gimage, drawable, NULL, float_tiles, interpolation, matrix);
|
||||
|
||||
/* free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
|
|
@ -54,7 +54,7 @@ static char center_x_buf [MAX_INFO_BUF];
|
|||
static char center_y_buf [MAX_INFO_BUF];
|
||||
|
||||
/* forward function declarations */
|
||||
static void * rotate_tool_rotate (GImage *, GimpDrawable *, double, TileManager *, int, GimpMatrix);
|
||||
static void * rotate_tool_rotate (GImage *, GimpDrawable *, GDisplay *, double, TileManager *, int, GimpMatrix);
|
||||
static void * rotate_tool_recalc (Tool *, void *);
|
||||
static void rotate_tool_motion (Tool *, void *);
|
||||
static void rotate_info_update (Tool *);
|
||||
|
@ -88,6 +88,7 @@ rotate_tool_transform (tool, gdisp_ptr, state)
|
|||
info_dialog_add_field (transform_info, _("Center X: "), center_x_buf, (GtkSignalFunc) rotate_center_x_changed, tool);
|
||||
info_dialog_add_field (transform_info, _("Center Y: "), center_y_buf, (GtkSignalFunc) rotate_center_y_changed, tool);
|
||||
}
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), TRUE);
|
||||
|
||||
transform_core->trans_info[ANGLE] = 0.0;
|
||||
transform_core->trans_info[REAL_ANGLE] = 0.0;
|
||||
|
@ -110,7 +111,8 @@ rotate_tool_transform (tool, gdisp_ptr, state)
|
|||
break;
|
||||
|
||||
case FINISH :
|
||||
return rotate_tool_rotate (gdisp->gimage, gimage_active_drawable (gdisp->gimage),
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), FALSE);
|
||||
return rotate_tool_rotate (gdisp->gimage, gimage_active_drawable (gdisp->gimage), gdisp,
|
||||
transform_core->trans_info[ANGLE], transform_core->original,
|
||||
transform_tool_smoothing (), transform_core->transform);
|
||||
break;
|
||||
|
@ -361,15 +363,27 @@ rotate_tool_recalc (tool, gdisp_ptr)
|
|||
*/
|
||||
|
||||
static void *
|
||||
rotate_tool_rotate (gimage, drawable, angle, float_tiles, interpolation, matrix)
|
||||
rotate_tool_rotate (gimage, drawable, gdisp, angle, float_tiles, interpolation, matrix)
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
GDisplay *gdisp;
|
||||
double angle;
|
||||
TileManager *float_tiles;
|
||||
int interpolation;
|
||||
GimpMatrix matrix;
|
||||
{
|
||||
return transform_core_do (gimage, drawable, float_tiles, interpolation, matrix);
|
||||
void *ret;
|
||||
gimp_progress *progress;
|
||||
|
||||
progress = progress_start (gdisp, _("Rotating..."), FALSE, NULL, NULL);
|
||||
|
||||
ret = transform_core_do (gimage, drawable, float_tiles,
|
||||
interpolation, matrix,
|
||||
progress? progress_update_and_flush:NULL, progress);
|
||||
if (progress)
|
||||
progress_end (progress);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -482,7 +496,7 @@ rotate_invoker (args)
|
|||
gimp_matrix_translate (matrix, +cx, +cy);
|
||||
|
||||
/* rotate the buffer */
|
||||
new_tiles = rotate_tool_rotate (gimage, drawable, angle, float_tiles, interpolation, matrix);
|
||||
new_tiles = rotate_tool_rotate (gimage, drawable, NULL, angle, float_tiles, interpolation, matrix);
|
||||
|
||||
/* free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
|
|
@ -47,7 +47,7 @@ char x_ratio_buf [MAX_INFO_BUF];
|
|||
char y_ratio_buf [MAX_INFO_BUF];
|
||||
|
||||
/* forward function declarations */
|
||||
static void * scale_tool_scale (GImage *, GimpDrawable *, double *, TileManager *, int, GimpMatrix);
|
||||
static void * scale_tool_scale (GImage *, GimpDrawable *, GDisplay *, double *, TileManager *, int, GimpMatrix);
|
||||
static void * scale_tool_recalc (Tool *, void *);
|
||||
static void scale_tool_motion (Tool *, void *);
|
||||
static void scale_info_update (Tool *);
|
||||
|
@ -82,6 +82,7 @@ scale_tool_transform (tool, gdisp_ptr, state)
|
|||
info_dialog_add_field (transform_info, _("X Scale Ratio: "), x_ratio_buf, NULL, NULL);
|
||||
info_dialog_add_field (transform_info, _("Y Scale Ratio: "), y_ratio_buf, NULL, NULL);
|
||||
}
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), TRUE);
|
||||
|
||||
transform_core->trans_info [X1] = (double) transform_core->x1;
|
||||
transform_core->trans_info [Y1] = (double) transform_core->y1;
|
||||
|
@ -102,7 +103,8 @@ scale_tool_transform (tool, gdisp_ptr, state)
|
|||
break;
|
||||
|
||||
case FINISH :
|
||||
return scale_tool_scale (gdisp->gimage, gimage_active_drawable (gdisp->gimage),
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), FALSE);
|
||||
return scale_tool_scale (gdisp->gimage, gimage_active_drawable (gdisp->gimage), gdisp,
|
||||
transform_core->trans_info, transform_core->original,
|
||||
transform_tool_smoothing (), transform_core->transform);
|
||||
break;
|
||||
|
@ -423,15 +425,27 @@ scale_tool_recalc (tool, gdisp_ptr)
|
|||
}
|
||||
|
||||
static void *
|
||||
scale_tool_scale (gimage, drawable, trans_info, float_tiles, interpolation, matrix)
|
||||
scale_tool_scale (gimage, drawable, gdisp, trans_info, float_tiles, interpolation, matrix)
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
GDisplay *gdisp;
|
||||
double *trans_info;
|
||||
TileManager *float_tiles;
|
||||
int interpolation;
|
||||
GimpMatrix matrix;
|
||||
{
|
||||
return transform_core_do (gimage, drawable, float_tiles, interpolation, matrix);
|
||||
void *ret;
|
||||
gimp_progress *progress;
|
||||
|
||||
progress = progress_start (gdisp, _("Scaling..."), FALSE, NULL, NULL);
|
||||
|
||||
ret = transform_core_do (gimage, drawable, float_tiles,
|
||||
interpolation, matrix,
|
||||
progress? progress_update_and_flush:NULL, progress);
|
||||
if (progress)
|
||||
progress_end (progress);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -568,7 +582,7 @@ scale_invoker (args)
|
|||
gimp_matrix_translate (matrix, trans_info[X1], trans_info[Y1]);
|
||||
|
||||
/* scale the buffer */
|
||||
new_tiles = scale_tool_scale (gimage, drawable, trans_info,
|
||||
new_tiles = scale_tool_scale (gimage, drawable, NULL, trans_info,
|
||||
float_tiles, interpolation, matrix);
|
||||
|
||||
/* free the cut/copied buffer */
|
||||
|
|
|
@ -53,7 +53,7 @@ static char xshear_buf [MAX_INFO_BUF];
|
|||
static char yshear_buf [MAX_INFO_BUF];
|
||||
|
||||
/* forward function declarations */
|
||||
static void * shear_tool_shear (GImage *, GimpDrawable *, TileManager *, int, GimpMatrix);
|
||||
static void * shear_tool_shear (GImage *, GimpDrawable *, GDisplay *, TileManager *, int, GimpMatrix);
|
||||
static void * shear_tool_recalc (Tool *, void *);
|
||||
static void shear_tool_motion (Tool *, void *);
|
||||
static void shear_info_update (Tool *);
|
||||
|
@ -84,6 +84,7 @@ shear_tool_transform (tool, gdisp_ptr, state)
|
|||
info_dialog_add_field (transform_info, _("X Shear Magnitude: "), xshear_buf, shear_x_mag_changed, tool);
|
||||
info_dialog_add_field (transform_info, _("Y Shear Magnitude: "), yshear_buf, shear_y_mag_changed, tool);
|
||||
}
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), TRUE);
|
||||
direction_unknown = 1;
|
||||
transform_core->trans_info[HORZ_OR_VERT] = HORZ;
|
||||
transform_core->trans_info[XSHEAR] = 0.0;
|
||||
|
@ -103,8 +104,9 @@ shear_tool_transform (tool, gdisp_ptr, state)
|
|||
break;
|
||||
|
||||
case FINISH :
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), FALSE);
|
||||
direction_unknown = 1;
|
||||
return shear_tool_shear (gdisp->gimage, gimage_active_drawable (gdisp->gimage),
|
||||
return shear_tool_shear (gdisp->gimage, gimage_active_drawable (gdisp->gimage), gdisp,
|
||||
transform_core->original, transform_tool_smoothing (),
|
||||
transform_core->transform);
|
||||
break;
|
||||
|
@ -349,14 +351,26 @@ shear_tool_recalc (tool, gdisp_ptr)
|
|||
|
||||
|
||||
static void *
|
||||
shear_tool_shear (gimage, drawable, float_tiles, interpolation, matrix)
|
||||
shear_tool_shear (gimage, drawable, gdisp, float_tiles, interpolation, matrix)
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
GDisplay *gdisp;
|
||||
TileManager *float_tiles;
|
||||
int interpolation;
|
||||
GimpMatrix matrix;
|
||||
{
|
||||
return transform_core_do (gimage, drawable, float_tiles, interpolation, matrix);
|
||||
void *ret;
|
||||
gimp_progress *progress;
|
||||
|
||||
progress = progress_start (gdisp, _("Shearing..."), FALSE, NULL, NULL);
|
||||
|
||||
ret = transform_core_do (gimage, drawable, float_tiles,
|
||||
interpolation, matrix,
|
||||
progress? progress_update_and_flush:NULL, progress);
|
||||
if (progress)
|
||||
progress_end (progress);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -491,7 +505,7 @@ shear_invoker (args)
|
|||
gimp_matrix_translate (matrix, +cx, +cy);
|
||||
|
||||
/* shear the buffer */
|
||||
new_tiles = shear_tool_shear (gimage, drawable, float_tiles, interpolation, matrix);
|
||||
new_tiles = shear_tool_shear (gimage, drawable, NULL, float_tiles, interpolation, matrix);
|
||||
|
||||
/* free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
static char matrix_row_buf [3][MAX_INFO_BUF];
|
||||
|
||||
/* forward function declarations */
|
||||
static void * perspective_tool_perspective (GImage *, GimpDrawable *, TileManager *, int, GimpMatrix);
|
||||
static void * perspective_tool_perspective (GImage *, GimpDrawable *, GDisplay *, TileManager *, int, GimpMatrix);
|
||||
static void perspective_find_transform (double *, GimpMatrix);
|
||||
static void * perspective_tool_recalc (Tool *, void *);
|
||||
static void perspective_tool_motion (Tool *, void *);
|
||||
|
@ -78,6 +78,7 @@ perspective_tool_transform (tool, gdisp_ptr, state)
|
|||
info_dialog_add_field (transform_info, " ",
|
||||
matrix_row_buf[2], NULL, NULL);
|
||||
}
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), TRUE);
|
||||
|
||||
transform_core->trans_info [X0] = (double) transform_core->x1;
|
||||
transform_core->trans_info [Y0] = (double) transform_core->y1;
|
||||
|
@ -103,7 +104,8 @@ perspective_tool_transform (tool, gdisp_ptr, state)
|
|||
|
||||
case FINISH :
|
||||
/* Let the transform core handle the inverse mapping */
|
||||
return perspective_tool_perspective (gdisp->gimage, gimage_active_drawable (gdisp->gimage),
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), FALSE);
|
||||
return perspective_tool_perspective (gdisp->gimage, gimage_active_drawable (gdisp->gimage), gdisp,
|
||||
transform_core->original, transform_tool_smoothing (),
|
||||
transform_core->transform);
|
||||
break;
|
||||
|
@ -309,14 +311,26 @@ perspective_find_transform (coords, m)
|
|||
|
||||
|
||||
static void *
|
||||
perspective_tool_perspective (gimage, drawable, float_tiles, interpolation, matrix)
|
||||
perspective_tool_perspective (gimage, drawable, gdisp, float_tiles, interpolation, matrix)
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
GDisplay *gdisp;
|
||||
TileManager *float_tiles;
|
||||
int interpolation;
|
||||
GimpMatrix matrix;
|
||||
{
|
||||
return transform_core_do (gimage, drawable, float_tiles, interpolation, matrix);
|
||||
void *ret;
|
||||
gimp_progress *progress;
|
||||
|
||||
progress = progress_start (gdisp, _("Perspective..."), FALSE, NULL, NULL);
|
||||
|
||||
ret = transform_core_do (gimage, drawable, float_tiles,
|
||||
interpolation, matrix,
|
||||
progress? progress_update_and_flush:NULL, progress);
|
||||
if (progress)
|
||||
progress_end (progress);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -479,7 +493,7 @@ perspective_invoker (args)
|
|||
gimp_matrix_mult (m, matrix);
|
||||
|
||||
/* perspective the buffer */
|
||||
new_tiles = perspective_tool_perspective (gimage, drawable, float_tiles, interpolation, matrix);
|
||||
new_tiles = perspective_tool_perspective (gimage, drawable, NULL, float_tiles, interpolation, matrix);
|
||||
|
||||
/* free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
|
|
@ -54,7 +54,7 @@ static char center_x_buf [MAX_INFO_BUF];
|
|||
static char center_y_buf [MAX_INFO_BUF];
|
||||
|
||||
/* forward function declarations */
|
||||
static void * rotate_tool_rotate (GImage *, GimpDrawable *, double, TileManager *, int, GimpMatrix);
|
||||
static void * rotate_tool_rotate (GImage *, GimpDrawable *, GDisplay *, double, TileManager *, int, GimpMatrix);
|
||||
static void * rotate_tool_recalc (Tool *, void *);
|
||||
static void rotate_tool_motion (Tool *, void *);
|
||||
static void rotate_info_update (Tool *);
|
||||
|
@ -88,6 +88,7 @@ rotate_tool_transform (tool, gdisp_ptr, state)
|
|||
info_dialog_add_field (transform_info, _("Center X: "), center_x_buf, (GtkSignalFunc) rotate_center_x_changed, tool);
|
||||
info_dialog_add_field (transform_info, _("Center Y: "), center_y_buf, (GtkSignalFunc) rotate_center_y_changed, tool);
|
||||
}
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), TRUE);
|
||||
|
||||
transform_core->trans_info[ANGLE] = 0.0;
|
||||
transform_core->trans_info[REAL_ANGLE] = 0.0;
|
||||
|
@ -110,7 +111,8 @@ rotate_tool_transform (tool, gdisp_ptr, state)
|
|||
break;
|
||||
|
||||
case FINISH :
|
||||
return rotate_tool_rotate (gdisp->gimage, gimage_active_drawable (gdisp->gimage),
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), FALSE);
|
||||
return rotate_tool_rotate (gdisp->gimage, gimage_active_drawable (gdisp->gimage), gdisp,
|
||||
transform_core->trans_info[ANGLE], transform_core->original,
|
||||
transform_tool_smoothing (), transform_core->transform);
|
||||
break;
|
||||
|
@ -361,15 +363,27 @@ rotate_tool_recalc (tool, gdisp_ptr)
|
|||
*/
|
||||
|
||||
static void *
|
||||
rotate_tool_rotate (gimage, drawable, angle, float_tiles, interpolation, matrix)
|
||||
rotate_tool_rotate (gimage, drawable, gdisp, angle, float_tiles, interpolation, matrix)
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
GDisplay *gdisp;
|
||||
double angle;
|
||||
TileManager *float_tiles;
|
||||
int interpolation;
|
||||
GimpMatrix matrix;
|
||||
{
|
||||
return transform_core_do (gimage, drawable, float_tiles, interpolation, matrix);
|
||||
void *ret;
|
||||
gimp_progress *progress;
|
||||
|
||||
progress = progress_start (gdisp, _("Rotating..."), FALSE, NULL, NULL);
|
||||
|
||||
ret = transform_core_do (gimage, drawable, float_tiles,
|
||||
interpolation, matrix,
|
||||
progress? progress_update_and_flush:NULL, progress);
|
||||
if (progress)
|
||||
progress_end (progress);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -482,7 +496,7 @@ rotate_invoker (args)
|
|||
gimp_matrix_translate (matrix, +cx, +cy);
|
||||
|
||||
/* rotate the buffer */
|
||||
new_tiles = rotate_tool_rotate (gimage, drawable, angle, float_tiles, interpolation, matrix);
|
||||
new_tiles = rotate_tool_rotate (gimage, drawable, NULL, angle, float_tiles, interpolation, matrix);
|
||||
|
||||
/* free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
|
|
@ -47,7 +47,7 @@ char x_ratio_buf [MAX_INFO_BUF];
|
|||
char y_ratio_buf [MAX_INFO_BUF];
|
||||
|
||||
/* forward function declarations */
|
||||
static void * scale_tool_scale (GImage *, GimpDrawable *, double *, TileManager *, int, GimpMatrix);
|
||||
static void * scale_tool_scale (GImage *, GimpDrawable *, GDisplay *, double *, TileManager *, int, GimpMatrix);
|
||||
static void * scale_tool_recalc (Tool *, void *);
|
||||
static void scale_tool_motion (Tool *, void *);
|
||||
static void scale_info_update (Tool *);
|
||||
|
@ -82,6 +82,7 @@ scale_tool_transform (tool, gdisp_ptr, state)
|
|||
info_dialog_add_field (transform_info, _("X Scale Ratio: "), x_ratio_buf, NULL, NULL);
|
||||
info_dialog_add_field (transform_info, _("Y Scale Ratio: "), y_ratio_buf, NULL, NULL);
|
||||
}
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), TRUE);
|
||||
|
||||
transform_core->trans_info [X1] = (double) transform_core->x1;
|
||||
transform_core->trans_info [Y1] = (double) transform_core->y1;
|
||||
|
@ -102,7 +103,8 @@ scale_tool_transform (tool, gdisp_ptr, state)
|
|||
break;
|
||||
|
||||
case FINISH :
|
||||
return scale_tool_scale (gdisp->gimage, gimage_active_drawable (gdisp->gimage),
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), FALSE);
|
||||
return scale_tool_scale (gdisp->gimage, gimage_active_drawable (gdisp->gimage), gdisp,
|
||||
transform_core->trans_info, transform_core->original,
|
||||
transform_tool_smoothing (), transform_core->transform);
|
||||
break;
|
||||
|
@ -423,15 +425,27 @@ scale_tool_recalc (tool, gdisp_ptr)
|
|||
}
|
||||
|
||||
static void *
|
||||
scale_tool_scale (gimage, drawable, trans_info, float_tiles, interpolation, matrix)
|
||||
scale_tool_scale (gimage, drawable, gdisp, trans_info, float_tiles, interpolation, matrix)
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
GDisplay *gdisp;
|
||||
double *trans_info;
|
||||
TileManager *float_tiles;
|
||||
int interpolation;
|
||||
GimpMatrix matrix;
|
||||
{
|
||||
return transform_core_do (gimage, drawable, float_tiles, interpolation, matrix);
|
||||
void *ret;
|
||||
gimp_progress *progress;
|
||||
|
||||
progress = progress_start (gdisp, _("Scaling..."), FALSE, NULL, NULL);
|
||||
|
||||
ret = transform_core_do (gimage, drawable, float_tiles,
|
||||
interpolation, matrix,
|
||||
progress? progress_update_and_flush:NULL, progress);
|
||||
if (progress)
|
||||
progress_end (progress);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -568,7 +582,7 @@ scale_invoker (args)
|
|||
gimp_matrix_translate (matrix, trans_info[X1], trans_info[Y1]);
|
||||
|
||||
/* scale the buffer */
|
||||
new_tiles = scale_tool_scale (gimage, drawable, trans_info,
|
||||
new_tiles = scale_tool_scale (gimage, drawable, NULL, trans_info,
|
||||
float_tiles, interpolation, matrix);
|
||||
|
||||
/* free the cut/copied buffer */
|
||||
|
|
|
@ -53,7 +53,7 @@ static char xshear_buf [MAX_INFO_BUF];
|
|||
static char yshear_buf [MAX_INFO_BUF];
|
||||
|
||||
/* forward function declarations */
|
||||
static void * shear_tool_shear (GImage *, GimpDrawable *, TileManager *, int, GimpMatrix);
|
||||
static void * shear_tool_shear (GImage *, GimpDrawable *, GDisplay *, TileManager *, int, GimpMatrix);
|
||||
static void * shear_tool_recalc (Tool *, void *);
|
||||
static void shear_tool_motion (Tool *, void *);
|
||||
static void shear_info_update (Tool *);
|
||||
|
@ -84,6 +84,7 @@ shear_tool_transform (tool, gdisp_ptr, state)
|
|||
info_dialog_add_field (transform_info, _("X Shear Magnitude: "), xshear_buf, shear_x_mag_changed, tool);
|
||||
info_dialog_add_field (transform_info, _("Y Shear Magnitude: "), yshear_buf, shear_y_mag_changed, tool);
|
||||
}
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), TRUE);
|
||||
direction_unknown = 1;
|
||||
transform_core->trans_info[HORZ_OR_VERT] = HORZ;
|
||||
transform_core->trans_info[XSHEAR] = 0.0;
|
||||
|
@ -103,8 +104,9 @@ shear_tool_transform (tool, gdisp_ptr, state)
|
|||
break;
|
||||
|
||||
case FINISH :
|
||||
gtk_widget_set_sensitive (GTK_WIDGET (transform_info->shell), FALSE);
|
||||
direction_unknown = 1;
|
||||
return shear_tool_shear (gdisp->gimage, gimage_active_drawable (gdisp->gimage),
|
||||
return shear_tool_shear (gdisp->gimage, gimage_active_drawable (gdisp->gimage), gdisp,
|
||||
transform_core->original, transform_tool_smoothing (),
|
||||
transform_core->transform);
|
||||
break;
|
||||
|
@ -349,14 +351,26 @@ shear_tool_recalc (tool, gdisp_ptr)
|
|||
|
||||
|
||||
static void *
|
||||
shear_tool_shear (gimage, drawable, float_tiles, interpolation, matrix)
|
||||
shear_tool_shear (gimage, drawable, gdisp, float_tiles, interpolation, matrix)
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
GDisplay *gdisp;
|
||||
TileManager *float_tiles;
|
||||
int interpolation;
|
||||
GimpMatrix matrix;
|
||||
{
|
||||
return transform_core_do (gimage, drawable, float_tiles, interpolation, matrix);
|
||||
void *ret;
|
||||
gimp_progress *progress;
|
||||
|
||||
progress = progress_start (gdisp, _("Shearing..."), FALSE, NULL, NULL);
|
||||
|
||||
ret = transform_core_do (gimage, drawable, float_tiles,
|
||||
interpolation, matrix,
|
||||
progress? progress_update_and_flush:NULL, progress);
|
||||
if (progress)
|
||||
progress_end (progress);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
|
@ -491,7 +505,7 @@ shear_invoker (args)
|
|||
gimp_matrix_translate (matrix, +cx, +cy);
|
||||
|
||||
/* shear the buffer */
|
||||
new_tiles = shear_tool_shear (gimage, drawable, float_tiles, interpolation, matrix);
|
||||
new_tiles = shear_tool_shear (gimage, drawable, NULL, float_tiles, interpolation, matrix);
|
||||
|
||||
/* free the cut/copied buffer */
|
||||
tile_manager_destroy (float_tiles);
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
/* variables */
|
||||
static TranInfo old_trans_info;
|
||||
InfoDialog * transform_info = NULL;
|
||||
static gboolean transform_info_inited = FALSE;
|
||||
|
||||
/* forward function declarations */
|
||||
static int transform_core_bounds (Tool *, void *);
|
||||
|
@ -59,6 +60,8 @@ static void * transform_core_recalc (Tool *, void *);
|
|||
static void transform_core_doit (Tool *, gpointer);
|
||||
static double cubic (double, int, int, int, int);
|
||||
static void transform_core_setup_grid (Tool *);
|
||||
static void transform_core_grid_recalc (TransformCore *);
|
||||
|
||||
|
||||
#define BILINEAR(jk,j1k,jk1,j1k1,dx,dy) \
|
||||
((1-dy) * ((1-dx)*jk + dx*j1k) + \
|
||||
|
@ -146,14 +149,12 @@ transform_core_button_press (tool, bevent, gdisp_ptr)
|
|||
for (i = 0; i < TRAN_INFO_SIZE; i++)
|
||||
old_trans_info [i] = transform_core->trans_info [i];
|
||||
}
|
||||
|
||||
|
||||
/* if we have already displayed the bounding box and handles,
|
||||
* check to make sure that the display which currently owns the
|
||||
* tool is the one which just received the button pressed event
|
||||
*/
|
||||
if ((transform_core->function >= CREATING) && (gdisp_ptr == tool->gdisp_ptr) &&
|
||||
transform_core->interactive)
|
||||
if ((gdisp_ptr == tool->gdisp_ptr) && transform_core->interactive)
|
||||
{
|
||||
/* start drawing the bounding box and handles... */
|
||||
draw_core_start (transform_core->core, gdisp->canvas->window, tool);
|
||||
|
@ -207,9 +208,9 @@ transform_core_button_press (tool, bevent, gdisp_ptr)
|
|||
return;
|
||||
}
|
||||
|
||||
/* if the cursor is clicked inside the current selection, show the
|
||||
* bounding box and handles...
|
||||
*/
|
||||
|
||||
/* Initialisation stuff: if the cursor is clicked inside the current
|
||||
* selection, show the bounding box and handles... */
|
||||
gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, FALSE, FALSE);
|
||||
if ((layer = gimage_get_active_layer (gdisp->gimage)))
|
||||
{
|
||||
|
@ -227,7 +228,8 @@ transform_core_button_press (tool, bevent, gdisp_ptr)
|
|||
return;
|
||||
}
|
||||
|
||||
/* If the tool is already active, clear the current state and reset */
|
||||
/* If the tool is already active, clear the current state
|
||||
* and reset */
|
||||
if (tool->state == ACTIVE)
|
||||
transform_core_reset (tool, gdisp_ptr);
|
||||
|
||||
|
@ -243,9 +245,9 @@ transform_core_button_press (tool, bevent, gdisp_ptr)
|
|||
GDK_BUTTON_RELEASE_MASK),
|
||||
NULL, NULL, bevent->time);
|
||||
|
||||
/* Find the transform bounds for some tools (like scale, perspective)
|
||||
* that actually need the bounds for initializing
|
||||
*/
|
||||
/* Find the transform bounds for some tools (like scale,
|
||||
* perspective) that actually need the bounds for
|
||||
* initializing */
|
||||
transform_core_bounds (tool, gdisp_ptr);
|
||||
|
||||
/* Calculate the grid line endpoints */
|
||||
|
@ -255,13 +257,14 @@ transform_core_button_press (tool, bevent, gdisp_ptr)
|
|||
/* Initialize the transform tool */
|
||||
(* transform_core->trans_func) (tool, gdisp_ptr, INIT);
|
||||
|
||||
if (transform_info != NULL)
|
||||
if (transform_info != NULL && !transform_info_inited)
|
||||
{
|
||||
action_items[0].label = action_labels[tool->type - ROTATE];
|
||||
action_items[0].user_data = tool;
|
||||
action_items[1].user_data = tool;
|
||||
build_action_area (GTK_DIALOG (transform_info->shell),
|
||||
action_items, 2, 0);
|
||||
transform_info_inited = TRUE;
|
||||
}
|
||||
|
||||
/* Recalculate the transform tool */
|
||||
|
@ -349,6 +352,9 @@ transform_core_doit (tool, gdisp_ptr)
|
|||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
transform_core = (TransformCore *) tool->private;
|
||||
|
||||
/* undraw the tool before we muck around with the transform matrix */
|
||||
draw_core_pause (transform_core->core, tool);
|
||||
|
||||
/* We're going to dirty this image, but we want to keep the tool
|
||||
around
|
||||
*/
|
||||
|
@ -730,6 +736,7 @@ transform_core_free (tool)
|
|||
if (transform_info)
|
||||
info_dialog_free (transform_info);
|
||||
transform_info = NULL;
|
||||
transform_info_inited = FALSE;
|
||||
|
||||
/* Free the grid line endpoint arrays if they exist */
|
||||
if (transform_core->grid_coords != NULL)
|
||||
|
@ -806,6 +813,7 @@ transform_core_reset(tool, gdisp_ptr)
|
|||
draw_core_stop (transform_core->core, tool);
|
||||
info_dialog_popdown (transform_info);
|
||||
tool->state = INACTIVE;
|
||||
tool->gdisp_ptr = NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -846,6 +854,9 @@ transform_core_bounds (tool, gdisp_ptr)
|
|||
transform_core->cx = (transform_core->x1 + transform_core->x2) / 2;
|
||||
transform_core->cy = (transform_core->y1 + transform_core->y2) / 2;
|
||||
|
||||
/* changing the bounds invalidates any grid we may have */
|
||||
transform_core_grid_recalc (transform_core);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -860,6 +871,14 @@ transform_core_grid_density_changed ()
|
|||
return;
|
||||
|
||||
draw_core_pause (transform_core->core, active_tool);
|
||||
transform_core_grid_recalc (transform_core);
|
||||
transform_bounding_box (active_tool);
|
||||
draw_core_resume (transform_core->core, active_tool);
|
||||
}
|
||||
|
||||
static void
|
||||
transform_core_grid_recalc (TransformCore *transform_core)
|
||||
{
|
||||
if (transform_core->grid_coords != NULL)
|
||||
{
|
||||
g_free (transform_core->grid_coords);
|
||||
|
@ -872,8 +891,6 @@ transform_core_grid_density_changed ()
|
|||
}
|
||||
if (transform_tool_show_grid())
|
||||
transform_core_setup_grid (active_tool);
|
||||
transform_bounding_box (active_tool);
|
||||
draw_core_resume (transform_core->core, active_tool);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -943,12 +960,15 @@ transform_core_recalc (tool, gdisp_ptr)
|
|||
|
||||
/* Actually carry out a transformation */
|
||||
TileManager *
|
||||
transform_core_do (gimage, drawable, float_tiles, interpolation, matrix)
|
||||
transform_core_do (gimage, drawable, float_tiles, interpolation, matrix,
|
||||
progress_callback, progress_data)
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
TileManager *float_tiles;
|
||||
int interpolation;
|
||||
GimpMatrix matrix;
|
||||
progress_func_t progress_callback;
|
||||
gpointer progress_data;
|
||||
{
|
||||
PixelRegion destPR;
|
||||
TileManager *tiles;
|
||||
|
@ -1070,6 +1090,9 @@ transform_core_do (gimage, drawable, float_tiles, interpolation, matrix)
|
|||
|
||||
for (y = ty1; y < ty2; y++)
|
||||
{
|
||||
if (progress_callback && !(y & 0xf))
|
||||
(*progress_callback)(ty1, ty2, y, progress_data);
|
||||
|
||||
/* When we calculate the inverse transformation, we should transform
|
||||
* the center of each destination pixel...
|
||||
*/
|
||||
|
@ -1338,7 +1361,8 @@ transform_core_paste (gimage, drawable, tiles, new_layer)
|
|||
|
||||
if (new_layer)
|
||||
{
|
||||
layer = layer_from_tiles (gimage, drawable, tiles, "Transformation", OPAQUE_OPACITY, NORMAL_MODE);
|
||||
layer = layer_from_tiles (gimage, drawable, tiles, _("Transformation"),
|
||||
OPAQUE_OPACITY, NORMAL_MODE);
|
||||
GIMP_DRAWABLE(layer)->offset_x = tiles->x;
|
||||
GIMP_DRAWABLE(layer)->offset_y = tiles->y;
|
||||
|
||||
|
@ -1392,6 +1416,11 @@ transform_core_paste (gimage, drawable, tiles, new_layer)
|
|||
|
||||
drawable_update (GIMP_DRAWABLE(layer), 0, 0, GIMP_DRAWABLE(layer)->width, GIMP_DRAWABLE(layer)->height);
|
||||
|
||||
/* if we were operating on the floating selection, then it's boundary
|
||||
* and previews need invalidating */
|
||||
if (layer == floating_layer)
|
||||
floating_sel_invalidate (floating_layer);
|
||||
|
||||
return layer;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "draw_core.h"
|
||||
#include "temp_buf.h"
|
||||
#include "libgimp/gimpmatrix.h"
|
||||
#include "gimpprogress.h"
|
||||
|
||||
/* possible scaling functions */
|
||||
#define CREATING 0
|
||||
|
@ -136,7 +137,7 @@ void transform_core_reset (Tool *, void *);
|
|||
void transform_core_grid_density_changed (void);
|
||||
|
||||
/* transform functions */
|
||||
TileManager * transform_core_do (GImage *, GimpDrawable *, TileManager *, int, GimpMatrix);
|
||||
TileManager * transform_core_do (GImage *, GimpDrawable *, TileManager *, int, GimpMatrix, progress_func_t, gpointer);
|
||||
TileManager * transform_core_cut (GImage *, GimpDrawable *, int *);
|
||||
Layer * transform_core_paste (GImage *, GimpDrawable *, TileManager *, int);
|
||||
void transform_bounding_box (Tool*);
|
||||
|
|
|
@ -52,6 +52,7 @@
|
|||
/* variables */
|
||||
static TranInfo old_trans_info;
|
||||
InfoDialog * transform_info = NULL;
|
||||
static gboolean transform_info_inited = FALSE;
|
||||
|
||||
/* forward function declarations */
|
||||
static int transform_core_bounds (Tool *, void *);
|
||||
|
@ -59,6 +60,8 @@ static void * transform_core_recalc (Tool *, void *);
|
|||
static void transform_core_doit (Tool *, gpointer);
|
||||
static double cubic (double, int, int, int, int);
|
||||
static void transform_core_setup_grid (Tool *);
|
||||
static void transform_core_grid_recalc (TransformCore *);
|
||||
|
||||
|
||||
#define BILINEAR(jk,j1k,jk1,j1k1,dx,dy) \
|
||||
((1-dy) * ((1-dx)*jk + dx*j1k) + \
|
||||
|
@ -146,14 +149,12 @@ transform_core_button_press (tool, bevent, gdisp_ptr)
|
|||
for (i = 0; i < TRAN_INFO_SIZE; i++)
|
||||
old_trans_info [i] = transform_core->trans_info [i];
|
||||
}
|
||||
|
||||
|
||||
/* if we have already displayed the bounding box and handles,
|
||||
* check to make sure that the display which currently owns the
|
||||
* tool is the one which just received the button pressed event
|
||||
*/
|
||||
if ((transform_core->function >= CREATING) && (gdisp_ptr == tool->gdisp_ptr) &&
|
||||
transform_core->interactive)
|
||||
if ((gdisp_ptr == tool->gdisp_ptr) && transform_core->interactive)
|
||||
{
|
||||
/* start drawing the bounding box and handles... */
|
||||
draw_core_start (transform_core->core, gdisp->canvas->window, tool);
|
||||
|
@ -207,9 +208,9 @@ transform_core_button_press (tool, bevent, gdisp_ptr)
|
|||
return;
|
||||
}
|
||||
|
||||
/* if the cursor is clicked inside the current selection, show the
|
||||
* bounding box and handles...
|
||||
*/
|
||||
|
||||
/* Initialisation stuff: if the cursor is clicked inside the current
|
||||
* selection, show the bounding box and handles... */
|
||||
gdisplay_untransform_coords (gdisp, bevent->x, bevent->y, &x, &y, FALSE, FALSE);
|
||||
if ((layer = gimage_get_active_layer (gdisp->gimage)))
|
||||
{
|
||||
|
@ -227,7 +228,8 @@ transform_core_button_press (tool, bevent, gdisp_ptr)
|
|||
return;
|
||||
}
|
||||
|
||||
/* If the tool is already active, clear the current state and reset */
|
||||
/* If the tool is already active, clear the current state
|
||||
* and reset */
|
||||
if (tool->state == ACTIVE)
|
||||
transform_core_reset (tool, gdisp_ptr);
|
||||
|
||||
|
@ -243,9 +245,9 @@ transform_core_button_press (tool, bevent, gdisp_ptr)
|
|||
GDK_BUTTON_RELEASE_MASK),
|
||||
NULL, NULL, bevent->time);
|
||||
|
||||
/* Find the transform bounds for some tools (like scale, perspective)
|
||||
* that actually need the bounds for initializing
|
||||
*/
|
||||
/* Find the transform bounds for some tools (like scale,
|
||||
* perspective) that actually need the bounds for
|
||||
* initializing */
|
||||
transform_core_bounds (tool, gdisp_ptr);
|
||||
|
||||
/* Calculate the grid line endpoints */
|
||||
|
@ -255,13 +257,14 @@ transform_core_button_press (tool, bevent, gdisp_ptr)
|
|||
/* Initialize the transform tool */
|
||||
(* transform_core->trans_func) (tool, gdisp_ptr, INIT);
|
||||
|
||||
if (transform_info != NULL)
|
||||
if (transform_info != NULL && !transform_info_inited)
|
||||
{
|
||||
action_items[0].label = action_labels[tool->type - ROTATE];
|
||||
action_items[0].user_data = tool;
|
||||
action_items[1].user_data = tool;
|
||||
build_action_area (GTK_DIALOG (transform_info->shell),
|
||||
action_items, 2, 0);
|
||||
transform_info_inited = TRUE;
|
||||
}
|
||||
|
||||
/* Recalculate the transform tool */
|
||||
|
@ -349,6 +352,9 @@ transform_core_doit (tool, gdisp_ptr)
|
|||
gdisp = (GDisplay *) gdisp_ptr;
|
||||
transform_core = (TransformCore *) tool->private;
|
||||
|
||||
/* undraw the tool before we muck around with the transform matrix */
|
||||
draw_core_pause (transform_core->core, tool);
|
||||
|
||||
/* We're going to dirty this image, but we want to keep the tool
|
||||
around
|
||||
*/
|
||||
|
@ -730,6 +736,7 @@ transform_core_free (tool)
|
|||
if (transform_info)
|
||||
info_dialog_free (transform_info);
|
||||
transform_info = NULL;
|
||||
transform_info_inited = FALSE;
|
||||
|
||||
/* Free the grid line endpoint arrays if they exist */
|
||||
if (transform_core->grid_coords != NULL)
|
||||
|
@ -806,6 +813,7 @@ transform_core_reset(tool, gdisp_ptr)
|
|||
draw_core_stop (transform_core->core, tool);
|
||||
info_dialog_popdown (transform_info);
|
||||
tool->state = INACTIVE;
|
||||
tool->gdisp_ptr = NULL;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -846,6 +854,9 @@ transform_core_bounds (tool, gdisp_ptr)
|
|||
transform_core->cx = (transform_core->x1 + transform_core->x2) / 2;
|
||||
transform_core->cy = (transform_core->y1 + transform_core->y2) / 2;
|
||||
|
||||
/* changing the bounds invalidates any grid we may have */
|
||||
transform_core_grid_recalc (transform_core);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -860,6 +871,14 @@ transform_core_grid_density_changed ()
|
|||
return;
|
||||
|
||||
draw_core_pause (transform_core->core, active_tool);
|
||||
transform_core_grid_recalc (transform_core);
|
||||
transform_bounding_box (active_tool);
|
||||
draw_core_resume (transform_core->core, active_tool);
|
||||
}
|
||||
|
||||
static void
|
||||
transform_core_grid_recalc (TransformCore *transform_core)
|
||||
{
|
||||
if (transform_core->grid_coords != NULL)
|
||||
{
|
||||
g_free (transform_core->grid_coords);
|
||||
|
@ -872,8 +891,6 @@ transform_core_grid_density_changed ()
|
|||
}
|
||||
if (transform_tool_show_grid())
|
||||
transform_core_setup_grid (active_tool);
|
||||
transform_bounding_box (active_tool);
|
||||
draw_core_resume (transform_core->core, active_tool);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -943,12 +960,15 @@ transform_core_recalc (tool, gdisp_ptr)
|
|||
|
||||
/* Actually carry out a transformation */
|
||||
TileManager *
|
||||
transform_core_do (gimage, drawable, float_tiles, interpolation, matrix)
|
||||
transform_core_do (gimage, drawable, float_tiles, interpolation, matrix,
|
||||
progress_callback, progress_data)
|
||||
GImage *gimage;
|
||||
GimpDrawable *drawable;
|
||||
TileManager *float_tiles;
|
||||
int interpolation;
|
||||
GimpMatrix matrix;
|
||||
progress_func_t progress_callback;
|
||||
gpointer progress_data;
|
||||
{
|
||||
PixelRegion destPR;
|
||||
TileManager *tiles;
|
||||
|
@ -1070,6 +1090,9 @@ transform_core_do (gimage, drawable, float_tiles, interpolation, matrix)
|
|||
|
||||
for (y = ty1; y < ty2; y++)
|
||||
{
|
||||
if (progress_callback && !(y & 0xf))
|
||||
(*progress_callback)(ty1, ty2, y, progress_data);
|
||||
|
||||
/* When we calculate the inverse transformation, we should transform
|
||||
* the center of each destination pixel...
|
||||
*/
|
||||
|
@ -1338,7 +1361,8 @@ transform_core_paste (gimage, drawable, tiles, new_layer)
|
|||
|
||||
if (new_layer)
|
||||
{
|
||||
layer = layer_from_tiles (gimage, drawable, tiles, "Transformation", OPAQUE_OPACITY, NORMAL_MODE);
|
||||
layer = layer_from_tiles (gimage, drawable, tiles, _("Transformation"),
|
||||
OPAQUE_OPACITY, NORMAL_MODE);
|
||||
GIMP_DRAWABLE(layer)->offset_x = tiles->x;
|
||||
GIMP_DRAWABLE(layer)->offset_y = tiles->y;
|
||||
|
||||
|
@ -1392,6 +1416,11 @@ transform_core_paste (gimage, drawable, tiles, new_layer)
|
|||
|
||||
drawable_update (GIMP_DRAWABLE(layer), 0, 0, GIMP_DRAWABLE(layer)->width, GIMP_DRAWABLE(layer)->height);
|
||||
|
||||
/* if we were operating on the floating selection, then it's boundary
|
||||
* and previews need invalidating */
|
||||
if (layer == floating_layer)
|
||||
floating_sel_invalidate (floating_layer);
|
||||
|
||||
return layer;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include "draw_core.h"
|
||||
#include "temp_buf.h"
|
||||
#include "libgimp/gimpmatrix.h"
|
||||
#include "gimpprogress.h"
|
||||
|
||||
/* possible scaling functions */
|
||||
#define CREATING 0
|
||||
|
@ -136,7 +137,7 @@ void transform_core_reset (Tool *, void *);
|
|||
void transform_core_grid_density_changed (void);
|
||||
|
||||
/* transform functions */
|
||||
TileManager * transform_core_do (GImage *, GimpDrawable *, TileManager *, int, GimpMatrix);
|
||||
TileManager * transform_core_do (GImage *, GimpDrawable *, TileManager *, int, GimpMatrix, progress_func_t, gpointer);
|
||||
TileManager * transform_core_cut (GImage *, GimpDrawable *, int *);
|
||||
Layer * transform_core_paste (GImage *, GimpDrawable *, TileManager *, int);
|
||||
void transform_bounding_box (Tool*);
|
||||
|
|
|
@ -0,0 +1,459 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* color_notebook module (C) 1998 Austin Donnelly <austin@greenend.org.uk>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include "appenv.h"
|
||||
#include "actionarea.h"
|
||||
#include "color_notebook.h"
|
||||
|
||||
#include "libgimp/color_selector.h"
|
||||
#include "libgimp/gimpintl.h"
|
||||
|
||||
|
||||
|
||||
static void color_notebook_ok_callback (GtkWidget *, gpointer);
|
||||
static void color_notebook_cancel_callback (GtkWidget *, gpointer);
|
||||
static gint color_notebook_delete_callback (GtkWidget *, GdkEvent *, gpointer);
|
||||
static void color_notebook_update_callback (void *, int, int, int);
|
||||
static void color_notebook_page_switch (GtkWidget *, GtkNotebookPage *, guint);
|
||||
|
||||
|
||||
static ActionAreaItem action_items[2] =
|
||||
{
|
||||
{ N_("OK"), color_notebook_ok_callback, NULL, NULL },
|
||||
{ N_("Cancel"), color_notebook_cancel_callback, NULL, NULL },
|
||||
};
|
||||
|
||||
|
||||
/* information we keep on each registered colour selector */
|
||||
typedef struct _ColorSelectorInfo {
|
||||
char *name; /* label used in notebook tab */
|
||||
GimpColorSelectorMethods m;
|
||||
int refs; /* number of instances around */
|
||||
gboolean active;
|
||||
void (*death_callback) (void *data);
|
||||
void *death_data;
|
||||
struct _ColorSelectorInfo *next;
|
||||
} ColorSelectorInfo;
|
||||
|
||||
typedef struct _ColorSelectorInstance {
|
||||
_ColorNotebook *color_notebook;
|
||||
ColorSelectorInfo *info;
|
||||
GtkWidget *frame; /* main widget */
|
||||
gpointer selector_data;
|
||||
struct _ColorSelectorInstance *next;
|
||||
} ColorSelectorInstance;
|
||||
|
||||
static void selector_death (ColorSelectorInfo *info);
|
||||
|
||||
|
||||
/* master list of all registered colour selectors */
|
||||
static ColorSelectorInfo *selector_info = NULL;
|
||||
|
||||
|
||||
#define RED 0
|
||||
#define GREEN 1
|
||||
#define BLUE 2
|
||||
#define NUM_COLORS 3
|
||||
|
||||
|
||||
ColorNotebookP
|
||||
color_notebook_new (int r,
|
||||
int g,
|
||||
int b,
|
||||
ColorNotebookCallback callback,
|
||||
void *client_data,
|
||||
int wants_updates)
|
||||
{
|
||||
ColorNotebookP cnp;
|
||||
GtkWidget *label;
|
||||
ColorSelectorInfo *info;
|
||||
ColorSelectorInstance *csel;
|
||||
|
||||
g_return_val_if_fail (selector_info != NULL, NULL);
|
||||
|
||||
cnp = g_malloc (sizeof (_ColorNotebook));
|
||||
|
||||
cnp->callback = callback;
|
||||
cnp->client_data = client_data;
|
||||
cnp->wants_updates = wants_updates;
|
||||
cnp->selectors = NULL;
|
||||
cnp->cur_page = NULL;
|
||||
|
||||
cnp->values[RED] = cnp->orig_values[RED] = r & 0xff;
|
||||
cnp->values[GREEN] = cnp->orig_values[GREEN] = g & 0xff;
|
||||
cnp->values[BLUE] = cnp->orig_values[BLUE] = b & 0xff;
|
||||
|
||||
/* window hints need to stay the same, so people's window manager
|
||||
* setups still work */
|
||||
cnp->shell = gtk_dialog_new ();
|
||||
gtk_window_set_wmclass (GTK_WINDOW (cnp->shell), "color_selection", "Gimp");
|
||||
gtk_window_set_title (GTK_WINDOW (cnp->shell), _("Color Selection"));
|
||||
gtk_window_set_policy (GTK_WINDOW (cnp->shell), FALSE, FALSE, FALSE);
|
||||
|
||||
/* handle the wm close signal */
|
||||
gtk_signal_connect (GTK_OBJECT (cnp->shell), "delete_event",
|
||||
(GtkSignalFunc) color_notebook_delete_callback, cnp);
|
||||
|
||||
/* do we actually need a notebook? */
|
||||
if (selector_info->next)
|
||||
{
|
||||
cnp->notebook = gtk_notebook_new ();
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (cnp->shell)->vbox),
|
||||
cnp->notebook, TRUE, TRUE, 1);
|
||||
gtk_widget_show (cnp->notebook);
|
||||
}
|
||||
else /* only one selector */
|
||||
{
|
||||
cnp->notebook = NULL;
|
||||
}
|
||||
|
||||
/* create each registered colour selector */
|
||||
info = selector_info;
|
||||
while (info)
|
||||
{
|
||||
if (info->active)
|
||||
{
|
||||
|
||||
csel = g_malloc (sizeof (ColorSelectorInstance));
|
||||
csel->color_notebook = cnp;
|
||||
csel->info = info;
|
||||
info->refs++;
|
||||
csel->frame = info->m.new (r, g, b,
|
||||
color_notebook_update_callback, csel,
|
||||
&csel->selector_data);
|
||||
gtk_object_set_data (GTK_OBJECT (csel->frame), "gimp_color_notebook",
|
||||
csel);
|
||||
|
||||
if (cnp->notebook)
|
||||
{
|
||||
label = gtk_label_new (info->name);
|
||||
gtk_widget_show (label);
|
||||
gtk_notebook_append_page (GTK_NOTEBOOK (cnp->notebook),
|
||||
csel->frame, label);
|
||||
}
|
||||
else
|
||||
{
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (cnp->shell)->vbox),
|
||||
csel->frame, TRUE, TRUE, 1);
|
||||
}
|
||||
|
||||
gtk_widget_show (csel->frame);
|
||||
|
||||
if (!cnp->cur_page)
|
||||
cnp->cur_page = csel;
|
||||
|
||||
/* link into list of all selectors hanging off the new notebook */
|
||||
csel->next = cnp->selectors;
|
||||
cnp->selectors = csel;
|
||||
}
|
||||
|
||||
info = info->next;
|
||||
}
|
||||
|
||||
/* The action area */
|
||||
action_items[0].user_data = cnp;
|
||||
action_items[1].user_data = cnp;
|
||||
if (cnp->wants_updates)
|
||||
{
|
||||
action_items[0].label = _("Close");
|
||||
action_items[1].label = _("Revert to Old Color");
|
||||
}
|
||||
else
|
||||
{
|
||||
action_items[0].label = _("OK");
|
||||
action_items[1].label = _("Cancel");
|
||||
}
|
||||
build_action_area (GTK_DIALOG (cnp->shell), action_items, 2, 0);
|
||||
|
||||
gtk_widget_show (cnp->shell);
|
||||
|
||||
/* this must come after showing the widget, otherwise we get a
|
||||
* switch_page signal for a non-visible color selector, which is bad
|
||||
* news. */
|
||||
if (cnp->notebook)
|
||||
{
|
||||
gtk_object_set_user_data (GTK_OBJECT (cnp->notebook), cnp);
|
||||
gtk_signal_connect (GTK_OBJECT (cnp->notebook), "switch_page",
|
||||
(GtkSignalFunc)color_notebook_page_switch, NULL);
|
||||
}
|
||||
|
||||
return cnp;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
color_notebook_show (ColorNotebookP cnp)
|
||||
{
|
||||
g_return_if_fail (cnp != NULL);
|
||||
gtk_widget_show (cnp->shell);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
color_notebook_hide (ColorNotebookP cnp)
|
||||
{
|
||||
g_return_if_fail (cnp != NULL);
|
||||
gtk_widget_hide (cnp->shell);
|
||||
}
|
||||
|
||||
void
|
||||
color_notebook_free (ColorNotebookP cnp)
|
||||
{
|
||||
ColorSelectorInstance *csel, *next;
|
||||
|
||||
g_return_if_fail (cnp != NULL);
|
||||
|
||||
gtk_widget_destroy (cnp->shell);
|
||||
|
||||
/* call the free functions for all the colour selectors */
|
||||
csel = cnp->selectors;
|
||||
while (csel)
|
||||
{
|
||||
next = csel->next;
|
||||
|
||||
csel->info->m.free (csel->selector_data);
|
||||
|
||||
csel->info->refs--;
|
||||
if (csel->info->refs == 0 && !csel->info->active)
|
||||
selector_death (csel->info);
|
||||
|
||||
g_free (csel);
|
||||
csel = next;
|
||||
}
|
||||
|
||||
g_free (cnp);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
color_notebook_set_color (ColorNotebookP cnp,
|
||||
int r,
|
||||
int g,
|
||||
int b,
|
||||
int set_current)
|
||||
{
|
||||
ColorSelectorInstance *csel;
|
||||
g_return_if_fail (cnp != NULL);
|
||||
|
||||
cnp->orig_values[RED] = r;
|
||||
cnp->orig_values[GREEN] = g;
|
||||
cnp->orig_values[BLUE] = b;
|
||||
|
||||
if (set_current)
|
||||
{
|
||||
cnp->values[RED] = r;
|
||||
cnp->values[GREEN] = g;
|
||||
cnp->values[BLUE] = b;
|
||||
}
|
||||
|
||||
csel = cnp->cur_page;
|
||||
csel->info->m.setcolor (csel->selector_data, r, g, b, set_current);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Called by a colour selector on user selection of a colour */
|
||||
static void
|
||||
color_notebook_update_callback (void *data, int r, int g, int b)
|
||||
{
|
||||
ColorSelectorInstance *csel;
|
||||
ColorNotebookP cnp;
|
||||
|
||||
g_return_if_fail (data != NULL);
|
||||
|
||||
csel = (ColorSelectorInstance *) data;
|
||||
cnp = csel->color_notebook;
|
||||
|
||||
cnp->values[RED] = r;
|
||||
cnp->values[GREEN] = g;
|
||||
cnp->values[BLUE] = b;
|
||||
|
||||
if (cnp->wants_updates && cnp->callback)
|
||||
{
|
||||
(* cnp->callback) (cnp->values[RED],
|
||||
cnp->values[GREEN],
|
||||
cnp->values[BLUE],
|
||||
COLOR_NOTEBOOK_UPDATE,
|
||||
cnp->client_data);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
static void
|
||||
color_notebook_ok_callback (GtkWidget *w,
|
||||
gpointer client_data)
|
||||
{
|
||||
ColorNotebookP cnp;
|
||||
|
||||
cnp = (ColorNotebookP) client_data;
|
||||
|
||||
if (cnp->callback)
|
||||
(* cnp->callback) (cnp->values[RED],
|
||||
cnp->values[GREEN],
|
||||
cnp->values[BLUE],
|
||||
COLOR_NOTEBOOK_OK,
|
||||
cnp->client_data);
|
||||
}
|
||||
|
||||
|
||||
static gint
|
||||
color_notebook_delete_callback (GtkWidget *w,
|
||||
GdkEvent *e,
|
||||
gpointer client_data)
|
||||
{
|
||||
color_notebook_cancel_callback (w, client_data);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
color_notebook_cancel_callback (GtkWidget *w,
|
||||
gpointer client_data)
|
||||
{
|
||||
ColorNotebookP cnp;
|
||||
|
||||
cnp = (ColorNotebookP) client_data;
|
||||
|
||||
if (cnp->callback)
|
||||
(* cnp->callback) (cnp->orig_values[RED],
|
||||
cnp->orig_values[GREEN],
|
||||
cnp->orig_values[BLUE],
|
||||
COLOR_NOTEBOOK_CANCEL,
|
||||
cnp->client_data);
|
||||
}
|
||||
|
||||
static void
|
||||
color_notebook_page_switch (GtkWidget *w,
|
||||
GtkNotebookPage *page,
|
||||
guint page_num)
|
||||
{
|
||||
ColorNotebookP cnp;
|
||||
ColorSelectorInstance *csel;
|
||||
|
||||
cnp = gtk_object_get_user_data (GTK_OBJECT (w));
|
||||
csel = gtk_object_get_data (GTK_OBJECT(page->child), "gimp_color_notebook");
|
||||
|
||||
g_return_if_fail (cnp != NULL && csel != NULL);
|
||||
|
||||
cnp->cur_page = csel;
|
||||
csel->info->m.setcolor (csel->selector_data,
|
||||
cnp->values[RED],
|
||||
cnp->values[GREEN],
|
||||
cnp->values[BLUE],
|
||||
TRUE);
|
||||
}
|
||||
|
||||
/**************************************************************/
|
||||
/* Registration functions */
|
||||
|
||||
|
||||
GimpColorSelectorID
|
||||
gimp_color_selector_register (const char *name,
|
||||
GimpColorSelectorMethods *methods)
|
||||
{
|
||||
ColorSelectorInfo *info;
|
||||
|
||||
/* check the name is unique */
|
||||
info = selector_info;
|
||||
while (info)
|
||||
{
|
||||
if (!strcmp (info->name, name))
|
||||
return NULL;
|
||||
info = info->next;
|
||||
}
|
||||
|
||||
info = g_malloc (sizeof (ColorSelectorInfo));
|
||||
|
||||
info->name = g_strdup (name);
|
||||
info->m = *methods;
|
||||
info->refs = 0;
|
||||
info->active = TRUE;
|
||||
|
||||
info->next = selector_info;
|
||||
selector_info = info;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
|
||||
gboolean
|
||||
gimp_color_selector_unregister (GimpColorSelectorID id,
|
||||
void (*callback)(void *data),
|
||||
void *data)
|
||||
{
|
||||
ColorSelectorInfo *info;
|
||||
|
||||
info = selector_info;
|
||||
while (info)
|
||||
{
|
||||
if (info == id)
|
||||
{
|
||||
info->active = FALSE;
|
||||
info->death_callback = callback;
|
||||
info->death_data = data;
|
||||
if (info->refs == 0)
|
||||
selector_death (info);
|
||||
return TRUE;
|
||||
}
|
||||
info = info->next;
|
||||
}
|
||||
|
||||
g_warning ("unknown color selector id %p", id);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
selector_death (ColorSelectorInfo *info)
|
||||
{
|
||||
ColorSelectorInfo *here, *prev;
|
||||
|
||||
here = selector_info;
|
||||
prev = NULL;
|
||||
while (here)
|
||||
{
|
||||
if (here == info)
|
||||
{
|
||||
if (prev)
|
||||
prev->next = info->next;
|
||||
else
|
||||
selector_info = info->next;
|
||||
|
||||
if (info->death_callback)
|
||||
(*info->death_callback) (info->death_data);
|
||||
|
||||
g_free (info->name);
|
||||
g_free (info);
|
||||
|
||||
return;
|
||||
}
|
||||
prev = here;
|
||||
here = here->next;
|
||||
}
|
||||
|
||||
g_warning ("color selector %p not found, can't happen!", info);
|
||||
}
|
||||
|
||||
|
||||
/* End of color_notebook.c */
|
|
@ -0,0 +1,53 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __COLOR_NOTEBOOK_H__
|
||||
#define __COLOR_NOTEBOOK_H__
|
||||
|
||||
typedef enum {
|
||||
COLOR_NOTEBOOK_OK,
|
||||
COLOR_NOTEBOOK_CANCEL,
|
||||
COLOR_NOTEBOOK_UPDATE
|
||||
} ColorNotebookState;
|
||||
|
||||
typedef struct _ColorNotebook _ColorNotebook, *ColorNotebookP;
|
||||
typedef void (*ColorNotebookCallback) (int, int, int, ColorNotebookState,
|
||||
void *);
|
||||
|
||||
struct _ColorSelectorInstance;
|
||||
|
||||
struct _ColorNotebook {
|
||||
GtkWidget *shell;
|
||||
GtkWidget *notebook;
|
||||
int values[3];
|
||||
int orig_values[3];
|
||||
ColorNotebookCallback callback;
|
||||
void *client_data;
|
||||
int wants_updates;
|
||||
struct _ColorSelectorInstance *selectors;
|
||||
struct _ColorSelectorInstance *cur_page;
|
||||
};
|
||||
|
||||
ColorNotebookP color_notebook_new (int, int, int, ColorNotebookCallback, void *, int);
|
||||
void color_notebook_show (ColorNotebookP);
|
||||
void color_notebook_hide (ColorNotebookP);
|
||||
void color_notebook_free (ColorNotebookP);
|
||||
void color_notebook_set_color (ColorNotebookP, int, int, int, int);
|
||||
|
||||
|
||||
#endif /* __COLOR_NOTEBOOK_H__ */
|
|
@ -20,7 +20,7 @@
|
|||
#include <stdlib.h>
|
||||
#include "appenv.h"
|
||||
#include "color_panel.h"
|
||||
#include "color_select.h"
|
||||
#include "color_notebook.h"
|
||||
#include "colormaps.h"
|
||||
|
||||
#define EVENT_MASK GDK_EXPOSURE_MASK | GDK_BUTTON_PRESS_MASK
|
||||
|
@ -32,13 +32,13 @@ struct _ColorPanelPrivate
|
|||
GtkWidget *drawing_area;
|
||||
GdkGC *gc;
|
||||
|
||||
ColorSelectP color_select;
|
||||
int color_select_active;
|
||||
ColorNotebookP color_notebook;
|
||||
int color_notebook_active;
|
||||
};
|
||||
|
||||
static void color_panel_draw (ColorPanel *);
|
||||
static gint color_panel_events (GtkWidget *area, GdkEvent *event);
|
||||
static void color_panel_select_callback (int, int, int, ColorSelectState, void *);
|
||||
static void color_panel_select_callback (int, int, int, ColorNotebookState, void *);
|
||||
|
||||
|
||||
ColorPanel *
|
||||
|
@ -52,8 +52,8 @@ color_panel_new (unsigned char *initial,
|
|||
|
||||
color_panel = g_new (ColorPanel, 1);
|
||||
private = g_new (ColorPanelPrivate, 1);
|
||||
private->color_select = NULL;
|
||||
private->color_select_active = 0;
|
||||
private->color_notebook = NULL;
|
||||
private->color_notebook_active = 0;
|
||||
private->gc = NULL;
|
||||
color_panel->private_part = private;
|
||||
|
||||
|
@ -85,11 +85,11 @@ color_panel_free (ColorPanel *color_panel)
|
|||
|
||||
private = (ColorPanelPrivate *) color_panel->private_part;
|
||||
|
||||
/* make sure we hide and free color_select */
|
||||
if (private->color_select)
|
||||
/* make sure we hide and free color_notebook */
|
||||
if (private->color_notebook)
|
||||
{
|
||||
color_select_hide (private->color_select);
|
||||
color_select_free (private->color_select);
|
||||
color_notebook_hide (private->color_notebook);
|
||||
color_notebook_free (private->color_notebook);
|
||||
}
|
||||
|
||||
if (private->gc)
|
||||
|
@ -144,24 +144,24 @@ color_panel_events (GtkWidget *widget,
|
|||
|
||||
if (bevent->button == 1)
|
||||
{
|
||||
if (! private->color_select)
|
||||
if (! private->color_notebook)
|
||||
{
|
||||
private->color_select = color_select_new (color_panel->color[0],
|
||||
private->color_notebook = color_notebook_new (color_panel->color[0],
|
||||
color_panel->color[1],
|
||||
color_panel->color[2],
|
||||
color_panel_select_callback,
|
||||
color_panel,
|
||||
FALSE);
|
||||
private->color_select_active = 1;
|
||||
private->color_notebook_active = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! private->color_select_active)
|
||||
color_select_show (private->color_select);
|
||||
color_select_set_color (private->color_select,
|
||||
color_panel->color[0],
|
||||
color_panel->color[1],
|
||||
color_panel->color[2], 1);
|
||||
if (! private->color_notebook_active)
|
||||
color_notebook_show (private->color_notebook);
|
||||
color_notebook_set_color (private->color_notebook,
|
||||
color_panel->color[0],
|
||||
color_panel->color[1],
|
||||
color_panel->color[2], 1);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -177,7 +177,7 @@ static void
|
|||
color_panel_select_callback (int r,
|
||||
int g,
|
||||
int b,
|
||||
ColorSelectState state,
|
||||
ColorNotebookState state,
|
||||
void *client_data)
|
||||
{
|
||||
ColorPanel *color_panel;
|
||||
|
@ -186,21 +186,21 @@ color_panel_select_callback (int r,
|
|||
color_panel = (ColorPanel *) client_data;
|
||||
private = (ColorPanelPrivate *) color_panel->private_part;
|
||||
|
||||
if (private->color_select)
|
||||
if (private->color_notebook)
|
||||
{
|
||||
switch (state) {
|
||||
case COLOR_SELECT_UPDATE:
|
||||
case COLOR_NOTEBOOK_UPDATE:
|
||||
break;
|
||||
case COLOR_SELECT_OK:
|
||||
case COLOR_NOTEBOOK_OK:
|
||||
color_panel->color[0] = r;
|
||||
color_panel->color[1] = g;
|
||||
color_panel->color[2] = b;
|
||||
|
||||
color_panel_draw (color_panel);
|
||||
/* Fallthrough */
|
||||
case COLOR_SELECT_CANCEL:
|
||||
color_select_hide (private->color_select);
|
||||
private->color_select_active = 0;
|
||||
case COLOR_NOTEBOOK_CANCEL:
|
||||
color_notebook_hide (private->color_notebook);
|
||||
private->color_notebook_active = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
#include <stdlib.h>
|
||||
#include "appenv.h"
|
||||
#include "color_area.h"
|
||||
#include "color_select.h"
|
||||
#include "color_notebook.h"
|
||||
#include "colormaps.h"
|
||||
#include "palette.h"
|
||||
|
||||
|
@ -37,8 +37,8 @@ static GtkWidget *color_area = NULL;
|
|||
static GdkPixmap *color_area_pixmap = NULL;
|
||||
static GdkPixmap *default_pixmap = NULL;
|
||||
static GdkPixmap *swap_pixmap = NULL;
|
||||
static ColorSelectP color_select = NULL;
|
||||
static int color_select_active = 0;
|
||||
static ColorNotebookP color_notebook = NULL;
|
||||
static int color_notebook_active = 0;
|
||||
static int edit_color;
|
||||
static unsigned char revert_fg_r, revert_fg_g, revert_fg_b;
|
||||
static unsigned char revert_bg_r, revert_bg_g, revert_bg_b;
|
||||
|
@ -195,25 +195,25 @@ static void
|
|||
color_area_select_callback (int r,
|
||||
int g,
|
||||
int b,
|
||||
ColorSelectState state,
|
||||
ColorNotebookState state,
|
||||
void *client_data)
|
||||
{
|
||||
if (color_select)
|
||||
if (color_notebook)
|
||||
{
|
||||
switch (state) {
|
||||
case COLOR_SELECT_OK:
|
||||
color_select_hide (color_select);
|
||||
color_select_active = 0;
|
||||
case COLOR_NOTEBOOK_OK:
|
||||
color_notebook_hide (color_notebook);
|
||||
color_notebook_active = 0;
|
||||
/* Fallthrough */
|
||||
case COLOR_SELECT_UPDATE:
|
||||
case COLOR_NOTEBOOK_UPDATE:
|
||||
if (edit_color == FOREGROUND)
|
||||
palette_set_foreground (r, g, b);
|
||||
else
|
||||
palette_set_background (r, g, b);
|
||||
break;
|
||||
case COLOR_SELECT_CANCEL:
|
||||
color_select_hide (color_select);
|
||||
color_select_active = 0;
|
||||
case COLOR_NOTEBOOK_CANCEL:
|
||||
color_notebook_hide (color_notebook);
|
||||
color_notebook_active = 0;
|
||||
palette_set_foreground (revert_fg_r, revert_fg_g, revert_fg_b);
|
||||
palette_set_background (revert_bg_r, revert_bg_g, revert_bg_b);
|
||||
}
|
||||
|
@ -225,7 +225,7 @@ color_area_edit (void)
|
|||
{
|
||||
unsigned char r, g, b;
|
||||
|
||||
if (!color_select_active)
|
||||
if (!color_notebook_active)
|
||||
{
|
||||
palette_get_foreground (&revert_fg_r, &revert_fg_g, &revert_fg_b);
|
||||
palette_get_background (&revert_bg_r, &revert_bg_g, &revert_bg_b);
|
||||
|
@ -241,19 +241,19 @@ color_area_edit (void)
|
|||
edit_color = BACKGROUND;
|
||||
}
|
||||
|
||||
if (! color_select)
|
||||
if (! color_notebook)
|
||||
{
|
||||
color_select = color_select_new (r, g, b, color_area_select_callback, NULL, TRUE);
|
||||
color_select_active = 1;
|
||||
color_notebook = color_notebook_new (r, g, b, color_area_select_callback, NULL, TRUE);
|
||||
color_notebook_active = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! color_select_active)
|
||||
color_select_show (color_select);
|
||||
if (! color_notebook_active)
|
||||
color_notebook_show (color_notebook);
|
||||
else
|
||||
gdk_window_raise (color_select->shell->window);
|
||||
gdk_window_raise (color_notebook->shell->window);
|
||||
|
||||
color_select_set_color (color_select, r, g, b, 1);
|
||||
color_notebook_set_color (color_notebook, r, g, b, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,6 +73,8 @@
|
|||
# the GIMP if the script-fu plug-in is never run.
|
||||
(script-fu-path "${gimp_dir}/scripts:${gimp_data_dir}/scripts")
|
||||
|
||||
# Set the path to modules that are to be initialized at startup
|
||||
(module-path "${gimp_dir}/modules:${gimp_plugin_dir}/modules")
|
||||
|
||||
# The tile cache is used to make sure the gimp doesn't thrash
|
||||
# tiles between memory and disk. Setting this value higher will
|
||||
|
|
|
@ -73,6 +73,8 @@
|
|||
# the GIMP if the script-fu plug-in is never run.
|
||||
(script-fu-path "${gimp_dir}/scripts:${gimp_data_dir}/scripts")
|
||||
|
||||
# Set the path to modules that are to be initialized at startup
|
||||
(module-path "${gimp_dir}/modules:${gimp_plugin_dir}/modules")
|
||||
|
||||
# The tile cache is used to make sure the gimp doesn't thrash
|
||||
# tiles between memory and disk. Setting this value higher will
|
||||
|
|
|
@ -61,17 +61,19 @@ libgimpui_la_SOURCES = \
|
|||
gimppatternmenu.c
|
||||
|
||||
gimpinclude_HEADERS = \
|
||||
gimp.h \
|
||||
gimpentry.h \
|
||||
gimpenums.h \
|
||||
gimpfeatures.h \
|
||||
gimpmatrix.h \
|
||||
gimpmenu.h \
|
||||
gimpui.h \
|
||||
gimpintl.h \
|
||||
gserialize.h \
|
||||
parasite.h \
|
||||
parasiteF.h \
|
||||
color_selector.h \
|
||||
gimp.h \
|
||||
gimpentry.h \
|
||||
gimpenums.h \
|
||||
gimpfeatures.h \
|
||||
gimpmatrix.h \
|
||||
gimpmenu.h \
|
||||
gimpmodule.h \
|
||||
gimpui.h \
|
||||
gimpintl.h \
|
||||
gserialize.h \
|
||||
parasite.h \
|
||||
parasiteF.h \
|
||||
parasiteP.h
|
||||
|
||||
libgimp_la_LDFLAGS = \
|
||||
|
|
|
@ -0,0 +1,97 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* Colour selector module (C) 1999 Austin Donnelly <austin@greenend.org.uk>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __COLOR_SELECTOR_H__
|
||||
#define __COLOR_SELECTOR_H__
|
||||
|
||||
|
||||
/********************************/
|
||||
/* color selector registration */
|
||||
|
||||
|
||||
/* A function of this type should be called by the color selector each
|
||||
* time the user modifies the selected color. */
|
||||
typedef void (*GimpColorSelector_Callback)(void *data, int r, int g, int b);
|
||||
|
||||
|
||||
/* A function of this type is called to create a new instance of the
|
||||
* color selector. The new selector should set its current color to
|
||||
* the RGB triple given (each component is in the range 0 - 255
|
||||
* inclusive, with white at 255,255,255 and black at 0,0,0).
|
||||
*
|
||||
* The selector should call "cb" with argument "data" each time the
|
||||
* user modifies the selected color.
|
||||
*
|
||||
* The selector must return a GtkWidget which implements the color
|
||||
* selection UI. The selector can optionally return "selector_data",
|
||||
* an opaque pointer which will be passed in to subsequent invokations
|
||||
* on the selector. */
|
||||
typedef GtkWidget * (*GimpColorSelector_NewFunc)(int r, int g, int b,
|
||||
GimpColorSelector_Callback cb,
|
||||
void *data,
|
||||
/* RETURNS: */
|
||||
void **selector_data);
|
||||
|
||||
/* A function of this type is called when the color selector is no
|
||||
* longer required. This function should not free widgets that are
|
||||
* containted within the UI widget returned by new(), since they are
|
||||
* destroyed on behalf of the selector by the caller of this
|
||||
* function. */
|
||||
typedef void (*GimpColorSelector_FreeFunc)(void *selector_data);
|
||||
|
||||
|
||||
/* A function of this type is called to change the selector's current
|
||||
* color. The required color is specified as in the new() function.
|
||||
* If the "set_current" parameter is FALSE, then only the old color
|
||||
* should be set - if "set_current" is TRUE, both the old color and
|
||||
* the current color should be set to the RGB triple given. This
|
||||
* function merely gives a hint to the color selector; the selector
|
||||
* can choose to ignore this information. */
|
||||
typedef void (*GimpColorSelector_SetColorFunc)(void *selector_data,
|
||||
int r, int g, int b,
|
||||
int set_current);
|
||||
|
||||
typedef struct {
|
||||
GimpColorSelector_NewFunc new;
|
||||
GimpColorSelector_FreeFunc free;
|
||||
GimpColorSelector_SetColorFunc setcolor;
|
||||
} GimpColorSelectorMethods;
|
||||
|
||||
typedef void *GimpColorSelectorID;
|
||||
|
||||
/* Register a color selector. Returns an identifier for the color
|
||||
* selector on success, or NULL if the name is already in use. Both
|
||||
* the name and method table are internalised, so may be freed after
|
||||
* this call. */
|
||||
GimpColorSelectorID gimp_color_selector_register (const char *name,
|
||||
GimpColorSelectorMethods *methods);
|
||||
|
||||
/* Remove the selector "id" from active service. New instances of the
|
||||
* selector will not be created, but existing ones are allowed to
|
||||
* continue. If "callback" is non-NULL, it will be called once all
|
||||
* instances have finished. The callback could be used to unload
|
||||
* dynamiclly loaded code, for example.
|
||||
*
|
||||
* Returns TRUE on success, FALSE if "id" was not found. */
|
||||
gboolean gimp_color_selector_unregister (GimpColorSelectorID id,
|
||||
void (*callback)(void *data),
|
||||
void *data);
|
||||
|
||||
#endif /* __COLOR_SELECTOR_H__ */
|
|
@ -0,0 +1,97 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* Colour selector module (C) 1999 Austin Donnelly <austin@greenend.org.uk>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __COLOR_SELECTOR_H__
|
||||
#define __COLOR_SELECTOR_H__
|
||||
|
||||
|
||||
/********************************/
|
||||
/* color selector registration */
|
||||
|
||||
|
||||
/* A function of this type should be called by the color selector each
|
||||
* time the user modifies the selected color. */
|
||||
typedef void (*GimpColorSelector_Callback)(void *data, int r, int g, int b);
|
||||
|
||||
|
||||
/* A function of this type is called to create a new instance of the
|
||||
* color selector. The new selector should set its current color to
|
||||
* the RGB triple given (each component is in the range 0 - 255
|
||||
* inclusive, with white at 255,255,255 and black at 0,0,0).
|
||||
*
|
||||
* The selector should call "cb" with argument "data" each time the
|
||||
* user modifies the selected color.
|
||||
*
|
||||
* The selector must return a GtkWidget which implements the color
|
||||
* selection UI. The selector can optionally return "selector_data",
|
||||
* an opaque pointer which will be passed in to subsequent invokations
|
||||
* on the selector. */
|
||||
typedef GtkWidget * (*GimpColorSelector_NewFunc)(int r, int g, int b,
|
||||
GimpColorSelector_Callback cb,
|
||||
void *data,
|
||||
/* RETURNS: */
|
||||
void **selector_data);
|
||||
|
||||
/* A function of this type is called when the color selector is no
|
||||
* longer required. This function should not free widgets that are
|
||||
* containted within the UI widget returned by new(), since they are
|
||||
* destroyed on behalf of the selector by the caller of this
|
||||
* function. */
|
||||
typedef void (*GimpColorSelector_FreeFunc)(void *selector_data);
|
||||
|
||||
|
||||
/* A function of this type is called to change the selector's current
|
||||
* color. The required color is specified as in the new() function.
|
||||
* If the "set_current" parameter is FALSE, then only the old color
|
||||
* should be set - if "set_current" is TRUE, both the old color and
|
||||
* the current color should be set to the RGB triple given. This
|
||||
* function merely gives a hint to the color selector; the selector
|
||||
* can choose to ignore this information. */
|
||||
typedef void (*GimpColorSelector_SetColorFunc)(void *selector_data,
|
||||
int r, int g, int b,
|
||||
int set_current);
|
||||
|
||||
typedef struct {
|
||||
GimpColorSelector_NewFunc new;
|
||||
GimpColorSelector_FreeFunc free;
|
||||
GimpColorSelector_SetColorFunc setcolor;
|
||||
} GimpColorSelectorMethods;
|
||||
|
||||
typedef void *GimpColorSelectorID;
|
||||
|
||||
/* Register a color selector. Returns an identifier for the color
|
||||
* selector on success, or NULL if the name is already in use. Both
|
||||
* the name and method table are internalised, so may be freed after
|
||||
* this call. */
|
||||
GimpColorSelectorID gimp_color_selector_register (const char *name,
|
||||
GimpColorSelectorMethods *methods);
|
||||
|
||||
/* Remove the selector "id" from active service. New instances of the
|
||||
* selector will not be created, but existing ones are allowed to
|
||||
* continue. If "callback" is non-NULL, it will be called once all
|
||||
* instances have finished. The callback could be used to unload
|
||||
* dynamiclly loaded code, for example.
|
||||
*
|
||||
* Returns TRUE on success, FALSE if "id" was not found. */
|
||||
gboolean gimp_color_selector_unregister (GimpColorSelectorID id,
|
||||
void (*callback)(void *data),
|
||||
void *data);
|
||||
|
||||
#endif /* __COLOR_SELECTOR_H__ */
|
|
@ -0,0 +1,44 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* gimpmodule.h (C) 1999 Austin Donnelly <austin@greenend.org.uk>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMPMODULE_H__
|
||||
#define __GIMPMODULE_H__
|
||||
|
||||
#include <gmodule.h>
|
||||
|
||||
|
||||
typedef enum {
|
||||
GIMP_MODULE_OK,
|
||||
GIMP_MODULE_UNLOAD
|
||||
} GimpModuleStatus;
|
||||
|
||||
|
||||
/* GIMP modules should G_MODULE_EXPORT a function named "module_init"
|
||||
* of the following type: */
|
||||
typedef GimpModuleStatus (*GimpModuleInitFunc) (void);
|
||||
|
||||
/* This function is called by the GIMP at startup, and should return
|
||||
* either GIMP_MODULE_OK if it sucessfully initialised or
|
||||
* GIMP_MODULE_UNLOAD if the module failed to hook whatever functions
|
||||
* it wanted. GIMP_MODULE_UNLOAD causes the module to be closed, so
|
||||
* the module must not have registered any internal functions or given
|
||||
* out pointers to its data to anyone. */
|
||||
|
||||
#endif /* __GIMPMODULE_H__ */
|
|
@ -20,6 +20,7 @@
|
|||
#include "appenv.h"
|
||||
#include "actionarea.h"
|
||||
#include "color_select.h"
|
||||
#include "libgimp/color_selector.h"
|
||||
#include "colormaps.h"
|
||||
#include "errors.h"
|
||||
#include "gimprc.h"
|
||||
|
@ -76,6 +77,8 @@ struct _ColorSelectFill {
|
|||
ColorSelectFillUpdateProc update;
|
||||
};
|
||||
|
||||
static GtkWidget * color_select_widget_new (ColorSelectP, int, int, int);
|
||||
|
||||
static void color_select_update (ColorSelectP, ColorSelectUpdateType);
|
||||
static void color_select_update_caller (ColorSelectP);
|
||||
static void color_select_update_values (ColorSelectP);
|
||||
|
@ -117,6 +120,18 @@ static void color_select_update_hue_saturation (ColorSelectFill *);
|
|||
static void color_select_update_hue_value (ColorSelectFill *);
|
||||
static void color_select_update_saturation_value (ColorSelectFill *);
|
||||
|
||||
static GtkWidget * color_select_notebook_new (int, int, int,
|
||||
GimpColorSelector_Callback,
|
||||
void *, void **);
|
||||
static void color_select_notebook_free (void *);
|
||||
static void color_select_notebook_setcolor (void *, int, int, int, int);
|
||||
static void color_select_notebook_update_callback (int, int, int,
|
||||
ColorSelectState, void *);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static ColorSelectFillUpdateProc update_procs[] =
|
||||
{
|
||||
color_select_update_hue,
|
||||
|
@ -147,26 +162,8 @@ color_select_new (int r,
|
|||
void *client_data,
|
||||
int wants_updates)
|
||||
{
|
||||
/* static char *toggle_titles[6] = { "Hue", "Saturation", "Value", "Red", "Green", "Blue" }; */
|
||||
static char *toggle_titles[6] = { "H", "S", "V", "R", "G", "B" };
|
||||
static gfloat slider_max_vals[6] = { 360, 100, 100, 255, 255, 255 };
|
||||
static gfloat slider_incs[6] = { 0.1, 0.1, 0.1, 1.0, 1.0, 1.0 };
|
||||
|
||||
ColorSelectP csp;
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *main_hbox;
|
||||
GtkWidget *xy_frame;
|
||||
GtkWidget *z_frame;
|
||||
GtkWidget *colors_frame;
|
||||
GtkWidget *colors_hbox;
|
||||
GtkWidget *right_vbox;
|
||||
GtkWidget *table;
|
||||
GtkWidget *slider;
|
||||
GtkWidget *hex_hbox;
|
||||
GtkWidget *label;
|
||||
GSList *group;
|
||||
char buffer[16];
|
||||
int i;
|
||||
|
||||
csp = g_malloc (sizeof (_ColorSelect));
|
||||
|
||||
|
@ -193,10 +190,58 @@ color_select_new (int r,
|
|||
gtk_signal_connect (GTK_OBJECT (csp->shell), "delete_event",
|
||||
(GtkSignalFunc) color_select_delete_callback, csp);
|
||||
|
||||
main_vbox = color_select_widget_new (csp, r, g, b);
|
||||
gtk_widget_show (main_vbox);
|
||||
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (csp->shell)->vbox), main_vbox, TRUE, TRUE, 0);
|
||||
|
||||
/* The action area */
|
||||
action_items[0].user_data = csp;
|
||||
action_items[1].user_data = csp;
|
||||
if (csp->wants_updates)
|
||||
{
|
||||
action_items[0].label = _("Close");
|
||||
action_items[1].label = _("Revert to Old Color");
|
||||
}
|
||||
else
|
||||
{
|
||||
action_items[0].label = _("OK");
|
||||
action_items[1].label = _("Cancel");
|
||||
}
|
||||
build_action_area (GTK_DIALOG (csp->shell), action_items, 2, 0);
|
||||
|
||||
color_select_image_fill (csp->z_color, csp->z_color_fill, csp->values);
|
||||
color_select_image_fill (csp->xy_color, csp->xy_color_fill, csp->values);
|
||||
|
||||
gtk_widget_show (csp->shell);
|
||||
|
||||
return csp;
|
||||
}
|
||||
|
||||
static GtkWidget *
|
||||
color_select_widget_new (ColorSelectP csp, int r, int g, int b)
|
||||
{
|
||||
static char *toggle_titles[6] = { "H", "S", "V", "R", "G", "B" };
|
||||
static gfloat slider_max_vals[6] = { 360, 100, 100, 255, 255, 255 };
|
||||
static gfloat slider_incs[6] = { 0.1, 0.1, 0.1, 1.0, 1.0, 1.0 };
|
||||
|
||||
GtkWidget *main_vbox;
|
||||
GtkWidget *main_hbox;
|
||||
GtkWidget *xy_frame;
|
||||
GtkWidget *z_frame;
|
||||
GtkWidget *colors_frame;
|
||||
GtkWidget *colors_hbox;
|
||||
GtkWidget *right_vbox;
|
||||
GtkWidget *table;
|
||||
GtkWidget *slider;
|
||||
GtkWidget *hex_hbox;
|
||||
GtkWidget *label;
|
||||
GSList *group;
|
||||
char buffer[16];
|
||||
int i;
|
||||
|
||||
main_vbox = gtk_vbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 2);
|
||||
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (csp->shell)->vbox), main_vbox, TRUE, TRUE, 0);
|
||||
gtk_widget_show (main_vbox);
|
||||
|
||||
main_hbox = gtk_hbox_new (FALSE, 2);
|
||||
gtk_container_set_border_width (GTK_CONTAINER (main_hbox), 0);
|
||||
|
@ -341,29 +386,25 @@ color_select_new (int r,
|
|||
gtk_box_pack_end (GTK_BOX (hex_hbox), label, FALSE, FALSE, 0);
|
||||
gtk_widget_show (label);
|
||||
|
||||
/* The action area */
|
||||
action_items[0].user_data = csp;
|
||||
action_items[1].user_data = csp;
|
||||
if (csp->wants_updates)
|
||||
{
|
||||
action_items[0].label = _("Close");
|
||||
action_items[1].label = _("Revert to Old Color");
|
||||
}
|
||||
else
|
||||
{
|
||||
action_items[0].label = _("OK");
|
||||
action_items[1].label = _("Cancel");
|
||||
}
|
||||
build_action_area (GTK_DIALOG (csp->shell), action_items, 2, 0);
|
||||
|
||||
color_select_image_fill (csp->z_color, csp->z_color_fill, csp->values);
|
||||
color_select_image_fill (csp->xy_color, csp->xy_color_fill, csp->values);
|
||||
|
||||
gtk_widget_show (csp->shell);
|
||||
|
||||
return csp;
|
||||
return main_vbox;
|
||||
}
|
||||
|
||||
|
||||
/* Register the GIMP colour selector with the color notebook */
|
||||
void
|
||||
color_select_init (void)
|
||||
{
|
||||
GimpColorSelectorMethods methods =
|
||||
{
|
||||
color_select_notebook_new,
|
||||
color_select_notebook_free,
|
||||
color_select_notebook_setcolor
|
||||
};
|
||||
|
||||
gimp_color_selector_register ("GIMP", &methods);
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
color_select_show (ColorSelectP csp)
|
||||
{
|
||||
|
@ -383,7 +424,8 @@ color_select_free (ColorSelectP csp)
|
|||
{
|
||||
if (csp)
|
||||
{
|
||||
gtk_widget_destroy (csp->shell);
|
||||
if (csp->shell)
|
||||
gtk_widget_destroy (csp->shell);
|
||||
gdk_gc_destroy (csp->gc);
|
||||
g_free (csp);
|
||||
}
|
||||
|
@ -1973,3 +2015,96 @@ color_select_update_saturation_value (ColorSelectFill *csf)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*****************************/
|
||||
/* Colour notebook glue */
|
||||
|
||||
typedef struct {
|
||||
GimpColorSelector_Callback callback;
|
||||
void *client_data;
|
||||
ColorSelectP csp;
|
||||
GtkWidget *main_vbox;
|
||||
} notebook_glue;
|
||||
|
||||
|
||||
static GtkWidget *
|
||||
color_select_notebook_new (int r, int g, int b,
|
||||
GimpColorSelector_Callback callback, void *client_data,
|
||||
/* RETURNS: */
|
||||
void **selector_data)
|
||||
{
|
||||
ColorSelectP csp;
|
||||
notebook_glue *glue;
|
||||
|
||||
glue = g_malloc (sizeof (notebook_glue));
|
||||
|
||||
csp = g_malloc (sizeof (_ColorSelect));
|
||||
|
||||
glue->csp = csp;
|
||||
glue->callback = callback;
|
||||
glue->client_data = client_data;
|
||||
|
||||
csp->callback = color_select_notebook_update_callback;
|
||||
csp->client_data = glue;
|
||||
csp->z_color_fill = HUE;
|
||||
csp->xy_color_fill = SATURATION_VALUE;
|
||||
csp->gc = NULL;
|
||||
csp->wants_updates = TRUE;
|
||||
|
||||
csp->values[RED] = csp->orig_values[0] = r;
|
||||
csp->values[GREEN] = csp->orig_values[1] = g;
|
||||
csp->values[BLUE] = csp->orig_values[2] = b;
|
||||
color_select_update_hsv_values (csp);
|
||||
color_select_update_pos (csp);
|
||||
|
||||
glue->main_vbox = color_select_widget_new (csp, r, g, b);
|
||||
|
||||
/* the shell is provided by the notebook */
|
||||
csp->shell = NULL;
|
||||
|
||||
color_select_image_fill (csp->z_color, csp->z_color_fill, csp->values);
|
||||
color_select_image_fill (csp->xy_color, csp->xy_color_fill, csp->values);
|
||||
|
||||
(*selector_data) = glue;
|
||||
return glue->main_vbox;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
color_select_notebook_free (void *data)
|
||||
{
|
||||
notebook_glue *glue = data;
|
||||
|
||||
color_select_free (glue->csp);
|
||||
/* don't need to destroy the widget, since it's done by the caller
|
||||
* of this function */
|
||||
g_free (glue);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
color_select_notebook_setcolor (void *data,
|
||||
int r, int g, int b, int set_current)
|
||||
{
|
||||
notebook_glue *glue = data;
|
||||
|
||||
color_select_set_color (glue->csp, r, g, b, set_current);
|
||||
}
|
||||
|
||||
static void
|
||||
color_select_notebook_update_callback (int r, int g, int b,
|
||||
ColorSelectState state, void *data)
|
||||
{
|
||||
notebook_glue *glue = data;
|
||||
|
||||
switch (state) {
|
||||
case COLOR_SELECT_UPDATE:
|
||||
glue->callback (glue->client_data, r, g, b);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_warning ("state %d can't happen!", state);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
Makefile.in
|
||||
Makefile
|
||||
.deps
|
||||
*.lo
|
||||
_libs
|
||||
.libs
|
||||
*.la
|
|
@ -0,0 +1,14 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
moduledir = $(gimpplugindir)/modules
|
||||
|
||||
INCLUDES = \
|
||||
-I$(top_srcdir) \
|
||||
-I$(top_srcdir)/intl \
|
||||
$(GTK_CFLAGS) \
|
||||
-I$(includedir)
|
||||
|
||||
module_LTLIBRARIES = libcolorsel_gtk.la
|
||||
|
||||
libcolorsel_gtk_la_SOURCES = colorsel_gtk.c
|
||||
|
|
@ -0,0 +1,135 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
||||
*
|
||||
* colorsel_gtk module (C) 1998 Austin Donnelly <austin@greenend.org.uk>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <gtk/gtk.h>
|
||||
#include <libgimp/color_selector.h>
|
||||
#include <libgimp/gimpmodule.h>
|
||||
|
||||
/* prototypes */
|
||||
static GtkWidget * colorsel_gtk_new (int, int, int,
|
||||
GimpColorSelector_Callback, void *,
|
||||
void **);
|
||||
static void colorsel_gtk_free (void *);
|
||||
static void colorsel_gtk_setcolor (void *, int, int, int, int);
|
||||
static void colorsel_gtk_update (GtkWidget *, gpointer);
|
||||
|
||||
|
||||
/* local methods */
|
||||
static GimpColorSelectorMethods methods =
|
||||
{
|
||||
colorsel_gtk_new,
|
||||
colorsel_gtk_free,
|
||||
colorsel_gtk_setcolor
|
||||
};
|
||||
|
||||
|
||||
/* globaly exported init function */
|
||||
G_MODULE_EXPORT GimpModuleStatus
|
||||
module_init (void)
|
||||
{
|
||||
if (gimp_color_selector_register ("GTK", &methods))
|
||||
return GIMP_MODULE_OK;
|
||||
else
|
||||
return GIMP_MODULE_UNLOAD;
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************/
|
||||
/* GTK colour selector methods */
|
||||
|
||||
typedef struct {
|
||||
GtkWidget *selector;
|
||||
GimpColorSelector_Callback callback;
|
||||
void *client_data;
|
||||
} ColorselGtk;
|
||||
|
||||
|
||||
static GtkWidget *
|
||||
colorsel_gtk_new (int r, int g, int b,
|
||||
GimpColorSelector_Callback callback, void *client_data,
|
||||
/* RETURNS: */
|
||||
void **selector_data)
|
||||
{
|
||||
ColorselGtk *p;
|
||||
|
||||
p = g_malloc (sizeof (ColorselGtk));
|
||||
|
||||
p->selector = gtk_color_selection_new ();
|
||||
p->callback = callback;
|
||||
p->client_data = client_data;
|
||||
|
||||
colorsel_gtk_setcolor (p, r, g, b, FALSE);
|
||||
|
||||
gtk_signal_connect (GTK_OBJECT (p->selector), "color_changed",
|
||||
(GtkSignalFunc) colorsel_gtk_update, p);
|
||||
|
||||
(*selector_data) = p;
|
||||
return p->selector;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
colorsel_gtk_free (void *data)
|
||||
{
|
||||
ColorselGtk *p = data;
|
||||
|
||||
/* don't need to gtk_widget_destroy() the selector, since that's
|
||||
* done for us. */
|
||||
|
||||
g_free (p);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
colorsel_gtk_setcolor (void *data,
|
||||
int r, int g, int b, int set_current)
|
||||
{
|
||||
ColorselGtk *p = data;
|
||||
double color[3];
|
||||
|
||||
color[0] = ((gdouble) r) / 255.999;
|
||||
color[1] = ((gdouble) g) / 255.999;
|
||||
color[2] = ((gdouble) b) / 255.999;
|
||||
|
||||
gtk_color_selection_set_color (GTK_COLOR_SELECTION (p->selector), color);
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void
|
||||
colorsel_gtk_update (GtkWidget *widget, gpointer data)
|
||||
{
|
||||
ColorselGtk *p = data;
|
||||
int r;
|
||||
int g;
|
||||
int b;
|
||||
double color[3];
|
||||
|
||||
gtk_color_selection_get_color (GTK_COLOR_SELECTION (p->selector), color);
|
||||
|
||||
r = (int) (color[0] * 255.999);
|
||||
g = (int) (color[1] * 255.999);
|
||||
b = (int) (color[2] * 255.999);
|
||||
|
||||
p->callback (p->client_data, r, g, b);
|
||||
}
|
||||
|
||||
/* End of colorsel_gtk.c */
|
|
@ -311,8 +311,7 @@ oilify_rgb (GDrawable *drawable)
|
|||
}
|
||||
|
||||
progress += dest_rgn.w * dest_rgn.h;
|
||||
if ((progress % 5) == 0)
|
||||
gimp_progress_update ((double) progress / (double) max_progress);
|
||||
gimp_progress_update ((double) progress / (double) max_progress);
|
||||
}
|
||||
|
||||
/* update the oil-painted region */
|
||||
|
|
|
@ -311,8 +311,7 @@ oilify_rgb (GDrawable *drawable)
|
|||
}
|
||||
|
||||
progress += dest_rgn.w * dest_rgn.h;
|
||||
if ((progress % 5) == 0)
|
||||
gimp_progress_update ((double) progress / (double) max_progress);
|
||||
gimp_progress_update ((double) progress / (double) max_progress);
|
||||
}
|
||||
|
||||
/* update the oil-painted region */
|
||||
|
|
Loading…
Reference in New Issue