Commit 5fc903b2 authored by Manish Singh's avatar Manish Singh

updated Adam's stuff

* updated Adam's stuff

* app/app_procs.c: squleched warning

* gimptool.in: quote stuff to be flexible about our CC settings

-Yosh
parent 4ae42037
Thu May 21 13:03:50 PDT 1998 Manish Singh <yosh@gimp.org>
* updated Adam's stuff
* app/app_procs.c: squleched warning
* gimptool.in: quote stuff to be flexible about our CC settings
Wed May 20 20:21:45 EST 1998 Stephen Norris <srn@fn.com.au> Wed May 20 20:21:45 EST 1998 Stephen Norris <srn@fn.com.au>
* plug-ins/bz2/bz2.c: Check return code from fopen. * plug-ins/bz2/bz2.c: Check return code from fopen.
......
...@@ -421,7 +421,7 @@ app_init_update_status(char *label1val, ...@@ -421,7 +421,7 @@ app_init_update_status(char *label1val,
gtk_progress_bar_update(GTK_PROGRESS_BAR(pbar), pct_progress); gtk_progress_bar_update(GTK_PROGRESS_BAR(pbar), pct_progress);
} }
gtk_widget_draw(win_initstatus, &area); gtk_widget_draw(win_initstatus, &area);
idle_tag = gtk_idle_add(gtk_true, NULL); idle_tag = gtk_idle_add((GtkFunction) gtk_true, NULL);
gtk_main_iteration(); gtk_main_iteration();
gtk_idle_remove(idle_tag); gtk_idle_remove(idle_tag);
} }
......
...@@ -20,15 +20,15 @@ if test $# -eq 0; then ...@@ -20,15 +20,15 @@ if test $# -eq 0; then
fi fi
if test x${GTK_CONFIG+set} != xset ; then if test x${GTK_CONFIG+set} != xset ; then
gtk_config=@GTK_CONFIG@ gtk_config='@GTK_CONFIG@'
else else
gtk_config=$GTK_CONFIG gtk_config="$GTK_CONFIG"
fi fi
if test x${CC+set} != xset ; then if test x${CC+set} != xset ; then
cc=@CC@ cc='@CC@'
else else
cc=$CC cc="$CC"
fi fi
if test x${CFLAGS+set} != xset ; then if test x${CFLAGS+set} != xset ; then
......
...@@ -20,15 +20,15 @@ if test $# -eq 0; then ...@@ -20,15 +20,15 @@ if test $# -eq 0; then
fi fi
if test x${GTK_CONFIG+set} != xset ; then if test x${GTK_CONFIG+set} != xset ; then
gtk_config=@GTK_CONFIG@ gtk_config='@GTK_CONFIG@'
else else
gtk_config=$GTK_CONFIG gtk_config="$GTK_CONFIG"
fi fi
if test x${CC+set} != xset ; then if test x${CC+set} != xset ; then
cc=@CC@ cc='@CC@'
else else
cc=$CC cc="$CC"
fi fi
if test x${CFLAGS+set} != xset ; then if test x${CFLAGS+set} != xset ; then
......
/* /*
* Animation Optimizer plug-in version 0.70.0 * Animation Optimizer plug-in version 1.0.0
* *
* by Adam D. Moss, 1997-98 * by Adam D. Moss, 1997-98
* adam@gimp.org * adam@gimp.org
...@@ -11,6 +11,10 @@ ...@@ -11,6 +11,10 @@
/* /*
* REVISION HISTORY: * REVISION HISTORY:
* *
* 98.05.17 : version 1.0.0
* Finally preserves frame timings / layer names. Has
* a progress bar now. No longer beta, I suppose.
*
* 98.04.19 : version 0.70.0 * 98.04.19 : version 0.70.0
* Plug-in doubles up as Animation UnOptimize too! (This * Plug-in doubles up as Animation UnOptimize too! (This
* is somewhat more useful than it sounds.) * is somewhat more useful than it sounds.)
...@@ -34,7 +38,7 @@ ...@@ -34,7 +38,7 @@
/* /*
* BUGS: * BUGS:
* Probably a few * ?
*/ */
/* /*
...@@ -48,7 +52,6 @@ ...@@ -48,7 +52,6 @@
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include "libgimp/gimp.h" #include "libgimp/gimp.h"
#include "gtk/gtk.h"
...@@ -73,9 +76,6 @@ static void do_optimizations (void); ...@@ -73,9 +76,6 @@ static void do_optimizations (void);
/*static int parse_ms_tag (char *str);*/ /*static int parse_ms_tag (char *str);*/
static DisposeType parse_disposal_tag (char *str); static DisposeType parse_disposal_tag (char *str);
static void window_close_callback (GtkWidget *widget,
gpointer data);
static DisposeType get_frame_disposal (guint whichframe); static DisposeType get_frame_disposal (guint whichframe);
...@@ -91,7 +91,6 @@ GPlugInInfo PLUG_IN_INFO = ...@@ -91,7 +91,6 @@ GPlugInInfo PLUG_IN_INFO =
/* Global widgets'n'stuff */ /* Global widgets'n'stuff */
GtkWidget* progress;
guint width,height; guint width,height;
gint32 image_id; gint32 image_id;
gint32 new_image_id; gint32 new_image_id;
...@@ -195,47 +194,9 @@ static void run(char *name, int n_params, GParam * param, int *nreturn_vals, ...@@ -195,47 +194,9 @@ static void run(char *name, int n_params, GParam * param, int *nreturn_vals,
} }
#if 0 /* function is presently not used */
static int
parse_ms_tag (char *str)
{
gint sum = 0;
gint offset = 0;
gint length;
length = strlen(str);
while ((offset<length) && (str[offset]!='('))
offset++;
if (offset>=length)
return(-1);
if (!isdigit(str[++offset]))
return(-2);
do
{
sum *= 10;
sum += str[offset] - '0';
offset++;
}
while ((offset<length) && (isdigit(str[offset])));
if (length-offset <= 2)
return(-3);
if ((toupper(str[offset]) != 'M') || (toupper(str[offset+1]) != 'S'))
return(-4);
return (sum);
}
#endif /* parse_ms_tag */
static DisposeType static DisposeType
parse_disposal_tag (char *str) parse_disposal_tag (gchar *str)
{ {
gint offset = 0; gint offset = 0;
gint length; gint length;
...@@ -255,151 +216,39 @@ parse_disposal_tag (char *str) ...@@ -255,151 +216,39 @@ parse_disposal_tag (char *str)
} }
#if 0 /* function is presently unused */
static void static gchar*
build_dialog(GImageType basetype, remove_disposal_tag (gchar* str)
char* imagename)
{ {
gchar** argv; gchar* dest;
gint argc; gint offset = 0;
gint destoffset = 0;
gchar* windowname; gint length;
GtkWidget* dlg;
GtkWidget* button;
GtkWidget* toggle;
GtkWidget* label;
GtkWidget* entry;
GtkWidget* frame;
GtkWidget* frame2;
GtkWidget* vbox;
GtkWidget* vbox2;
GtkWidget* hbox;
GtkWidget* hbox2;
guchar* color_cube;
GSList* group = NULL;
argc = 1;
argv = g_new (gchar *, 1);
argv[0] = g_strdup ("animationoptimize");
gtk_init (&argc, &argv);
gtk_rc_parse (gimp_gtkrc ());
gdk_set_use_xshm (gimp_use_xshm ());
/* gtk_preview_set_gamma (gimp_gamma ());
gtk_preview_set_install_cmap (gimp_install_cmap ());
color_cube = gimp_color_cube ();
gtk_preview_set_color_cube (color_cube[0], color_cube[1],
color_cube[2], color_cube[3]);
gtk_widget_set_default_visual (gtk_preview_get_visual ());
gtk_widget_set_default_colormap (gtk_preview_get_cmap ());*/
dlg = gtk_dialog_new ();
windowname = g_malloc(strlen("Animation Playback: ")+strlen(imagename)+1);
strcpy(windowname,"Animation Playback: ");
strcat(windowname,imagename);
gtk_window_set_title (GTK_WINDOW (dlg), windowname);
g_free(windowname);
gtk_window_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE);
gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
(GtkSignalFunc) window_close_callback,
NULL);
length = strlen(str);
/* Action area - 'close' button only. */ dest = g_malloc(length+11);
memset(dest, 0, length+11);
button = gtk_button_new_with_label ("Close");
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) window_close_callback,
NULL);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->action_area),
button, TRUE, TRUE, 0);
gtk_widget_grab_default (button);
gtk_widget_show (button);
{ strcpy(dest, str);
/* The 'playback' half of the dialog */
while ((offset+9)<=length)
/* windowname = g_malloc(strlen("Playback: ")+strlen(imagename)+1);
strcpy(windowname,"Playback: ");
strcat(windowname,imagename);
frame = gtk_frame_new (windowname);
g_free(windowname);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
gtk_container_border_width (GTK_CONTAINER (frame), 3);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
frame, TRUE, TRUE, 0);
{ {
hbox = gtk_hbox_new (FALSE, 5); if (strncmp(&str[offset],"(combine)",9)==0)
gtk_container_border_width (GTK_CONTAINER (hbox), 3);
gtk_container_add (GTK_CONTAINER (frame), hbox);
{
vbox = gtk_vbox_new (FALSE, 5);
gtk_container_border_width (GTK_CONTAINER (vbox), 3);
gtk_container_add (GTK_CONTAINER (hbox), vbox);
{ {
progress = gtk_progress_bar_new (); offset+=9;
gtk_widget_set_usize (progress, 150, 15);
gtk_box_pack_start (GTK_BOX (vbox), progress, TRUE, TRUE, 0);
gtk_widget_show (progress);
hbox2 = gtk_hbox_new (FALSE, 0);
gtk_container_border_width (GTK_CONTAINER (hbox2), 0);
gtk_box_pack_start (GTK_BOX (vbox), hbox2, TRUE, TRUE, 0);
{
button = gtk_button_new_with_label ("Play/Stop");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) playstop_callback, NULL);
gtk_box_pack_start (GTK_BOX (hbox2), button, TRUE, TRUE, 0);
gtk_widget_show (button);
button = gtk_button_new_with_label ("Rewind");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) rewind_callback, NULL);
gtk_box_pack_start (GTK_BOX (hbox2), button, TRUE, TRUE, 0);
gtk_widget_show (button);
button = gtk_button_new_with_label ("Step");
gtk_signal_connect (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) step_callback, NULL);
gtk_box_pack_start (GTK_BOX (hbox2), button, TRUE, TRUE, 0);
gtk_widget_show (button);
}
if (total_frames<=1) gtk_widget_set_sensitive (hbox2, FALSE);
gtk_widget_show(hbox2);
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);
{
preview = gtk_preview_new (GTK_PREVIEW_COLOR);
gtk_preview_size (GTK_PREVIEW (preview), width, height);
gtk_container_add (GTK_CONTAINER (frame2), preview);
gtk_widget_show(preview);
}
gtk_widget_show(frame2);
} }
gtk_widget_show(vbox); if (strncmp(&str[offset],"(replace)",9)==0)
{
} offset+=9;
gtk_widget_show(hbox); }
dest[destoffset] = str[offset];
destoffset++;
offset++;
} }
gtk_widget_show(frame);
*/ return dest;
}
gtk_widget_show(dlg);
} }
#endif /* build_dialog */
/* Rendering Functions */ /* Rendering Functions */
...@@ -429,12 +278,20 @@ do_optimizations(void) ...@@ -429,12 +278,20 @@ do_optimizations(void)
guchar* this_frame = NULL; guchar* this_frame = NULL;
guchar* last_frame = NULL; guchar* last_frame = NULL;
guchar* opti_frame = NULL; guchar* opti_frame = NULL;
gchar* oldlayer_name;
gchar* newlayer_name;
gboolean can_combine; gboolean can_combine;
gint32 bbox_top, bbox_bottom, bbox_left, bbox_right; gint32 bbox_top, bbox_bottom, bbox_left, bbox_right;
gint32 rbox_top, rbox_bottom, rbox_left, rbox_right; gint32 rbox_top, rbox_bottom, rbox_left, rbox_right;
if (optimize)
gimp_progress_init ("Optimizing Animation...");
else
gimp_progress_init ("UnOptimizing Animation...");
width = gimp_image_width(image_id); width = gimp_image_width(image_id);
height = gimp_image_height(image_id); height = gimp_image_height(image_id);
layers = gimp_image_get_layers (image_id, &total_frames); layers = gimp_image_get_layers (image_id, &total_frames);
...@@ -483,7 +340,7 @@ do_optimizations(void) ...@@ -483,7 +340,7 @@ do_optimizations(void)
/* FIXME - How do we tell if a gimp_drawable_get() fails? */ /* FIXME - How do we tell if a gimp_drawable_get() fails? */
if (gimp_drawable_width(drawable->id)==0) if (gimp_drawable_width(drawable->id)==0)
{ {
window_close_callback(NULL, NULL); gimp_quit();
} }
dispose = get_frame_disposal(this_frame_num); dispose = get_frame_disposal(this_frame_num);
...@@ -934,13 +791,22 @@ do_optimizations(void) ...@@ -934,13 +791,22 @@ do_optimizations(void)
* *
*/ */
oldlayer_name =
gimp_layer_get_name(layers[total_frames-(this_frame_num+1)]);
newlayer_name = remove_disposal_tag(oldlayer_name);
g_free(oldlayer_name);
if (this_frame_num > 0)
strcat(newlayer_name, can_combine?"(combine)":"(replace)");
new_layer_id = gimp_layer_new(new_image_id, new_layer_id = gimp_layer_new(new_image_id,
can_combine?"(combine)":"(replace)", newlayer_name,
bbox_right-bbox_left, bbox_right-bbox_left,
bbox_bottom-bbox_top, bbox_bottom-bbox_top,
drawabletype_alpha, drawabletype_alpha,
100.0, 100.0,
NORMAL_MODE); NORMAL_MODE);
g_free(newlayer_name);
gimp_image_add_layer (new_image_id, new_layer_id, 0); gimp_image_add_layer (new_image_id, new_layer_id, 0);
...@@ -955,7 +821,10 @@ do_optimizations(void) ...@@ -955,7 +821,10 @@ do_optimizations(void)
bbox_bottom-bbox_top); bbox_bottom-bbox_top);
gimp_drawable_flush (drawable); gimp_drawable_flush (drawable);
gimp_drawable_detach (drawable); gimp_drawable_detach (drawable);
gimp_layer_translate (new_layer_id, (gint)bbox_left, (gint)bbox_top); gimp_layer_translate (new_layer_id, (gint)bbox_left, (gint)bbox_top);
gimp_progress_update (((double)this_frame_num+1.0) /
((double)total_frames));
} }
gimp_display_new (new_image_id); gimp_display_new (new_image_id);
...@@ -975,26 +844,6 @@ do_optimizations(void) ...@@ -975,26 +844,6 @@ do_optimizations(void)
/* Util. */ /* Util. */
#if 0 /* function is presently unused */
static guint32
get_frame_duration (guint whichframe)
{
gchar* layer_name;
gint duration;
layer_name = gimp_layer_get_name(layers[total_frames-(whichframe+1)]);
duration = parse_ms_tag(layer_name);
g_free(layer_name);
if (duration < 0) duration = 100; /* FIXME for default-if-not-said */
if (duration == 0) duration = 60; /* FIXME - 0-wait is nasty */
return ((guint32) duration);
}
#endif /* get_frame_duration */
static DisposeType static DisposeType
get_frame_disposal (guint whichframe) get_frame_disposal (guint whichframe)
{ {
...@@ -1009,13 +858,3 @@ get_frame_disposal (guint whichframe) ...@@ -1009,13 +858,3 @@ get_frame_disposal (guint whichframe)
} }
/* Callbacks */
static void
window_close_callback (GtkWidget *widget,
gpointer data)
{
gtk_main_quit();
}
/* /*
* Animation Optimizer plug-in version 0.70.0 * Animation Optimizer plug-in version 1.0.0
* *
* by Adam D. Moss, 1997-98 * by Adam D. Moss, 1997-98
* adam@gimp.org * adam@gimp.org
...@@ -11,6 +11,10 @@ ...@@ -11,6 +11,10 @@
/* /*
* REVISION HISTORY: * REVISION HISTORY:
* *
* 98.05.17 : version 1.0.0
* Finally preserves frame timings / layer names. Has
* a progress bar now. No longer beta, I suppose.
*
* 98.04.19 : version 0.70.0 * 98.04.19 : version 0.70.0
* Plug-in doubles up as Animation UnOptimize too! (This * Plug-in doubles up as Animation UnOptimize too! (This
* is somewhat more useful than it sounds.) * is somewhat more useful than it sounds.)
...@@ -34,7 +38,7 @@ ...@@ -34,7 +38,7 @@
/* /*
* BUGS: * BUGS:
* Probably a few * ?
*/ */
/* /*
...@@ -48,7 +52,6 @@ ...@@ -48,7 +52,6 @@
#include <string.h> #include <string.h>
#include <ctype.h> #include <ctype.h>
#include "libgimp/gimp.h" #include "libgimp/gimp.h"
#include "gtk/gtk.h"
...@@ -73,9 +76,6 @@ static void do_optimizations (void); ...@@ -73,9 +76,6 @@ static void do_optimizations (void);
/*static int parse_ms_tag (char *str);*/ /*static int parse_ms_tag (char *str);*/
static DisposeType parse_disposal_tag (char *str); static DisposeType parse_disposal_tag (char *str);
static void window_close_callback (GtkWidget *widget,
gpointer data);
static DisposeType get_frame_disposal (guint whichframe); static DisposeType get_frame_disposal (guint whichframe);
...@@ -91,7 +91,6 @@ GPlugInInfo PLUG_IN_INFO = ...@@ -91,7 +91,6 @@ GPlugInInfo PLUG_IN_INFO =
/* Global widgets'n'stuff */ /* Global widgets'n'stuff */
GtkWidget* progress;
guint width,height; guint width,height;
gint32 image_id; gint32 image_id;
gint32 new_image_id; gint32 new_image_id;
...@@ -195,47 +194,9 @@ static void run(char *name, int n_params, GParam * param, int *nreturn_vals, ...@@ -195,47 +194,9 @@ static void run(char *name, int n_params, GParam * param, int *nreturn_vals,
} }
#if 0 /* function is presently not used */
static int
parse_ms_tag (char *str)
{
gint sum = 0;
gint offset = 0;
gint length;
length = strlen(str);
while ((offset<length) && (str[offset]!='('))
offset++;
if (offset>=length)
return(-1);
if (!isdigit(str[++offset]))
return(-2);
do
{
sum *= 10;
sum += str[offset] - '0';
offset++;
}
while ((offset<length) && (isdigit(str[offset])));
if (length-offset <= 2)
return(-3);
if ((toupper(str[offset]) != 'M') || (toupper(str[offset+1]) != 'S'))
return(-4);
return (sum);
}
#endif /* parse_ms_tag */
static DisposeType static DisposeType
parse_disposal_tag (char *str) parse_disposal_tag (gchar *str)
{ {
gint offset = 0; gint offset = 0;
gint length; gint length;
...@@ -255,151 +216,39 @@ parse_disposal_tag (char *str) ...@@ -255,151 +216,39 @@ parse_disposal_tag (char *str)
} }
#if 0 /* function is presently unused */
static void static gchar*
build_dialog(GImageType basetype, remove_disposal_tag (gchar* str)
char* imagename)
{ {
gchar** argv; gchar* dest;
gint argc; gint offset = 0;
gint destoffset = 0;
gchar* windowname; gint length;
GtkWidget* dlg;
GtkWidget* button;
GtkWidget* toggle;
GtkWidget* label;
GtkWidget* entry;
GtkWidget* frame;
GtkWidget* frame2;
GtkWidget* vbox;
GtkWidget* vbox2;
GtkWidget* hbox;
GtkWidget* hbox2;
guchar* color_cube;
GSList* group = NULL;
argc = 1;
argv = g_new (gchar *, 1);
argv[0] = g_strdup ("animationoptimize");
gtk_init (&argc, &argv);
gtk_rc_parse (gimp_gtkrc ());
gdk_set_use_xshm (gimp_use_xshm ());
/* gtk_preview_set_gamma (gimp_gamma ());
gtk_preview_set_install_cmap (gimp_install_cmap ());
color_cube = gimp_color_cube ();
gtk_preview_set_color_cube (color_cube[0], color_cube[1],
color_cube[2], color_cube[3]);
gtk_widget_set_default_visual (gtk_preview_get_visual ());
gtk_widget_set_default_colormap (gtk_preview_get_cmap ());*/
dlg = gtk_dialog_new ();
windowname = g_malloc(strlen("Animation Playback: ")+strlen(imagename)+1);
strcpy(windowname,"Animation Playback: ");
strcat(windowname,imagename);
gtk_window_set_title (GTK_WINDOW (dlg), windowname);
g_free(windowname);
gtk_window_position (GTK_WINDOW (dlg), GTK_WIN_POS_MOUSE);
gtk_signal_connect (GTK_OBJECT (dlg), "destroy",
(GtkSignalFunc) window_close_callback,
NULL);
length = strlen(str);
/* Action area - 'close' button only. */ dest = g_malloc(length+11);
memset(dest, 0, length+11);
button = gtk_button_new_with_label ("Close");
GTK_WIDGET_SET_FLAGS (button, GTK_CAN_DEFAULT);
gtk_signal_connect_object (GTK_OBJECT (button), "clicked",
(GtkSignalFunc) window_close_callback,
NULL);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->action_area),
button, TRUE, TRUE, 0);
gtk_widget_grab_default (button);
gtk_widget_show (button);
{ strcpy(dest, str);
/* The 'playback' half of the dialog */
while ((offset+9)<=length)
/* windowname = g_malloc(strlen("Playback: ")+strlen(imagename)+1);
strcpy(windowname,"Playback: ");
strcat(windowname,imagename);
frame = gtk_frame_new (windowname);
g_free(windowname);
gtk_frame_set_shadow_type (GTK_FRAME (frame), GTK_SHADOW_ETCHED_IN);
gtk_container_border_width (GTK_CONTAINER (frame), 3);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dlg)->vbox),
frame, TRUE, TRUE, 0);
{ {
hbox = gtk_hbox_new (FALSE, 5); if (strncmp(&str[offset],"(combine)",9)==0)