Commit e585b343 authored by Sven Neumann's avatar Sven Neumann

hide the file_selector when the main dialog is unmapped

* app/curves.c:
* app/levels.c: hide the file_selector when the main dialog is unmapped

* app/fileops.c: indentation


--Sven
parent f052ff54
2000-03-27 Sven Neumann <sven@gimp.org>
* app/curves.c:
* app/levels.c: hide the file_selector when the dialog is unmapped
* app/fileops.c: indentation (actually I have a fix for the stray
load/save dialogs, but I want to discuss it with a gtk+ guru
first, so it's not checked in yet...)
2000-03-27 David Monniaux <monniaux@quatramaran.ens.fr>
* plug-ins/gap/gap_decode_mpeg_main.c: fixed a typo (spurious
......
......@@ -107,26 +107,26 @@ static void curves_preview (CurvesDialog *);
static void curves_channel_callback (GtkWidget *, gpointer);
static void curves_smooth_callback (GtkWidget *, gpointer);
static void curves_free_callback (GtkWidget *, gpointer);
static void curves_smooth_callback (GtkWidget *, gpointer);
static void curves_free_callback (GtkWidget *, gpointer);
static void curves_reset_callback (GtkWidget *, gpointer);
static void curves_ok_callback (GtkWidget *, gpointer);
static void curves_cancel_callback (GtkWidget *, gpointer);
static void curves_load_callback (GtkWidget *, gpointer);
static void curves_save_callback (GtkWidget *, gpointer);
static void curves_preview_update (GtkWidget *, gpointer);
static gint curves_xrange_events (GtkWidget *, GdkEvent *, CurvesDialog *);
static gint curves_yrange_events (GtkWidget *, GdkEvent *, CurvesDialog *);
static gint curves_graph_events (GtkWidget *, GdkEvent *, CurvesDialog *);
static void curves_CR_compose (CRMatrix, CRMatrix, CRMatrix);
static void curves_reset_callback (GtkWidget *, gpointer);
static void curves_ok_callback (GtkWidget *, gpointer);
static void curves_cancel_callback (GtkWidget *, gpointer);
static void curves_load_callback (GtkWidget *, gpointer);
static void curves_save_callback (GtkWidget *, gpointer);
static void curves_preview_update (GtkWidget *, gpointer);
static gint curves_xrange_events (GtkWidget *, GdkEvent *, CurvesDialog *);
static gint curves_yrange_events (GtkWidget *, GdkEvent *, CurvesDialog *);
static gint curves_graph_events (GtkWidget *, GdkEvent *, CurvesDialog *);
static void curves_CR_compose (CRMatrix, CRMatrix, CRMatrix);
static void make_file_dlg (gpointer);
static void file_ok_callback (GtkWidget *, gpointer);
static void file_cancel_callback (GtkWidget *, gpointer);
static void file_dialog_create (GtkWidget *);
static void file_dialog_ok_callback (GtkWidget *, gpointer);
static void file_dialog_cancel_callback (GtkWidget *, gpointer);
static gboolean read_curves_from_file (FILE *f);
static void write_curves_to_file (FILE *f);
static gboolean curves_read_from_file (FILE *f);
static void curves_write_to_file (FILE *f);
/* curves machinery */
......@@ -698,7 +698,7 @@ curves_dialog_new (void)
gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (curves_load_callback),
NULL);
cd->shell);
gtk_widget_show (button);
button = gtk_button_new_with_label (_("Save"));
......@@ -706,7 +706,7 @@ curves_dialog_new (void)
gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (curves_save_callback),
NULL);
cd->shell);
gtk_widget_show (button);
gtk_widget_show (hbbox);
......@@ -1263,7 +1263,7 @@ curves_load_callback (GtkWidget *widget,
gpointer data)
{
if (!file_dlg)
make_file_dlg (NULL);
file_dialog_create (GTK_WIDGET (data));
else if (GTK_WIDGET_VISIBLE (file_dlg))
return;
......@@ -1278,7 +1278,7 @@ curves_save_callback (GtkWidget *widget,
gpointer data)
{
if (!file_dlg)
make_file_dlg (NULL);
file_dialog_create (GTK_WIDGET (data));
else if (GTK_WIDGET_VISIBLE (file_dlg))
return;
......@@ -1561,7 +1561,7 @@ curves_CR_compose (CRMatrix a,
static void
make_file_dlg (gpointer data)
file_dialog_create (GtkWidget *parent)
{
gchar *temp;
......@@ -1573,14 +1573,18 @@ make_file_dlg (gpointer data)
gtk_container_set_border_width (GTK_CONTAINER (GTK_FILE_SELECTION (file_dlg)->button_area), 2);
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (file_dlg)->cancel_button),
"clicked", GTK_SIGNAL_FUNC (file_cancel_callback),
data);
"clicked", GTK_SIGNAL_FUNC (file_dialog_cancel_callback),
NULL);
gtk_signal_connect (GTK_OBJECT (file_dlg), "delete_event",
GTK_SIGNAL_FUNC (file_cancel_callback),
data);
GTK_SIGNAL_FUNC (file_dialog_cancel_callback),
NULL);
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (file_dlg)->ok_button),
"clicked", GTK_SIGNAL_FUNC (file_ok_callback),
data);
"clicked", GTK_SIGNAL_FUNC (file_dialog_ok_callback),
NULL);
gtk_signal_connect (GTK_OBJECT (parent), "unmap",
GTK_SIGNAL_FUNC (file_dialog_cancel_callback),
NULL);
temp = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "curves" G_DIR_SEPARATOR_S,
gimp_directory ());
......@@ -1592,8 +1596,8 @@ make_file_dlg (gpointer data)
}
static void
file_ok_callback (GtkWidget *widget,
gpointer data)
file_dialog_ok_callback (GtkWidget *widget,
gpointer data)
{
FILE *f;
gchar *filename;
......@@ -1610,7 +1614,7 @@ file_ok_callback (GtkWidget *widget,
return;
}
if (!read_curves_from_file (f))
if (!curves_read_from_file (f))
{
g_message (("Error in reading file %s"), filename);
return;
......@@ -1628,7 +1632,7 @@ file_ok_callback (GtkWidget *widget,
return;
}
write_curves_to_file (f);
curves_write_to_file (f);
fclose (f);
}
......@@ -1637,14 +1641,14 @@ file_ok_callback (GtkWidget *widget,
}
static void
file_cancel_callback (GtkWidget *widget,
gpointer data)
file_dialog_cancel_callback (GtkWidget *widget,
gpointer data)
{
gtk_widget_hide (file_dlg);
}
static gboolean
read_curves_from_file (FILE *f)
curves_read_from_file (FILE *f)
{
gint i, j, fields;
gchar buf[50];
......@@ -1701,7 +1705,7 @@ read_curves_from_file (FILE *f)
}
static void
write_curves_to_file (FILE *f)
curves_write_to_file (FILE *f)
{
int i, j;
gint32 index;
......
......@@ -107,26 +107,26 @@ static void curves_preview (CurvesDialog *);
static void curves_channel_callback (GtkWidget *, gpointer);
static void curves_smooth_callback (GtkWidget *, gpointer);
static void curves_free_callback (GtkWidget *, gpointer);
static void curves_smooth_callback (GtkWidget *, gpointer);
static void curves_free_callback (GtkWidget *, gpointer);
static void curves_reset_callback (GtkWidget *, gpointer);
static void curves_ok_callback (GtkWidget *, gpointer);
static void curves_cancel_callback (GtkWidget *, gpointer);
static void curves_load_callback (GtkWidget *, gpointer);
static void curves_save_callback (GtkWidget *, gpointer);
static void curves_preview_update (GtkWidget *, gpointer);
static gint curves_xrange_events (GtkWidget *, GdkEvent *, CurvesDialog *);
static gint curves_yrange_events (GtkWidget *, GdkEvent *, CurvesDialog *);
static gint curves_graph_events (GtkWidget *, GdkEvent *, CurvesDialog *);
static void curves_CR_compose (CRMatrix, CRMatrix, CRMatrix);
static void curves_reset_callback (GtkWidget *, gpointer);
static void curves_ok_callback (GtkWidget *, gpointer);
static void curves_cancel_callback (GtkWidget *, gpointer);
static void curves_load_callback (GtkWidget *, gpointer);
static void curves_save_callback (GtkWidget *, gpointer);
static void curves_preview_update (GtkWidget *, gpointer);
static gint curves_xrange_events (GtkWidget *, GdkEvent *, CurvesDialog *);
static gint curves_yrange_events (GtkWidget *, GdkEvent *, CurvesDialog *);
static gint curves_graph_events (GtkWidget *, GdkEvent *, CurvesDialog *);
static void curves_CR_compose (CRMatrix, CRMatrix, CRMatrix);
static void make_file_dlg (gpointer);
static void file_ok_callback (GtkWidget *, gpointer);
static void file_cancel_callback (GtkWidget *, gpointer);
static void file_dialog_create (GtkWidget *);
static void file_dialog_ok_callback (GtkWidget *, gpointer);
static void file_dialog_cancel_callback (GtkWidget *, gpointer);
static gboolean read_curves_from_file (FILE *f);
static void write_curves_to_file (FILE *f);
static gboolean curves_read_from_file (FILE *f);
static void curves_write_to_file (FILE *f);
/* curves machinery */
......@@ -698,7 +698,7 @@ curves_dialog_new (void)
gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (curves_load_callback),
NULL);
cd->shell);
gtk_widget_show (button);
button = gtk_button_new_with_label (_("Save"));
......@@ -706,7 +706,7 @@ curves_dialog_new (void)
gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (curves_save_callback),
NULL);
cd->shell);
gtk_widget_show (button);
gtk_widget_show (hbbox);
......@@ -1263,7 +1263,7 @@ curves_load_callback (GtkWidget *widget,
gpointer data)
{
if (!file_dlg)
make_file_dlg (NULL);
file_dialog_create (GTK_WIDGET (data));
else if (GTK_WIDGET_VISIBLE (file_dlg))
return;
......@@ -1278,7 +1278,7 @@ curves_save_callback (GtkWidget *widget,
gpointer data)
{
if (!file_dlg)
make_file_dlg (NULL);
file_dialog_create (GTK_WIDGET (data));
else if (GTK_WIDGET_VISIBLE (file_dlg))
return;
......@@ -1561,7 +1561,7 @@ curves_CR_compose (CRMatrix a,
static void
make_file_dlg (gpointer data)
file_dialog_create (GtkWidget *parent)
{
gchar *temp;
......@@ -1573,14 +1573,18 @@ make_file_dlg (gpointer data)
gtk_container_set_border_width (GTK_CONTAINER (GTK_FILE_SELECTION (file_dlg)->button_area), 2);
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (file_dlg)->cancel_button),
"clicked", GTK_SIGNAL_FUNC (file_cancel_callback),
data);
"clicked", GTK_SIGNAL_FUNC (file_dialog_cancel_callback),
NULL);
gtk_signal_connect (GTK_OBJECT (file_dlg), "delete_event",
GTK_SIGNAL_FUNC (file_cancel_callback),
data);
GTK_SIGNAL_FUNC (file_dialog_cancel_callback),
NULL);
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (file_dlg)->ok_button),
"clicked", GTK_SIGNAL_FUNC (file_ok_callback),
data);
"clicked", GTK_SIGNAL_FUNC (file_dialog_ok_callback),
NULL);
gtk_signal_connect (GTK_OBJECT (parent), "unmap",
GTK_SIGNAL_FUNC (file_dialog_cancel_callback),
NULL);
temp = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "curves" G_DIR_SEPARATOR_S,
gimp_directory ());
......@@ -1592,8 +1596,8 @@ make_file_dlg (gpointer data)
}
static void
file_ok_callback (GtkWidget *widget,
gpointer data)
file_dialog_ok_callback (GtkWidget *widget,
gpointer data)
{
FILE *f;
gchar *filename;
......@@ -1610,7 +1614,7 @@ file_ok_callback (GtkWidget *widget,
return;
}
if (!read_curves_from_file (f))
if (!curves_read_from_file (f))
{
g_message (("Error in reading file %s"), filename);
return;
......@@ -1628,7 +1632,7 @@ file_ok_callback (GtkWidget *widget,
return;
}
write_curves_to_file (f);
curves_write_to_file (f);
fclose (f);
}
......@@ -1637,14 +1641,14 @@ file_ok_callback (GtkWidget *widget,
}
static void
file_cancel_callback (GtkWidget *widget,
gpointer data)
file_dialog_cancel_callback (GtkWidget *widget,
gpointer data)
{
gtk_widget_hide (file_dlg);
}
static gboolean
read_curves_from_file (FILE *f)
curves_read_from_file (FILE *f)
{
gint i, j, fields;
gchar buf[50];
......@@ -1701,7 +1705,7 @@ read_curves_from_file (FILE *f)
}
static void
write_curves_to_file (FILE *f)
curves_write_to_file (FILE *f)
{
int i, j;
gint32 index;
......
......@@ -371,8 +371,8 @@ file_open_callback (GtkWidget *widget,
open_options, FALSE, FALSE, 0);
}
gtk_frame_set_label (GTK_FRAME(open_options_frame), _("Preview"));
gtk_label_set_text (GTK_LABEL(open_options_label), _("No Selection."));
gtk_frame_set_label (GTK_FRAME (open_options_frame), _("Preview"));
gtk_label_set_text (GTK_LABEL (open_options_label), _("No Selection."));
gtk_widget_show (GTK_WIDGET (open_options_genbuttonlabel));
gtk_widget_hide (GTK_WIDGET (open_options_preview));
......@@ -843,7 +843,7 @@ file_save_thumbnail (GimpImage *gimage,
FILE *fp;
struct stat statbuf;
if (stat(full_source_filename, &statbuf) != 0)
if (stat (full_source_filename, &statbuf) != 0)
{
return FALSE;
}
......@@ -972,10 +972,10 @@ file_save_thumbnail (GimpImage *gimage,
}
else /* Error writing thumbnail */
{
return (FALSE);
return FALSE;
}
return (TRUE);
return TRUE;
}
gint
......@@ -1083,15 +1083,15 @@ readXVThumb (const gchar *fnam,
fp = fopen (fnam, "rb");
if (!fp)
return (NULL);
return NULL;
fread (P7_buf, 6, 1, fp);
if (strncmp(P7_buf, P7_332, 6)!=0)
{
g_warning("Thumbnail doesn't have the 'P7 332' header.");
fclose(fp);
return(NULL);
g_warning ("Thumbnail doesn't have the 'P7 332' header.");
fclose (fp);
return NULL;
}
/*newline*/
......@@ -1120,24 +1120,24 @@ readXVThumb (const gchar *fnam,
if (!ptr)
{
/* g_warning("Thumbnail ended - not an image?"); */
fclose(fp);
return(NULL);
fclose (fp);
return NULL;
}
sscanf(linebuf, "%d %d %d\n", w, h, &twofivefive);
if (twofivefive!=255)
{
g_warning("Thumbnail is of funky depth.");
fclose(fp);
return(NULL);
g_warning ("Thumbnail is of funky depth.");
fclose (fp);
return NULL;
}
if ((*w)<1 || (*h)<1 || (*w)>80 || (*h)>60)
{
g_warning ("Thumbnail size bad. Corrupted?");
fclose(fp);
return (NULL);
fclose (fp);
return NULL;
}
buf = g_malloc ((*w) * (*h));
......@@ -1146,7 +1146,7 @@ readXVThumb (const gchar *fnam,
fclose (fp);
return (buf);
return buf;
}
/* don't call with preview_fullname as parameter! will be clobbered! */
......
......@@ -152,12 +152,12 @@ static gint levels_input_da_events (GtkWidget *, GdkEvent *,
static gint levels_output_da_events (GtkWidget *, GdkEvent *,
LevelsDialog *);
static void make_file_dlg (gpointer);
static void file_ok_callback (GtkWidget *, gpointer);
static void file_cancel_callback (GtkWidget *, gpointer);
static void file_dialog_create (GtkWidget *);
static void file_dialog_ok_callback (GtkWidget *, gpointer);
static void file_dialog_cancel_callback (GtkWidget *, gpointer);
static gboolean read_levels_from_file (FILE *f);
static void write_levels_to_file (FILE *f);
static gboolean levels_read_from_file (FILE *f);
static void levels_write_to_file (FILE *f);
/* levels action functions */
......@@ -601,7 +601,7 @@ levels_dialog_new (void)
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (levels_load_callback),
NULL);
ld->shell);
gtk_widget_show (button);
......@@ -611,7 +611,7 @@ levels_dialog_new (void)
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (levels_save_callback),
NULL);
ld->shell);
gtk_widget_show (button);
......@@ -1044,7 +1044,7 @@ levels_load_callback (GtkWidget *widget,
gpointer data)
{
if (!file_dlg)
make_file_dlg (NULL);
file_dialog_create (GTK_WIDGET (data));
else if (GTK_WIDGET_VISIBLE (file_dlg))
return;
......@@ -1059,7 +1059,7 @@ levels_save_callback (GtkWidget *widget,
gpointer data)
{
if (!file_dlg)
make_file_dlg (NULL);
file_dialog_create (GTK_WIDGET (data));
else if (GTK_WIDGET_VISIBLE (file_dlg))
return;
......@@ -1380,7 +1380,7 @@ levels_output_da_events (GtkWidget *widget,
}
static void
make_file_dlg (gpointer data)
file_dialog_create (GtkWidget *parent)
{
gchar *temp;
......@@ -1392,14 +1392,18 @@ make_file_dlg (gpointer data)
gtk_container_set_border_width (GTK_CONTAINER (GTK_FILE_SELECTION (file_dlg)->button_area), 2);
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (file_dlg)->cancel_button),
"clicked", GTK_SIGNAL_FUNC (file_cancel_callback),
data);
"clicked", GTK_SIGNAL_FUNC (file_dialog_cancel_callback),
NULL);
gtk_signal_connect (GTK_OBJECT (file_dlg), "delete_event",
GTK_SIGNAL_FUNC (file_cancel_callback),
data);
GTK_SIGNAL_FUNC (file_dialog_cancel_callback),
NULL);
gtk_signal_connect (GTK_OBJECT (GTK_FILE_SELECTION (file_dlg)->ok_button),
"clicked", GTK_SIGNAL_FUNC (file_ok_callback),
data);
"clicked", GTK_SIGNAL_FUNC (file_dialog_ok_callback),
NULL);
gtk_signal_connect (GTK_OBJECT (parent), "unmap",
GTK_SIGNAL_FUNC (file_dialog_cancel_callback),
NULL);
temp = g_strdup_printf ("%s" G_DIR_SEPARATOR_S "levels" G_DIR_SEPARATOR_S,
gimp_directory ());
......@@ -1411,8 +1415,8 @@ make_file_dlg (gpointer data)
}
static void
file_ok_callback (GtkWidget *widget,
gpointer data)
file_dialog_ok_callback (GtkWidget *widget,
gpointer data)
{
FILE *f;
gchar *filename;
......@@ -1429,7 +1433,7 @@ file_ok_callback (GtkWidget *widget,
return;
}
if (!read_levels_from_file (f))
if (!levels_read_from_file (f))
{
g_message (("Error in reading file %s"), filename);
return;
......@@ -1447,7 +1451,7 @@ file_ok_callback (GtkWidget *widget,
return;
}
write_levels_to_file (f);
levels_write_to_file (f);
fclose (f);
}
......@@ -1456,14 +1460,14 @@ file_ok_callback (GtkWidget *widget,
}
static void
file_cancel_callback (GtkWidget *widget,
gpointer data)
file_dialog_cancel_callback (GtkWidget *widget,
gpointer data)
{
gtk_widget_hide (file_dlg);
}
static gboolean
read_levels_from_file (FILE *f)
levels_read_from_file (FILE *f)
{
int low_input[5];
int high_input[5];
......@@ -1517,7 +1521,7 @@ read_levels_from_file (FILE *f)
}
static void
write_levels_to_file (FILE *f)
levels_write_to_file (FILE *f)
{
int i;
......
......@@ -107,26 +107,26 @@ static void curves_preview (CurvesDialog *);
static void curves_channel_callback (GtkWidget *, gpointer);
static void curves_smooth_callback (GtkWidget *, gpointer);
static void curves_free_callback (GtkWidget *, gpointer);
static void curves_smooth_callback (GtkWidget *, gpointer);
static void curves_free_callback (GtkWidget *, gpointer);
static void curves_reset_callback (GtkWidget *, gpointer);
static void curves_ok_callback (GtkWidget *, gpointer);
static void curves_cancel_callback (GtkWidget *, gpointer);
static void curves_load_callback (GtkWidget *, gpointer);
static void curves_save_callback (GtkWidget *, gpointer);
static void curves_preview_update (GtkWidget *, gpointer);
static gint curves_xrange_events (GtkWidget *, GdkEvent *, CurvesDialog *);
static gint curves_yrange_events (GtkWidget *, GdkEvent *, CurvesDialog *);
static gint curves_graph_events (GtkWidget *, GdkEvent *, CurvesDialog *);
static void curves_CR_compose (CRMatrix, CRMatrix, CRMatrix);
static void curves_reset_callback (GtkWidget *, gpointer);
static void curves_ok_callback (GtkWidget *, gpointer);
static void curves_cancel_callback (GtkWidget *, gpointer);
static void curves_load_callback (GtkWidget *, gpointer);
static void curves_save_callback (GtkWidget *, gpointer);
static void curves_preview_update (GtkWidget *, gpointer);
static gint curves_xrange_events (GtkWidget *, GdkEvent *, CurvesDialog *);
static gint curves_yrange_events (GtkWidget *, GdkEvent *, CurvesDialog *);
static gint curves_graph_events (GtkWidget *, GdkEvent *, CurvesDialog *);
static void curves_CR_compose (CRMatrix, CRMatrix, CRMatrix);
static void make_file_dlg (gpointer);
static void file_ok_callback (GtkWidget *, gpointer);
static void file_cancel_callback (GtkWidget *, gpointer);
static void file_dialog_create (GtkWidget *);
static void file_dialog_ok_callback (GtkWidget *, gpointer);
static void file_dialog_cancel_callback (GtkWidget *, gpointer);
static gboolean read_curves_from_file (FILE *f);
static void write_curves_to_file (FILE *f);
static gboolean curves_read_from_file (FILE *f);
static void curves_write_to_file (FILE *f);
/* curves machinery */
......@@ -698,7 +698,7 @@ curves_dialog_new (void)
gtk_box_pack_start (GTK_BOX (hbbox), button, FALSE, FALSE, 0);
gtk_signal_connect (GTK_OBJECT (button), "clicked",
GTK_SIGNAL_FUNC (curves_load_callback),
NULL);
cd->shell);
gtk_widget_show (button);
button = gtk_button_new_with_label (_("Save"));
......@@ -706,7 +706,7 @@ curves_dialog_new (void)