using the GimpPixmap here was a bad idea because showing/hiding the pixmap

2000-04-20  Michael Natterer  <mitch@gimp.org>

	* libgimp/gimpfileselection.[ch]: using the GimpPixmap here was a
	bad idea because showing/hiding the pixmap widgets is no solution
	(somebody may call gtk_widget_show_all() and we suddenly see both
	pixmaps, eek).
	Reverted it to use GtkPixmap and gtk_pixmap_set().
This commit is contained in:
Michael Natterer
2000-04-20 15:48:00 +00:00
committed by Michael Natterer
parent 91d956d412
commit 66e1b6f680
7 changed files with 215 additions and 96 deletions

View File

@ -1,3 +1,11 @@
2000-04-20 Michael Natterer <mitch@gimp.org>
* libgimp/gimpfileselection.[ch]: using the GimpPixmap here was a
bad idea because showing/hiding the pixmap widgets is no solution
(somebody may call gtk_widget_show_all() and we suddenly see both
pixmaps, eek).
Reverted it to use GtkPixmap and gtk_pixmap_set().
2000-04-20 Jens Lautenbacher <jtl@schlund.de> 2000-04-20 Jens Lautenbacher <jtl@schlund.de>
* plug-ins/common/bumpmap.c (bumpmap_dialog): restrict scale for * plug-ins/common/bumpmap.c (bumpmap_dialog): restrict scale for

View File

@ -2,7 +2,7 @@
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
* *
* gimpfileselection.c * gimpfileselection.c
* Copyright (C) 1999 Michael Natterer <mitch@gimp.org> * Copyright (C) 1999-2000 Michael Natterer <mitch@gimp.org>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -47,6 +47,7 @@
#endif #endif
/* callbacks */ /* callbacks */
static void gimp_file_selection_realize (GtkWidget *widget);
static void gimp_file_selection_entry_callback (GtkWidget *widget, static void gimp_file_selection_entry_callback (GtkWidget *widget,
gpointer data); gpointer data);
static gint gimp_file_selection_entry_focus_out_callback (GtkWidget *widget, static gint gimp_file_selection_entry_focus_out_callback (GtkWidget *widget,
@ -84,6 +85,16 @@ gimp_file_selection_destroy (GtkObject *object)
if (gfs->title) if (gfs->title)
g_free (gfs->title); g_free (gfs->title);
if (gfs->yes_pixmap)
gdk_pixmap_unref (gfs->yes_pixmap);
if (gfs->yes_mask)
gdk_bitmap_unref (gfs->yes_mask);
if (gfs->no_pixmap)
gdk_pixmap_unref (gfs->no_pixmap);
if (gfs->no_mask)
gdk_bitmap_unref (gfs->no_mask);
if (GTK_OBJECT_CLASS (parent_class)->destroy) if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object); (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
} }
@ -92,8 +103,10 @@ static void
gimp_file_selection_class_init (GimpFileSelectionClass *class) gimp_file_selection_class_init (GimpFileSelectionClass *class)
{ {
GtkObjectClass *object_class; GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = (GtkObjectClass *) class; object_class = (GtkObjectClass *) class;
widget_class = (GtkWidgetClass *) class;
parent_class = gtk_type_class (gtk_hbox_get_type ()); parent_class = gtk_type_class (gtk_hbox_get_type ());
@ -111,6 +124,8 @@ gimp_file_selection_class_init (GimpFileSelectionClass *class)
class->filename_changed = NULL; class->filename_changed = NULL;
object_class->destroy = gimp_file_selection_destroy; object_class->destroy = gimp_file_selection_destroy;
widget_class->realize = gimp_file_selection_realize;
} }
static void static void
@ -120,8 +135,11 @@ gimp_file_selection_init (GimpFileSelection *gfs)
gfs->file_selection = NULL; gfs->file_selection = NULL;
gfs->check_valid = FALSE; gfs->check_valid = FALSE;
gfs->file_exists = NULL;
gfs->yes_pixmap = NULL; gfs->yes_pixmap = NULL;
gfs->yes_mask = NULL;
gfs->no_pixmap = NULL; gfs->no_pixmap = NULL;
gfs->no_mask = NULL;
gtk_box_set_spacing (GTK_BOX (gfs), 2); gtk_box_set_spacing (GTK_BOX (gfs), 2);
gtk_box_set_homogeneous (GTK_BOX (gfs), FALSE); gtk_box_set_homogeneous (GTK_BOX (gfs), FALSE);
@ -196,17 +214,6 @@ gimp_file_selection_new (gchar *title,
gfs->dir_only = dir_only; gfs->dir_only = dir_only;
gfs->check_valid = check_valid; gfs->check_valid = check_valid;
if (check_valid)
{
gfs->yes_pixmap = gimp_pixmap_new (yes_xpm);
gtk_box_pack_start (GTK_BOX (gfs), gfs->yes_pixmap, FALSE, FALSE, 0);
/* don't show */
gfs->no_pixmap = gimp_pixmap_new (no_xpm);
gtk_box_pack_start (GTK_BOX (gfs), gfs->no_pixmap, FALSE, FALSE, 0);
gtk_widget_show (gfs->no_pixmap);
}
gimp_file_selection_set_filename (gfs, filename); gimp_file_selection_set_filename (gfs, filename);
return GTK_WIDGET (gfs); return GTK_WIDGET (gfs);
@ -254,6 +261,37 @@ gimp_file_selection_set_filename (GimpFileSelection *gfs,
gimp_file_selection_entry_callback (gfs->entry, (gpointer) gfs); gimp_file_selection_entry_callback (gfs->entry, (gpointer) gfs);
} }
static void
gimp_file_selection_realize (GtkWidget *widget)
{
GimpFileSelection *gfs;
GtkStyle *style;
gfs = GIMP_FILE_SELECTION (widget);
if (! gfs->check_valid)
return;
if (GTK_WIDGET_CLASS (parent_class)->realize)
(* GTK_WIDGET_CLASS (parent_class)->realize) (widget);
style = gtk_widget_get_style (widget);
gfs->yes_pixmap = gdk_pixmap_create_from_xpm_d (widget->window,
&gfs->yes_mask,
&style->bg[GTK_STATE_NORMAL],
yes_xpm);
gfs->no_pixmap = gdk_pixmap_create_from_xpm_d (widget->window,
&gfs->no_mask,
&style->bg[GTK_STATE_NORMAL],
no_xpm);
gfs->file_exists = gtk_pixmap_new (gfs->no_pixmap, gfs->no_mask);
gtk_box_pack_start (GTK_BOX (gfs), gfs->file_exists, FALSE, FALSE, 0);
gimp_file_selection_check_filename (gfs);
gtk_widget_show (gfs->file_exists);
}
static void static void
gimp_file_selection_entry_callback (GtkWidget *widget, gimp_file_selection_entry_callback (GtkWidget *widget,
gpointer data) gpointer data)
@ -400,23 +438,20 @@ gimp_file_selection_check_filename (GimpFileSelection *gfs)
if (! gfs->check_valid) if (! gfs->check_valid)
return; return;
if (gfs->yes_pixmap == NULL || gfs->no_pixmap == NULL) if (gfs->file_exists == NULL)
return; return;
filename = gtk_editable_get_chars (GTK_EDITABLE (gfs->entry), 0, -1); filename = gtk_editable_get_chars (GTK_EDITABLE (gfs->entry), 0, -1);
if ((stat (filename, &statbuf) == 0) && if ((stat (filename, &statbuf) == 0) &&
(gfs->dir_only ? S_ISDIR (statbuf.st_mode) : S_ISREG (statbuf.st_mode))) (gfs->dir_only ? S_ISDIR (statbuf.st_mode) : S_ISREG (statbuf.st_mode)))
{ {
if (GTK_WIDGET_VISIBLE (gfs->no_pixmap)) gtk_pixmap_set (GTK_PIXMAP (gfs->file_exists),
{ gfs->yes_pixmap, gfs->yes_mask);
gtk_widget_hide (gfs->no_pixmap);
gtk_widget_show (gfs->yes_pixmap);
}
} }
else if (GTK_WIDGET_VISIBLE (gfs->yes_pixmap)) else
{ {
gtk_widget_hide (gfs->yes_pixmap); gtk_pixmap_set (GTK_PIXMAP (gfs->file_exists),
gtk_widget_show (gfs->no_pixmap); gfs->no_pixmap, gfs->no_mask);
} }
g_free (filename); g_free (filename);

View File

@ -25,8 +25,6 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "gimppixmap.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
@ -42,18 +40,22 @@ typedef struct _GimpFileSelectionClass GimpFileSelectionClass;
struct _GimpFileSelection struct _GimpFileSelection
{ {
GtkHBox hbox; GtkHBox hbox;
GtkWidget *yes_pixmap; GtkWidget *file_exists;
GtkWidget *no_pixmap; GtkWidget *entry;
GtkWidget *entry; GtkWidget *browse_button;
GtkWidget *browse_button;
GtkWidget *file_selection; GtkWidget *file_selection;
gchar *title; GdkPixmap *yes_pixmap;
gboolean dir_only; GdkBitmap *yes_mask;
gboolean check_valid; GdkPixmap *no_pixmap;
GdkBitmap *no_mask;
gchar *title;
gboolean dir_only;
gboolean check_valid;
}; };
struct _GimpFileSelectionClass struct _GimpFileSelectionClass

View File

@ -2,7 +2,7 @@
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
* *
* gimpfileselection.c * gimpfileselection.c
* Copyright (C) 1999 Michael Natterer <mitch@gimp.org> * Copyright (C) 1999-2000 Michael Natterer <mitch@gimp.org>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -47,6 +47,7 @@
#endif #endif
/* callbacks */ /* callbacks */
static void gimp_file_selection_realize (GtkWidget *widget);
static void gimp_file_selection_entry_callback (GtkWidget *widget, static void gimp_file_selection_entry_callback (GtkWidget *widget,
gpointer data); gpointer data);
static gint gimp_file_selection_entry_focus_out_callback (GtkWidget *widget, static gint gimp_file_selection_entry_focus_out_callback (GtkWidget *widget,
@ -84,6 +85,16 @@ gimp_file_selection_destroy (GtkObject *object)
if (gfs->title) if (gfs->title)
g_free (gfs->title); g_free (gfs->title);
if (gfs->yes_pixmap)
gdk_pixmap_unref (gfs->yes_pixmap);
if (gfs->yes_mask)
gdk_bitmap_unref (gfs->yes_mask);
if (gfs->no_pixmap)
gdk_pixmap_unref (gfs->no_pixmap);
if (gfs->no_mask)
gdk_bitmap_unref (gfs->no_mask);
if (GTK_OBJECT_CLASS (parent_class)->destroy) if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object); (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
} }
@ -92,8 +103,10 @@ static void
gimp_file_selection_class_init (GimpFileSelectionClass *class) gimp_file_selection_class_init (GimpFileSelectionClass *class)
{ {
GtkObjectClass *object_class; GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = (GtkObjectClass *) class; object_class = (GtkObjectClass *) class;
widget_class = (GtkWidgetClass *) class;
parent_class = gtk_type_class (gtk_hbox_get_type ()); parent_class = gtk_type_class (gtk_hbox_get_type ());
@ -111,6 +124,8 @@ gimp_file_selection_class_init (GimpFileSelectionClass *class)
class->filename_changed = NULL; class->filename_changed = NULL;
object_class->destroy = gimp_file_selection_destroy; object_class->destroy = gimp_file_selection_destroy;
widget_class->realize = gimp_file_selection_realize;
} }
static void static void
@ -120,8 +135,11 @@ gimp_file_selection_init (GimpFileSelection *gfs)
gfs->file_selection = NULL; gfs->file_selection = NULL;
gfs->check_valid = FALSE; gfs->check_valid = FALSE;
gfs->file_exists = NULL;
gfs->yes_pixmap = NULL; gfs->yes_pixmap = NULL;
gfs->yes_mask = NULL;
gfs->no_pixmap = NULL; gfs->no_pixmap = NULL;
gfs->no_mask = NULL;
gtk_box_set_spacing (GTK_BOX (gfs), 2); gtk_box_set_spacing (GTK_BOX (gfs), 2);
gtk_box_set_homogeneous (GTK_BOX (gfs), FALSE); gtk_box_set_homogeneous (GTK_BOX (gfs), FALSE);
@ -196,17 +214,6 @@ gimp_file_selection_new (gchar *title,
gfs->dir_only = dir_only; gfs->dir_only = dir_only;
gfs->check_valid = check_valid; gfs->check_valid = check_valid;
if (check_valid)
{
gfs->yes_pixmap = gimp_pixmap_new (yes_xpm);
gtk_box_pack_start (GTK_BOX (gfs), gfs->yes_pixmap, FALSE, FALSE, 0);
/* don't show */
gfs->no_pixmap = gimp_pixmap_new (no_xpm);
gtk_box_pack_start (GTK_BOX (gfs), gfs->no_pixmap, FALSE, FALSE, 0);
gtk_widget_show (gfs->no_pixmap);
}
gimp_file_selection_set_filename (gfs, filename); gimp_file_selection_set_filename (gfs, filename);
return GTK_WIDGET (gfs); return GTK_WIDGET (gfs);
@ -254,6 +261,37 @@ gimp_file_selection_set_filename (GimpFileSelection *gfs,
gimp_file_selection_entry_callback (gfs->entry, (gpointer) gfs); gimp_file_selection_entry_callback (gfs->entry, (gpointer) gfs);
} }
static void
gimp_file_selection_realize (GtkWidget *widget)
{
GimpFileSelection *gfs;
GtkStyle *style;
gfs = GIMP_FILE_SELECTION (widget);
if (! gfs->check_valid)
return;
if (GTK_WIDGET_CLASS (parent_class)->realize)
(* GTK_WIDGET_CLASS (parent_class)->realize) (widget);
style = gtk_widget_get_style (widget);
gfs->yes_pixmap = gdk_pixmap_create_from_xpm_d (widget->window,
&gfs->yes_mask,
&style->bg[GTK_STATE_NORMAL],
yes_xpm);
gfs->no_pixmap = gdk_pixmap_create_from_xpm_d (widget->window,
&gfs->no_mask,
&style->bg[GTK_STATE_NORMAL],
no_xpm);
gfs->file_exists = gtk_pixmap_new (gfs->no_pixmap, gfs->no_mask);
gtk_box_pack_start (GTK_BOX (gfs), gfs->file_exists, FALSE, FALSE, 0);
gimp_file_selection_check_filename (gfs);
gtk_widget_show (gfs->file_exists);
}
static void static void
gimp_file_selection_entry_callback (GtkWidget *widget, gimp_file_selection_entry_callback (GtkWidget *widget,
gpointer data) gpointer data)
@ -400,23 +438,20 @@ gimp_file_selection_check_filename (GimpFileSelection *gfs)
if (! gfs->check_valid) if (! gfs->check_valid)
return; return;
if (gfs->yes_pixmap == NULL || gfs->no_pixmap == NULL) if (gfs->file_exists == NULL)
return; return;
filename = gtk_editable_get_chars (GTK_EDITABLE (gfs->entry), 0, -1); filename = gtk_editable_get_chars (GTK_EDITABLE (gfs->entry), 0, -1);
if ((stat (filename, &statbuf) == 0) && if ((stat (filename, &statbuf) == 0) &&
(gfs->dir_only ? S_ISDIR (statbuf.st_mode) : S_ISREG (statbuf.st_mode))) (gfs->dir_only ? S_ISDIR (statbuf.st_mode) : S_ISREG (statbuf.st_mode)))
{ {
if (GTK_WIDGET_VISIBLE (gfs->no_pixmap)) gtk_pixmap_set (GTK_PIXMAP (gfs->file_exists),
{ gfs->yes_pixmap, gfs->yes_mask);
gtk_widget_hide (gfs->no_pixmap);
gtk_widget_show (gfs->yes_pixmap);
}
} }
else if (GTK_WIDGET_VISIBLE (gfs->yes_pixmap)) else
{ {
gtk_widget_hide (gfs->yes_pixmap); gtk_pixmap_set (GTK_PIXMAP (gfs->file_exists),
gtk_widget_show (gfs->no_pixmap); gfs->no_pixmap, gfs->no_mask);
} }
g_free (filename); g_free (filename);

View File

@ -25,8 +25,6 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "gimppixmap.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
@ -42,18 +40,22 @@ typedef struct _GimpFileSelectionClass GimpFileSelectionClass;
struct _GimpFileSelection struct _GimpFileSelection
{ {
GtkHBox hbox; GtkHBox hbox;
GtkWidget *yes_pixmap; GtkWidget *file_exists;
GtkWidget *no_pixmap; GtkWidget *entry;
GtkWidget *entry; GtkWidget *browse_button;
GtkWidget *browse_button;
GtkWidget *file_selection; GtkWidget *file_selection;
gchar *title; GdkPixmap *yes_pixmap;
gboolean dir_only; GdkBitmap *yes_mask;
gboolean check_valid; GdkPixmap *no_pixmap;
GdkBitmap *no_mask;
gchar *title;
gboolean dir_only;
gboolean check_valid;
}; };
struct _GimpFileSelectionClass struct _GimpFileSelectionClass

View File

@ -2,7 +2,7 @@
* Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball * Copyright (C) 1995-1997 Peter Mattis and Spencer Kimball
* *
* gimpfileselection.c * gimpfileselection.c
* Copyright (C) 1999 Michael Natterer <mitch@gimp.org> * Copyright (C) 1999-2000 Michael Natterer <mitch@gimp.org>
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -47,6 +47,7 @@
#endif #endif
/* callbacks */ /* callbacks */
static void gimp_file_selection_realize (GtkWidget *widget);
static void gimp_file_selection_entry_callback (GtkWidget *widget, static void gimp_file_selection_entry_callback (GtkWidget *widget,
gpointer data); gpointer data);
static gint gimp_file_selection_entry_focus_out_callback (GtkWidget *widget, static gint gimp_file_selection_entry_focus_out_callback (GtkWidget *widget,
@ -84,6 +85,16 @@ gimp_file_selection_destroy (GtkObject *object)
if (gfs->title) if (gfs->title)
g_free (gfs->title); g_free (gfs->title);
if (gfs->yes_pixmap)
gdk_pixmap_unref (gfs->yes_pixmap);
if (gfs->yes_mask)
gdk_bitmap_unref (gfs->yes_mask);
if (gfs->no_pixmap)
gdk_pixmap_unref (gfs->no_pixmap);
if (gfs->no_mask)
gdk_bitmap_unref (gfs->no_mask);
if (GTK_OBJECT_CLASS (parent_class)->destroy) if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object); (* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
} }
@ -92,8 +103,10 @@ static void
gimp_file_selection_class_init (GimpFileSelectionClass *class) gimp_file_selection_class_init (GimpFileSelectionClass *class)
{ {
GtkObjectClass *object_class; GtkObjectClass *object_class;
GtkWidgetClass *widget_class;
object_class = (GtkObjectClass *) class; object_class = (GtkObjectClass *) class;
widget_class = (GtkWidgetClass *) class;
parent_class = gtk_type_class (gtk_hbox_get_type ()); parent_class = gtk_type_class (gtk_hbox_get_type ());
@ -111,6 +124,8 @@ gimp_file_selection_class_init (GimpFileSelectionClass *class)
class->filename_changed = NULL; class->filename_changed = NULL;
object_class->destroy = gimp_file_selection_destroy; object_class->destroy = gimp_file_selection_destroy;
widget_class->realize = gimp_file_selection_realize;
} }
static void static void
@ -120,8 +135,11 @@ gimp_file_selection_init (GimpFileSelection *gfs)
gfs->file_selection = NULL; gfs->file_selection = NULL;
gfs->check_valid = FALSE; gfs->check_valid = FALSE;
gfs->file_exists = NULL;
gfs->yes_pixmap = NULL; gfs->yes_pixmap = NULL;
gfs->yes_mask = NULL;
gfs->no_pixmap = NULL; gfs->no_pixmap = NULL;
gfs->no_mask = NULL;
gtk_box_set_spacing (GTK_BOX (gfs), 2); gtk_box_set_spacing (GTK_BOX (gfs), 2);
gtk_box_set_homogeneous (GTK_BOX (gfs), FALSE); gtk_box_set_homogeneous (GTK_BOX (gfs), FALSE);
@ -196,17 +214,6 @@ gimp_file_selection_new (gchar *title,
gfs->dir_only = dir_only; gfs->dir_only = dir_only;
gfs->check_valid = check_valid; gfs->check_valid = check_valid;
if (check_valid)
{
gfs->yes_pixmap = gimp_pixmap_new (yes_xpm);
gtk_box_pack_start (GTK_BOX (gfs), gfs->yes_pixmap, FALSE, FALSE, 0);
/* don't show */
gfs->no_pixmap = gimp_pixmap_new (no_xpm);
gtk_box_pack_start (GTK_BOX (gfs), gfs->no_pixmap, FALSE, FALSE, 0);
gtk_widget_show (gfs->no_pixmap);
}
gimp_file_selection_set_filename (gfs, filename); gimp_file_selection_set_filename (gfs, filename);
return GTK_WIDGET (gfs); return GTK_WIDGET (gfs);
@ -254,6 +261,37 @@ gimp_file_selection_set_filename (GimpFileSelection *gfs,
gimp_file_selection_entry_callback (gfs->entry, (gpointer) gfs); gimp_file_selection_entry_callback (gfs->entry, (gpointer) gfs);
} }
static void
gimp_file_selection_realize (GtkWidget *widget)
{
GimpFileSelection *gfs;
GtkStyle *style;
gfs = GIMP_FILE_SELECTION (widget);
if (! gfs->check_valid)
return;
if (GTK_WIDGET_CLASS (parent_class)->realize)
(* GTK_WIDGET_CLASS (parent_class)->realize) (widget);
style = gtk_widget_get_style (widget);
gfs->yes_pixmap = gdk_pixmap_create_from_xpm_d (widget->window,
&gfs->yes_mask,
&style->bg[GTK_STATE_NORMAL],
yes_xpm);
gfs->no_pixmap = gdk_pixmap_create_from_xpm_d (widget->window,
&gfs->no_mask,
&style->bg[GTK_STATE_NORMAL],
no_xpm);
gfs->file_exists = gtk_pixmap_new (gfs->no_pixmap, gfs->no_mask);
gtk_box_pack_start (GTK_BOX (gfs), gfs->file_exists, FALSE, FALSE, 0);
gimp_file_selection_check_filename (gfs);
gtk_widget_show (gfs->file_exists);
}
static void static void
gimp_file_selection_entry_callback (GtkWidget *widget, gimp_file_selection_entry_callback (GtkWidget *widget,
gpointer data) gpointer data)
@ -400,23 +438,20 @@ gimp_file_selection_check_filename (GimpFileSelection *gfs)
if (! gfs->check_valid) if (! gfs->check_valid)
return; return;
if (gfs->yes_pixmap == NULL || gfs->no_pixmap == NULL) if (gfs->file_exists == NULL)
return; return;
filename = gtk_editable_get_chars (GTK_EDITABLE (gfs->entry), 0, -1); filename = gtk_editable_get_chars (GTK_EDITABLE (gfs->entry), 0, -1);
if ((stat (filename, &statbuf) == 0) && if ((stat (filename, &statbuf) == 0) &&
(gfs->dir_only ? S_ISDIR (statbuf.st_mode) : S_ISREG (statbuf.st_mode))) (gfs->dir_only ? S_ISDIR (statbuf.st_mode) : S_ISREG (statbuf.st_mode)))
{ {
if (GTK_WIDGET_VISIBLE (gfs->no_pixmap)) gtk_pixmap_set (GTK_PIXMAP (gfs->file_exists),
{ gfs->yes_pixmap, gfs->yes_mask);
gtk_widget_hide (gfs->no_pixmap);
gtk_widget_show (gfs->yes_pixmap);
}
} }
else if (GTK_WIDGET_VISIBLE (gfs->yes_pixmap)) else
{ {
gtk_widget_hide (gfs->yes_pixmap); gtk_pixmap_set (GTK_PIXMAP (gfs->file_exists),
gtk_widget_show (gfs->no_pixmap); gfs->no_pixmap, gfs->no_mask);
} }
g_free (filename); g_free (filename);

View File

@ -25,8 +25,6 @@
#include <gtk/gtk.h> #include <gtk/gtk.h>
#include "gimppixmap.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif /* __cplusplus */ #endif /* __cplusplus */
@ -42,18 +40,22 @@ typedef struct _GimpFileSelectionClass GimpFileSelectionClass;
struct _GimpFileSelection struct _GimpFileSelection
{ {
GtkHBox hbox; GtkHBox hbox;
GtkWidget *yes_pixmap; GtkWidget *file_exists;
GtkWidget *no_pixmap; GtkWidget *entry;
GtkWidget *entry; GtkWidget *browse_button;
GtkWidget *browse_button;
GtkWidget *file_selection; GtkWidget *file_selection;
gchar *title; GdkPixmap *yes_pixmap;
gboolean dir_only; GdkBitmap *yes_mask;
gboolean check_valid; GdkPixmap *no_pixmap;
GdkBitmap *no_mask;
gchar *title;
gboolean dir_only;
gboolean check_valid;
}; };
struct _GimpFileSelectionClass struct _GimpFileSelectionClass