more carefull when the active brush changes white_space() was ungetch'ing

* app/brush_generated.c: more carefull when the active brush
	  changes
	* app/docindexif.c: white_space() was ungetch'ing the eof
	  marker which can clear the eof flag on some systems.
	* app/docindex.c: check for ferror()s
	* app/brush_select[ch]: sensitize the edit button iff the
	  active brush is a generated brush.
This commit is contained in:
jaycox 1998-09-09 01:35:35 +00:00
parent 6825ca8bd9
commit 21c343913a
10 changed files with 78 additions and 33 deletions

View File

@ -1,3 +1,13 @@
Tue Sep 8 18:28:44 1998 Jay Cox (jaycox@earthlink.net)
* app/brush_generated.c: more carefull when the active brush
changes
* app/docindexif.c: white_space() was ungetch'ing the eof
marker which can clear the eof flag on some systems.
* app/docindex.c: check for ferror()s
* app/brush_select[ch]: sensitize the edit button iff the
active brush is a generated brush.
Mon Sep 7 22:30:53 PDT 1998 Manish Singh <yosh@gimp.org>
* app/main.c: s/ATEXIT/g_atexit/ to sync with gtk changes

View File

@ -141,18 +141,22 @@ brush_edit_generated_set_brush(BrushEditGeneratedWindow *begw,
GimpBrush *gbrush)
{
GimpBrushGenerated *brush = 0;
if (!GIMP_IS_BRUSH_GENERATED(gbrush))
if (begw->brush == (GimpBrushGenerated*)gbrush)
return;
if (begw->brush)
{
gtk_signal_disconnect_by_data(GTK_OBJECT(begw->brush), begw);
gtk_object_unref(GTK_OBJECT(begw->brush));
begw->brush = NULL;
}
if (!gbrush || !GIMP_IS_BRUSH_GENERATED(gbrush))
{
begw->brush = NULL;
if (GTK_WIDGET_VISIBLE (begw->shell))
gtk_widget_hide (begw->shell);
return;
}
brush = GIMP_BRUSH_GENERATED(gbrush);
if (begw->brush)
{
gtk_signal_disconnect_by_data(GTK_OBJECT(begw->brush), begw);
gtk_object_unref(GTK_OBJECT(begw->brush));
}
if (begw)
{
gtk_signal_connect(GTK_OBJECT (brush), "dirty",

View File

@ -153,7 +153,7 @@ brush_select_new ()
GtkWidget *option_menu;
GtkWidget *slider;
GimpBrushP active;
GtkWidget *button1, *button2;
GtkWidget *button2;
bsp = g_malloc (sizeof (_BrushSelect));
bsp->redraw = TRUE;
@ -287,11 +287,11 @@ brush_select_new ()
/* Create the edit/new buttons */
util_box = gtk_hbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (bsp->options_box), util_box, FALSE, FALSE, 0);
button1 = gtk_button_new_with_label ("Edit Brush");
gtk_signal_connect (GTK_OBJECT (button1), "clicked",
bsp->edit_button = gtk_button_new_with_label ("Edit Brush");
gtk_signal_connect (GTK_OBJECT (bsp->edit_button), "clicked",
(GtkSignalFunc) edit_brush_callback,
NULL);
gtk_box_pack_start (GTK_BOX (util_box), button1, TRUE, TRUE, 5);
gtk_box_pack_start (GTK_BOX (util_box), bsp->edit_button, TRUE, TRUE, 5);
button2 = gtk_button_new_with_label ("New Brush");
gtk_signal_connect (GTK_OBJECT (button2), "clicked",
@ -299,7 +299,7 @@ brush_select_new ()
NULL);
gtk_box_pack_start (GTK_BOX (util_box), button2, TRUE, TRUE, 5);
gtk_widget_show (button1);
gtk_widget_show (bsp->edit_button);
gtk_widget_show (button2);
gtk_widget_show (util_box);
@ -342,6 +342,10 @@ brush_select_new ()
brush_select_select (bsp, gimp_brush_list_get_brush_index(brush_list,
active));
bsp->redraw = old_value;
if (GIMP_IS_BRUSH_GENERATED(active))
gtk_widget_set_sensitive (bsp->edit_button, 1);
else
gtk_widget_set_sensitive (bsp->edit_button, 0);
}
return bsp;
@ -803,6 +807,12 @@ brush_select_events (GtkWidget *widget,
/* Make this brush the active brush */
select_brush (brush);
if (GIMP_IS_BRUSH_GENERATED(brush))
gtk_widget_set_sensitive (bsp->edit_button, 1);
else
gtk_widget_set_sensitive (bsp->edit_button, 0);
if (brush_edit_generated_dialog)
brush_edit_generated_set_brush(brush_edit_generated_dialog,
get_active_brush());

View File

@ -40,6 +40,7 @@ struct _BrushSelect {
/* Brush preview */
GtkWidget *brush_popup;
GtkWidget *brush_preview;
GtkWidget *edit_button;
};
BrushSelectP brush_select_new (void);

View File

@ -233,7 +233,7 @@ load_idea_manager( idea_manager *ideas )
}
}
if ( idea_list || fp )
if ( idea_list || fp)
{
gtk_widget_set_usize( ideas->window, width, height );
gtk_widget_show( ideas->window );
@ -245,7 +245,7 @@ load_idea_manager( idea_manager *ideas )
gint length;
clear_white( fp );
while ( ! feof( fp ) )
while ( ! feof( fp ) && !ferror(fp))
{
length = getinteger( fp );
title = g_malloc0( length + 1 );
@ -460,7 +460,7 @@ static void idea_add_in_position_with_select( gchar *title, gint position, gbool
clear_white( fp );
while ( ! feof( fp ) )
while ( ! feof( fp ) && !ferror(fp))
{
length = getinteger( fp );
title = g_malloc0( length + 1 );

View File

@ -139,11 +139,12 @@ int getinteger( FILE *fp )
void clear_white( FILE *fp )
{
gchar nextchar;
int nextchar;
while ( isspace( nextchar = fgetc( fp ) ) )
/* empty statement */ ;
ungetc( nextchar, fp );
if (nextchar != EOF)
ungetc( nextchar, fp );
}
/* reset_usize

View File

@ -141,18 +141,22 @@ brush_edit_generated_set_brush(BrushEditGeneratedWindow *begw,
GimpBrush *gbrush)
{
GimpBrushGenerated *brush = 0;
if (!GIMP_IS_BRUSH_GENERATED(gbrush))
if (begw->brush == (GimpBrushGenerated*)gbrush)
return;
if (begw->brush)
{
gtk_signal_disconnect_by_data(GTK_OBJECT(begw->brush), begw);
gtk_object_unref(GTK_OBJECT(begw->brush));
begw->brush = NULL;
}
if (!gbrush || !GIMP_IS_BRUSH_GENERATED(gbrush))
{
begw->brush = NULL;
if (GTK_WIDGET_VISIBLE (begw->shell))
gtk_widget_hide (begw->shell);
return;
}
brush = GIMP_BRUSH_GENERATED(gbrush);
if (begw->brush)
{
gtk_signal_disconnect_by_data(GTK_OBJECT(begw->brush), begw);
gtk_object_unref(GTK_OBJECT(begw->brush));
}
if (begw)
{
gtk_signal_connect(GTK_OBJECT (brush), "dirty",

View File

@ -153,7 +153,7 @@ brush_select_new ()
GtkWidget *option_menu;
GtkWidget *slider;
GimpBrushP active;
GtkWidget *button1, *button2;
GtkWidget *button2;
bsp = g_malloc (sizeof (_BrushSelect));
bsp->redraw = TRUE;
@ -287,11 +287,11 @@ brush_select_new ()
/* Create the edit/new buttons */
util_box = gtk_hbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (bsp->options_box), util_box, FALSE, FALSE, 0);
button1 = gtk_button_new_with_label ("Edit Brush");
gtk_signal_connect (GTK_OBJECT (button1), "clicked",
bsp->edit_button = gtk_button_new_with_label ("Edit Brush");
gtk_signal_connect (GTK_OBJECT (bsp->edit_button), "clicked",
(GtkSignalFunc) edit_brush_callback,
NULL);
gtk_box_pack_start (GTK_BOX (util_box), button1, TRUE, TRUE, 5);
gtk_box_pack_start (GTK_BOX (util_box), bsp->edit_button, TRUE, TRUE, 5);
button2 = gtk_button_new_with_label ("New Brush");
gtk_signal_connect (GTK_OBJECT (button2), "clicked",
@ -299,7 +299,7 @@ brush_select_new ()
NULL);
gtk_box_pack_start (GTK_BOX (util_box), button2, TRUE, TRUE, 5);
gtk_widget_show (button1);
gtk_widget_show (bsp->edit_button);
gtk_widget_show (button2);
gtk_widget_show (util_box);
@ -342,6 +342,10 @@ brush_select_new ()
brush_select_select (bsp, gimp_brush_list_get_brush_index(brush_list,
active));
bsp->redraw = old_value;
if (GIMP_IS_BRUSH_GENERATED(active))
gtk_widget_set_sensitive (bsp->edit_button, 1);
else
gtk_widget_set_sensitive (bsp->edit_button, 0);
}
return bsp;
@ -803,6 +807,12 @@ brush_select_events (GtkWidget *widget,
/* Make this brush the active brush */
select_brush (brush);
if (GIMP_IS_BRUSH_GENERATED(brush))
gtk_widget_set_sensitive (bsp->edit_button, 1);
else
gtk_widget_set_sensitive (bsp->edit_button, 0);
if (brush_edit_generated_dialog)
brush_edit_generated_set_brush(brush_edit_generated_dialog,
get_active_brush());

View File

@ -40,6 +40,7 @@ struct _BrushSelect {
/* Brush preview */
GtkWidget *brush_popup;
GtkWidget *brush_preview;
GtkWidget *edit_button;
};
BrushSelectP brush_select_new (void);

View File

@ -141,18 +141,22 @@ brush_edit_generated_set_brush(BrushEditGeneratedWindow *begw,
GimpBrush *gbrush)
{
GimpBrushGenerated *brush = 0;
if (!GIMP_IS_BRUSH_GENERATED(gbrush))
if (begw->brush == (GimpBrushGenerated*)gbrush)
return;
if (begw->brush)
{
gtk_signal_disconnect_by_data(GTK_OBJECT(begw->brush), begw);
gtk_object_unref(GTK_OBJECT(begw->brush));
begw->brush = NULL;
}
if (!gbrush || !GIMP_IS_BRUSH_GENERATED(gbrush))
{
begw->brush = NULL;
if (GTK_WIDGET_VISIBLE (begw->shell))
gtk_widget_hide (begw->shell);
return;
}
brush = GIMP_BRUSH_GENERATED(gbrush);
if (begw->brush)
{
gtk_signal_disconnect_by_data(GTK_OBJECT(begw->brush), begw);
gtk_object_unref(GTK_OBJECT(begw->brush));
}
if (begw)
{
gtk_signal_connect(GTK_OBJECT (brush), "dirty",