From 21c343913a4f5068500d16f147a734a94456bf01 Mon Sep 17 00:00:00 2001 From: jaycox Date: Wed, 9 Sep 1998 01:35:35 +0000 Subject: [PATCH] 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. --- ChangeLog | 10 ++++++++++ app/brush_edit.c | 16 ++++++++++------ app/brush_select.c | 20 +++++++++++++++----- app/brush_select.h | 1 + app/docindex.c | 6 +++--- app/docindexif.c | 5 +++-- app/gui/brush-editor.c | 16 ++++++++++------ app/gui/brush-select.c | 20 +++++++++++++++----- app/gui/brush-select.h | 1 + app/widgets/gimpbrusheditor.c | 16 ++++++++++------ 10 files changed, 78 insertions(+), 33 deletions(-) diff --git a/ChangeLog b/ChangeLog index fe37ff36b9..7c754f8a33 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 * app/main.c: s/ATEXIT/g_atexit/ to sync with gtk changes diff --git a/app/brush_edit.c b/app/brush_edit.c index 6bae5dda0c..12f83a10a0 100644 --- a/app/brush_edit.c +++ b/app/brush_edit.c @@ -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", diff --git a/app/brush_select.c b/app/brush_select.c index 2c3255ac00..12c8759989 100644 --- a/app/brush_select.c +++ b/app/brush_select.c @@ -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()); diff --git a/app/brush_select.h b/app/brush_select.h index 8e48cd7b84..b39dcc37ff 100644 --- a/app/brush_select.h +++ b/app/brush_select.h @@ -40,6 +40,7 @@ struct _BrushSelect { /* Brush preview */ GtkWidget *brush_popup; GtkWidget *brush_preview; + GtkWidget *edit_button; }; BrushSelectP brush_select_new (void); diff --git a/app/docindex.c b/app/docindex.c index 3d24eb21c1..cdc0d8e5e7 100644 --- a/app/docindex.c +++ b/app/docindex.c @@ -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 ); diff --git a/app/docindexif.c b/app/docindexif.c index 7b540f8cb1..3edb909a02 100644 --- a/app/docindexif.c +++ b/app/docindexif.c @@ -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 diff --git a/app/gui/brush-editor.c b/app/gui/brush-editor.c index 6bae5dda0c..12f83a10a0 100644 --- a/app/gui/brush-editor.c +++ b/app/gui/brush-editor.c @@ -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", diff --git a/app/gui/brush-select.c b/app/gui/brush-select.c index 2c3255ac00..12c8759989 100644 --- a/app/gui/brush-select.c +++ b/app/gui/brush-select.c @@ -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()); diff --git a/app/gui/brush-select.h b/app/gui/brush-select.h index 8e48cd7b84..b39dcc37ff 100644 --- a/app/gui/brush-select.h +++ b/app/gui/brush-select.h @@ -40,6 +40,7 @@ struct _BrushSelect { /* Brush preview */ GtkWidget *brush_popup; GtkWidget *brush_preview; + GtkWidget *edit_button; }; BrushSelectP brush_select_new (void); diff --git a/app/widgets/gimpbrusheditor.c b/app/widgets/gimpbrusheditor.c index 6bae5dda0c..12f83a10a0 100644 --- a/app/widgets/gimpbrusheditor.c +++ b/app/widgets/gimpbrusheditor.c @@ -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",