added vitrual function GimpViewable::get_description() which returns the

2003-04-08  Michael Natterer  <mitch@gimp.org>

	* app/core/gimpviewable.[ch]: added vitrual function
	GimpViewable::get_description() which returns the string that
	should be presented to the user plus an optional tooltip with more
	information. The default implementation just returns the object's
	name and no tooltip.

	* app/core/gimpbrush.c
	* app/core/gimpbuffer.c
	* app/core/gimpimage.c
	* app/core/gimppalette.c
	* app/core/gimppattern.c
	* app/core/gimptoolinfo.c: implement get_description().

	* app/core/gimpimagefile.[ch]: ditto. Renamed
	gimp_imagefile_get_description() to
	gimp_imagefile_get_desc_string(). Well, um, gimme a better name...

	* app/gui/file-open-dialog.c: changed accordingly.

	* app/file/file-utils.[ch]: renamed readXVThumb() to
	file_utils_readXVThumb().

	* tools/pdbgen/pdb/fileops.pdb: changed accordingly.

	* app/widgets/widgets-types.h: removed GimpItemGetNameFunc typedef.

	* app/widgets/gimpcontainerview-utils.[ch]: removed the the actual
	get_name_funcs. They now live in the core as
	GimpViewable::get_description() implementations.

	* app/widgets/gimpcontainermenu.[ch]
	* app/widgets/gimpcontainergridview.c
	* app/widgets/gimpcontainermenuimpl.c
	* app/widgets/gimpcontainertreeview.c
	* app/widgets/gimpcontainerview.[ch]
	* app/widgets/gimpmenuitem.[ch]
	* app/widgets/gimpviewabledialog.c: removed get_name_func stuff
	and use gimp_viewable_get_description().

	* app/widgets/gimpcontainermenu.[ch]: added "preview_border_width"
	to gimp_container_menu_set_preview_size().

	* app/widgets/gimpimagedock.c: changed accordingly.

	* app/pdb/fileops_cmds.c: regenerated.
This commit is contained in:
Michael Natterer 2003-04-08 16:01:01 +00:00 committed by Michael Natterer
parent f20e559bbf
commit 99d93b9255
36 changed files with 483 additions and 619 deletions

View File

@ -1,3 +1,51 @@
2003-04-08 Michael Natterer <mitch@gimp.org>
* app/core/gimpviewable.[ch]: added vitrual function
GimpViewable::get_description() which returns the string that
should be presented to the user plus an optional tooltip with more
information. The default implementation just returns the object's
name and no tooltip.
* app/core/gimpbrush.c
* app/core/gimpbuffer.c
* app/core/gimpimage.c
* app/core/gimppalette.c
* app/core/gimppattern.c
* app/core/gimptoolinfo.c: implement get_description().
* app/core/gimpimagefile.[ch]: ditto. Renamed
gimp_imagefile_get_description() to
gimp_imagefile_get_desc_string(). Well, um, gimme a better name...
* app/gui/file-open-dialog.c: changed accordingly.
* app/file/file-utils.[ch]: renamed readXVThumb() to
file_utils_readXVThumb().
* tools/pdbgen/pdb/fileops.pdb: changed accordingly.
* app/widgets/widgets-types.h: removed GimpItemGetNameFunc typedef.
* app/widgets/gimpcontainerview-utils.[ch]: removed the the actual
get_name_funcs. They now live in the core as
GimpViewable::get_description() implementations.
* app/widgets/gimpcontainermenu.[ch]
* app/widgets/gimpcontainergridview.c
* app/widgets/gimpcontainermenuimpl.c
* app/widgets/gimpcontainertreeview.c
* app/widgets/gimpcontainerview.[ch]
* app/widgets/gimpmenuitem.[ch]
* app/widgets/gimpviewabledialog.c: removed get_name_func stuff
and use gimp_viewable_get_description().
* app/widgets/gimpcontainermenu.[ch]: added "preview_border_width"
to gimp_container_menu_set_preview_size().
* app/widgets/gimpimagedock.c: changed accordingly.
* app/pdb/fileops_cmds.c: regenerated.
2003-04-08 Michael Natterer <mitch@gimp.org> 2003-04-08 Michael Natterer <mitch@gimp.org>
* app/widgets/gimpbrushfactoryview.[ch] * app/widgets/gimpbrushfactoryview.[ch]

View File

@ -80,6 +80,8 @@ static gboolean gimp_brush_get_popup_size (GimpViewable *viewable,
static TempBuf * gimp_brush_get_new_preview (GimpViewable *viewable, static TempBuf * gimp_brush_get_new_preview (GimpViewable *viewable,
gint width, gint width,
gint height); gint height);
static gchar * gimp_brush_get_description (GimpViewable *viewable,
gchar **tooltip);
static gchar * gimp_brush_get_extension (GimpData *data); static gchar * gimp_brush_get_extension (GimpData *data);
static GimpBrush * gimp_brush_real_select_brush (GimpBrush *brush, static GimpBrush * gimp_brush_real_select_brush (GimpBrush *brush,
@ -153,6 +155,7 @@ gimp_brush_class_init (GimpBrushClass *klass)
viewable_class->get_popup_size = gimp_brush_get_popup_size; viewable_class->get_popup_size = gimp_brush_get_popup_size;
viewable_class->get_new_preview = gimp_brush_get_new_preview; viewable_class->get_new_preview = gimp_brush_get_new_preview;
viewable_class->get_description = gimp_brush_get_description;
data_class->get_extension = gimp_brush_get_extension; data_class->get_extension = gimp_brush_get_extension;
@ -328,6 +331,23 @@ gimp_brush_get_new_preview (GimpViewable *viewable,
return return_buf; return return_buf;
} }
static gchar *
gimp_brush_get_description (GimpViewable *viewable,
gchar **tooltip)
{
GimpBrush *brush;
brush = GIMP_BRUSH (viewable);
if (tooltip)
*tooltip = NULL;
return g_strdup_printf ("%s (%d x %d)",
GIMP_OBJECT (brush)->name,
brush->mask->width,
brush->mask->height);
}
static gchar * static gchar *
gimp_brush_get_extension (GimpData *data) gimp_brush_get_extension (GimpData *data)
{ {

View File

@ -80,6 +80,8 @@ static gboolean gimp_brush_get_popup_size (GimpViewable *viewable,
static TempBuf * gimp_brush_get_new_preview (GimpViewable *viewable, static TempBuf * gimp_brush_get_new_preview (GimpViewable *viewable,
gint width, gint width,
gint height); gint height);
static gchar * gimp_brush_get_description (GimpViewable *viewable,
gchar **tooltip);
static gchar * gimp_brush_get_extension (GimpData *data); static gchar * gimp_brush_get_extension (GimpData *data);
static GimpBrush * gimp_brush_real_select_brush (GimpBrush *brush, static GimpBrush * gimp_brush_real_select_brush (GimpBrush *brush,
@ -153,6 +155,7 @@ gimp_brush_class_init (GimpBrushClass *klass)
viewable_class->get_popup_size = gimp_brush_get_popup_size; viewable_class->get_popup_size = gimp_brush_get_popup_size;
viewable_class->get_new_preview = gimp_brush_get_new_preview; viewable_class->get_new_preview = gimp_brush_get_new_preview;
viewable_class->get_description = gimp_brush_get_description;
data_class->get_extension = gimp_brush_get_extension; data_class->get_extension = gimp_brush_get_extension;
@ -328,6 +331,23 @@ gimp_brush_get_new_preview (GimpViewable *viewable,
return return_buf; return return_buf;
} }
static gchar *
gimp_brush_get_description (GimpViewable *viewable,
gchar **tooltip)
{
GimpBrush *brush;
brush = GIMP_BRUSH (viewable);
if (tooltip)
*tooltip = NULL;
return g_strdup_printf ("%s (%d x %d)",
GIMP_OBJECT (brush)->name,
brush->mask->width,
brush->mask->height);
}
static gchar * static gchar *
gimp_brush_get_extension (GimpData *data) gimp_brush_get_extension (GimpData *data)
{ {

View File

@ -55,6 +55,8 @@ static gboolean gimp_buffer_get_popup_size (GimpViewable *viewable,
static TempBuf * gimp_buffer_get_new_preview (GimpViewable *viewable, static TempBuf * gimp_buffer_get_new_preview (GimpViewable *viewable,
gint width, gint width,
gint height); gint height);
static gchar * gimp_buffer_get_description (GimpViewable *viewable,
gchar **tooltip);
static GimpViewableClass *parent_class = NULL; static GimpViewableClass *parent_class = NULL;
@ -108,6 +110,7 @@ gimp_buffer_class_init (GimpBufferClass *klass)
viewable_class->get_preview_size = gimp_buffer_get_preview_size; viewable_class->get_preview_size = gimp_buffer_get_preview_size;
viewable_class->get_popup_size = gimp_buffer_get_popup_size; viewable_class->get_popup_size = gimp_buffer_get_popup_size;
viewable_class->get_new_preview = gimp_buffer_get_new_preview; viewable_class->get_new_preview = gimp_buffer_get_new_preview;
viewable_class->get_description = gimp_buffer_get_description;
} }
static void static void
@ -272,6 +275,23 @@ gimp_buffer_get_new_preview (GimpViewable *viewable,
return temp_buf; return temp_buf;
} }
static gchar *
gimp_buffer_get_description (GimpViewable *viewable,
gchar **tooltip)
{
GimpBuffer *buffer;
buffer = GIMP_BUFFER (viewable);
if (tooltip)
*tooltip = NULL;
return g_strdup_printf ("%s (%d x %d)",
GIMP_OBJECT (buffer)->name,
gimp_buffer_get_width (buffer),
gimp_buffer_get_height (buffer));
}
GimpBuffer * GimpBuffer *
gimp_buffer_new (TileManager *tiles, gimp_buffer_new (TileManager *tiles,
const gchar *name, const gchar *name,

View File

@ -112,6 +112,8 @@ static gsize gimp_image_get_memsize (GimpObject *object);
static void gimp_image_invalidate_preview (GimpViewable *viewable); static void gimp_image_invalidate_preview (GimpViewable *viewable);
static void gimp_image_size_changed (GimpViewable *viewable); static void gimp_image_size_changed (GimpViewable *viewable);
static gchar * gimp_image_get_description (GimpViewable *viewable,
gchar **tooltip);
static void gimp_image_real_colormap_changed (GimpImage *gimage, static void gimp_image_real_colormap_changed (GimpImage *gimage,
gint ncol); gint ncol);
@ -398,6 +400,7 @@ gimp_image_class_init (GimpImageClass *klass)
viewable_class->get_popup_size = gimp_image_get_popup_size; viewable_class->get_popup_size = gimp_image_get_popup_size;
viewable_class->get_preview = gimp_image_get_preview; viewable_class->get_preview = gimp_image_get_preview;
viewable_class->get_new_preview = gimp_image_get_new_preview; viewable_class->get_new_preview = gimp_image_get_new_preview;
viewable_class->get_description = gimp_image_get_description;
klass->mode_changed = NULL; klass->mode_changed = NULL;
klass->alpha_changed = NULL; klass->alpha_changed = NULL;
@ -697,6 +700,31 @@ gimp_image_size_changed (GimpViewable *viewable)
gimp_viewable_size_changed (GIMP_VIEWABLE (gimp_image_get_mask (gimage))); gimp_viewable_size_changed (GIMP_VIEWABLE (gimp_image_get_mask (gimage)));
} }
static gchar *
gimp_image_get_description (GimpViewable *viewable,
gchar **tooltip)
{
GimpImage *gimage;
const gchar *uri;
gchar *basename;
gchar *retval;
gimage = GIMP_IMAGE (viewable);
uri = gimp_image_get_uri (GIMP_IMAGE (gimage));
basename = file_utils_uri_to_utf8_basename (uri);
if (tooltip)
*tooltip = file_utils_uri_to_utf8_filename (uri);
retval = g_strdup_printf ("%s-%d", basename, gimp_image_get_ID (gimage));
g_free (basename);
return retval;
}
static void static void
gimp_image_real_colormap_changed (GimpImage *gimage, gimp_image_real_colormap_changed (GimpImage *gimage,
gint ncol) gint ncol)

View File

@ -61,6 +61,7 @@
#include "gimpmarshal.h" #include "gimpmarshal.h"
#include "file/file-open.h" #include "file/file-open.h"
#include "file/file-utils.h"
#include "gimp-intl.h" #include "gimp-intl.h"
@ -102,6 +103,8 @@ static void gimp_imagefile_set_info (GimpImagefile *imagefile,
static TempBuf * gimp_imagefile_get_new_preview (GimpViewable *viewable, static TempBuf * gimp_imagefile_get_new_preview (GimpViewable *viewable,
gint width, gint width,
gint height); gint height);
static gchar * gimp_imagefile_get_description (GimpViewable *viewable,
gchar **tooltip);
static TempBuf * gimp_imagefile_read_png_thumb (GimpImagefile *imagefile, static TempBuf * gimp_imagefile_read_png_thumb (GimpImagefile *imagefile,
gint thumb_size); gint thumb_size);
@ -206,6 +209,7 @@ gimp_imagefile_class_init (GimpImagefileClass *klass)
viewable_class->name_changed_signal = "info_changed"; viewable_class->name_changed_signal = "info_changed";
viewable_class->get_new_preview = gimp_imagefile_get_new_preview; viewable_class->get_new_preview = gimp_imagefile_get_new_preview;
viewable_class->get_description = gimp_imagefile_get_description;
g_type_class_ref (GIMP_TYPE_IMAGE_TYPE); g_type_class_ref (GIMP_TYPE_IMAGE_TYPE);
@ -678,8 +682,55 @@ gimp_imagefile_get_new_preview (GimpViewable *viewable,
return temp_buf; return temp_buf;
} }
static gchar *
gimp_imagefile_get_description (GimpViewable *viewable,
gchar **tooltip)
{
GimpImagefile *imagefile;
const gchar *uri;
gchar *basename;
imagefile = GIMP_IMAGEFILE (viewable);
uri = gimp_object_get_name (GIMP_OBJECT (imagefile));
basename = file_utils_uri_to_utf8_basename (uri);
if (tooltip)
{
gchar *filename;
const gchar *desc;
filename = file_utils_uri_to_utf8_filename (uri);
desc = gimp_imagefile_get_desc_string (imagefile);
if (desc)
{
*tooltip = g_strdup_printf ("%s\n%s", filename, desc);
g_free (filename);
}
else
{
*tooltip = filename;
}
}
if (imagefile->width > 0 && imagefile->height > 0)
{
gchar *tmp = basename;
basename = g_strdup_printf ("%s (%d x %d)",
tmp,
imagefile->width,
imagefile->height);
g_free (tmp);
}
return basename;
}
const gchar * const gchar *
gimp_imagefile_get_description (GimpImagefile *imagefile) gimp_imagefile_get_desc_string (GimpImagefile *imagefile)
{ {
g_return_val_if_fail (GIMP_IS_IMAGEFILE (imagefile), NULL); g_return_val_if_fail (GIMP_IS_IMAGEFILE (imagefile), NULL);

View File

@ -94,7 +94,7 @@ void gimp_imagefile_create_thumbnail (GimpImagefile *imagefile,
gint thumb_size); gint thumb_size);
gboolean gimp_imagefile_save_thumbnail (GimpImagefile *imagefile, gboolean gimp_imagefile_save_thumbnail (GimpImagefile *imagefile,
GimpImage *gimage); GimpImage *gimage);
const gchar * gimp_imagefile_get_description (GimpImagefile *imagefile); const gchar * gimp_imagefile_get_desc_string (GimpImagefile *imagefile);
#endif /* __GIMP_IMAGEFILE_H__ */ #endif /* __GIMP_IMAGEFILE_H__ */

View File

@ -63,6 +63,8 @@ static gboolean gimp_palette_get_popup_size (GimpViewable *viewable,
static TempBuf * gimp_palette_get_new_preview (GimpViewable *viewable, static TempBuf * gimp_palette_get_new_preview (GimpViewable *viewable,
gint width, gint width,
gint height); gint height);
static gchar * gimp_palette_get_description (GimpViewable *viewable,
gchar **tooltip);
static void gimp_palette_dirty (GimpData *data); static void gimp_palette_dirty (GimpData *data);
static gboolean gimp_palette_save (GimpData *data, static gboolean gimp_palette_save (GimpData *data,
GError **error); GError **error);
@ -128,6 +130,7 @@ gimp_palette_class_init (GimpPaletteClass *klass)
viewable_class->get_preview_size = gimp_palette_get_preview_size; viewable_class->get_preview_size = gimp_palette_get_preview_size;
viewable_class->get_popup_size = gimp_palette_get_popup_size; viewable_class->get_popup_size = gimp_palette_get_popup_size;
viewable_class->get_new_preview = gimp_palette_get_new_preview; viewable_class->get_new_preview = gimp_palette_get_new_preview;
viewable_class->get_description = gimp_palette_get_description;
data_class->dirty = gimp_palette_dirty; data_class->dirty = gimp_palette_dirty;
data_class->save = gimp_palette_save; data_class->save = gimp_palette_save;
@ -304,6 +307,22 @@ gimp_palette_get_new_preview (GimpViewable *viewable,
return temp_buf; return temp_buf;
} }
static gchar *
gimp_palette_get_description (GimpViewable *viewable,
gchar **tooltip)
{
GimpPalette *palette;
palette = GIMP_PALETTE (viewable);
if (tooltip)
*tooltip = NULL;
return g_strdup_printf ("%s (%d)",
GIMP_OBJECT (palette)->name,
palette->n_colors);
}
GimpData * GimpData *
gimp_palette_new (const gchar *name, gimp_palette_new (const gchar *name,
gboolean stingy_memory_use) gboolean stingy_memory_use)

View File

@ -63,6 +63,8 @@ static gboolean gimp_palette_get_popup_size (GimpViewable *viewable,
static TempBuf * gimp_palette_get_new_preview (GimpViewable *viewable, static TempBuf * gimp_palette_get_new_preview (GimpViewable *viewable,
gint width, gint width,
gint height); gint height);
static gchar * gimp_palette_get_description (GimpViewable *viewable,
gchar **tooltip);
static void gimp_palette_dirty (GimpData *data); static void gimp_palette_dirty (GimpData *data);
static gboolean gimp_palette_save (GimpData *data, static gboolean gimp_palette_save (GimpData *data,
GError **error); GError **error);
@ -128,6 +130,7 @@ gimp_palette_class_init (GimpPaletteClass *klass)
viewable_class->get_preview_size = gimp_palette_get_preview_size; viewable_class->get_preview_size = gimp_palette_get_preview_size;
viewable_class->get_popup_size = gimp_palette_get_popup_size; viewable_class->get_popup_size = gimp_palette_get_popup_size;
viewable_class->get_new_preview = gimp_palette_get_new_preview; viewable_class->get_new_preview = gimp_palette_get_new_preview;
viewable_class->get_description = gimp_palette_get_description;
data_class->dirty = gimp_palette_dirty; data_class->dirty = gimp_palette_dirty;
data_class->save = gimp_palette_save; data_class->save = gimp_palette_save;
@ -304,6 +307,22 @@ gimp_palette_get_new_preview (GimpViewable *viewable,
return temp_buf; return temp_buf;
} }
static gchar *
gimp_palette_get_description (GimpViewable *viewable,
gchar **tooltip)
{
GimpPalette *palette;
palette = GIMP_PALETTE (viewable);
if (tooltip)
*tooltip = NULL;
return g_strdup_printf ("%s (%d)",
GIMP_OBJECT (palette)->name,
palette->n_colors);
}
GimpData * GimpData *
gimp_palette_new (const gchar *name, gimp_palette_new (const gchar *name,
gboolean stingy_memory_use) gboolean stingy_memory_use)

View File

@ -63,6 +63,8 @@ static gboolean gimp_palette_get_popup_size (GimpViewable *viewable,
static TempBuf * gimp_palette_get_new_preview (GimpViewable *viewable, static TempBuf * gimp_palette_get_new_preview (GimpViewable *viewable,
gint width, gint width,
gint height); gint height);
static gchar * gimp_palette_get_description (GimpViewable *viewable,
gchar **tooltip);
static void gimp_palette_dirty (GimpData *data); static void gimp_palette_dirty (GimpData *data);
static gboolean gimp_palette_save (GimpData *data, static gboolean gimp_palette_save (GimpData *data,
GError **error); GError **error);
@ -128,6 +130,7 @@ gimp_palette_class_init (GimpPaletteClass *klass)
viewable_class->get_preview_size = gimp_palette_get_preview_size; viewable_class->get_preview_size = gimp_palette_get_preview_size;
viewable_class->get_popup_size = gimp_palette_get_popup_size; viewable_class->get_popup_size = gimp_palette_get_popup_size;
viewable_class->get_new_preview = gimp_palette_get_new_preview; viewable_class->get_new_preview = gimp_palette_get_new_preview;
viewable_class->get_description = gimp_palette_get_description;
data_class->dirty = gimp_palette_dirty; data_class->dirty = gimp_palette_dirty;
data_class->save = gimp_palette_save; data_class->save = gimp_palette_save;
@ -304,6 +307,22 @@ gimp_palette_get_new_preview (GimpViewable *viewable,
return temp_buf; return temp_buf;
} }
static gchar *
gimp_palette_get_description (GimpViewable *viewable,
gchar **tooltip)
{
GimpPalette *palette;
palette = GIMP_PALETTE (viewable);
if (tooltip)
*tooltip = NULL;
return g_strdup_printf ("%s (%d)",
GIMP_OBJECT (palette)->name,
palette->n_colors);
}
GimpData * GimpData *
gimp_palette_new (const gchar *name, gimp_palette_new (const gchar *name,
gboolean stingy_memory_use) gboolean stingy_memory_use)

View File

@ -70,6 +70,8 @@ static gboolean gimp_pattern_get_popup_size (GimpViewable *viewable,
static TempBuf * gimp_pattern_get_new_preview (GimpViewable *viewable, static TempBuf * gimp_pattern_get_new_preview (GimpViewable *viewable,
gint width, gint width,
gint height); gint height);
static gchar * gimp_pattern_get_description (GimpViewable *viewable,
gchar **tooltip);
static gchar * gimp_pattern_get_extension (GimpData *data); static gchar * gimp_pattern_get_extension (GimpData *data);
static GimpData * gimp_pattern_duplicate (GimpData *data, static GimpData * gimp_pattern_duplicate (GimpData *data,
gboolean stingy_memory_use); gboolean stingy_memory_use);
@ -127,6 +129,7 @@ gimp_pattern_class_init (GimpPatternClass *klass)
viewable_class->get_popup_size = gimp_pattern_get_popup_size; viewable_class->get_popup_size = gimp_pattern_get_popup_size;
viewable_class->get_new_preview = gimp_pattern_get_new_preview; viewable_class->get_new_preview = gimp_pattern_get_new_preview;
viewable_class->get_description = gimp_pattern_get_description;
data_class->get_extension = gimp_pattern_get_extension; data_class->get_extension = gimp_pattern_get_extension;
data_class->duplicate = gimp_pattern_duplicate; data_class->duplicate = gimp_pattern_duplicate;
@ -216,6 +219,23 @@ gimp_pattern_get_new_preview (GimpViewable *viewable,
return temp_buf; return temp_buf;
} }
static gchar *
gimp_pattern_get_description (GimpViewable *viewable,
gchar **tooltip)
{
GimpPattern *pattern;
pattern = GIMP_PATTERN (viewable);
if (tooltip)
*tooltip = NULL;
return g_strdup_printf ("%s (%d x %d)",
GIMP_OBJECT (pattern)->name,
pattern->mask->width,
pattern->mask->height);
}
static gchar * static gchar *
gimp_pattern_get_extension (GimpData *data) gimp_pattern_get_extension (GimpData *data)
{ {

View File

@ -70,6 +70,8 @@ static gboolean gimp_pattern_get_popup_size (GimpViewable *viewable,
static TempBuf * gimp_pattern_get_new_preview (GimpViewable *viewable, static TempBuf * gimp_pattern_get_new_preview (GimpViewable *viewable,
gint width, gint width,
gint height); gint height);
static gchar * gimp_pattern_get_description (GimpViewable *viewable,
gchar **tooltip);
static gchar * gimp_pattern_get_extension (GimpData *data); static gchar * gimp_pattern_get_extension (GimpData *data);
static GimpData * gimp_pattern_duplicate (GimpData *data, static GimpData * gimp_pattern_duplicate (GimpData *data,
gboolean stingy_memory_use); gboolean stingy_memory_use);
@ -127,6 +129,7 @@ gimp_pattern_class_init (GimpPatternClass *klass)
viewable_class->get_popup_size = gimp_pattern_get_popup_size; viewable_class->get_popup_size = gimp_pattern_get_popup_size;
viewable_class->get_new_preview = gimp_pattern_get_new_preview; viewable_class->get_new_preview = gimp_pattern_get_new_preview;
viewable_class->get_description = gimp_pattern_get_description;
data_class->get_extension = gimp_pattern_get_extension; data_class->get_extension = gimp_pattern_get_extension;
data_class->duplicate = gimp_pattern_duplicate; data_class->duplicate = gimp_pattern_duplicate;
@ -216,6 +219,23 @@ gimp_pattern_get_new_preview (GimpViewable *viewable,
return temp_buf; return temp_buf;
} }
static gchar *
gimp_pattern_get_description (GimpViewable *viewable,
gchar **tooltip)
{
GimpPattern *pattern;
pattern = GIMP_PATTERN (viewable);
if (tooltip)
*tooltip = NULL;
return g_strdup_printf ("%s (%d x %d)",
GIMP_OBJECT (pattern)->name,
pattern->mask->width,
pattern->mask->height);
}
static gchar * static gchar *
gimp_pattern_get_extension (GimpData *data) gimp_pattern_get_extension (GimpData *data)
{ {

View File

@ -37,6 +37,8 @@ static void gimp_tool_info_class_init (GimpToolInfoClass *klass);
static void gimp_tool_info_init (GimpToolInfo *tool_info); static void gimp_tool_info_init (GimpToolInfo *tool_info);
static void gimp_tool_info_finalize (GObject *object); static void gimp_tool_info_finalize (GObject *object);
static gchar * gimp_tool_info_get_description (GimpViewable *viewable,
gchar **tooltip);
static GimpDataClass *parent_class = NULL; static GimpDataClass *parent_class = NULL;
@ -74,12 +76,16 @@ static void
gimp_tool_info_class_init (GimpToolInfoClass *klass) gimp_tool_info_class_init (GimpToolInfoClass *klass)
{ {
GObjectClass *object_class; GObjectClass *object_class;
GimpViewableClass *viewable_class;
object_class = G_OBJECT_CLASS (klass); object_class = G_OBJECT_CLASS (klass);
viewable_class = GIMP_VIEWABLE_CLASS (klass);
parent_class = g_type_class_peek_parent (klass); parent_class = g_type_class_peek_parent (klass);
object_class->finalize = gimp_tool_info_finalize; object_class->finalize = gimp_tool_info_finalize;
viewable_class->get_description = gimp_tool_info_get_description;
} }
static void static void
@ -150,6 +156,20 @@ gimp_tool_info_finalize (GObject *object)
G_OBJECT_CLASS (parent_class)->finalize (object); G_OBJECT_CLASS (parent_class)->finalize (object);
} }
static gchar *
gimp_tool_info_get_description (GimpViewable *viewable,
gchar **tooltip)
{
GimpToolInfo *tool_info;
tool_info = GIMP_TOOL_INFO (viewable);
if (tooltip)
*tooltip = NULL;
return g_strdup (tool_info->blurb);
}
GimpToolInfo * GimpToolInfo *
gimp_tool_info_new (Gimp *gimp, gimp_tool_info_new (Gimp *gimp,
GType tool_type, GType tool_type,

View File

@ -70,6 +70,8 @@ static void gimp_viewable_real_get_preview_size (GimpViewable *viewable,
gboolean dot_for_dot, gboolean dot_for_dot,
gint *width, gint *width,
gint *height); gint *height);
static gchar * gimp_viewable_real_get_description (GimpViewable *viewable,
gchar **tooltip);
static guint viewable_signals[LAST_SIGNAL] = { 0 }; static guint viewable_signals[LAST_SIGNAL] = { 0 };
@ -156,6 +158,7 @@ gimp_viewable_class_init (GimpViewableClass *klass)
klass->get_popup_size = NULL; klass->get_popup_size = NULL;
klass->get_preview = NULL; klass->get_preview = NULL;
klass->get_new_preview = NULL; klass->get_new_preview = NULL;
klass->get_description = gimp_viewable_real_get_description;
GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_STOCK_ID, "stock-id", GIMP_CONFIG_INSTALL_PROP_STRING (object_class, PROP_STOCK_ID, "stock-id",
NULL, NULL, 0); NULL, NULL, 0);
@ -275,6 +278,16 @@ gimp_viewable_real_get_preview_size (GimpViewable *viewable,
*height = size; *height = size;
} }
static gchar *
gimp_viewable_real_get_description (GimpViewable *viewable,
gchar **tooltip)
{
if (tooltip)
*tooltip = NULL;
return g_strdup (gimp_object_get_name (GIMP_OBJECT (viewable)));
}
void void
gimp_viewable_invalidate_preview (GimpViewable *viewable) gimp_viewable_invalidate_preview (GimpViewable *viewable)
{ {
@ -547,6 +560,16 @@ gimp_viewable_get_new_preview_pixbuf (GimpViewable *viewable,
return pixbuf; return pixbuf;
} }
gchar *
gimp_viewable_get_description (GimpViewable *viewable,
gchar **tooltip)
{
g_return_val_if_fail (GIMP_IS_VIEWABLE (viewable), NULL);
return GIMP_VIEWABLE_GET_CLASS (viewable)->get_description (viewable,
tooltip);
}
const gchar * const gchar *
gimp_viewable_get_stock_id (GimpViewable *viewable) gimp_viewable_get_stock_id (GimpViewable *viewable)
{ {

View File

@ -80,6 +80,8 @@ struct _GimpViewableClass
TempBuf * (* get_new_preview) (GimpViewable *viewable, TempBuf * (* get_new_preview) (GimpViewable *viewable,
gint width, gint width,
gint height); gint height);
gchar * (* get_description) (GimpViewable *viewable,
gchar **tooltip);
}; };
@ -126,6 +128,10 @@ GdkPixbuf * gimp_viewable_get_preview_pixbuf (GimpViewable *viewable,
GdkPixbuf * gimp_viewable_get_new_preview_pixbuf (GimpViewable *viewable, GdkPixbuf * gimp_viewable_get_new_preview_pixbuf (GimpViewable *viewable,
gint width, gint width,
gint height); gint height);
gchar * gimp_viewable_get_description (GimpViewable *viewable,
gchar **tooltip);
const gchar * gimp_viewable_get_stock_id (GimpViewable *viewable); const gchar * gimp_viewable_get_stock_id (GimpViewable *viewable);
void gimp_viewable_set_stock_id (GimpViewable *viewable, void gimp_viewable_set_stock_id (GimpViewable *viewable,
const gchar *stock_id); const gchar *stock_id);

View File

@ -350,7 +350,7 @@ static void
file_open_imagefile_info_changed (GimpImagefile *imagefile, file_open_imagefile_info_changed (GimpImagefile *imagefile,
GtkLabel *label) GtkLabel *label)
{ {
gtk_label_set_text (label, gimp_imagefile_get_description (imagefile)); gtk_label_set_text (label, gimp_imagefile_get_desc_string (imagefile));
} }
static void static void

View File

@ -594,9 +594,10 @@ file_check_magic_list (GSList *magics_list,
/* The readXVThumb function source may be re-used under /* The readXVThumb function source may be re-used under
the XFree86-style license. <adam@gimp.org> */ * the XFree86-style license. <adam@gimp.org>
*/
guchar * guchar *
readXVThumb (const gchar *fnam, file_utils_readXVThumb (const gchar *fnam,
gint *w, gint *w,
gint *h, gint *h,
gchar **imginfo /* caller frees if != NULL */) gchar **imginfo /* caller frees if != NULL */)

View File

@ -34,7 +34,7 @@ gchar * file_utils_uri_to_utf8_filename (const gchar *uri);
/* .xvpics thumbnail stuff */ /* .xvpics thumbnail stuff */
guchar * readXVThumb (const gchar *fnam, guchar * file_utils_readXVThumb (const gchar *fnam,
gint *w, gint *w,
gint *h, gint *h,
gchar **imginfo /* caller frees if != NULL */); gchar **imginfo /* caller frees if != NULL */);

View File

@ -350,7 +350,7 @@ static void
file_open_imagefile_info_changed (GimpImagefile *imagefile, file_open_imagefile_info_changed (GimpImagefile *imagefile,
GtkLabel *label) GtkLabel *label)
{ {
gtk_label_set_text (label, gimp_imagefile_get_description (imagefile)); gtk_label_set_text (label, gimp_imagefile_get_desc_string (imagefile));
} }
static void static void

View File

@ -242,7 +242,7 @@ file_load_thumbnail_invoker (Gimp *gimp,
tname = g_build_filename (pname, ".xvpics", fname, NULL); tname = g_build_filename (pname, ".xvpics", fname, NULL);
g_free (pname); g_free (pname);
g_free (fname); g_free (fname);
raw_thumb = readXVThumb (tname, &width, &height, &imginfo); raw_thumb = file_utils_readXVThumb (tname, &width, &height, &imginfo);
g_free (tname); g_free (tname);
if (raw_thumb) if (raw_thumb)

View File

@ -533,6 +533,7 @@ gimp_container_grid_view_highlight_item (GimpContainerView *view,
gint item_height; gint item_height;
gint index; gint index;
gint row; gint row;
gchar *name;
adj = gtk_scrolled_window_get_vadjustment adj = gtk_scrolled_window_get_vadjustment
(GTK_SCROLLED_WINDOW (view->scrolled_win)); (GTK_SCROLLED_WINDOW (view->scrolled_win));
@ -557,22 +558,10 @@ gimp_container_grid_view_highlight_item (GimpContainerView *view,
gimp_preview_set_border_color (preview, &black_color); gimp_preview_set_border_color (preview, &black_color);
gimp_preview_renderer_update (preview->renderer); gimp_preview_renderer_update (preview->renderer);
if (view->get_name_func) name = gimp_viewable_get_description (preview->renderer->viewable, NULL);
{
gchar *name;
name = view->get_name_func (G_OBJECT (preview), NULL);
gtk_label_set_text (GTK_LABEL (grid_view->name_label), name); gtk_label_set_text (GTK_LABEL (grid_view->name_label), name);
g_free (name); g_free (name);
} }
else
{
gtk_label_set_text (GTK_LABEL (grid_view->name_label),
GIMP_OBJECT (viewable)->name);
}
}
else else
{ {
gtk_label_set_text (GTK_LABEL (grid_view->name_label), _("(None)")); gtk_label_set_text (GTK_LABEL (grid_view->name_label), _("(None)"));

View File

@ -31,7 +31,7 @@
#include "core/gimpviewable.h" #include "core/gimpviewable.h"
#include "gimpcontainermenu.h" #include "gimpcontainermenu.h"
#include "gimpcontainerview-utils.h" #include "gimppreviewrenderer.h"
enum enum
@ -234,27 +234,12 @@ gimp_container_menu_real_set_container (GimpContainerMenu *menu,
gimp_container_menu_context_changed, gimp_container_menu_context_changed,
menu); menu);
} }
if (menu->get_name_func &&
gimp_container_view_is_built_in_name_func (menu->get_name_func))
{
gimp_container_menu_set_name_func (menu, NULL);
}
} }
menu->container = container; menu->container = container;
if (menu->container) if (menu->container)
{ {
if (! menu->get_name_func)
{
GimpItemGetNameFunc get_name_func;
get_name_func = gimp_container_view_get_built_in_name_func (menu->container->children_type);
gimp_container_menu_set_name_func (menu, get_name_func);
}
gimp_container_foreach (menu->container, gimp_container_foreach (menu->container,
(GFunc) gimp_container_menu_add_foreach, (GFunc) gimp_container_menu_add_foreach,
menu); menu);
@ -344,29 +329,25 @@ gimp_container_menu_set_context (GimpContainerMenu *menu,
void void
gimp_container_menu_set_preview_size (GimpContainerMenu *menu, gimp_container_menu_set_preview_size (GimpContainerMenu *menu,
gint preview_size) gint preview_size,
gint preview_border_width)
{ {
g_return_if_fail (GIMP_IS_CONTAINER_MENU (menu)); g_return_if_fail (GIMP_IS_CONTAINER_MENU (menu));
g_return_if_fail (preview_size > 0 && g_return_if_fail (preview_size > 0 &&
preview_size <= GIMP_VIEWABLE_MAX_POPUP_SIZE); preview_size <= GIMP_VIEWABLE_MAX_POPUP_SIZE);
g_return_if_fail (preview_border_width >= 0 &&
preview_border_width <= GIMP_PREVIEW_MAX_BORDER_WIDTH);
if (menu->preview_size != preview_size) if (menu->preview_size != preview_size ||
menu->preview_border_width != preview_border_width)
{ {
menu->preview_size = preview_size; menu->preview_size = preview_size;
menu->preview_border_width = preview_border_width;
GIMP_CONTAINER_MENU_GET_CLASS (menu)->set_preview_size (menu); GIMP_CONTAINER_MENU_GET_CLASS (menu)->set_preview_size (menu);
} }
} }
void
gimp_container_menu_set_name_func (GimpContainerMenu *menu,
GimpItemGetNameFunc get_name_func)
{
g_return_if_fail (GIMP_IS_CONTAINER_MENU (menu));
menu->get_name_func = get_name_func;
}
void void
gimp_container_menu_select_item (GimpContainerMenu *menu, gimp_container_menu_select_item (GimpContainerMenu *menu,
GimpViewable *viewable) GimpViewable *viewable)

View File

@ -51,8 +51,6 @@ struct _GimpContainerMenu
gint preview_size; gint preview_size;
gint preview_border_width; gint preview_border_width;
GimpItemGetNameFunc get_name_func;
}; };
struct _GimpContainerMenuClass struct _GimpContainerMenuClass
@ -95,9 +93,8 @@ void gimp_container_menu_set_container (GimpContainerMenu *menu,
void gimp_container_menu_set_context (GimpContainerMenu *menu, void gimp_container_menu_set_context (GimpContainerMenu *menu,
GimpContext *context); GimpContext *context);
void gimp_container_menu_set_preview_size (GimpContainerMenu *menu, void gimp_container_menu_set_preview_size (GimpContainerMenu *menu,
gint preview_size); gint preview_size,
void gimp_container_menu_set_name_func (GimpContainerMenu *menu, gint preview_border_width);
GimpItemGetNameFunc get_name_func);
void gimp_container_menu_select_item (GimpContainerMenu *menu, void gimp_container_menu_select_item (GimpContainerMenu *menu,
GimpViewable *viewable); GimpViewable *viewable);

View File

@ -176,9 +176,6 @@ gimp_container_menu_impl_insert_item (GimpContainerMenu *menu,
menu->preview_size, menu->preview_size,
menu->preview_border_width); menu->preview_border_width);
gimp_menu_item_set_name_func (GIMP_MENU_ITEM (menu_item),
menu->get_name_func);
g_signal_connect (menu_item, "activate", g_signal_connect (menu_item, "activate",
G_CALLBACK (gimp_container_menu_impl_item_selected), G_CALLBACK (gimp_container_menu_impl_item_selected),
menu); menu);

View File

@ -286,10 +286,7 @@ gimp_container_tree_view_set (GimpContainerTreeView *tree_view,
view = GIMP_CONTAINER_VIEW (tree_view); view = GIMP_CONTAINER_VIEW (tree_view);
if (view->get_name_func) name = gimp_viewable_get_description (viewable, NULL);
name = view->get_name_func (G_OBJECT (viewable), NULL);
else
name = g_strdup (gimp_object_get_name (GIMP_OBJECT (viewable)));
renderer = gimp_preview_renderer_new (G_TYPE_FROM_INSTANCE (viewable), renderer = gimp_preview_renderer_new (G_TYPE_FROM_INSTANCE (viewable),
view->preview_size, view->preview_size,
@ -883,10 +880,7 @@ gimp_container_tree_view_name_changed (GimpObject *object,
{ {
gchar *name; gchar *name;
if (view->get_name_func) name = gimp_viewable_get_description (GIMP_VIEWABLE (object), NULL);
name = view->get_name_func (G_OBJECT (object), NULL);
else
name = g_strdup (gimp_object_get_name (object));
gtk_list_store_set (GTK_LIST_STORE (tree_view->model), iter, gtk_list_store_set (GTK_LIST_STORE (tree_view->model), iter,
COLUMN_NAME, name, COLUMN_NAME, name,

View File

@ -22,61 +22,10 @@
#include "widgets-types.h" #include "widgets-types.h"
#include "base/temp-buf.h"
#include "core/gimpbrush.h"
#include "core/gimpbuffer.h"
#include "core/gimpimage.h"
#include "core/gimpimagefile.h"
#include "core/gimppalette.h"
#include "core/gimppattern.h"
#include "core/gimptoolinfo.h"
#include "file/file-utils.h"
#include "gimpcontainereditor.h" #include "gimpcontainereditor.h"
#include "gimpcontainerview.h" #include "gimpcontainerview.h"
#include "gimpcontainerview-utils.h" #include "gimpcontainerview-utils.h"
#include "gimpdockable.h" #include "gimpdockable.h"
#include "gimpmenuitem.h"
#include "gimppreview.h"
typedef struct _GimpNameFuncEntry GimpNameFuncEntry;
struct _GimpNameFuncEntry
{
GType type;
GimpItemGetNameFunc name_func;
};
static gchar * gimp_container_view_tool_name_func (GObject *object,
gchar **tooltip);
static gchar * gimp_container_view_image_name_func (GObject *object,
gchar **tooltip);
static gchar * gimp_container_view_brush_name_func (GObject *object,
gchar **tooltip);
static gchar * gimp_container_view_pattern_name_func (GObject *object,
gchar **tooltip);
static gchar * gimp_container_view_palette_name_func (GObject *object,
gchar **tooltip);
static gchar * gimp_container_view_buffer_name_func (GObject *object,
gchar **tooltip);
static gchar * gimp_container_view_imagefile_name_func (GObject *object,
gchar **tooltip);
static GimpNameFuncEntry name_func_entries[] =
{
{ G_TYPE_NONE, gimp_container_view_tool_name_func },
{ G_TYPE_NONE, gimp_container_view_image_name_func },
{ G_TYPE_NONE, gimp_container_view_brush_name_func },
{ G_TYPE_NONE, gimp_container_view_pattern_name_func },
{ G_TYPE_NONE, gimp_container_view_palette_name_func },
{ G_TYPE_NONE, gimp_container_view_buffer_name_func },
{ G_TYPE_NONE, gimp_container_view_imagefile_name_func }
};
/* public functions */ /* public functions */
@ -104,291 +53,3 @@ gimp_container_view_get_by_dockable (GimpDockable *dockable)
return NULL; return NULL;
} }
GimpItemGetNameFunc
gimp_container_view_get_built_in_name_func (GType type)
{
gint i;
if (name_func_entries[0].type == G_TYPE_NONE)
{
name_func_entries[0].type = GIMP_TYPE_TOOL_INFO;
name_func_entries[1].type = GIMP_TYPE_IMAGE;
name_func_entries[2].type = GIMP_TYPE_BRUSH;
name_func_entries[3].type = GIMP_TYPE_PATTERN;
name_func_entries[4].type = GIMP_TYPE_PALETTE;
name_func_entries[5].type = GIMP_TYPE_BUFFER;
name_func_entries[6].type = GIMP_TYPE_IMAGEFILE;
}
for (i = 0; i < G_N_ELEMENTS (name_func_entries); i++)
{
if (type == name_func_entries[i].type)
return name_func_entries[i].name_func;
}
return NULL;
}
gboolean
gimp_container_view_is_built_in_name_func (GimpItemGetNameFunc get_name_func)
{
gint i;
for (i = 0; i < G_N_ELEMENTS (name_func_entries); i++)
{
if (get_name_func == name_func_entries[i].name_func)
return TRUE;
}
return FALSE;
}
/* private functions */
static GimpViewable *
gimp_container_view_get_name_func_viewable (GObject *object)
{
if (GIMP_IS_VIEWABLE (object))
{
return GIMP_VIEWABLE (object);
}
if (GIMP_IS_PREVIEW (object))
{
return GIMP_PREVIEW (object)->viewable;
}
else if (GIMP_IS_MENU_ITEM (object))
{
return GIMP_PREVIEW (GIMP_MENU_ITEM (object)->preview)->viewable;
}
g_warning ("%s: can't figure GimpViewable from type %s",
G_STRLOC, g_type_name (G_TYPE_FROM_INSTANCE (object)));
return NULL;
}
static gchar *
gimp_container_view_tool_name_func (GObject *object,
gchar **tooltip)
{
GimpViewable *viewable;
viewable = gimp_container_view_get_name_func_viewable (object);
if (viewable)
{
GimpToolInfo *tool_info;
tool_info = GIMP_TOOL_INFO (viewable);
if (tooltip)
*tooltip = NULL;
return g_strdup (tool_info->blurb);
}
return g_strdup ("EEK");
}
static gchar *
gimp_container_view_image_name_func (GObject *object,
gchar **tooltip)
{
GimpViewable *viewable;
viewable = gimp_container_view_get_name_func_viewable (object);
if (viewable)
{
GimpImage *gimage;
const gchar *uri;
gchar *basename;
gchar *retval;
gimage = GIMP_IMAGE (viewable);
uri = gimp_image_get_uri (GIMP_IMAGE (gimage));
basename = file_utils_uri_to_utf8_basename (uri);
if (tooltip)
{
gchar *filename;
filename = file_utils_uri_to_utf8_filename (uri);
*tooltip = filename;
}
retval = g_strdup_printf ("%s-%d",
basename,
gimp_image_get_ID (gimage));
g_free (basename);
return retval;
}
return g_strdup ("EEK");
}
static gchar *
gimp_container_view_brush_name_func (GObject *object,
gchar **tooltip)
{
GimpViewable *viewable;
viewable = gimp_container_view_get_name_func_viewable (object);
if (viewable)
{
GimpBrush *brush;
brush = GIMP_BRUSH (viewable);
if (tooltip)
*tooltip = NULL;
return g_strdup_printf ("%s (%d x %d)",
GIMP_OBJECT (brush)->name,
brush->mask->width,
brush->mask->height);
}
return g_strdup ("EEK");
}
static gchar *
gimp_container_view_pattern_name_func (GObject *object,
gchar **tooltip)
{
GimpViewable *viewable;
viewable = gimp_container_view_get_name_func_viewable (object);
if (viewable)
{
GimpPattern *pattern;
pattern = GIMP_PATTERN (viewable);
if (tooltip)
*tooltip = NULL;
return g_strdup_printf ("%s (%d x %d)",
GIMP_OBJECT (pattern)->name,
pattern->mask->width,
pattern->mask->height);
}
return g_strdup ("EEK");
}
static gchar *
gimp_container_view_palette_name_func (GObject *object,
gchar **tooltip)
{
GimpViewable *viewable;
viewable = gimp_container_view_get_name_func_viewable (object);
if (viewable)
{
GimpPalette *palette;
palette = GIMP_PALETTE (viewable);
if (tooltip)
*tooltip = NULL;
return g_strdup_printf ("%s (%d)",
GIMP_OBJECT (palette)->name,
palette->n_colors);
}
return g_strdup ("EEK");
}
static gchar *
gimp_container_view_buffer_name_func (GObject *object,
gchar **tooltip)
{
GimpViewable *viewable;
viewable = gimp_container_view_get_name_func_viewable (object);
if (viewable)
{
GimpBuffer *buffer;
buffer = GIMP_BUFFER (viewable);
if (tooltip)
*tooltip = NULL;
return g_strdup_printf ("%s (%d x %d)",
GIMP_OBJECT (buffer)->name,
gimp_buffer_get_width (buffer),
gimp_buffer_get_height (buffer));
}
return g_strdup ("EEK");
}
static gchar *
gimp_container_view_imagefile_name_func (GObject *object,
gchar **tooltip)
{
GimpViewable *viewable;
viewable = gimp_container_view_get_name_func_viewable (object);
if (viewable)
{
GimpImagefile *imagefile;
const gchar *uri;
gchar *basename;
imagefile = GIMP_IMAGEFILE (viewable);
uri = gimp_object_get_name (GIMP_OBJECT (imagefile));
basename = file_utils_uri_to_utf8_basename (uri);
if (tooltip)
{
gchar *filename;
const gchar *desc;
filename = file_utils_uri_to_utf8_filename (uri);
desc = gimp_imagefile_get_description (imagefile);
if (desc)
{
*tooltip = g_strdup_printf ("%s\n%s", filename, desc);
g_free (filename);
}
else
{
*tooltip = filename;
}
}
if (imagefile->width > 0 && imagefile->height > 0)
{
gchar *tmp = basename;
basename = g_strdup_printf ("%s (%d x %d)",
tmp,
imagefile->width,
imagefile->height);
g_free (tmp);
}
return basename;
}
return g_strdup ("EEK");
}

View File

@ -23,17 +23,7 @@
#define __GIMP_CONTAINER_VIEW_UTILS_H__ #define __GIMP_CONTAINER_VIEW_UTILS_H__
/* public */
GimpContainerView * gimp_container_view_get_by_dockable (GimpDockable *dockable); GimpContainerView * gimp_container_view_get_by_dockable (GimpDockable *dockable);
/* private */
GimpItemGetNameFunc gimp_container_view_get_built_in_name_func
(GType type);
gboolean gimp_container_view_is_built_in_name_func
(GimpItemGetNameFunc get_name_func);
#endif /* __GIMP_CONTAINER_VIEW_UTILS_H__ */ #endif /* __GIMP_CONTAINER_VIEW_UTILS_H__ */

View File

@ -33,7 +33,6 @@
#include "core/gimpviewable.h" #include "core/gimpviewable.h"
#include "gimpcontainerview.h" #include "gimpcontainerview.h"
#include "gimpcontainerview-utils.h"
#include "gimpdnd.h" #include "gimpdnd.h"
#include "gimppreviewrenderer.h" #include "gimppreviewrenderer.h"
@ -187,7 +186,6 @@ gimp_container_view_init (GimpContainerView *view,
view->preview_size = 0; view->preview_size = 0;
view->preview_border_width = 1; view->preview_border_width = 1;
view->reorderable = FALSE; view->reorderable = FALSE;
view->get_name_func = NULL;
view->scrolled_win = gtk_scrolled_window_new (NULL, NULL); view->scrolled_win = gtk_scrolled_window_new (NULL, NULL);
gtk_box_pack_start (GTK_BOX (view), view->scrolled_win, TRUE, TRUE, 0); gtk_box_pack_start (GTK_BOX (view), view->scrolled_win, TRUE, TRUE, 0);
@ -274,28 +272,12 @@ gimp_container_view_real_set_container (GimpContainerView *view,
view->container->children_type); view->container->children_type);
} }
} }
if (view->get_name_func &&
gimp_container_view_is_built_in_name_func (view->get_name_func))
{
gimp_container_view_set_name_func (view, NULL);
}
} }
view->container = container; view->container = container;
if (view->container) if (view->container)
{ {
if (! view->get_name_func)
{
GimpItemGetNameFunc get_name_func;
get_name_func =
gimp_container_view_get_built_in_name_func (view->container->children_type);
gimp_container_view_set_name_func (view, get_name_func);
}
gimp_container_foreach (view->container, gimp_container_foreach (view->container,
(GFunc) gimp_container_view_add_foreach, (GFunc) gimp_container_view_add_foreach,
view); view);
@ -451,15 +433,6 @@ gimp_container_view_set_preview_size (GimpContainerView *view,
} }
} }
void
gimp_container_view_set_name_func (GimpContainerView *view,
GimpItemGetNameFunc get_name_func)
{
g_return_if_fail (GIMP_IS_CONTAINER_VIEW (view));
view->get_name_func = get_name_func;
}
void void
gimp_container_view_enable_dnd (GimpContainerView *view, gimp_container_view_enable_dnd (GimpContainerView *view,
GtkButton *button, GtkButton *button,

View File

@ -49,8 +49,6 @@ struct _GimpContainerView
gint preview_border_width; gint preview_border_width;
gboolean reorderable; gboolean reorderable;
GimpItemGetNameFunc get_name_func;
GtkWidget *scrolled_win; GtkWidget *scrolled_win;
/* initialized by subclass */ /* initialized by subclass */
@ -109,8 +107,6 @@ void gimp_container_view_set_context (GimpContainerView *view,
void gimp_container_view_set_preview_size (GimpContainerView *view, void gimp_container_view_set_preview_size (GimpContainerView *view,
gint preview_size, gint preview_size,
gint preview_border_width); gint preview_border_width);
void gimp_container_view_set_name_func (GimpContainerView *view,
GimpItemGetNameFunc get_name_func);
void gimp_container_view_enable_dnd (GimpContainerView *editor, void gimp_container_view_enable_dnd (GimpContainerView *editor,
GtkButton *button, GtkButton *button,

View File

@ -222,7 +222,7 @@ gimp_image_dock_style_set (GtkWidget *widget,
gtk_widget_set_size_request (widget, minimal_width, -1); gtk_widget_set_size_request (widget, minimal_width, -1);
gimp_container_menu_set_preview_size (GIMP_CONTAINER_MENU (image_dock->menu), gimp_container_menu_set_preview_size (GIMP_CONTAINER_MENU (image_dock->menu),
menu_preview_height); menu_preview_height, 1);
gtk_widget_set_size_request (image_dock->auto_button, -1, gtk_widget_set_size_request (image_dock->auto_button, -1,
menu_preview_height + menu_preview_height +

View File

@ -222,7 +222,7 @@ gimp_image_dock_style_set (GtkWidget *widget,
gtk_widget_set_size_request (widget, minimal_width, -1); gtk_widget_set_size_request (widget, minimal_width, -1);
gimp_container_menu_set_preview_size (GIMP_CONTAINER_MENU (image_dock->menu), gimp_container_menu_set_preview_size (GIMP_CONTAINER_MENU (image_dock->menu),
menu_preview_height); menu_preview_height, 1);
gtk_widget_set_size_request (image_dock->auto_button, -1, gtk_widget_set_size_request (image_dock->auto_button, -1,
menu_preview_height + menu_preview_height +

View File

@ -102,7 +102,6 @@ gimp_menu_item_init (GimpMenuItem *menu_item)
menu_item->preview_size = 0; menu_item->preview_size = 0;
menu_item->preview_border_width = 1; menu_item->preview_border_width = 1;
menu_item->get_name_func = NULL;
} }
GtkWidget * GtkWidget *
@ -176,47 +175,20 @@ gimp_menu_item_real_set_viewable (GimpMenuItem *menu_item,
NULL); NULL);
} }
void
gimp_menu_item_set_name_func (GimpMenuItem *menu_item,
GimpItemGetNameFunc get_name_func)
{
g_return_if_fail (GIMP_IS_MENU_ITEM (menu_item));
if (menu_item->get_name_func != get_name_func)
{
GimpViewable *viewable;
menu_item->get_name_func = get_name_func;
viewable = GIMP_PREVIEW (menu_item->preview)->viewable;
if (viewable)
gimp_menu_item_name_changed (viewable, menu_item);
}
}
static void static void
gimp_menu_item_name_changed (GimpViewable *viewable, gimp_menu_item_name_changed (GimpViewable *viewable,
GimpMenuItem *menu_item) GimpMenuItem *menu_item)
{ {
if (menu_item->get_name_func)
{
gchar *name = NULL; gchar *name = NULL;
gchar *tooltip = NULL; gchar *tooltip = NULL;
name = menu_item->get_name_func (G_OBJECT (menu_item), &tooltip); name = gimp_viewable_get_description (viewable, &tooltip);
gtk_label_set_text (GTK_LABEL (menu_item->name_label), name); gtk_label_set_text (GTK_LABEL (menu_item->name_label), name);
gimp_help_set_help_data (GTK_WIDGET (menu_item), tooltip, NULL); gimp_help_set_help_data (GTK_WIDGET (menu_item), tooltip, NULL);
g_free (name); g_free (name);
g_free (tooltip); g_free (tooltip);
}
else
{
gtk_label_set_text (GTK_LABEL (menu_item->name_label),
gimp_object_get_name (GIMP_OBJECT (viewable)));
}
} }
static GimpViewable * static GimpViewable *

View File

@ -44,12 +44,8 @@ struct _GimpMenuItem
GtkWidget *preview; GtkWidget *preview;
GtkWidget *name_label; GtkWidget *name_label;
/*< protected >*/
gint preview_size; gint preview_size;
gint preview_border_width; gint preview_border_width;
/*< private >*/
GimpItemGetNameFunc get_name_func;
}; };
struct _GimpMenuItemClass struct _GimpMenuItemClass
@ -68,8 +64,5 @@ GtkWidget * gimp_menu_item_new (GimpViewable *viewable,
gint preview_size, gint preview_size,
gint preview_border_width); gint preview_border_width);
void gimp_menu_item_set_name_func (GimpMenuItem *menu_item,
GimpItemGetNameFunc get_name_func);
#endif /* __GIMP_MENU_ITEM_H__ */ #endif /* __GIMP_MENU_ITEM_H__ */

View File

@ -32,7 +32,6 @@
#include "file/file-utils.h" #include "file/file-utils.h"
#include "gimpcontainerview-utils.h"
#include "gimppreview.h" #include "gimppreview.h"
#include "gimpviewabledialog.h" #include "gimpviewabledialog.h"
@ -295,19 +294,9 @@ static void
gimp_viewable_dialog_name_changed (GimpObject *object, gimp_viewable_dialog_name_changed (GimpObject *object,
GimpViewableDialog *dialog) GimpViewableDialog *dialog)
{ {
GimpItemGetNameFunc get_name_func;
gchar *name; gchar *name;
get_name_func = gimp_container_view_get_built_in_name_func (G_TYPE_FROM_INSTANCE (object)); name = gimp_viewable_get_description (GIMP_VIEWABLE (object), NULL);
if (get_name_func && dialog->preview)
{
name = get_name_func (G_OBJECT (dialog->preview), NULL);
}
else
{
name = g_strdup (gimp_object_get_name (object));
}
if (GIMP_IS_ITEM (object)) if (GIMP_IS_ITEM (object))
{ {

View File

@ -117,8 +117,6 @@ typedef struct _GimpItemFactoryEntry GimpItemFactoryEntry;
typedef void (* GimpItemFactorySetupFunc) (GimpItemFactory *factory); typedef void (* GimpItemFactorySetupFunc) (GimpItemFactory *factory);
typedef void (* GimpItemFactoryUpdateFunc) (GtkItemFactory *factory, typedef void (* GimpItemFactoryUpdateFunc) (GtkItemFactory *factory,
gpointer data); gpointer data);
typedef gchar * (* GimpItemGetNameFunc) (GObject *object,
gchar **tooltip);
#endif /* __WIDGETS_TYPES_H__ */ #endif /* __WIDGETS_TYPES_H__ */

View File

@ -198,7 +198,7 @@ HELP
tname = g_build_filename (pname, ".xvpics", fname, NULL); tname = g_build_filename (pname, ".xvpics", fname, NULL);
g_free (pname); g_free (pname);
g_free (fname); g_free (fname);
raw_thumb = readXVThumb (tname, &width, &height, &imginfo); raw_thumb = file_utils_readXVThumb (tname, &width, &height, &imginfo);
g_free (tname); g_free (tname);
if (raw_thumb) if (raw_thumb)