call undo_push_qmask() before removing the channel since the callback will

2000-06-08  Sven Neumann  <sven@gimp.org>

        * app/qmask.c: call undo_push_qmask() before removing the
        channel since the callback will set the qmask_state
        incorrectly otherwise. Fixes bug #13472.

        * app/undo.[ch]: code cleanup

        * plug-ins/common/gif.c: put save_comment into the values
        that are stored between calls to the GIF plug-in, so it
        remembers if the user wants to save the comment. Fixes
        bug #12755.
This commit is contained in:
Sven Neumann 2000-06-07 22:51:23 +00:00 committed by Sven Neumann
parent 0157738431
commit fd4355bc89
13 changed files with 1019 additions and 968 deletions

View File

@ -1,3 +1,16 @@
2000-06-08 Sven Neumann <sven@gimp.org>
* app/qmask.c: call undo_push_qmask() before removing the
channel since the callback will set the qmask_state
incorrectly otherwise. Fixes bug #13472.
* app/undo.[ch]: code cleanup
* plug-ins/common/gif.c: put save_comment into the values
that are stored between calls to the GIF plug-in, so it
remembers if the user wants to save the comment. Fixes
bug #12755.
Wed Jun 7 12:00:39 PDT 2000 Manish Singh <yosh@gimp.org>
[patches from Daniel Egger]

View File

@ -40,12 +40,12 @@
struct _EditQmaskOptions
{
GtkWidget *query_box;
GtkWidget *name_entry;
GtkWidget *query_box;
GtkWidget *name_entry;
GimpImage *gimage;
ColorPanel *color_panel;
double opacity;
GimpImage *gimage;
ColorPanel *color_panel;
gdouble opacity;
};
typedef struct _EditQmaskOptions EditQmaskOptions;
@ -81,7 +81,7 @@ qmask_removed_callback (GtkObject *qmask,
if (!gdisp->gimage)
return;
gdisp->gimage->qmask_state = 0;
gdisp->gimage->qmask_state = FALSE;
qmask_buttons_update (gdisp);
}
@ -90,11 +90,10 @@ qmask_removed_callback (GtkObject *qmask,
void
qmask_buttons_update (GDisplay *gdisp)
{
g_assert(gdisp);
g_assert (gdisp);
g_assert (gdisp->gimage);
g_assert(gdisp->gimage);
if (gdisp->gimage->qmask_state != GTK_TOGGLE_BUTTON(gdisp->qmaskon)->active)
if (gdisp->gimage->qmask_state != GTK_TOGGLE_BUTTON (gdisp->qmaskon)->active)
{
/* Disable toggle from doing anything */
gtk_signal_handler_block_by_func(GTK_OBJECT(gdisp->qmaskoff),
@ -118,8 +117,6 @@ qmask_buttons_update (GDisplay *gdisp)
gtk_signal_handler_unblock_by_func(GTK_OBJECT(gdisp->qmaskon),
(GtkSignalFunc) qmask_activate,
gdisp);
/* Flush event queue */
/* while (g_main_iteration(FALSE)); */
}
}
@ -139,10 +136,10 @@ qmask_click_handler (GtkWidget *widget,
}
void
qmask_deactivate (GtkWidget *w,
GDisplay *gdisp)
qmask_deactivate (GtkWidget *widget,
GDisplay *gdisp)
{
GimpImage *gimg;
GimpImage *gimg;
GimpChannel *gmask;
if (gdisp)
@ -154,35 +151,35 @@ qmask_deactivate (GtkWidget *w,
if (!gdisp->gimage->qmask_state)
return; /* if already set do nothing */
undo_push_group_start (gimg, QMASK_UNDO);
if ( (gmask = gimp_image_get_channel_by_name (gimg, "Qmask")) )
{
undo_push_group_start (gimg, QMASK_UNDO);
/* push the undo here since removing the mask will
call the qmask_removed_callback() which will set
the qmask_state to FALSE */
undo_push_qmask (gimg);
gimage_mask_load (gimg, gmask);
gimage_remove_channel (gimg, gmask);
undo_push_qmask (gimg);
gdisp->gimage->qmask_state = 0;
undo_push_group_end (gimg);
}
else
gdisp->gimage->qmask_state = 0;
undo_push_group_end (gimg);
gdisp->gimage->qmask_state = FALSE;
if (gmask)
gdisplays_flush ();
gdisplays_flush ();
}
}
void
qmask_activate (GtkWidget *w,
qmask_activate (GtkWidget *widget,
GDisplay *gdisp)
{
GimpImage *gimg;
GimpImage *gimg;
GimpChannel *gmask;
GimpLayer *layer;
GimpLayer *layer;
double opacity;
unsigned char *color;
gdouble opacity;
guchar *color;
if (gdisp)
{
@ -194,16 +191,18 @@ qmask_activate (GtkWidget *w,
return; /* If already set, do nothing */
/* Set the defaults */
opacity = (double) gimg->qmask_opacity;
opacity = (gdouble) gimg->qmask_opacity;
color = gimg->qmask_color;
if ( (gmask = gimp_image_get_channel_by_name (gimg, "Qmask")) )
{
gimg->qmask_state = 1; /* if the user was clever and created his own */
gimg->qmask_state = TRUE;
/* if the user was clever and created his own */
return;
}
undo_push_group_start (gimg, QMASK_UNDO);
if (gimage_mask_is_empty(gimg))
{
if ((layer = gimage_floating_sel (gimg)))
@ -211,31 +210,29 @@ qmask_activate (GtkWidget *w,
floating_sel_to_layer (layer);
}
/* if no selection */
gmask = channel_new(gimg,
gimg->width,
gimg->height,
"Qmask",
(int)(255*opacity)/100,
color);
gmask = channel_new (gimg,
gimg->width,
gimg->height,
"Qmask",
(gint)(255*opacity)/100,
color);
gimp_image_add_channel (gimg, gmask, 0);
gimp_drawable_fill (GIMP_DRAWABLE(gmask), 0, 0, 0, 0);
/* edit_clear(gimg,GIMP_DRAWABLE(gmask)); */
undo_push_qmask (gimg);
gdisp->gimage->qmask_state = 1;
gimp_drawable_fill (GIMP_DRAWABLE (gmask), 0, 0, 0, 0);
}
else
{ /* if selection */
gmask = channel_copy (gimage_get_mask (gimg));
gimp_image_add_channel (gimg, gmask, 0);
channel_set_color(gmask, color);
channel_set_name(gmask, "Qmask");
channel_set_opacity(gmask, opacity);
channel_set_color (gmask, color);
channel_set_name (gmask, "Qmask");
channel_set_opacity (gmask, opacity);
gimage_mask_none (gimg); /* Clear the selection */
undo_push_qmask (gimg);
gdisp->gimage->qmask_state = 1;
}
undo_push_group_end(gimg);
gdisplays_flush();
undo_push_qmask (gimg);
undo_push_group_end (gimg);
gdisp->gimage->qmask_state = TRUE;
gdisplays_flush ();
/* connect to the removed signal, so the buttons get updated */
gtk_signal_connect (GTK_OBJECT (gmask), "removed",
@ -255,7 +252,7 @@ edit_qmask_channel_query (GDisplay * gdisp)
GtkObject *opacity_scale_data;
gint i;
guchar channel_color[3] = { 0, 0, 0 };
guchar channel_color[3] = { 0, 0, 0 };
/* channel = gimp_image_get_channel_by_name (gdisp->gimage, "Qmask"); */
/* the new options structure */
@ -330,16 +327,16 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
gpointer client_data)
{
EditQmaskOptions *options;
Channel *channel;
gint opacity;
gint update = FALSE;
guchar *tmpcolp;
guchar tmpcol[3];
gint i;
Channel *channel;
guchar *tmpcolp;
guchar tmpcol[3];
gboolean update = FALSE;
gint opacity;
gint i;
options = (EditQmaskOptions *) client_data;
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
opacity = (int) (255 * options->opacity/100);
opacity = (gint) (255 * options->opacity/100);
if (options->gimage && channel)
{ /* don't update if opacity hasn't changed */

View File

@ -40,12 +40,12 @@
struct _EditQmaskOptions
{
GtkWidget *query_box;
GtkWidget *name_entry;
GtkWidget *query_box;
GtkWidget *name_entry;
GimpImage *gimage;
ColorPanel *color_panel;
double opacity;
GimpImage *gimage;
ColorPanel *color_panel;
gdouble opacity;
};
typedef struct _EditQmaskOptions EditQmaskOptions;
@ -81,7 +81,7 @@ qmask_removed_callback (GtkObject *qmask,
if (!gdisp->gimage)
return;
gdisp->gimage->qmask_state = 0;
gdisp->gimage->qmask_state = FALSE;
qmask_buttons_update (gdisp);
}
@ -90,11 +90,10 @@ qmask_removed_callback (GtkObject *qmask,
void
qmask_buttons_update (GDisplay *gdisp)
{
g_assert(gdisp);
g_assert (gdisp);
g_assert (gdisp->gimage);
g_assert(gdisp->gimage);
if (gdisp->gimage->qmask_state != GTK_TOGGLE_BUTTON(gdisp->qmaskon)->active)
if (gdisp->gimage->qmask_state != GTK_TOGGLE_BUTTON (gdisp->qmaskon)->active)
{
/* Disable toggle from doing anything */
gtk_signal_handler_block_by_func(GTK_OBJECT(gdisp->qmaskoff),
@ -118,8 +117,6 @@ qmask_buttons_update (GDisplay *gdisp)
gtk_signal_handler_unblock_by_func(GTK_OBJECT(gdisp->qmaskon),
(GtkSignalFunc) qmask_activate,
gdisp);
/* Flush event queue */
/* while (g_main_iteration(FALSE)); */
}
}
@ -139,10 +136,10 @@ qmask_click_handler (GtkWidget *widget,
}
void
qmask_deactivate (GtkWidget *w,
GDisplay *gdisp)
qmask_deactivate (GtkWidget *widget,
GDisplay *gdisp)
{
GimpImage *gimg;
GimpImage *gimg;
GimpChannel *gmask;
if (gdisp)
@ -154,35 +151,35 @@ qmask_deactivate (GtkWidget *w,
if (!gdisp->gimage->qmask_state)
return; /* if already set do nothing */
undo_push_group_start (gimg, QMASK_UNDO);
if ( (gmask = gimp_image_get_channel_by_name (gimg, "Qmask")) )
{
undo_push_group_start (gimg, QMASK_UNDO);
/* push the undo here since removing the mask will
call the qmask_removed_callback() which will set
the qmask_state to FALSE */
undo_push_qmask (gimg);
gimage_mask_load (gimg, gmask);
gimage_remove_channel (gimg, gmask);
undo_push_qmask (gimg);
gdisp->gimage->qmask_state = 0;
undo_push_group_end (gimg);
}
else
gdisp->gimage->qmask_state = 0;
undo_push_group_end (gimg);
gdisp->gimage->qmask_state = FALSE;
if (gmask)
gdisplays_flush ();
gdisplays_flush ();
}
}
void
qmask_activate (GtkWidget *w,
qmask_activate (GtkWidget *widget,
GDisplay *gdisp)
{
GimpImage *gimg;
GimpImage *gimg;
GimpChannel *gmask;
GimpLayer *layer;
GimpLayer *layer;
double opacity;
unsigned char *color;
gdouble opacity;
guchar *color;
if (gdisp)
{
@ -194,16 +191,18 @@ qmask_activate (GtkWidget *w,
return; /* If already set, do nothing */
/* Set the defaults */
opacity = (double) gimg->qmask_opacity;
opacity = (gdouble) gimg->qmask_opacity;
color = gimg->qmask_color;
if ( (gmask = gimp_image_get_channel_by_name (gimg, "Qmask")) )
{
gimg->qmask_state = 1; /* if the user was clever and created his own */
gimg->qmask_state = TRUE;
/* if the user was clever and created his own */
return;
}
undo_push_group_start (gimg, QMASK_UNDO);
if (gimage_mask_is_empty(gimg))
{
if ((layer = gimage_floating_sel (gimg)))
@ -211,31 +210,29 @@ qmask_activate (GtkWidget *w,
floating_sel_to_layer (layer);
}
/* if no selection */
gmask = channel_new(gimg,
gimg->width,
gimg->height,
"Qmask",
(int)(255*opacity)/100,
color);
gmask = channel_new (gimg,
gimg->width,
gimg->height,
"Qmask",
(gint)(255*opacity)/100,
color);
gimp_image_add_channel (gimg, gmask, 0);
gimp_drawable_fill (GIMP_DRAWABLE(gmask), 0, 0, 0, 0);
/* edit_clear(gimg,GIMP_DRAWABLE(gmask)); */
undo_push_qmask (gimg);
gdisp->gimage->qmask_state = 1;
gimp_drawable_fill (GIMP_DRAWABLE (gmask), 0, 0, 0, 0);
}
else
{ /* if selection */
gmask = channel_copy (gimage_get_mask (gimg));
gimp_image_add_channel (gimg, gmask, 0);
channel_set_color(gmask, color);
channel_set_name(gmask, "Qmask");
channel_set_opacity(gmask, opacity);
channel_set_color (gmask, color);
channel_set_name (gmask, "Qmask");
channel_set_opacity (gmask, opacity);
gimage_mask_none (gimg); /* Clear the selection */
undo_push_qmask (gimg);
gdisp->gimage->qmask_state = 1;
}
undo_push_group_end(gimg);
gdisplays_flush();
undo_push_qmask (gimg);
undo_push_group_end (gimg);
gdisp->gimage->qmask_state = TRUE;
gdisplays_flush ();
/* connect to the removed signal, so the buttons get updated */
gtk_signal_connect (GTK_OBJECT (gmask), "removed",
@ -255,7 +252,7 @@ edit_qmask_channel_query (GDisplay * gdisp)
GtkObject *opacity_scale_data;
gint i;
guchar channel_color[3] = { 0, 0, 0 };
guchar channel_color[3] = { 0, 0, 0 };
/* channel = gimp_image_get_channel_by_name (gdisp->gimage, "Qmask"); */
/* the new options structure */
@ -330,16 +327,16 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
gpointer client_data)
{
EditQmaskOptions *options;
Channel *channel;
gint opacity;
gint update = FALSE;
guchar *tmpcolp;
guchar tmpcol[3];
gint i;
Channel *channel;
guchar *tmpcolp;
guchar tmpcol[3];
gboolean update = FALSE;
gint opacity;
gint i;
options = (EditQmaskOptions *) client_data;
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
opacity = (int) (255 * options->opacity/100);
opacity = (gint) (255 * options->opacity/100);
if (options->gimage && channel)
{ /* don't update if opacity hasn't changed */

View File

@ -40,12 +40,12 @@
struct _EditQmaskOptions
{
GtkWidget *query_box;
GtkWidget *name_entry;
GtkWidget *query_box;
GtkWidget *name_entry;
GimpImage *gimage;
ColorPanel *color_panel;
double opacity;
GimpImage *gimage;
ColorPanel *color_panel;
gdouble opacity;
};
typedef struct _EditQmaskOptions EditQmaskOptions;
@ -81,7 +81,7 @@ qmask_removed_callback (GtkObject *qmask,
if (!gdisp->gimage)
return;
gdisp->gimage->qmask_state = 0;
gdisp->gimage->qmask_state = FALSE;
qmask_buttons_update (gdisp);
}
@ -90,11 +90,10 @@ qmask_removed_callback (GtkObject *qmask,
void
qmask_buttons_update (GDisplay *gdisp)
{
g_assert(gdisp);
g_assert (gdisp);
g_assert (gdisp->gimage);
g_assert(gdisp->gimage);
if (gdisp->gimage->qmask_state != GTK_TOGGLE_BUTTON(gdisp->qmaskon)->active)
if (gdisp->gimage->qmask_state != GTK_TOGGLE_BUTTON (gdisp->qmaskon)->active)
{
/* Disable toggle from doing anything */
gtk_signal_handler_block_by_func(GTK_OBJECT(gdisp->qmaskoff),
@ -118,8 +117,6 @@ qmask_buttons_update (GDisplay *gdisp)
gtk_signal_handler_unblock_by_func(GTK_OBJECT(gdisp->qmaskon),
(GtkSignalFunc) qmask_activate,
gdisp);
/* Flush event queue */
/* while (g_main_iteration(FALSE)); */
}
}
@ -139,10 +136,10 @@ qmask_click_handler (GtkWidget *widget,
}
void
qmask_deactivate (GtkWidget *w,
GDisplay *gdisp)
qmask_deactivate (GtkWidget *widget,
GDisplay *gdisp)
{
GimpImage *gimg;
GimpImage *gimg;
GimpChannel *gmask;
if (gdisp)
@ -154,35 +151,35 @@ qmask_deactivate (GtkWidget *w,
if (!gdisp->gimage->qmask_state)
return; /* if already set do nothing */
undo_push_group_start (gimg, QMASK_UNDO);
if ( (gmask = gimp_image_get_channel_by_name (gimg, "Qmask")) )
{
undo_push_group_start (gimg, QMASK_UNDO);
/* push the undo here since removing the mask will
call the qmask_removed_callback() which will set
the qmask_state to FALSE */
undo_push_qmask (gimg);
gimage_mask_load (gimg, gmask);
gimage_remove_channel (gimg, gmask);
undo_push_qmask (gimg);
gdisp->gimage->qmask_state = 0;
undo_push_group_end (gimg);
}
else
gdisp->gimage->qmask_state = 0;
undo_push_group_end (gimg);
gdisp->gimage->qmask_state = FALSE;
if (gmask)
gdisplays_flush ();
gdisplays_flush ();
}
}
void
qmask_activate (GtkWidget *w,
qmask_activate (GtkWidget *widget,
GDisplay *gdisp)
{
GimpImage *gimg;
GimpImage *gimg;
GimpChannel *gmask;
GimpLayer *layer;
GimpLayer *layer;
double opacity;
unsigned char *color;
gdouble opacity;
guchar *color;
if (gdisp)
{
@ -194,16 +191,18 @@ qmask_activate (GtkWidget *w,
return; /* If already set, do nothing */
/* Set the defaults */
opacity = (double) gimg->qmask_opacity;
opacity = (gdouble) gimg->qmask_opacity;
color = gimg->qmask_color;
if ( (gmask = gimp_image_get_channel_by_name (gimg, "Qmask")) )
{
gimg->qmask_state = 1; /* if the user was clever and created his own */
gimg->qmask_state = TRUE;
/* if the user was clever and created his own */
return;
}
undo_push_group_start (gimg, QMASK_UNDO);
if (gimage_mask_is_empty(gimg))
{
if ((layer = gimage_floating_sel (gimg)))
@ -211,31 +210,29 @@ qmask_activate (GtkWidget *w,
floating_sel_to_layer (layer);
}
/* if no selection */
gmask = channel_new(gimg,
gimg->width,
gimg->height,
"Qmask",
(int)(255*opacity)/100,
color);
gmask = channel_new (gimg,
gimg->width,
gimg->height,
"Qmask",
(gint)(255*opacity)/100,
color);
gimp_image_add_channel (gimg, gmask, 0);
gimp_drawable_fill (GIMP_DRAWABLE(gmask), 0, 0, 0, 0);
/* edit_clear(gimg,GIMP_DRAWABLE(gmask)); */
undo_push_qmask (gimg);
gdisp->gimage->qmask_state = 1;
gimp_drawable_fill (GIMP_DRAWABLE (gmask), 0, 0, 0, 0);
}
else
{ /* if selection */
gmask = channel_copy (gimage_get_mask (gimg));
gimp_image_add_channel (gimg, gmask, 0);
channel_set_color(gmask, color);
channel_set_name(gmask, "Qmask");
channel_set_opacity(gmask, opacity);
channel_set_color (gmask, color);
channel_set_name (gmask, "Qmask");
channel_set_opacity (gmask, opacity);
gimage_mask_none (gimg); /* Clear the selection */
undo_push_qmask (gimg);
gdisp->gimage->qmask_state = 1;
}
undo_push_group_end(gimg);
gdisplays_flush();
undo_push_qmask (gimg);
undo_push_group_end (gimg);
gdisp->gimage->qmask_state = TRUE;
gdisplays_flush ();
/* connect to the removed signal, so the buttons get updated */
gtk_signal_connect (GTK_OBJECT (gmask), "removed",
@ -255,7 +252,7 @@ edit_qmask_channel_query (GDisplay * gdisp)
GtkObject *opacity_scale_data;
gint i;
guchar channel_color[3] = { 0, 0, 0 };
guchar channel_color[3] = { 0, 0, 0 };
/* channel = gimp_image_get_channel_by_name (gdisp->gimage, "Qmask"); */
/* the new options structure */
@ -330,16 +327,16 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
gpointer client_data)
{
EditQmaskOptions *options;
Channel *channel;
gint opacity;
gint update = FALSE;
guchar *tmpcolp;
guchar tmpcol[3];
gint i;
Channel *channel;
guchar *tmpcolp;
guchar tmpcol[3];
gboolean update = FALSE;
gint opacity;
gint i;
options = (EditQmaskOptions *) client_data;
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
opacity = (int) (255 * options->opacity/100);
opacity = (gint) (255 * options->opacity/100);
if (options->gimage && channel)
{ /* don't update if opacity hasn't changed */

View File

@ -40,12 +40,12 @@
struct _EditQmaskOptions
{
GtkWidget *query_box;
GtkWidget *name_entry;
GtkWidget *query_box;
GtkWidget *name_entry;
GimpImage *gimage;
ColorPanel *color_panel;
double opacity;
GimpImage *gimage;
ColorPanel *color_panel;
gdouble opacity;
};
typedef struct _EditQmaskOptions EditQmaskOptions;
@ -81,7 +81,7 @@ qmask_removed_callback (GtkObject *qmask,
if (!gdisp->gimage)
return;
gdisp->gimage->qmask_state = 0;
gdisp->gimage->qmask_state = FALSE;
qmask_buttons_update (gdisp);
}
@ -90,11 +90,10 @@ qmask_removed_callback (GtkObject *qmask,
void
qmask_buttons_update (GDisplay *gdisp)
{
g_assert(gdisp);
g_assert (gdisp);
g_assert (gdisp->gimage);
g_assert(gdisp->gimage);
if (gdisp->gimage->qmask_state != GTK_TOGGLE_BUTTON(gdisp->qmaskon)->active)
if (gdisp->gimage->qmask_state != GTK_TOGGLE_BUTTON (gdisp->qmaskon)->active)
{
/* Disable toggle from doing anything */
gtk_signal_handler_block_by_func(GTK_OBJECT(gdisp->qmaskoff),
@ -118,8 +117,6 @@ qmask_buttons_update (GDisplay *gdisp)
gtk_signal_handler_unblock_by_func(GTK_OBJECT(gdisp->qmaskon),
(GtkSignalFunc) qmask_activate,
gdisp);
/* Flush event queue */
/* while (g_main_iteration(FALSE)); */
}
}
@ -139,10 +136,10 @@ qmask_click_handler (GtkWidget *widget,
}
void
qmask_deactivate (GtkWidget *w,
GDisplay *gdisp)
qmask_deactivate (GtkWidget *widget,
GDisplay *gdisp)
{
GimpImage *gimg;
GimpImage *gimg;
GimpChannel *gmask;
if (gdisp)
@ -154,35 +151,35 @@ qmask_deactivate (GtkWidget *w,
if (!gdisp->gimage->qmask_state)
return; /* if already set do nothing */
undo_push_group_start (gimg, QMASK_UNDO);
if ( (gmask = gimp_image_get_channel_by_name (gimg, "Qmask")) )
{
undo_push_group_start (gimg, QMASK_UNDO);
/* push the undo here since removing the mask will
call the qmask_removed_callback() which will set
the qmask_state to FALSE */
undo_push_qmask (gimg);
gimage_mask_load (gimg, gmask);
gimage_remove_channel (gimg, gmask);
undo_push_qmask (gimg);
gdisp->gimage->qmask_state = 0;
undo_push_group_end (gimg);
}
else
gdisp->gimage->qmask_state = 0;
undo_push_group_end (gimg);
gdisp->gimage->qmask_state = FALSE;
if (gmask)
gdisplays_flush ();
gdisplays_flush ();
}
}
void
qmask_activate (GtkWidget *w,
qmask_activate (GtkWidget *widget,
GDisplay *gdisp)
{
GimpImage *gimg;
GimpImage *gimg;
GimpChannel *gmask;
GimpLayer *layer;
GimpLayer *layer;
double opacity;
unsigned char *color;
gdouble opacity;
guchar *color;
if (gdisp)
{
@ -194,16 +191,18 @@ qmask_activate (GtkWidget *w,
return; /* If already set, do nothing */
/* Set the defaults */
opacity = (double) gimg->qmask_opacity;
opacity = (gdouble) gimg->qmask_opacity;
color = gimg->qmask_color;
if ( (gmask = gimp_image_get_channel_by_name (gimg, "Qmask")) )
{
gimg->qmask_state = 1; /* if the user was clever and created his own */
gimg->qmask_state = TRUE;
/* if the user was clever and created his own */
return;
}
undo_push_group_start (gimg, QMASK_UNDO);
if (gimage_mask_is_empty(gimg))
{
if ((layer = gimage_floating_sel (gimg)))
@ -211,31 +210,29 @@ qmask_activate (GtkWidget *w,
floating_sel_to_layer (layer);
}
/* if no selection */
gmask = channel_new(gimg,
gimg->width,
gimg->height,
"Qmask",
(int)(255*opacity)/100,
color);
gmask = channel_new (gimg,
gimg->width,
gimg->height,
"Qmask",
(gint)(255*opacity)/100,
color);
gimp_image_add_channel (gimg, gmask, 0);
gimp_drawable_fill (GIMP_DRAWABLE(gmask), 0, 0, 0, 0);
/* edit_clear(gimg,GIMP_DRAWABLE(gmask)); */
undo_push_qmask (gimg);
gdisp->gimage->qmask_state = 1;
gimp_drawable_fill (GIMP_DRAWABLE (gmask), 0, 0, 0, 0);
}
else
{ /* if selection */
gmask = channel_copy (gimage_get_mask (gimg));
gimp_image_add_channel (gimg, gmask, 0);
channel_set_color(gmask, color);
channel_set_name(gmask, "Qmask");
channel_set_opacity(gmask, opacity);
channel_set_color (gmask, color);
channel_set_name (gmask, "Qmask");
channel_set_opacity (gmask, opacity);
gimage_mask_none (gimg); /* Clear the selection */
undo_push_qmask (gimg);
gdisp->gimage->qmask_state = 1;
}
undo_push_group_end(gimg);
gdisplays_flush();
undo_push_qmask (gimg);
undo_push_group_end (gimg);
gdisp->gimage->qmask_state = TRUE;
gdisplays_flush ();
/* connect to the removed signal, so the buttons get updated */
gtk_signal_connect (GTK_OBJECT (gmask), "removed",
@ -255,7 +252,7 @@ edit_qmask_channel_query (GDisplay * gdisp)
GtkObject *opacity_scale_data;
gint i;
guchar channel_color[3] = { 0, 0, 0 };
guchar channel_color[3] = { 0, 0, 0 };
/* channel = gimp_image_get_channel_by_name (gdisp->gimage, "Qmask"); */
/* the new options structure */
@ -330,16 +327,16 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
gpointer client_data)
{
EditQmaskOptions *options;
Channel *channel;
gint opacity;
gint update = FALSE;
guchar *tmpcolp;
guchar tmpcol[3];
gint i;
Channel *channel;
guchar *tmpcolp;
guchar tmpcol[3];
gboolean update = FALSE;
gint opacity;
gint i;
options = (EditQmaskOptions *) client_data;
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
opacity = (int) (255 * options->opacity/100);
opacity = (gint) (255 * options->opacity/100);
if (options->gimage && channel)
{ /* don't update if opacity hasn't changed */

File diff suppressed because it is too large Load Diff

View File

@ -18,71 +18,117 @@
#ifndef __UNDO_H__
#define __UNDO_H__
#include "undo_types.h"
#include "gimage.h"
#include "undo_types.h"
/* Undo interface functions */
int undo_push_group_start (GImage *, UndoType);
int undo_push_group_end (GImage *);
int undo_push_image (GImage *, GimpDrawable *, int, int, int, int);
int undo_push_image_mod (GImage *, GimpDrawable *, int, int, int, int, void *, int);
int undo_push_mask (GImage *, void *);
int undo_push_layer_displace (GImage *, GimpLayer*);
int undo_push_transform (GImage *, void *);
int undo_push_paint (GImage *, void *);
int undo_push_layer (GImage *, UndoType, void *);
int undo_push_layer_mod (GImage *, void *);
int undo_push_layer_mask (GImage *, UndoType, void *);
int undo_push_layer_change (GImage *, GimpLayer *);
int undo_push_layer_reposition (GImage *, GimpLayer *);
int undo_push_channel (GImage *, UndoType, void *);
int undo_push_channel_mod (GImage *, void *);
int undo_push_fs_to_layer (GImage *, void *);
int undo_push_fs_rigor (GImage *, int);
int undo_push_fs_relax (GImage *, int);
int undo_push_gimage_mod (GImage *);
int undo_push_guide (GImage *, void *);
int undo_push_image_parasite (GImage *, void *);
int undo_push_drawable_parasite (GImage *, GimpDrawable *, void *);
int undo_push_image_parasite_remove (GImage *, const char *);
int undo_push_drawable_parasite_remove (GImage *, GimpDrawable *,
const char *);
int undo_push_qmask (GImage *);
int undo_push_resolution (GImage *);
int undo_push_layer_rename (GImage *, GimpLayer *);
int undo_push_cantundo (GImage *, const char *);
gboolean undo_push_group_start (GImage *gimage,
UndoType type);
gboolean undo_push_group_end (GImage *gimage);
gboolean undo_push_image (GImage *gimage,
GimpDrawable *drawable,
gint x1,
gint y1,
gint x2,
gint y2);
gboolean undo_push_image_mod (GImage *gimage,
GimpDrawable *drawable,
gint x1,
gint y1,
gint x2,
gint y2,
gpointer tiles_ptr,
gboolean sparse);
gboolean undo_push_mask (GImage *gimage,
gpointer mask_ptr);
gboolean undo_push_layer_displace (GImage *gimage,
GimpLayer *layer);
gboolean undo_push_transform (GImage *gimage,
gpointer tu_ptr);
gboolean undo_push_paint (GImage *gimage,
gpointer pu_ptr);
gboolean undo_push_layer (GImage *gimage,
UndoType type,
gpointer lu_ptr);
gboolean undo_push_layer_mod (GImage *gimage,
gpointer layer_ptr);
gboolean undo_push_layer_mask (GImage *gimage,
UndoType type,
gpointer lmu_prt);
gboolean undo_push_layer_change (GImage *gimage,
GimpLayer *layer);
gboolean undo_push_layer_reposition (GImage *gimage,
GimpLayer *layer);
gboolean undo_push_channel (GImage *gimage,
UndoType type,
gpointer cu_ptr);
gboolean undo_push_channel_mod (GImage *gimage,
gpointer cmu_ptr);
gboolean undo_push_fs_to_layer (GImage *gimage,
gpointer fsu_ptr);
gboolean undo_push_fs_rigor (GImage *gimage,
gint32 layer_ID);
gboolean undo_push_fs_relax (GImage *gimage,
gint32 layer_ID);
gboolean undo_push_gimage_mod (GImage *gimage);
gboolean undo_push_guide (GImage *gimage,
gpointer guide);
gboolean undo_push_image_parasite (GImage *gimage,
gpointer parasite);
gboolean undo_push_drawable_parasite (GImage *gimage,
GimpDrawable *drawable,
gpointer parasite);
gboolean undo_push_image_parasite_remove
(GImage *gimage,
const gchar *name);
gboolean undo_push_drawable_parasite_remove
(GImage *gimage,
GimpDrawable *drabable,
const gchar *name);
gboolean undo_push_qmask (GImage *gimage);
gboolean undo_push_resolution (GImage *gimage);
gboolean undo_push_layer_rename (GImage *gimage,
GimpLayer *layer);
gboolean undo_push_cantundo (GImage *gimage,
const gchar *action);
int undo_pop (GImage *);
int undo_redo (GImage *);
void undo_free (GImage *);
gboolean undo_pop (GImage *gimage);
gboolean undo_redo (GImage *gimage);
void undo_free (GImage *gimage);
const gchar *undo_get_undo_name (GImage *gimage);
const gchar *undo_get_redo_name (GImage *gimage);
const char *undo_get_undo_name (GImage *);
const char *undo_get_redo_name (GImage *);
/* Stack peeking functions */
typedef int (*undo_map_fn) (const char *undoitemname, void *data);
void undo_map_over_undo_stack (GImage *, undo_map_fn, void *data);
void undo_map_over_redo_stack (GImage *, undo_map_fn, void *data);
UndoType undo_get_undo_top_type (GImage *);
typedef gint (*undo_map_fn) (const gchar *undoitemname,
gpointer data);
void undo_map_over_undo_stack (GImage *gimage,
undo_map_fn fn,
gpointer data);
void undo_map_over_redo_stack (GImage *gimage,
undo_map_fn fn,
gpointer data);
UndoType undo_get_undo_top_type (GImage *gimage);
/* Not really appropriate here, since undo_history_new is not defined
* in undo.c, but it saves on having a full header file for just one
* function prototype. */
GtkWidget *undo_history_new (GImage *gimage);
GtkWidget *undo_history_new (GImage *gimage);
/* Argument to undo_event signal emitted by gimages: */
typedef enum {
UNDO_PUSHED, /* a new undo has been added to the undo stack */
UNDO_EXPIRED, /* an undo has been freed from the undo stack */
UNDO_POPPED, /* an undo has been executed and moved to redo stack */
UNDO_REDO, /* a redo has been executed and moved to undo stack */
UNDO_FREE /* all undo and redo info has been cleared */
typedef enum
{
UNDO_PUSHED, /* a new undo has been added to the undo stack */
UNDO_EXPIRED, /* an undo has been freed from the undo stack */
UNDO_POPPED, /* an undo has been executed and moved to redo stack */
UNDO_REDO, /* a redo has been executed and moved to undo stack */
UNDO_FREE /* all undo and redo info has been cleared */
} undo_event_t;
#endif /* __UNDO_H__ */

View File

@ -40,12 +40,12 @@
struct _EditQmaskOptions
{
GtkWidget *query_box;
GtkWidget *name_entry;
GtkWidget *query_box;
GtkWidget *name_entry;
GimpImage *gimage;
ColorPanel *color_panel;
double opacity;
GimpImage *gimage;
ColorPanel *color_panel;
gdouble opacity;
};
typedef struct _EditQmaskOptions EditQmaskOptions;
@ -81,7 +81,7 @@ qmask_removed_callback (GtkObject *qmask,
if (!gdisp->gimage)
return;
gdisp->gimage->qmask_state = 0;
gdisp->gimage->qmask_state = FALSE;
qmask_buttons_update (gdisp);
}
@ -90,11 +90,10 @@ qmask_removed_callback (GtkObject *qmask,
void
qmask_buttons_update (GDisplay *gdisp)
{
g_assert(gdisp);
g_assert (gdisp);
g_assert (gdisp->gimage);
g_assert(gdisp->gimage);
if (gdisp->gimage->qmask_state != GTK_TOGGLE_BUTTON(gdisp->qmaskon)->active)
if (gdisp->gimage->qmask_state != GTK_TOGGLE_BUTTON (gdisp->qmaskon)->active)
{
/* Disable toggle from doing anything */
gtk_signal_handler_block_by_func(GTK_OBJECT(gdisp->qmaskoff),
@ -118,8 +117,6 @@ qmask_buttons_update (GDisplay *gdisp)
gtk_signal_handler_unblock_by_func(GTK_OBJECT(gdisp->qmaskon),
(GtkSignalFunc) qmask_activate,
gdisp);
/* Flush event queue */
/* while (g_main_iteration(FALSE)); */
}
}
@ -139,10 +136,10 @@ qmask_click_handler (GtkWidget *widget,
}
void
qmask_deactivate (GtkWidget *w,
GDisplay *gdisp)
qmask_deactivate (GtkWidget *widget,
GDisplay *gdisp)
{
GimpImage *gimg;
GimpImage *gimg;
GimpChannel *gmask;
if (gdisp)
@ -154,35 +151,35 @@ qmask_deactivate (GtkWidget *w,
if (!gdisp->gimage->qmask_state)
return; /* if already set do nothing */
undo_push_group_start (gimg, QMASK_UNDO);
if ( (gmask = gimp_image_get_channel_by_name (gimg, "Qmask")) )
{
undo_push_group_start (gimg, QMASK_UNDO);
/* push the undo here since removing the mask will
call the qmask_removed_callback() which will set
the qmask_state to FALSE */
undo_push_qmask (gimg);
gimage_mask_load (gimg, gmask);
gimage_remove_channel (gimg, gmask);
undo_push_qmask (gimg);
gdisp->gimage->qmask_state = 0;
undo_push_group_end (gimg);
}
else
gdisp->gimage->qmask_state = 0;
undo_push_group_end (gimg);
gdisp->gimage->qmask_state = FALSE;
if (gmask)
gdisplays_flush ();
gdisplays_flush ();
}
}
void
qmask_activate (GtkWidget *w,
qmask_activate (GtkWidget *widget,
GDisplay *gdisp)
{
GimpImage *gimg;
GimpImage *gimg;
GimpChannel *gmask;
GimpLayer *layer;
GimpLayer *layer;
double opacity;
unsigned char *color;
gdouble opacity;
guchar *color;
if (gdisp)
{
@ -194,16 +191,18 @@ qmask_activate (GtkWidget *w,
return; /* If already set, do nothing */
/* Set the defaults */
opacity = (double) gimg->qmask_opacity;
opacity = (gdouble) gimg->qmask_opacity;
color = gimg->qmask_color;
if ( (gmask = gimp_image_get_channel_by_name (gimg, "Qmask")) )
{
gimg->qmask_state = 1; /* if the user was clever and created his own */
gimg->qmask_state = TRUE;
/* if the user was clever and created his own */
return;
}
undo_push_group_start (gimg, QMASK_UNDO);
if (gimage_mask_is_empty(gimg))
{
if ((layer = gimage_floating_sel (gimg)))
@ -211,31 +210,29 @@ qmask_activate (GtkWidget *w,
floating_sel_to_layer (layer);
}
/* if no selection */
gmask = channel_new(gimg,
gimg->width,
gimg->height,
"Qmask",
(int)(255*opacity)/100,
color);
gmask = channel_new (gimg,
gimg->width,
gimg->height,
"Qmask",
(gint)(255*opacity)/100,
color);
gimp_image_add_channel (gimg, gmask, 0);
gimp_drawable_fill (GIMP_DRAWABLE(gmask), 0, 0, 0, 0);
/* edit_clear(gimg,GIMP_DRAWABLE(gmask)); */
undo_push_qmask (gimg);
gdisp->gimage->qmask_state = 1;
gimp_drawable_fill (GIMP_DRAWABLE (gmask), 0, 0, 0, 0);
}
else
{ /* if selection */
gmask = channel_copy (gimage_get_mask (gimg));
gimp_image_add_channel (gimg, gmask, 0);
channel_set_color(gmask, color);
channel_set_name(gmask, "Qmask");
channel_set_opacity(gmask, opacity);
channel_set_color (gmask, color);
channel_set_name (gmask, "Qmask");
channel_set_opacity (gmask, opacity);
gimage_mask_none (gimg); /* Clear the selection */
undo_push_qmask (gimg);
gdisp->gimage->qmask_state = 1;
}
undo_push_group_end(gimg);
gdisplays_flush();
undo_push_qmask (gimg);
undo_push_group_end (gimg);
gdisp->gimage->qmask_state = TRUE;
gdisplays_flush ();
/* connect to the removed signal, so the buttons get updated */
gtk_signal_connect (GTK_OBJECT (gmask), "removed",
@ -255,7 +252,7 @@ edit_qmask_channel_query (GDisplay * gdisp)
GtkObject *opacity_scale_data;
gint i;
guchar channel_color[3] = { 0, 0, 0 };
guchar channel_color[3] = { 0, 0, 0 };
/* channel = gimp_image_get_channel_by_name (gdisp->gimage, "Qmask"); */
/* the new options structure */
@ -330,16 +327,16 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
gpointer client_data)
{
EditQmaskOptions *options;
Channel *channel;
gint opacity;
gint update = FALSE;
guchar *tmpcolp;
guchar tmpcol[3];
gint i;
Channel *channel;
guchar *tmpcolp;
guchar tmpcol[3];
gboolean update = FALSE;
gint opacity;
gint i;
options = (EditQmaskOptions *) client_data;
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
opacity = (int) (255 * options->opacity/100);
opacity = (gint) (255 * options->opacity/100);
if (options->gimage && channel)
{ /* don't update if opacity hasn't changed */

View File

@ -40,12 +40,12 @@
struct _EditQmaskOptions
{
GtkWidget *query_box;
GtkWidget *name_entry;
GtkWidget *query_box;
GtkWidget *name_entry;
GimpImage *gimage;
ColorPanel *color_panel;
double opacity;
GimpImage *gimage;
ColorPanel *color_panel;
gdouble opacity;
};
typedef struct _EditQmaskOptions EditQmaskOptions;
@ -81,7 +81,7 @@ qmask_removed_callback (GtkObject *qmask,
if (!gdisp->gimage)
return;
gdisp->gimage->qmask_state = 0;
gdisp->gimage->qmask_state = FALSE;
qmask_buttons_update (gdisp);
}
@ -90,11 +90,10 @@ qmask_removed_callback (GtkObject *qmask,
void
qmask_buttons_update (GDisplay *gdisp)
{
g_assert(gdisp);
g_assert (gdisp);
g_assert (gdisp->gimage);
g_assert(gdisp->gimage);
if (gdisp->gimage->qmask_state != GTK_TOGGLE_BUTTON(gdisp->qmaskon)->active)
if (gdisp->gimage->qmask_state != GTK_TOGGLE_BUTTON (gdisp->qmaskon)->active)
{
/* Disable toggle from doing anything */
gtk_signal_handler_block_by_func(GTK_OBJECT(gdisp->qmaskoff),
@ -118,8 +117,6 @@ qmask_buttons_update (GDisplay *gdisp)
gtk_signal_handler_unblock_by_func(GTK_OBJECT(gdisp->qmaskon),
(GtkSignalFunc) qmask_activate,
gdisp);
/* Flush event queue */
/* while (g_main_iteration(FALSE)); */
}
}
@ -139,10 +136,10 @@ qmask_click_handler (GtkWidget *widget,
}
void
qmask_deactivate (GtkWidget *w,
GDisplay *gdisp)
qmask_deactivate (GtkWidget *widget,
GDisplay *gdisp)
{
GimpImage *gimg;
GimpImage *gimg;
GimpChannel *gmask;
if (gdisp)
@ -154,35 +151,35 @@ qmask_deactivate (GtkWidget *w,
if (!gdisp->gimage->qmask_state)
return; /* if already set do nothing */
undo_push_group_start (gimg, QMASK_UNDO);
if ( (gmask = gimp_image_get_channel_by_name (gimg, "Qmask")) )
{
undo_push_group_start (gimg, QMASK_UNDO);
/* push the undo here since removing the mask will
call the qmask_removed_callback() which will set
the qmask_state to FALSE */
undo_push_qmask (gimg);
gimage_mask_load (gimg, gmask);
gimage_remove_channel (gimg, gmask);
undo_push_qmask (gimg);
gdisp->gimage->qmask_state = 0;
undo_push_group_end (gimg);
}
else
gdisp->gimage->qmask_state = 0;
undo_push_group_end (gimg);
gdisp->gimage->qmask_state = FALSE;
if (gmask)
gdisplays_flush ();
gdisplays_flush ();
}
}
void
qmask_activate (GtkWidget *w,
qmask_activate (GtkWidget *widget,
GDisplay *gdisp)
{
GimpImage *gimg;
GimpImage *gimg;
GimpChannel *gmask;
GimpLayer *layer;
GimpLayer *layer;
double opacity;
unsigned char *color;
gdouble opacity;
guchar *color;
if (gdisp)
{
@ -194,16 +191,18 @@ qmask_activate (GtkWidget *w,
return; /* If already set, do nothing */
/* Set the defaults */
opacity = (double) gimg->qmask_opacity;
opacity = (gdouble) gimg->qmask_opacity;
color = gimg->qmask_color;
if ( (gmask = gimp_image_get_channel_by_name (gimg, "Qmask")) )
{
gimg->qmask_state = 1; /* if the user was clever and created his own */
gimg->qmask_state = TRUE;
/* if the user was clever and created his own */
return;
}
undo_push_group_start (gimg, QMASK_UNDO);
if (gimage_mask_is_empty(gimg))
{
if ((layer = gimage_floating_sel (gimg)))
@ -211,31 +210,29 @@ qmask_activate (GtkWidget *w,
floating_sel_to_layer (layer);
}
/* if no selection */
gmask = channel_new(gimg,
gimg->width,
gimg->height,
"Qmask",
(int)(255*opacity)/100,
color);
gmask = channel_new (gimg,
gimg->width,
gimg->height,
"Qmask",
(gint)(255*opacity)/100,
color);
gimp_image_add_channel (gimg, gmask, 0);
gimp_drawable_fill (GIMP_DRAWABLE(gmask), 0, 0, 0, 0);
/* edit_clear(gimg,GIMP_DRAWABLE(gmask)); */
undo_push_qmask (gimg);
gdisp->gimage->qmask_state = 1;
gimp_drawable_fill (GIMP_DRAWABLE (gmask), 0, 0, 0, 0);
}
else
{ /* if selection */
gmask = channel_copy (gimage_get_mask (gimg));
gimp_image_add_channel (gimg, gmask, 0);
channel_set_color(gmask, color);
channel_set_name(gmask, "Qmask");
channel_set_opacity(gmask, opacity);
channel_set_color (gmask, color);
channel_set_name (gmask, "Qmask");
channel_set_opacity (gmask, opacity);
gimage_mask_none (gimg); /* Clear the selection */
undo_push_qmask (gimg);
gdisp->gimage->qmask_state = 1;
}
undo_push_group_end(gimg);
gdisplays_flush();
undo_push_qmask (gimg);
undo_push_group_end (gimg);
gdisp->gimage->qmask_state = TRUE;
gdisplays_flush ();
/* connect to the removed signal, so the buttons get updated */
gtk_signal_connect (GTK_OBJECT (gmask), "removed",
@ -255,7 +252,7 @@ edit_qmask_channel_query (GDisplay * gdisp)
GtkObject *opacity_scale_data;
gint i;
guchar channel_color[3] = { 0, 0, 0 };
guchar channel_color[3] = { 0, 0, 0 };
/* channel = gimp_image_get_channel_by_name (gdisp->gimage, "Qmask"); */
/* the new options structure */
@ -330,16 +327,16 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
gpointer client_data)
{
EditQmaskOptions *options;
Channel *channel;
gint opacity;
gint update = FALSE;
guchar *tmpcolp;
guchar tmpcol[3];
gint i;
Channel *channel;
guchar *tmpcolp;
guchar tmpcol[3];
gboolean update = FALSE;
gint opacity;
gint i;
options = (EditQmaskOptions *) client_data;
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
opacity = (int) (255 * options->opacity/100);
opacity = (gint) (255 * options->opacity/100);
if (options->gimage && channel)
{ /* don't update if opacity hasn't changed */

View File

@ -40,12 +40,12 @@
struct _EditQmaskOptions
{
GtkWidget *query_box;
GtkWidget *name_entry;
GtkWidget *query_box;
GtkWidget *name_entry;
GimpImage *gimage;
ColorPanel *color_panel;
double opacity;
GimpImage *gimage;
ColorPanel *color_panel;
gdouble opacity;
};
typedef struct _EditQmaskOptions EditQmaskOptions;
@ -81,7 +81,7 @@ qmask_removed_callback (GtkObject *qmask,
if (!gdisp->gimage)
return;
gdisp->gimage->qmask_state = 0;
gdisp->gimage->qmask_state = FALSE;
qmask_buttons_update (gdisp);
}
@ -90,11 +90,10 @@ qmask_removed_callback (GtkObject *qmask,
void
qmask_buttons_update (GDisplay *gdisp)
{
g_assert(gdisp);
g_assert (gdisp);
g_assert (gdisp->gimage);
g_assert(gdisp->gimage);
if (gdisp->gimage->qmask_state != GTK_TOGGLE_BUTTON(gdisp->qmaskon)->active)
if (gdisp->gimage->qmask_state != GTK_TOGGLE_BUTTON (gdisp->qmaskon)->active)
{
/* Disable toggle from doing anything */
gtk_signal_handler_block_by_func(GTK_OBJECT(gdisp->qmaskoff),
@ -118,8 +117,6 @@ qmask_buttons_update (GDisplay *gdisp)
gtk_signal_handler_unblock_by_func(GTK_OBJECT(gdisp->qmaskon),
(GtkSignalFunc) qmask_activate,
gdisp);
/* Flush event queue */
/* while (g_main_iteration(FALSE)); */
}
}
@ -139,10 +136,10 @@ qmask_click_handler (GtkWidget *widget,
}
void
qmask_deactivate (GtkWidget *w,
GDisplay *gdisp)
qmask_deactivate (GtkWidget *widget,
GDisplay *gdisp)
{
GimpImage *gimg;
GimpImage *gimg;
GimpChannel *gmask;
if (gdisp)
@ -154,35 +151,35 @@ qmask_deactivate (GtkWidget *w,
if (!gdisp->gimage->qmask_state)
return; /* if already set do nothing */
undo_push_group_start (gimg, QMASK_UNDO);
if ( (gmask = gimp_image_get_channel_by_name (gimg, "Qmask")) )
{
undo_push_group_start (gimg, QMASK_UNDO);
/* push the undo here since removing the mask will
call the qmask_removed_callback() which will set
the qmask_state to FALSE */
undo_push_qmask (gimg);
gimage_mask_load (gimg, gmask);
gimage_remove_channel (gimg, gmask);
undo_push_qmask (gimg);
gdisp->gimage->qmask_state = 0;
undo_push_group_end (gimg);
}
else
gdisp->gimage->qmask_state = 0;
undo_push_group_end (gimg);
gdisp->gimage->qmask_state = FALSE;
if (gmask)
gdisplays_flush ();
gdisplays_flush ();
}
}
void
qmask_activate (GtkWidget *w,
qmask_activate (GtkWidget *widget,
GDisplay *gdisp)
{
GimpImage *gimg;
GimpImage *gimg;
GimpChannel *gmask;
GimpLayer *layer;
GimpLayer *layer;
double opacity;
unsigned char *color;
gdouble opacity;
guchar *color;
if (gdisp)
{
@ -194,16 +191,18 @@ qmask_activate (GtkWidget *w,
return; /* If already set, do nothing */
/* Set the defaults */
opacity = (double) gimg->qmask_opacity;
opacity = (gdouble) gimg->qmask_opacity;
color = gimg->qmask_color;
if ( (gmask = gimp_image_get_channel_by_name (gimg, "Qmask")) )
{
gimg->qmask_state = 1; /* if the user was clever and created his own */
gimg->qmask_state = TRUE;
/* if the user was clever and created his own */
return;
}
undo_push_group_start (gimg, QMASK_UNDO);
if (gimage_mask_is_empty(gimg))
{
if ((layer = gimage_floating_sel (gimg)))
@ -211,31 +210,29 @@ qmask_activate (GtkWidget *w,
floating_sel_to_layer (layer);
}
/* if no selection */
gmask = channel_new(gimg,
gimg->width,
gimg->height,
"Qmask",
(int)(255*opacity)/100,
color);
gmask = channel_new (gimg,
gimg->width,
gimg->height,
"Qmask",
(gint)(255*opacity)/100,
color);
gimp_image_add_channel (gimg, gmask, 0);
gimp_drawable_fill (GIMP_DRAWABLE(gmask), 0, 0, 0, 0);
/* edit_clear(gimg,GIMP_DRAWABLE(gmask)); */
undo_push_qmask (gimg);
gdisp->gimage->qmask_state = 1;
gimp_drawable_fill (GIMP_DRAWABLE (gmask), 0, 0, 0, 0);
}
else
{ /* if selection */
gmask = channel_copy (gimage_get_mask (gimg));
gimp_image_add_channel (gimg, gmask, 0);
channel_set_color(gmask, color);
channel_set_name(gmask, "Qmask");
channel_set_opacity(gmask, opacity);
channel_set_color (gmask, color);
channel_set_name (gmask, "Qmask");
channel_set_opacity (gmask, opacity);
gimage_mask_none (gimg); /* Clear the selection */
undo_push_qmask (gimg);
gdisp->gimage->qmask_state = 1;
}
undo_push_group_end(gimg);
gdisplays_flush();
undo_push_qmask (gimg);
undo_push_group_end (gimg);
gdisp->gimage->qmask_state = TRUE;
gdisplays_flush ();
/* connect to the removed signal, so the buttons get updated */
gtk_signal_connect (GTK_OBJECT (gmask), "removed",
@ -255,7 +252,7 @@ edit_qmask_channel_query (GDisplay * gdisp)
GtkObject *opacity_scale_data;
gint i;
guchar channel_color[3] = { 0, 0, 0 };
guchar channel_color[3] = { 0, 0, 0 };
/* channel = gimp_image_get_channel_by_name (gdisp->gimage, "Qmask"); */
/* the new options structure */
@ -330,16 +327,16 @@ edit_qmask_query_ok_callback (GtkWidget *widget,
gpointer client_data)
{
EditQmaskOptions *options;
Channel *channel;
gint opacity;
gint update = FALSE;
guchar *tmpcolp;
guchar tmpcol[3];
gint i;
Channel *channel;
guchar *tmpcolp;
guchar tmpcol[3];
gboolean update = FALSE;
gint opacity;
gint i;
options = (EditQmaskOptions *) client_data;
channel = gimp_image_get_channel_by_name (options->gimage, "Qmask");
opacity = (int) (255 * options->opacity/100);
opacity = (gint) (255 * options->opacity/100);
if (options->gimage && channel)
{ /* don't update if opacity hasn't changed */

File diff suppressed because it is too large Load Diff

View File

@ -18,71 +18,117 @@
#ifndef __UNDO_H__
#define __UNDO_H__
#include "undo_types.h"
#include "gimage.h"
#include "undo_types.h"
/* Undo interface functions */
int undo_push_group_start (GImage *, UndoType);
int undo_push_group_end (GImage *);
int undo_push_image (GImage *, GimpDrawable *, int, int, int, int);
int undo_push_image_mod (GImage *, GimpDrawable *, int, int, int, int, void *, int);
int undo_push_mask (GImage *, void *);
int undo_push_layer_displace (GImage *, GimpLayer*);
int undo_push_transform (GImage *, void *);
int undo_push_paint (GImage *, void *);
int undo_push_layer (GImage *, UndoType, void *);
int undo_push_layer_mod (GImage *, void *);
int undo_push_layer_mask (GImage *, UndoType, void *);
int undo_push_layer_change (GImage *, GimpLayer *);
int undo_push_layer_reposition (GImage *, GimpLayer *);
int undo_push_channel (GImage *, UndoType, void *);
int undo_push_channel_mod (GImage *, void *);
int undo_push_fs_to_layer (GImage *, void *);
int undo_push_fs_rigor (GImage *, int);
int undo_push_fs_relax (GImage *, int);
int undo_push_gimage_mod (GImage *);
int undo_push_guide (GImage *, void *);
int undo_push_image_parasite (GImage *, void *);
int undo_push_drawable_parasite (GImage *, GimpDrawable *, void *);
int undo_push_image_parasite_remove (GImage *, const char *);
int undo_push_drawable_parasite_remove (GImage *, GimpDrawable *,
const char *);
int undo_push_qmask (GImage *);
int undo_push_resolution (GImage *);
int undo_push_layer_rename (GImage *, GimpLayer *);
int undo_push_cantundo (GImage *, const char *);
gboolean undo_push_group_start (GImage *gimage,
UndoType type);
gboolean undo_push_group_end (GImage *gimage);
gboolean undo_push_image (GImage *gimage,
GimpDrawable *drawable,
gint x1,
gint y1,
gint x2,
gint y2);
gboolean undo_push_image_mod (GImage *gimage,
GimpDrawable *drawable,
gint x1,
gint y1,
gint x2,
gint y2,
gpointer tiles_ptr,
gboolean sparse);
gboolean undo_push_mask (GImage *gimage,
gpointer mask_ptr);
gboolean undo_push_layer_displace (GImage *gimage,
GimpLayer *layer);
gboolean undo_push_transform (GImage *gimage,
gpointer tu_ptr);
gboolean undo_push_paint (GImage *gimage,
gpointer pu_ptr);
gboolean undo_push_layer (GImage *gimage,
UndoType type,
gpointer lu_ptr);
gboolean undo_push_layer_mod (GImage *gimage,
gpointer layer_ptr);
gboolean undo_push_layer_mask (GImage *gimage,
UndoType type,
gpointer lmu_prt);
gboolean undo_push_layer_change (GImage *gimage,
GimpLayer *layer);
gboolean undo_push_layer_reposition (GImage *gimage,
GimpLayer *layer);
gboolean undo_push_channel (GImage *gimage,
UndoType type,
gpointer cu_ptr);
gboolean undo_push_channel_mod (GImage *gimage,
gpointer cmu_ptr);
gboolean undo_push_fs_to_layer (GImage *gimage,
gpointer fsu_ptr);
gboolean undo_push_fs_rigor (GImage *gimage,
gint32 layer_ID);
gboolean undo_push_fs_relax (GImage *gimage,
gint32 layer_ID);
gboolean undo_push_gimage_mod (GImage *gimage);
gboolean undo_push_guide (GImage *gimage,
gpointer guide);
gboolean undo_push_image_parasite (GImage *gimage,
gpointer parasite);
gboolean undo_push_drawable_parasite (GImage *gimage,
GimpDrawable *drawable,
gpointer parasite);
gboolean undo_push_image_parasite_remove
(GImage *gimage,
const gchar *name);
gboolean undo_push_drawable_parasite_remove
(GImage *gimage,
GimpDrawable *drabable,
const gchar *name);
gboolean undo_push_qmask (GImage *gimage);
gboolean undo_push_resolution (GImage *gimage);
gboolean undo_push_layer_rename (GImage *gimage,
GimpLayer *layer);
gboolean undo_push_cantundo (GImage *gimage,
const gchar *action);
int undo_pop (GImage *);
int undo_redo (GImage *);
void undo_free (GImage *);
gboolean undo_pop (GImage *gimage);
gboolean undo_redo (GImage *gimage);
void undo_free (GImage *gimage);
const gchar *undo_get_undo_name (GImage *gimage);
const gchar *undo_get_redo_name (GImage *gimage);
const char *undo_get_undo_name (GImage *);
const char *undo_get_redo_name (GImage *);
/* Stack peeking functions */
typedef int (*undo_map_fn) (const char *undoitemname, void *data);
void undo_map_over_undo_stack (GImage *, undo_map_fn, void *data);
void undo_map_over_redo_stack (GImage *, undo_map_fn, void *data);
UndoType undo_get_undo_top_type (GImage *);
typedef gint (*undo_map_fn) (const gchar *undoitemname,
gpointer data);
void undo_map_over_undo_stack (GImage *gimage,
undo_map_fn fn,
gpointer data);
void undo_map_over_redo_stack (GImage *gimage,
undo_map_fn fn,
gpointer data);
UndoType undo_get_undo_top_type (GImage *gimage);
/* Not really appropriate here, since undo_history_new is not defined
* in undo.c, but it saves on having a full header file for just one
* function prototype. */
GtkWidget *undo_history_new (GImage *gimage);
GtkWidget *undo_history_new (GImage *gimage);
/* Argument to undo_event signal emitted by gimages: */
typedef enum {
UNDO_PUSHED, /* a new undo has been added to the undo stack */
UNDO_EXPIRED, /* an undo has been freed from the undo stack */
UNDO_POPPED, /* an undo has been executed and moved to redo stack */
UNDO_REDO, /* a redo has been executed and moved to undo stack */
UNDO_FREE /* all undo and redo info has been cleared */
typedef enum
{
UNDO_PUSHED, /* a new undo has been added to the undo stack */
UNDO_EXPIRED, /* an undo has been freed from the undo stack */
UNDO_POPPED, /* an undo has been executed and moved to redo stack */
UNDO_REDO, /* a redo has been executed and moved to undo stack */
UNDO_FREE /* all undo and redo info has been cleared */
} undo_event_t;
#endif /* __UNDO_H__ */

View File

@ -297,6 +297,7 @@ enum
typedef struct
{
gint interlace;
gint save_comment;
gint loop;
gint default_delay;
gint default_dispose;
@ -355,10 +356,11 @@ GPlugInInfo PLUG_IN_INFO =
static GIFSaveVals gsvals =
{
FALSE, /* interlace */
TRUE, /* loop infinitely */
FALSE, /* interlace */
TRUE, /* save comment */
TRUE, /* loop infinitely */
100, /* default_delay between frames (100ms) */
0 /* default_dispose = "don't care" */
0 /* default_dispose = "don't care" */
};
static GIFSaveInterface gsint =
@ -475,8 +477,9 @@ run (gchar *name,
}
else
{
gsvals.interlace = (param[5].data.d_int32) ? TRUE : FALSE;
gsvals.loop = (param[6].data.d_int32) ? TRUE : FALSE;
gsvals.interlace = (param[5].data.d_int32) ? TRUE : FALSE;
gsvals.save_comment = TRUE; /* no way to to specify that through the PDB */
gsvals.loop = (param[6].data.d_int32) ? TRUE : FALSE;
gsvals.default_delay = param[7].data.d_int32;
gsvals.default_dispose = param[8].data.d_int32;
}
@ -533,7 +536,6 @@ typedef guchar CMap[3][MAXCOLORMAPSIZE];
gint verbose = FALSE;
gchar *globalcomment = NULL;
gint globalusecomment = TRUE;
@ -890,7 +892,8 @@ save_image (gchar *filename,
GIF87a. */
if (nlayers > 1)
is_gif89 = TRUE;
if (globalusecomment)
if (gsvals.save_comment)
is_gif89 = TRUE;
switch (drawable_type)
@ -983,7 +986,7 @@ save_image (gchar *filename,
GIFEncodeLoopExt (outfile, 0);
/* Write comment extension - mustn't be written before the looping ext. */
if (globalusecomment)
if (gsvals.save_comment)
{
GIFEncodeCommentExt (outfile, globalcomment);
}
@ -1249,8 +1252,8 @@ save_dialog (gint32 image_ID)
gtk_box_pack_start (GTK_BOX (hbox), toggle, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (toggle), "toggled",
GTK_SIGNAL_FUNC (gimp_toggle_button_update),
&globalusecomment);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), TRUE);
&gsvals.save_comment);
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle), gsvals.save_comment);
gtk_widget_show (toggle);
com_table = gtk_table_new (1, 1, FALSE);