Commit 59b06707 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer
Browse files

added GimpDropMode... ...removed from here.

2001-05-06  Michael Natterer  <mitch@gimp.org>

	* app/appenums.h: added GimpDropMode...
	* app/gimpdnd.h: ...removed from here.

	* app/gimpimage.[ch]:
	- New signal "mode_changed".
	- removed "const GimpImage*" from gimp_image_colormap_changed()
	  because a signal emission is never "const" for the object
	  which emits the signal.
	- Fixed gimp_image_[set|get]_component_[active|visible]():
	  ALPHA_CHANNEL maps to ALPHA_PIX only in RGB mode, use
	  ALPHA_G_PIX/ALPHA_I_PIX in GRAY/INDEXED mode.

	* app/gimpimage-convert.c
	* app/undo.c: call gimp_image_mode_changed().

	* app/gimpviewable.c: added an implementation of
	"invalidate_preview" which frees the preview temp_buf which may be
	attached to the viewable. Subclasses need to chain up now.

	* app/gimpdrawable.c
	* app/gimpimage.c: chain up in invalidate_preview().

	* app/widgets/gimpchannellistview.c: connect to the image's
	"mode_changed" signal and rebuild the channel list in the
	callback.

	* app/widgets/gimpcontainerview.h: indentation.

	* app/widgets/gimpdockbook.c: set the dockable's context to NULL
	in gimp_dockbook_remove()

	* app/widgets/gimpimagedock.c: forgot to actually set the dock's
	image in gimp_image_dock_new().

	* app/gui/dialogs-constructors.c: added a get_name_func() for tool
	views which returns the tool's "blurb". It's safe to assume now
	that a dockable's context will exist as long as the dockable
	exists unless it's explicitely set to NULL, so remove ugly hacks
	handling context destruction.

	* app/tools/gimptool.c: removed COMPAT_CRUFT and useless #include's.
parent b4ad2ab0
2001-05-06 Michael Natterer <mitch@gimp.org>
* app/appenums.h: added GimpDropMode...
* app/gimpdnd.h: ...removed from here.
* app/gimpimage.[ch]:
- New signal "mode_changed".
- removed "const GimpImage*" from gimp_image_colormap_changed()
because a signal emission is never "const" for the object
which emits the signal.
- Fixed gimp_image_[set|get]_component_[active|visible]():
ALPHA_CHANNEL maps to ALPHA_PIX only in RGB mode, use
ALPHA_G_PIX/ALPHA_I_PIX in GRAY/INDEXED mode.
* app/gimpimage-convert.c
* app/undo.c: call gimp_image_mode_changed().
* app/gimpviewable.c: added an implementation of
"invalidate_preview" which frees the preview temp_buf which may be
attached to the viewable. Subclasses need to chain up now.
* app/gimpdrawable.c
* app/gimpimage.c: chain up in invalidate_preview().
* app/widgets/gimpchannellistview.c: connect to the image's
"mode_changed" signal and rebuild the channel list in the
callback.
* app/widgets/gimpcontainerview.h: indentation.
* app/widgets/gimpdockbook.c: set the dockable's context to NULL
in gimp_dockbook_remove()
* app/widgets/gimpimagedock.c: forgot to actually set the dock's
image in gimp_image_dock_new().
* app/gui/dialogs-constructors.c: added a get_name_func() for tool
views which returns the tool's "blurb". It's safe to assume now
that a dockable's context will exist as long as the dockable
exists unless it's explicitely set to NULL, so remove ugly hacks
handling context destruction.
* app/tools/gimptool.c: removed COMPAT_CRUFT and useless #include's.
2001-05-04 Michael Natterer <mitch@gimp.org>
* configure.in
......
......@@ -20,6 +20,13 @@
#define __APPENUMS_H__
typedef enum /*< skip >*/
{
GIMP_DROP_NONE,
GIMP_DROP_ABOVE,
GIMP_DROP_BELOW
} GimpDropType;
/* Base image types */
typedef enum
{
......
......@@ -301,6 +301,9 @@ gimp_drawable_invalidate_preview (GimpViewable *viewable)
GimpDrawable *drawable;
GimpImage *gimage;
if (GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview)
GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview (viewable);
drawable = GIMP_DRAWABLE (viewable);
drawable->preview_valid = FALSE;
......
......@@ -943,6 +943,8 @@ gimp_image_convert (GimpImage *gimage,
gimp_image_colormap_changed (gimage, -1);
gimp_image_mode_changed (gimage);
gimp_remove_busy_cursors(NULL);
}
......
......@@ -155,6 +155,7 @@ guint32 next_guide_id = 1; /* For generating guide_ID handles for PDB stuff */
enum
{
MODE_CHANGED,
ACTIVE_LAYER_CHANGED,
ACTIVE_CHANNEL_CHANGED,
COMPONENT_VISIBILITY_CHANGED,
......@@ -215,6 +216,15 @@ gimp_image_class_init (GimpImageClass *klass)
parent_class = gtk_type_class (GIMP_TYPE_VIEWABLE);
gimp_image_signals[MODE_CHANGED] =
gtk_signal_new ("mode_changed",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpImageClass,
mode_changed),
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
gimp_image_signals[ACTIVE_LAYER_CHANGED] =
gtk_signal_new ("active_layer_changed",
GTK_RUN_FIRST,
......@@ -484,6 +494,9 @@ gimp_image_invalidate_preview (GimpViewable *viewable)
GimpImage *gimage;
GimpLayer *layer;
if (GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview)
GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview (viewable);
gimage = GIMP_IMAGE (viewable);
/* Invalidate the floating sel if it exists */
......@@ -1599,8 +1612,8 @@ gimp_image_get_paths (const GimpImage *gimage)
}
void
gimp_image_colormap_changed (const GimpImage *gimage,
gint col)
gimp_image_colormap_changed (GimpImage *gimage,
gint col)
{
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (col < gimage->num_cols);
......@@ -1610,6 +1623,14 @@ gimp_image_colormap_changed (const GimpImage *gimage,
col);
}
void
gimp_image_mode_changed (GimpImage *gimage)
{
g_return_if_fail (GIMP_IS_IMAGE (gimage));
gtk_signal_emit (GTK_OBJECT (gimage), gimp_image_signals[MODE_CHANGED]);
}
/************************************************************/
/* Projection functions */
/************************************************************/
......@@ -2363,6 +2384,51 @@ gimp_image_get_mask (const GimpImage *gimage)
return gimage->selection_mask;
}
void
gimp_image_set_component_active (GimpImage *gimage,
ChannelType type,
gboolean active)
{
gint pixel = -1;
g_return_if_fail (gimage != NULL);
g_return_if_fail (GIMP_IS_IMAGE (gimage));
switch (type)
{
case RED_CHANNEL: pixel = RED_PIX; break;
case GREEN_CHANNEL: pixel = GREEN_PIX; break;
case BLUE_CHANNEL: pixel = BLUE_PIX; break;
case GRAY_CHANNEL: pixel = GRAY_PIX; break;
case INDEXED_CHANNEL: pixel = INDEXED_PIX; break;
case ALPHA_CHANNEL:
switch (gimp_image_base_type (gimage))
{
case RGB: pixel = ALPHA_PIX; break;
case GRAY: pixel = ALPHA_G_PIX; break;
case INDEXED: pixel = ALPHA_I_PIX; break;
}
break;
default:
break;
}
if (pixel != -1 && active != gimage->active[pixel])
{
gimage->active[pixel] = active ? TRUE : FALSE;
/* If there is an active channel and we mess with the components,
* the active channel gets unset...
*/
gimp_image_unset_active_channel (gimage);
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[COMPONENT_ACTIVE_CHANGED],
type);
}
}
gboolean
gimp_image_get_component_active (const GimpImage *gimage,
ChannelType type)
......@@ -2370,13 +2436,64 @@ gimp_image_get_component_active (const GimpImage *gimage,
/* No sanity checking here... */
switch (type)
{
case RED_CHANNEL: return gimage->active[RED_PIX]; break;
case GREEN_CHANNEL: return gimage->active[GREEN_PIX]; break;
case BLUE_CHANNEL: return gimage->active[BLUE_PIX]; break;
case GRAY_CHANNEL: return gimage->active[GRAY_PIX]; break;
case RED_CHANNEL: return gimage->active[RED_PIX]; break;
case GREEN_CHANNEL: return gimage->active[GREEN_PIX]; break;
case BLUE_CHANNEL: return gimage->active[BLUE_PIX]; break;
case GRAY_CHANNEL: return gimage->active[GRAY_PIX]; break;
case INDEXED_CHANNEL: return gimage->active[INDEXED_PIX]; break;
case ALPHA_CHANNEL: return gimage->active[ALPHA_PIX]; break;
default: return FALSE; break;
case ALPHA_CHANNEL:
switch (gimp_image_base_type (gimage))
{
case RGB: return gimage->active[ALPHA_PIX]; break;
case GRAY: return gimage->active[ALPHA_G_PIX]; break;
case INDEXED: return gimage->active[ALPHA_I_PIX]; break;
}
break;
default:
break;
}
return FALSE;
}
void
gimp_image_set_component_visible (GimpImage *gimage,
ChannelType type,
gboolean visible)
{
gint pixel = -1;
g_return_if_fail (gimage != NULL);
g_return_if_fail (GIMP_IS_IMAGE (gimage));
switch (type)
{
case RED_CHANNEL: pixel = RED_PIX; break;
case GREEN_CHANNEL: pixel = GREEN_PIX; break;
case BLUE_CHANNEL: pixel = BLUE_PIX; break;
case GRAY_CHANNEL: pixel = GRAY_PIX; break;
case INDEXED_CHANNEL: pixel = INDEXED_PIX; break;
case ALPHA_CHANNEL:
switch (gimp_image_base_type (gimage))
{
case RGB: pixel = ALPHA_PIX; break;
case GRAY: pixel = ALPHA_G_PIX; break;
case INDEXED: pixel = ALPHA_I_PIX; break;
}
break;
default:
break;
}
if (pixel != -1 && visible != gimage->visible[pixel])
{
gimage->visible[pixel] = visible ? TRUE : FALSE;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[COMPONENT_VISIBILITY_CHANGED],
type);
}
}
......@@ -2387,14 +2504,25 @@ gimp_image_get_component_visible (const GimpImage *gimage,
/* No sanity checking here... */
switch (type)
{
case RED_CHANNEL: return gimage->visible[RED_PIX]; break;
case GREEN_CHANNEL: return gimage->visible[GREEN_PIX]; break;
case BLUE_CHANNEL: return gimage->visible[BLUE_PIX]; break;
case GRAY_CHANNEL: return gimage->visible[GRAY_PIX]; break;
case RED_CHANNEL: return gimage->visible[RED_PIX]; break;
case GREEN_CHANNEL: return gimage->visible[GREEN_PIX]; break;
case BLUE_CHANNEL: return gimage->visible[BLUE_PIX]; break;
case GRAY_CHANNEL: return gimage->visible[GRAY_PIX]; break;
case INDEXED_CHANNEL: return gimage->visible[INDEXED_PIX]; break;
case ALPHA_CHANNEL: return gimage->visible[ALPHA_PIX]; break;
default: return FALSE; break;
case ALPHA_CHANNEL:
switch (gimp_image_base_type (gimage))
{
case RGB: return gimage->visible[ALPHA_PIX]; break;
case GRAY: return gimage->visible[ALPHA_G_PIX]; break;
case INDEXED: return gimage->visible[ALPHA_I_PIX]; break;
}
break;
default:
break;
}
return FALSE;
}
gboolean
......@@ -2534,73 +2662,6 @@ gimp_image_unset_active_channel (GimpImage *gimage)
return channel;
}
void
gimp_image_set_component_active (GimpImage *gimage,
ChannelType type,
gboolean active)
{
gint pixel = -1;
g_return_if_fail (gimage != NULL);
g_return_if_fail (GIMP_IS_IMAGE (gimage));
switch (type)
{
case RED_CHANNEL: pixel = RED_PIX; break;
case GREEN_CHANNEL: pixel = GREEN_PIX; break;
case BLUE_CHANNEL: pixel = BLUE_PIX; break;
case GRAY_CHANNEL: pixel = GRAY_PIX; break;
case INDEXED_CHANNEL: pixel = INDEXED_PIX; break;
case ALPHA_CHANNEL: pixel = ALPHA_PIX; break;
default: break;
}
if (pixel != -1 && active != gimage->active[pixel])
{
gimage->active[pixel] = active ? TRUE : FALSE;
/* If there is an active channel and we mess with the components,
* the active channel gets unset...
*/
gimp_image_unset_active_channel (gimage);
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[COMPONENT_ACTIVE_CHANGED],
type);
}
}
void
gimp_image_set_component_visible (GimpImage *gimage,
ChannelType type,
gboolean visible)
{
gint pixel = -1;
g_return_if_fail (gimage != NULL);
g_return_if_fail (GIMP_IS_IMAGE (gimage));
switch (type)
{
case RED_CHANNEL: pixel = RED_PIX; break;
case GREEN_CHANNEL: pixel = GREEN_PIX; break;
case BLUE_CHANNEL: pixel = BLUE_PIX; break;
case GRAY_CHANNEL: pixel = GRAY_PIX; break;
case INDEXED_CHANNEL: pixel = INDEXED_PIX; break;
case ALPHA_CHANNEL: pixel = ALPHA_PIX; break;
default: break;
}
if (pixel != -1 && visible != gimage->visible[pixel])
{
gimage->visible[pixel] = visible ? TRUE : FALSE;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[COMPONENT_VISIBILITY_CHANGED],
type);
}
}
GimpLayer *
gimp_image_pick_correlate_layer (const GimpImage *gimage,
gint x,
......
......@@ -148,6 +148,7 @@ struct _GimpImageClass
{
GimpViewableClass parent_class;
void (* mode_changed) (GimpImage *gimage);
void (* active_layer_changed) (GimpImage *gimage);
void (* active_channel_changed) (GimpImage *gimage);
void (* component_visibility_changed) (GimpImage *gimage,
......@@ -302,9 +303,11 @@ PathList * gimp_image_get_paths (const GimpImage *gimage);
Currently, use this also when the image's base type is changed to/from
indexed. */
void gimp_image_colormap_changed (const GimpImage *image,
void gimp_image_colormap_changed (GimpImage *gimage,
gint col);
void gimp_image_mode_changed (GimpImage *gimage);
/* layer/channel functions */
......@@ -324,10 +327,19 @@ GimpChannel * gimp_image_get_channel_by_tattoo (const GimpImage *gimage,
GimpChannel * gimp_image_get_channel_by_name (const GimpImage *gimage,
const gchar *name);
GimpChannel * gimp_image_get_mask (const GimpImage *gimage);
void gimp_image_set_component_active (GimpImage *gimage,
ChannelType type,
gboolean active);
gboolean gimp_image_get_component_active (const GimpImage *gimage,
ChannelType type);
void gimp_image_set_component_visible (GimpImage *gimage,
ChannelType type,
gboolean visible);
gboolean gimp_image_get_component_visible (const GimpImage *gimage,
ChannelType type);
gboolean gimp_image_layer_boundary (const GimpImage *gimage,
BoundSeg **segs,
gint *n_segs);
......@@ -336,12 +348,6 @@ GimpLayer * gimp_image_set_active_layer (GimpImage *gimage,
GimpChannel * gimp_image_set_active_channel (GimpImage *gimage,
GimpChannel *channel);
GimpChannel * gimp_image_unset_active_channel (GimpImage *gimage);
void gimp_image_set_component_active (GimpImage *gimage,
ChannelType type,
gboolean active);
void gimp_image_set_component_visible (GimpImage *gimage,
ChannelType type,
gboolean visible);
GimpLayer * gimp_image_pick_correlate_layer (const GimpImage *gimage,
gint x,
gint y);
......
......@@ -155,6 +155,7 @@ guint32 next_guide_id = 1; /* For generating guide_ID handles for PDB stuff */
enum
{
MODE_CHANGED,
ACTIVE_LAYER_CHANGED,
ACTIVE_CHANNEL_CHANGED,
COMPONENT_VISIBILITY_CHANGED,
......@@ -215,6 +216,15 @@ gimp_image_class_init (GimpImageClass *klass)
parent_class = gtk_type_class (GIMP_TYPE_VIEWABLE);
gimp_image_signals[MODE_CHANGED] =
gtk_signal_new ("mode_changed",
GTK_RUN_FIRST,
object_class->type,
GTK_SIGNAL_OFFSET (GimpImageClass,
mode_changed),
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
gimp_image_signals[ACTIVE_LAYER_CHANGED] =
gtk_signal_new ("active_layer_changed",
GTK_RUN_FIRST,
......@@ -484,6 +494,9 @@ gimp_image_invalidate_preview (GimpViewable *viewable)
GimpImage *gimage;
GimpLayer *layer;
if (GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview)
GIMP_VIEWABLE_CLASS (parent_class)->invalidate_preview (viewable);
gimage = GIMP_IMAGE (viewable);
/* Invalidate the floating sel if it exists */
......@@ -1599,8 +1612,8 @@ gimp_image_get_paths (const GimpImage *gimage)
}
void
gimp_image_colormap_changed (const GimpImage *gimage,
gint col)
gimp_image_colormap_changed (GimpImage *gimage,
gint col)
{
g_return_if_fail (GIMP_IS_IMAGE (gimage));
g_return_if_fail (col < gimage->num_cols);
......@@ -1610,6 +1623,14 @@ gimp_image_colormap_changed (const GimpImage *gimage,
col);
}
void
gimp_image_mode_changed (GimpImage *gimage)
{
g_return_if_fail (GIMP_IS_IMAGE (gimage));
gtk_signal_emit (GTK_OBJECT (gimage), gimp_image_signals[MODE_CHANGED]);
}
/************************************************************/
/* Projection functions */
/************************************************************/
......@@ -2363,6 +2384,51 @@ gimp_image_get_mask (const GimpImage *gimage)
return gimage->selection_mask;
}
void
gimp_image_set_component_active (GimpImage *gimage,
ChannelType type,
gboolean active)
{
gint pixel = -1;
g_return_if_fail (gimage != NULL);
g_return_if_fail (GIMP_IS_IMAGE (gimage));
switch (type)
{
case RED_CHANNEL: pixel = RED_PIX; break;
case GREEN_CHANNEL: pixel = GREEN_PIX; break;
case BLUE_CHANNEL: pixel = BLUE_PIX; break;
case GRAY_CHANNEL: pixel = GRAY_PIX; break;
case INDEXED_CHANNEL: pixel = INDEXED_PIX; break;
case ALPHA_CHANNEL:
switch (gimp_image_base_type (gimage))
{
case RGB: pixel = ALPHA_PIX; break;
case GRAY: pixel = ALPHA_G_PIX; break;
case INDEXED: pixel = ALPHA_I_PIX; break;
}
break;
default:
break;
}
if (pixel != -1 && active != gimage->active[pixel])
{
gimage->active[pixel] = active ? TRUE : FALSE;
/* If there is an active channel and we mess with the components,
* the active channel gets unset...
*/
gimp_image_unset_active_channel (gimage);
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[COMPONENT_ACTIVE_CHANGED],
type);
}
}
gboolean
gimp_image_get_component_active (const GimpImage *gimage,
ChannelType type)
......@@ -2370,13 +2436,64 @@ gimp_image_get_component_active (const GimpImage *gimage,
/* No sanity checking here... */
switch (type)
{
case RED_CHANNEL: return gimage->active[RED_PIX]; break;
case GREEN_CHANNEL: return gimage->active[GREEN_PIX]; break;
case BLUE_CHANNEL: return gimage->active[BLUE_PIX]; break;
case GRAY_CHANNEL: return gimage->active[GRAY_PIX]; break;
case RED_CHANNEL: return gimage->active[RED_PIX]; break;
case GREEN_CHANNEL: return gimage->active[GREEN_PIX]; break;
case BLUE_CHANNEL: return gimage->active[BLUE_PIX]; break;
case GRAY_CHANNEL: return gimage->active[GRAY_PIX]; break;
case INDEXED_CHANNEL: return gimage->active[INDEXED_PIX]; break;
case ALPHA_CHANNEL: return gimage->active[ALPHA_PIX]; break;
default: return FALSE; break;
case ALPHA_CHANNEL:
switch (gimp_image_base_type (gimage))
{
case RGB: return gimage->active[ALPHA_PIX]; break;
case GRAY: return gimage->active[ALPHA_G_PIX]; break;
case INDEXED: return gimage->active[ALPHA_I_PIX]; break;
}
break;
default:
break;
}
return FALSE;
}
void
gimp_image_set_component_visible (GimpImage *gimage,
ChannelType type,
gboolean visible)
{
gint pixel = -1;
g_return_if_fail (gimage != NULL);
g_return_if_fail (GIMP_IS_IMAGE (gimage));
switch (type)
{
case RED_CHANNEL: pixel = RED_PIX; break;
case GREEN_CHANNEL: pixel = GREEN_PIX; break;
case BLUE_CHANNEL: pixel = BLUE_PIX; break;
case GRAY_CHANNEL: pixel = GRAY_PIX; break;
case INDEXED_CHANNEL: pixel = INDEXED_PIX; break;
case ALPHA_CHANNEL:
switch (gimp_image_base_type (gimage))
{
case RGB: pixel = ALPHA_PIX; break;
case GRAY: pixel = ALPHA_G_PIX; break;
case INDEXED: pixel = ALPHA_I_PIX; break;
}
break;
default:
break;
}
if (pixel != -1 && visible != gimage->visible[pixel])
{
gimage->visible[pixel] = visible ? TRUE : FALSE;
gtk_signal_emit (GTK_OBJECT (gimage),
gimp_image_signals[COMPONENT_VISIBILITY_CHANGED],
type);
}
}
......@@ -2387,14 +2504,25 @@ gimp_image_get_component_visible (const GimpImage *gimage,
/* No sanity checking here... */
switch (type)
{
case RED_CHANNEL: return gimage->visible[RED_PIX]; break;