Commit 83757a67 authored by Michael Natterer's avatar Michael Natterer 😴 Committed by Michael Natterer

app/docindex.c app/fileops.c app/gdisplay.c

2001-01-14  Michael Natterer  <mitch@gimp.org>

	* app/docindex.c
	* app/fileops.c
	* app/gdisplay.c
	* app/gimpimage.[ch]:

	Removed the "has_filename" boolean from GimpImage:

	- to get the filename, ask for GimpObjects's name.
	- gimp_image_filename() returns the *display* filename (and will be
	  renamed to gimp_image_display_name() soon), i.e. returns
	  "Unnamed" if object->name == NULL.
	- no need any more to check if the filename is the "" string because
	  GimpImage overrides GimpObject's "name_changed" method and
	  sets the name to NULL if it was "".
parent c3d53e1f
2001-01-14 Michael Natterer <mitch@gimp.org>
* app/docindex.c
* app/fileops.c
* app/gdisplay.c
* app/gimpimage.[ch]:
Removed the "has_filename" boolean from GimpImage:
- to get the filename, ask for GimpObjects's name.
- gimp_image_filename() returns the *display* filename (and will be
renamed to gimp_image_display_name() soon), i.e. returns
"Unnamed" if object->name == NULL.
- no need any more to check if the filename is the "" string because
GimpImage overrides GimpObject's "name_changed" method and
sets the name to NULL if it was "".
2001-01-14 Sven Neumann <sven@gimp.org>
Merged fixes from gimp-1-2:
......
......@@ -259,7 +259,6 @@ gimp_image_class_init (GimpImageClass *klass)
static void
gimp_image_init (GimpImage *gimage)
{
gimage->has_filename = FALSE;
gimage->num_cols = 0;
gimage->cmap = NULL;
gimage->disp_count = 0;
......@@ -435,20 +434,17 @@ gimp_image_name_changed (GimpObject *object)
GimpImage *gimage;
const gchar *name;
if (GIMP_OBJECT_CLASS (parent_class)->name_changed)
GIMP_OBJECT_CLASS (parent_class)->name_changed (object);
gimage = GIMP_IMAGE (object);
name = gimp_object_get_name (object);
if (name && name[0])
{
gimage->has_filename = TRUE;
}
else
if (! (name && strlen (name)))
{
gimage->has_filename = FALSE;
g_free (object->name);
object->name = NULL;
}
if (GIMP_OBJECT_CLASS (parent_class)->name_changed)
GIMP_OBJECT_CLASS (parent_class)->name_changed (object);
}
void
......@@ -3607,13 +3603,14 @@ gimp_image_base_type_with_alpha (const GimpImage *gimage)
const gchar *
gimp_image_filename (const GimpImage *gimage)
{
const gchar *filename;
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
if (gimage->has_filename)
return gimp_object_get_name (GIMP_OBJECT (gimage));
else
return _("Untitled");
filename = gimp_object_get_name (GIMP_OBJECT (gimage));
return filename ? filename : _("Untitled");
}
gboolean
......
......@@ -48,7 +48,6 @@ struct _GimpImage
{
GimpObject parent_instance;
gboolean has_filename; /* has a valid filename */
PlugInProcDef *save_proc; /* last PDB save proc used */
gint width, height; /* width and height attributes */
......
......@@ -259,7 +259,6 @@ gimp_image_class_init (GimpImageClass *klass)
static void
gimp_image_init (GimpImage *gimage)
{
gimage->has_filename = FALSE;
gimage->num_cols = 0;
gimage->cmap = NULL;
gimage->disp_count = 0;
......@@ -435,20 +434,17 @@ gimp_image_name_changed (GimpObject *object)
GimpImage *gimage;
const gchar *name;
if (GIMP_OBJECT_CLASS (parent_class)->name_changed)
GIMP_OBJECT_CLASS (parent_class)->name_changed (object);
gimage = GIMP_IMAGE (object);
name = gimp_object_get_name (object);
if (name && name[0])
{
gimage->has_filename = TRUE;
}
else
if (! (name && strlen (name)))
{
gimage->has_filename = FALSE;
g_free (object->name);
object->name = NULL;
}
if (GIMP_OBJECT_CLASS (parent_class)->name_changed)
GIMP_OBJECT_CLASS (parent_class)->name_changed (object);
}
void
......@@ -3607,13 +3603,14 @@ gimp_image_base_type_with_alpha (const GimpImage *gimage)
const gchar *
gimp_image_filename (const GimpImage *gimage)
{
const gchar *filename;
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
if (gimage->has_filename)
return gimp_object_get_name (GIMP_OBJECT (gimage));
else
return _("Untitled");
filename = gimp_object_get_name (GIMP_OBJECT (gimage));
return filename ? filename : _("Untitled");
}
gboolean
......
......@@ -48,7 +48,6 @@ struct _GimpImage
{
GimpObject parent_instance;
gboolean has_filename; /* has a valid filename */
PlugInProcDef *save_proc; /* last PDB save proc used */
gint width, height; /* width and height attributes */
......
......@@ -259,7 +259,6 @@ gimp_image_class_init (GimpImageClass *klass)
static void
gimp_image_init (GimpImage *gimage)
{
gimage->has_filename = FALSE;
gimage->num_cols = 0;
gimage->cmap = NULL;
gimage->disp_count = 0;
......@@ -435,20 +434,17 @@ gimp_image_name_changed (GimpObject *object)
GimpImage *gimage;
const gchar *name;
if (GIMP_OBJECT_CLASS (parent_class)->name_changed)
GIMP_OBJECT_CLASS (parent_class)->name_changed (object);
gimage = GIMP_IMAGE (object);
name = gimp_object_get_name (object);
if (name && name[0])
{
gimage->has_filename = TRUE;
}
else
if (! (name && strlen (name)))
{
gimage->has_filename = FALSE;
g_free (object->name);
object->name = NULL;
}
if (GIMP_OBJECT_CLASS (parent_class)->name_changed)
GIMP_OBJECT_CLASS (parent_class)->name_changed (object);
}
void
......@@ -3607,13 +3603,14 @@ gimp_image_base_type_with_alpha (const GimpImage *gimage)
const gchar *
gimp_image_filename (const GimpImage *gimage)
{
const gchar *filename;
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
if (gimage->has_filename)
return gimp_object_get_name (GIMP_OBJECT (gimage));
else
return _("Untitled");
filename = gimp_object_get_name (GIMP_OBJECT (gimage));
return filename ? filename : _("Untitled");
}
gboolean
......
......@@ -48,7 +48,6 @@ struct _GimpImage
{
GimpObject parent_instance;
gboolean has_filename; /* has a valid filename */
PlugInProcDef *save_proc; /* last PDB save proc used */
gint width, height; /* width and height attributes */
......
......@@ -259,7 +259,6 @@ gimp_image_class_init (GimpImageClass *klass)
static void
gimp_image_init (GimpImage *gimage)
{
gimage->has_filename = FALSE;
gimage->num_cols = 0;
gimage->cmap = NULL;
gimage->disp_count = 0;
......@@ -435,20 +434,17 @@ gimp_image_name_changed (GimpObject *object)
GimpImage *gimage;
const gchar *name;
if (GIMP_OBJECT_CLASS (parent_class)->name_changed)
GIMP_OBJECT_CLASS (parent_class)->name_changed (object);
gimage = GIMP_IMAGE (object);
name = gimp_object_get_name (object);
if (name && name[0])
{
gimage->has_filename = TRUE;
}
else
if (! (name && strlen (name)))
{
gimage->has_filename = FALSE;
g_free (object->name);
object->name = NULL;
}
if (GIMP_OBJECT_CLASS (parent_class)->name_changed)
GIMP_OBJECT_CLASS (parent_class)->name_changed (object);
}
void
......@@ -3607,13 +3603,14 @@ gimp_image_base_type_with_alpha (const GimpImage *gimage)
const gchar *
gimp_image_filename (const GimpImage *gimage)
{
const gchar *filename;
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
if (gimage->has_filename)
return gimp_object_get_name (GIMP_OBJECT (gimage));
else
return _("Untitled");
filename = gimp_object_get_name (GIMP_OBJECT (gimage));
return filename ? filename : _("Untitled");
}
gboolean
......
......@@ -48,7 +48,6 @@ struct _GimpImage
{
GimpObject parent_instance;
gboolean has_filename; /* has a valid filename */
PlugInProcDef *save_proc; /* last PDB save proc used */
gint width, height; /* width and height attributes */
......
......@@ -259,7 +259,6 @@ gimp_image_class_init (GimpImageClass *klass)
static void
gimp_image_init (GimpImage *gimage)
{
gimage->has_filename = FALSE;
gimage->num_cols = 0;
gimage->cmap = NULL;
gimage->disp_count = 0;
......@@ -435,20 +434,17 @@ gimp_image_name_changed (GimpObject *object)
GimpImage *gimage;
const gchar *name;
if (GIMP_OBJECT_CLASS (parent_class)->name_changed)
GIMP_OBJECT_CLASS (parent_class)->name_changed (object);
gimage = GIMP_IMAGE (object);
name = gimp_object_get_name (object);
if (name && name[0])
{
gimage->has_filename = TRUE;
}
else
if (! (name && strlen (name)))
{
gimage->has_filename = FALSE;
g_free (object->name);
object->name = NULL;
}
if (GIMP_OBJECT_CLASS (parent_class)->name_changed)
GIMP_OBJECT_CLASS (parent_class)->name_changed (object);
}
void
......@@ -3607,13 +3603,14 @@ gimp_image_base_type_with_alpha (const GimpImage *gimage)
const gchar *
gimp_image_filename (const GimpImage *gimage)
{
const gchar *filename;
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
if (gimage->has_filename)
return gimp_object_get_name (GIMP_OBJECT (gimage));
else
return _("Untitled");
filename = gimp_object_get_name (GIMP_OBJECT (gimage));
return filename ? filename : _("Untitled");
}
gboolean
......
......@@ -48,7 +48,6 @@ struct _GimpImage
{
GimpObject parent_instance;
gboolean has_filename; /* has a valid filename */
PlugInProcDef *save_proc; /* last PDB save proc used */
gint width, height; /* width and height attributes */
......
......@@ -259,7 +259,6 @@ gimp_image_class_init (GimpImageClass *klass)
static void
gimp_image_init (GimpImage *gimage)
{
gimage->has_filename = FALSE;
gimage->num_cols = 0;
gimage->cmap = NULL;
gimage->disp_count = 0;
......@@ -435,20 +434,17 @@ gimp_image_name_changed (GimpObject *object)
GimpImage *gimage;
const gchar *name;
if (GIMP_OBJECT_CLASS (parent_class)->name_changed)
GIMP_OBJECT_CLASS (parent_class)->name_changed (object);
gimage = GIMP_IMAGE (object);
name = gimp_object_get_name (object);
if (name && name[0])
{
gimage->has_filename = TRUE;
}
else
if (! (name && strlen (name)))
{
gimage->has_filename = FALSE;
g_free (object->name);
object->name = NULL;
}
if (GIMP_OBJECT_CLASS (parent_class)->name_changed)
GIMP_OBJECT_CLASS (parent_class)->name_changed (object);
}
void
......@@ -3607,13 +3603,14 @@ gimp_image_base_type_with_alpha (const GimpImage *gimage)
const gchar *
gimp_image_filename (const GimpImage *gimage)
{
const gchar *filename;
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
if (gimage->has_filename)
return gimp_object_get_name (GIMP_OBJECT (gimage));
else
return _("Untitled");
filename = gimp_object_get_name (GIMP_OBJECT (gimage));
return filename ? filename : _("Untitled");
}
gboolean
......
......@@ -48,7 +48,6 @@ struct _GimpImage
{
GimpObject parent_instance;
gboolean has_filename; /* has a valid filename */
PlugInProcDef *save_proc; /* last PDB save proc used */
gint width, height; /* width and height attributes */
......
......@@ -259,7 +259,6 @@ gimp_image_class_init (GimpImageClass *klass)
static void
gimp_image_init (GimpImage *gimage)
{
gimage->has_filename = FALSE;
gimage->num_cols = 0;
gimage->cmap = NULL;
gimage->disp_count = 0;
......@@ -435,20 +434,17 @@ gimp_image_name_changed (GimpObject *object)
GimpImage *gimage;
const gchar *name;
if (GIMP_OBJECT_CLASS (parent_class)->name_changed)
GIMP_OBJECT_CLASS (parent_class)->name_changed (object);
gimage = GIMP_IMAGE (object);
name = gimp_object_get_name (object);
if (name && name[0])
{
gimage->has_filename = TRUE;
}
else
if (! (name && strlen (name)))
{
gimage->has_filename = FALSE;
g_free (object->name);
object->name = NULL;
}
if (GIMP_OBJECT_CLASS (parent_class)->name_changed)
GIMP_OBJECT_CLASS (parent_class)->name_changed (object);
}
void
......@@ -3607,13 +3603,14 @@ gimp_image_base_type_with_alpha (const GimpImage *gimage)
const gchar *
gimp_image_filename (const GimpImage *gimage)
{
const gchar *filename;
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
if (gimage->has_filename)
return gimp_object_get_name (GIMP_OBJECT (gimage));
else
return _("Untitled");
filename = gimp_object_get_name (GIMP_OBJECT (gimage));
return filename ? filename : _("Untitled");
}
gboolean
......
......@@ -48,7 +48,6 @@ struct _GimpImage
{
GimpObject parent_instance;
gboolean has_filename; /* has a valid filename */
PlugInProcDef *save_proc; /* last PDB save proc used */
gint width, height; /* width and height attributes */
......
......@@ -1779,7 +1779,7 @@ gdisplay_set_menu_sensitivity (GDisplay *gdisp)
SET_SENSITIVE ("File/Save", gdisp && drawable);
SET_SENSITIVE ("File/Save as...", gdisp && drawable);
SET_SENSITIVE ("File/Save a Copy as...", gdisp && drawable);
SET_SENSITIVE ("File/Revert...", gdisp && gdisp->gimage->has_filename);
SET_SENSITIVE ("File/Revert...", gdisp && GIMP_OBJECT (gdisp->gimage)->name);
SET_SENSITIVE ("File/Close", gdisp);
SET_SENSITIVE ("Edit", gdisp);
......
......@@ -1779,7 +1779,7 @@ gdisplay_set_menu_sensitivity (GDisplay *gdisp)
SET_SENSITIVE ("File/Save", gdisp && drawable);
SET_SENSITIVE ("File/Save as...", gdisp && drawable);
SET_SENSITIVE ("File/Save a Copy as...", gdisp && drawable);
SET_SENSITIVE ("File/Revert...", gdisp && gdisp->gimage->has_filename);
SET_SENSITIVE ("File/Revert...", gdisp && GIMP_OBJECT (gdisp->gimage)->name);
SET_SENSITIVE ("File/Close", gdisp);
SET_SENSITIVE ("Edit", gdisp);
......
......@@ -481,13 +481,15 @@ raise_if_match (gpointer data,
{
GDisplay *gdisp;
BoolCharPair *pair;
const gchar *filename;
gdisp = (GDisplay *) data;
pair = (BoolCharPair *) user_data;
if (gdisp->gimage->has_filename &&
strcmp (pair->string,
gimp_object_get_name (GIMP_OBJECT (gdisp->gimage))) == 0)
filename = gimp_object_get_name (GIMP_OBJECT (gdisp->gimage));
if (filename &&
strcmp (pair->string, filename) == 0)
{
pair->boole = TRUE;
gdk_window_raise (gdisp->shell->window);
......
......@@ -518,17 +518,20 @@ file_save_callback (GtkWidget *widget,
/* Only save if the gimage has been modified */
if (!trust_dirty_flag || gdisplay->gimage->dirty != 0)
{
if (gdisplay->gimage->has_filename == FALSE)
gchar *filename;
filename =
g_strdup (gimp_object_get_name (GIMP_OBJECT (gdisplay->gimage)));
if (! filename)
{
file_save_as_callback (widget, data);
}
else
{
gchar *filename;
gchar *raw_filename;
gint status;
filename = g_strdup (gimp_image_filename (gdisplay->gimage));
raw_filename = g_basename (filename);
status = file_save (gdisplay->gimage,
......@@ -543,8 +546,9 @@ file_save_callback (GtkWidget *widget,
g_message (_("Save failed.\n%s"), filename);
}
g_free (filename);
}
g_free (filename);
}
}
......@@ -552,7 +556,8 @@ void
file_save_as_callback (GtkWidget *widget,
gpointer data)
{
GDisplay *gdisplay;
GDisplay *gdisplay;
const gchar *filename;
gdisplay = gdisplay_active ();
if (! gdisplay)
......@@ -565,7 +570,9 @@ file_save_as_callback (GtkWidget *widget,
set_filename = TRUE;
if (!filesave)
filename = gimp_object_get_name (GIMP_OBJECT (the_gimage));
if (! filesave)
file_save_dialog_create ();
gtk_widget_set_sensitive (GTK_WIDGET (filesave), TRUE);
......@@ -575,8 +582,8 @@ file_save_as_callback (GtkWidget *widget,
gtk_window_set_title (GTK_WINDOW (filesave), _("Save Image"));
gtk_file_selection_set_filename (GTK_FILE_SELECTION (filesave),
gdisplay->gimage->has_filename ?
gimp_image_filename (gdisplay->gimage) :
filename ?
filename :
"." G_DIR_SEPARATOR_S);
switch (gimp_drawable_type (gimp_image_active_drawable (gdisplay->gimage)))
......@@ -608,7 +615,8 @@ void
file_save_a_copy_as_callback (GtkWidget *widget,
gpointer data)
{
GDisplay *gdisplay;
GDisplay *gdisplay;
const gchar *filename;
gdisplay = gdisplay_active ();
if (! gdisplay)
......@@ -621,6 +629,8 @@ file_save_a_copy_as_callback (GtkWidget *widget,
set_filename = FALSE;
filename = gimp_object_get_name (GIMP_OBJECT (the_gimage));
if (!filesave)
file_save_dialog_create ();
......@@ -631,8 +641,8 @@ file_save_a_copy_as_callback (GtkWidget *widget,
gtk_window_set_title (GTK_WINDOW (filesave), _("Save a Copy of the Image"));
gtk_file_selection_set_filename (GTK_FILE_SELECTION (filesave),
gdisplay->gimage->has_filename ?
gimp_image_filename (gdisplay->gimage) :
filename ?
filename :
"." G_DIR_SEPARATOR_S);
switch (gimp_drawable_type (gimp_image_active_drawable (gdisplay->gimage)))
......@@ -664,9 +674,10 @@ void
file_revert_callback (GtkWidget *widget,
gpointer data)
{
GDisplay *gdisplay;
GimpImage *gimage;
GtkWidget *query_box;
GDisplay *gdisplay;
GimpImage *gimage;
GtkWidget *query_box;
const gchar *filename;
gdisplay = gdisplay_active ();
if (!gdisplay || !gdisplay->gimage)
......@@ -674,9 +685,11 @@ file_revert_callback (GtkWidget *widget,
gimage = gdisplay->gimage;
filename = gimp_object_get_name (GIMP_OBJECT (gimage));
query_box = gtk_object_get_data (GTK_OBJECT (gimage), REVERT_DATA_KEY);
if (gimage->has_filename == FALSE)
if (! filename)
{
g_message (_("Revert failed.\n"
"No filename associated with this image."));
......@@ -693,8 +706,8 @@ file_revert_callback (GtkWidget *widget,
"%s\n\n"
"(You will loose all your changes\n"
"including all undo information)"),
g_basename (gimp_image_filename (gimage)),
gimp_image_filename (gimage));
g_basename (filename),
filename);
query_box = gimp_query_boolean_box (_("Revert Image?"),
gimp_standard_help_func,
......@@ -2032,7 +2045,7 @@ file_revert_confirm_callback (GtkWidget *widget,
const gchar *filename;
gint status;
filename = gimp_image_filename (old_gimage);
filename = gimp_object_get_name (GIMP_OBJECT (old_gimage));
new_gimage = file_open_image (filename, filename, _("Revert"),
RUN_INTERACTIVE, &status);
......
......@@ -1779,7 +1779,7 @@ gdisplay_set_menu_sensitivity (GDisplay *gdisp)
SET_SENSITIVE ("File/Save", gdisp && drawable);
SET_SENSITIVE ("File/Save as...", gdisp && drawable);
SET_SENSITIVE ("File/Save a Copy as...", gdisp && drawable);
SET_SENSITIVE ("File/Revert...", gdisp && gdisp->gimage->has_filename);
SET_SENSITIVE ("File/Revert...", gdisp && GIMP_OBJECT (gdisp->gimage)->name);
SET_SENSITIVE ("File/Close", gdisp);
SET_SENSITIVE ("Edit", gdisp);
......
......@@ -259,7 +259,6 @@ gimp_image_class_init (GimpImageClass *klass)
static void
gimp_image_init (GimpImage *gimage)
{
gimage->has_filename = FALSE;
gimage->num_cols = 0;
gimage->cmap = NULL;
gimage->disp_count = 0;
......@@ -435,20 +434,17 @@ gimp_image_name_changed (GimpObject *object)
GimpImage *gimage;
const gchar *name;
if (GIMP_OBJECT_CLASS (parent_class)->name_changed)
GIMP_OBJECT_CLASS (parent_class)->name_changed (object);
gimage = GIMP_IMAGE (object);
name = gimp_object_get_name (object);
if (name && name[0])
{
gimage->has_filename = TRUE;
}
else
if (! (name && strlen (name)))
{
gimage->has_filename = FALSE;
g_free (object->name);
object->name = NULL;
}
if (GIMP_OBJECT_CLASS (parent_class)->name_changed)
GIMP_OBJECT_CLASS (parent_class)->name_changed (object);
}
void
......@@ -3607,13 +3603,14 @@ gimp_image_base_type_with_alpha (const GimpImage *gimage)
const gchar *
gimp_image_filename (const GimpImage *gimage)
{
const gchar *filename;
g_return_val_if_fail (gimage != NULL, NULL);
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);
if (gimage->has_filename)
return gimp_object_get_name (GIMP_OBJECT (gimage));
else
return _("Untitled");
filename = gimp_object_get_name (GIMP_OBJECT (gimage));
return filename ? filename : _("Untitled");
}
gboolean
......
......@@ -48,7 +48,6 @@ struct _GimpImage
{
GimpObject parent_instance;
gboolean has_filename; /* has a valid filename */
PlugInProcDef *save_proc; /* last PDB save proc used */
gint width, height; /* width and height attributes */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment