Commit 6849f64a authored by Manish Singh's avatar Manish Singh

make text entry for function name read-only

* plug-ins/dbbrowser/dbbrowser_util.c: make text entry for function name
read-only

* plug-ins/film/film.c
* plug-ins/animationplay/animationplay.c: minor cleanups

-Yosh
parent 24fb7f74
Sat Apr 18 11:37:46 PDT 1998 Manish Singh <yosh@gimp.org>
* plug-ins/dbbrowser/dbbrowser_util.c: make text entry for function
name read-only
* plug-ins/film/film.c
* plug-ins/animationplay/animationplay.c: minor cleanups
Thu Apr 16 19:46:46 MEST 1998 Sven Neumann <sven@gimp.org>
* plug-ins/script-fu/interp_slib.c: changed the link to
......
......@@ -2,7 +2,7 @@
SUBDIRS = libgimp plug-ins app data
EXTRA_DIST = TODO NOTES gtkrc gimp_logo.ppm gimp_splash.ppm rmshm user_install gimp_tips.txt ps-menurc
EXTRA_DIST = TODO NOTES gtkrc gimp_logo.ppm gimp_splash.ppm rmshm user_install gimp_tips.txt ps-menurc gimp.spec
gimpdata_DATA = gimprc gimprc_user gtkrc gimp_logo.ppm gimp_splash.ppm gimp_tips.txt ps-menurc
......
......@@ -268,6 +268,7 @@ dialog_select (dbbrowser_t *dbbrowser,
label = gtk_entry_new();
gtk_entry_set_text(GTK_ENTRY(label),dbbrowser->selected_scheme_proc_name);
gtk_entry_set_editable(GTK_ENTRY(label), FALSE);
gtk_table_attach (GTK_TABLE (dbbrowser->descr_table), label,
1, 4, row, row+1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show(label);
......
......@@ -268,6 +268,7 @@ dialog_select (dbbrowser_t *dbbrowser,
label = gtk_entry_new();
gtk_entry_set_text(GTK_ENTRY(label),dbbrowser->selected_scheme_proc_name);
gtk_entry_set_editable(GTK_ENTRY(label), FALSE);
gtk_table_attach (GTK_TABLE (dbbrowser->descr_table), label,
1, 4, row, row+1, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show(label);
......
/*
* Animation Playback plug-in version 0.85.0
* Animation Playback plug-in version 0.94.0
*
* by Adam D. Moss, 1997-98
* adam@gimp.org
* adam@foxbox.org
* Adam D. Moss : 1997-98 : adam@gimp.org : adam@foxbox.org
*
* This is part of the GIMP package and falls under the GPL.
*
* This is part of the GIMP package and is released under the GNU
* Public License.
*/
/*
* REVISION HISTORY:
*
* 98.04.05 : version 0.94.0
* Improved performance and removed flicker when shaped.
* Shaped mode also works with RGB* images now.
* Fixed some longstanding potential visual debris.
*
* 98.04.04 : version 0.92.0
* Improved responsiveness and performance for the new
* shaped-animation mode. Still some flicker.
*
* 98.04.02 : version 0.90.0
* EXPERIMENTAL wackyness - try dragging the animation
* out of the plugin dialog's preview box...
* (only works on non-RGB* images for now)
*
* 98.03.16 : version 0.85.0
* Implemented some more rare opaque/alpha combinations.
*
......@@ -44,10 +58,15 @@
/*
* BUGS:
* Leaks memory. Not sure why.
* Gets understandably upset if the source image is deleted
* while the animation is playing.
* Decent solutions to either of the above are most welcome.
* while the animation is playing. Decent solution welcome.
*
* In shaped mode, the shaped-window's mask and its pixmap contents
* can get way out of sync (specifically, the mask changes but
* the contents are frozen). Starvation of GTK's redrawing thread?
* How do I fix this?
*
* Often segfaults on exit. GTK stuff. Help.
*
* Any more? Let me know!
*/
......@@ -55,8 +74,11 @@
/*
* TODO:
* pdb interface - should we bother?
*
* speedups (caching? most bottlenecks seem to be in pixelrgns)
* write other half of the user interface
* -> do pixelrgns properly!
*
* write other half of the user interface (default timing, disposal &c)
*/
#include <stdlib.h>
......@@ -64,6 +86,7 @@
#include <string.h>
#include <ctype.h>
#include "libgimp/gimp.h"
#include "gdk/gdkx.h"
#include "gtk/gtk.h"
......@@ -105,6 +128,7 @@ static void total_alpha_preview (void);
static void init_preview_misc (void);
GPlugInInfo PLUG_IN_INFO =
{
NULL, /* init_proc */
......@@ -136,6 +160,20 @@ gint ncolours;
/* for shaping */
guchar *shape_preview_mask;
GtkWidget *shape_window;
GtkWidget *shape_fixed;
GtkPreview *shape_preview;
GdkPixmap *shape_pixmap;
typedef struct _cursoroffset {gint x,y;} CursorOffset;
gint shaping = 0;
static GdkWindow *root_win = NULL;
MAIN()
......@@ -156,7 +194,7 @@ static void query()
"",
"Adam D. Moss <adam@gimp.org>",
"Adam D. Moss <adam@gimp.org>",
"1997",
"1997, 1998...",
"<Image>/Filters/Animation/Animation Playback",
"RGB*, INDEXED*, GRAY*",
PROC_PLUG_IN,
......@@ -255,6 +293,188 @@ parse_disposal_tag (char *str)
}
static void
reshape_from_bitmap(guchar* bitmap)
{
GdkBitmap *shape_mask;
shape_mask = gdk_bitmap_create_from_data(shape_window->window,
bitmap,
width, height);
gtk_widget_shape_combine_mask (shape_window, shape_mask, 0, 0);
gdk_bitmap_unref (shape_mask);
}
static void
shape_pressed (GtkWidget *widget, GdkEventButton *event)
{
CursorOffset *p;
/* ignore double and triple click */
if (event->type != GDK_BUTTON_PRESS)
return;
p = gtk_object_get_user_data (GTK_OBJECT(widget));
p->x = (int) event->x;
p->y = (int) event->y;
gtk_grab_add (widget);
gdk_pointer_grab (widget->window, TRUE,
GDK_BUTTON_RELEASE_MASK |
GDK_BUTTON_MOTION_MASK |
GDK_POINTER_MOTION_HINT_MASK,
NULL, NULL, 0);
gdk_window_raise (widget->window);
}
static void
blocked_expose (GtkWidget *widget, GdkEventExpose *event)
{
gtk_signal_emit_stop_by_name (GTK_OBJECT(widget), "expose_event");
}
#ifdef I_AM_STUPID
static void
xblocked_expose (GtkWidget *widget, GdkEventExpose *event)
{
printf("eep!\n");fflush(stdout);
abort();
}
static void
unblocked_expose (GtkWidget *widget, GdkEventExpose *event)
{
gboolean should_block;
printf("%p: t%d w:%p s:%d c:%d \n",widget, event->type, event->window,
event->send_event, event->count);
fflush(stdout);
return;
/*
* If the animation is playing, we only respond to exposures
* which are artificially generated as a result of i.e.
* draw_widget. This is to avoid needlessly redrawing twice
* per frame, because also 'real' exposure events may be generated
* by reshaping the windoow.
*
* If the animation is not playing, then we respond to any type
* of expose event.
*/
if (playing)
should_block = (!event->send_event) || (event->count != 0);
else
should_block = FALSE;
if (should_block)
{
/*
* Since a whole load of exposures can come back-to-back,
* starvation can occur for the dialog etc. This alleviates
* the pain.
*/
while (gtk_events_pending())
gtk_main_iteration_do(TRUE);
/*
* Block the expose from being acted upon.
*/
blocked_expose(widget, event);
return;
}
}
#endif
static void
shape_released (GtkWidget *widget)
{
gtk_grab_remove (widget);
gdk_pointer_ungrab (0);
gdk_flush();
}
static void
shape_motion (GtkWidget *widget,
GdkEventMotion *event)
{
gint xp, yp;
CursorOffset * p;
GdkModifierType mask;
gdk_window_get_pointer (root_win, &xp, &yp, &mask);
// printf("%u %d\n", mask, event->state);fflush(stdout);
/* if a button is still held by the time we process this event... */
if (mask & (GDK_BUTTON1_MASK|
GDK_BUTTON2_MASK|
GDK_BUTTON3_MASK|
GDK_BUTTON4_MASK|
GDK_BUTTON5_MASK))
{
p = gtk_object_get_user_data (GTK_OBJECT (widget));
gtk_widget_set_uposition (widget, xp - p->x, yp - p->y);
}
else /* the user has released all buttons */
{
shape_released(widget);
}
}
static void
preview_pressed (GtkWidget *widget, GdkEventButton *event)
{
gint i;
gint xp, yp;
GdkModifierType mask;
if (shaping) return;
/* put current preview buf into shaped buf */
for (i=0;i<height;i++)
{
gtk_preview_draw_row (shape_preview,
&preview_data[3*i*width],
0, i, width);
}
gdk_window_get_pointer (root_win, &xp, &yp, &mask);
gtk_widget_set_uposition (shape_window, xp - event->x, yp - event->y);
gtk_widget_show (shape_window);
gdk_window_set_back_pixmap(shape_window->window, NULL, 0);
gdk_window_set_back_pixmap(shape_fixed->window, NULL, 1);
/* clear nonshaped preview widget */
total_alpha_preview();
for (i=0;i<height;i++)
{
gtk_preview_draw_row (preview,
&preview_data[3*i*width],
0, i, width);
}
show_frame();
shaping = 1;
memset(shape_preview_mask, 0, (width*height)/8 + height);
render_frame(frame_number);
show_frame();
/* mildly amusing hack */
shape_pressed(shape_window, event);
}
static void
......@@ -265,6 +485,7 @@ build_dialog(GImageType basetype,
gint argc;
gchar* windowname;
CursorOffset* icon_pos;
GtkWidget* dlg;
GtkWidget* button;
......@@ -273,7 +494,9 @@ build_dialog(GImageType basetype,
GtkWidget* vbox;
GtkWidget* hbox;
GtkWidget* hbox2;
GtkWidget* eventbox;
guchar* color_cube;
GdkCursor* cursor;
argc = 1;
argv = g_new (gchar *, 1);
......@@ -299,7 +522,7 @@ build_dialog(GImageType basetype,
gtk_window_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE);
gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
(GtkSignalFunc) window_close_callback,
(GtkObject *)dlg);
GTK_OBJECT (dlg));
/* Action area - 'close' button only. */
......@@ -373,19 +596,35 @@ build_dialog(GImageType basetype,
if (total_frames<=1) gtk_widget_set_sensitive (hbox2, FALSE);
gtk_widget_show(hbox2);
hbox2 = gtk_hbox_new (TRUE, 0);
gtk_container_border_width (GTK_CONTAINER (hbox2), 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox2, FALSE, FALSE, 0);
{
frame2 = gtk_frame_new (NULL);
gtk_frame_set_shadow_type (GTK_FRAME (frame2), GTK_SHADOW_ETCHED_IN);
gtk_box_pack_start (GTK_BOX (vbox), frame2, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox2), frame2, FALSE, FALSE, 0);
{
eventbox = gtk_event_box_new();
gtk_container_add (GTK_CONTAINER (frame2), GTK_WIDGET (eventbox));
{
preview =
GTK_PREVIEW (gtk_preview_new (GTK_PREVIEW_COLOR)); /* FIXME */
GTK_PREVIEW (gtk_preview_new (GTK_PREVIEW_COLOR));/* FIXME */
gtk_preview_size (preview, width, height);
gtk_container_add (GTK_CONTAINER (frame2), GTK_WIDGET (preview));
gtk_container_add (GTK_CONTAINER (eventbox),
GTK_WIDGET (preview));
gtk_widget_show(GTK_WIDGET (preview));
}
gtk_widget_show(eventbox);
gtk_widget_set_events (eventbox,
gtk_widget_get_events (eventbox)
| GDK_BUTTON_PRESS_MASK);
}
gtk_widget_show(frame2);
}
gtk_widget_show(hbox2);
}
gtk_widget_show(vbox);
}
......@@ -396,6 +635,60 @@ build_dialog(GImageType basetype,
}
gtk_widget_show(dlg);
/* let's get into shape. */
shape_window = gtk_window_new (GTK_WINDOW_POPUP);
{
shape_fixed = gtk_fixed_new ();
{
gtk_widget_set_usize (shape_fixed, width,height);
gtk_container_add (GTK_CONTAINER (shape_window), shape_fixed);
shape_preview =
GTK_PREVIEW (gtk_preview_new (GTK_PREVIEW_COLOR)); /* FIXME */
{
gtk_preview_size (shape_preview, width, height);
/* gtk_fixed_put (GTK_FIXED (shape_fixed), GTK_WIDGET(shape_preview),
0,0);*/
}
/* gtk_widget_show (GTK_WIDGET(shape_preview));*/
}
gtk_widget_show (shape_fixed);
gtk_widget_realize (shape_window);
shape_pixmap = gdk_pixmap_new (shape_window->window,
width, height,
gtk_preview_get_visual()->depth);
gdk_window_set_back_pixmap(shape_window->window, NULL, 0);
cursor = gdk_cursor_new (GDK_CENTER_PTR);
gdk_window_set_cursor(shape_window->window, cursor);
gdk_cursor_destroy (cursor);
gtk_signal_connect (GTK_OBJECT (shape_window), "button_press_event",
GTK_SIGNAL_FUNC (shape_pressed),NULL);
gtk_signal_connect (GTK_OBJECT (shape_window), "button_release_event",
GTK_SIGNAL_FUNC (shape_released),NULL);
gtk_signal_connect (GTK_OBJECT (shape_window), "motion_notify_event",
GTK_SIGNAL_FUNC (shape_motion),NULL);
icon_pos = g_new (CursorOffset, 1);
gtk_object_set_user_data(GTK_OBJECT(shape_window), icon_pos);
}
gtk_signal_connect (GTK_OBJECT (eventbox), "button_press_event",
GTK_SIGNAL_FUNC (preview_pressed),NULL);
#ifdef I_AM_STUPID
gtk_signal_connect (GTK_OBJECT (shape_window), "expose_event",
GTK_SIGNAL_FUNC (unblocked_expose),shape_window);
#endif
gtk_signal_connect (GTK_OBJECT (shape_fixed), "expose_event",
GTK_SIGNAL_FUNC (blocked_expose),shape_fixed);
root_win = gdk_window_foreign_new (GDK_ROOT_WINDOW ());
}
......@@ -462,7 +755,7 @@ render_frame(gint32 whichframe)
gint rawx=0, rawy=0;
guchar* srcptr;
guchar* destptr;
gint i,j;
gint i,j,k; /* imaginative loop variables */
DisposeType dispose;
......@@ -563,6 +856,22 @@ render_frame(gint32 whichframe)
*(destptr++) = *(srcptr++);
srcptr++;
}
/* calculate the shape mask */
if (shaping)
{
srcptr = rawframe + 3;
for (j=0;j<rawheight;j++)
{
k = j * ((7 + rawwidth) / 8);
for (i=0;i<rawwidth;i++)
{
if ((*srcptr)&128)
shape_preview_mask[k+i/8] |= (1<<(i&7));
srcptr += 4;
}
}
}
}
else /* no alpha */
{
......@@ -571,8 +880,26 @@ render_frame(gint32 whichframe)
/*printf("quickie\n");fflush(stdout);*/
memcpy(preview_data, rawframe, width*height*3);
}
if (shaping)
{
/* opacify the shape mask */
memset(shape_preview_mask, 255,
(rawwidth*rawheight)/8 + rawheight);
}
}
/* Display the preview buffer... finally. */
if (shaping)
{
for (i=0;i<height;i++)
{
gtk_preview_draw_row (shape_preview,
&preview_data[3*i*width],
0, i, width);
}
}
else
{
for (i=0;i<height;i++)
{
gtk_preview_draw_row (preview,
......@@ -580,14 +907,13 @@ render_frame(gint32 whichframe)
0, i, width);
}
}
}
else
{
/* --- These are suboptimal catch-all cases for when --- */
/* --- this frame is bigger/smaller than the preview --- */
/* --- buffer, and/or offset within it. --- */
/* FIXME: FINISH ME! */
if (gimp_drawable_has_alpha (drawable->id))
{ /* alpha */
......@@ -611,6 +937,25 @@ render_frame(gint32 whichframe)
srcptr += 4;
}
}
if (shaping)
{
srcptr = rawframe + 3;
for (j=rawy; j<rawheight+rawy; j++)
{
k = j * ((width+7)/8);
for (i=rawx; i<rawwidth+rawx; i++)
{
if ((i>=0 && i<width) &&
(j>=0 && j<height))
{
if ((*srcptr)&128)
shape_preview_mask[k+i/8] |= (1<<(i&7));
}
srcptr += 4;
}
}
}
}
else
{
......@@ -636,7 +981,31 @@ render_frame(gint32 whichframe)
}
/* Display the preview buffer... finally. */
if (dispose!=DISPOSE_REPLACE)
if (shaping)
{
if ((dispose!=DISPOSE_REPLACE)&&(whichframe!=0))
{
for (i=rawy;i<rawy+rawheight;i++)
{
if (i>=0 && i<height)
gtk_preview_draw_row (shape_preview,
&preview_data[3*i*width],
0, i, width);
}
}
else
{
for (i=0;i<height;i++)
{
gtk_preview_draw_row (shape_preview,
&preview_data[3*i*width],
0, i, width);
}
}
}
else
{
if ((dispose!=DISPOSE_REPLACE)&&(whichframe!=0))
{
for (i=rawy;i<rawy+rawheight;i++)
{
......@@ -656,6 +1025,7 @@ render_frame(gint32 whichframe)
}
}
}
}
break;
case GRAY:
......@@ -683,11 +1053,28 @@ render_frame(gint32 whichframe)
destptr += 3;
continue;
}
*(destptr++) = palette[3*(*(srcptr))];
*(destptr++) = palette[1+3*(*(srcptr))];
*(destptr++) = palette[2+3*(*(srcptr))];
srcptr+=2;
}
/* calculate the shape mask */
if (shaping)
{
srcptr = rawframe + 1;
for (j=0;j<rawheight;j++)
{
k = j * ((7 + rawwidth) / 8);
for (i=0;i<rawwidth;i++)
{
if (*srcptr)
shape_preview_mask[k+i/8] |= (1<<(i&7));
srcptr += 2;
}
}
}
}
else /* no alpha */
{
......@@ -702,9 +1089,27 @@ render_frame(gint32 whichframe)
*(destptr++) = palette[2+3*(*(srcptr))];
srcptr++;
}
if (shaping)
{
/* opacify the shape mask */
memset(shape_preview_mask, 255,
(rawwidth*rawheight)/8 + rawheight);
}
}
/* Display the preview buffer... finally. */
if (shaping)
{
for (i=0;i<height;i++)
{
gtk_preview_draw_row (shape_preview,
&preview_data[3*i*width],
0, i, width);
}
}
else
{
for (i=0;i<height;i++)
{
gtk_preview_draw_row (preview,
......@@ -712,14 +1117,13 @@ render_frame(gint32 whichframe)
0, i, width);
}
}
}
else
{
/* --- These are suboptimal catch-all cases for when --- */
/* --- this frame is bigger/smaller than the preview --- */
/* --- buffer, and/or offset within it. --- */
/* FIXME: FINISH ME! */
if (gimp_drawable_has_alpha (drawable->id))
{ /* alpha */
......@@ -746,6 +1150,25 @@ render_frame(gint32 whichframe)
srcptr += 2;
}
}
if (shaping)
{
srcptr = rawframe + 1;
for (j=rawy; j<rawheight+rawy; j++)
{
k = j * ((width+7)/8);
for (i=rawx; i<rawwidth+rawx; i++)
{
if ((i>=0 && i<width) &&
(j>=0 && j<height))
{
if (*srcptr)
shape_preview_mask[k+i/8] |= (1<<(i&7));
</