diff --git a/ChangeLog b/ChangeLog index 6db0a6d55d..f85677b533 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,51 @@ +2003-04-08 Michael Natterer + + * 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 * app/widgets/gimpbrushfactoryview.[ch] diff --git a/app/core/gimpbrush-load.c b/app/core/gimpbrush-load.c index 97113ab500..3f633b1a57 100644 --- a/app/core/gimpbrush-load.c +++ b/app/core/gimpbrush-load.c @@ -80,6 +80,8 @@ static gboolean gimp_brush_get_popup_size (GimpViewable *viewable, static TempBuf * gimp_brush_get_new_preview (GimpViewable *viewable, gint width, gint height); +static gchar * gimp_brush_get_description (GimpViewable *viewable, + gchar **tooltip); static gchar * gimp_brush_get_extension (GimpData *data); 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_new_preview = gimp_brush_get_new_preview; + viewable_class->get_description = gimp_brush_get_description; data_class->get_extension = gimp_brush_get_extension; @@ -328,6 +331,23 @@ gimp_brush_get_new_preview (GimpViewable *viewable, 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 * gimp_brush_get_extension (GimpData *data) { diff --git a/app/core/gimpbrush.c b/app/core/gimpbrush.c index 97113ab500..3f633b1a57 100644 --- a/app/core/gimpbrush.c +++ b/app/core/gimpbrush.c @@ -80,6 +80,8 @@ static gboolean gimp_brush_get_popup_size (GimpViewable *viewable, static TempBuf * gimp_brush_get_new_preview (GimpViewable *viewable, gint width, gint height); +static gchar * gimp_brush_get_description (GimpViewable *viewable, + gchar **tooltip); static gchar * gimp_brush_get_extension (GimpData *data); 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_new_preview = gimp_brush_get_new_preview; + viewable_class->get_description = gimp_brush_get_description; data_class->get_extension = gimp_brush_get_extension; @@ -328,6 +331,23 @@ gimp_brush_get_new_preview (GimpViewable *viewable, 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 * gimp_brush_get_extension (GimpData *data) { diff --git a/app/core/gimpbuffer.c b/app/core/gimpbuffer.c index 1b382cbb48..8b7fecd016 100644 --- a/app/core/gimpbuffer.c +++ b/app/core/gimpbuffer.c @@ -55,6 +55,8 @@ static gboolean gimp_buffer_get_popup_size (GimpViewable *viewable, static TempBuf * gimp_buffer_get_new_preview (GimpViewable *viewable, gint width, gint height); +static gchar * gimp_buffer_get_description (GimpViewable *viewable, + gchar **tooltip); 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_popup_size = gimp_buffer_get_popup_size; viewable_class->get_new_preview = gimp_buffer_get_new_preview; + viewable_class->get_description = gimp_buffer_get_description; } static void @@ -272,6 +275,23 @@ gimp_buffer_get_new_preview (GimpViewable *viewable, 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 * gimp_buffer_new (TileManager *tiles, const gchar *name, diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c index 58b194d7e4..7aaa973e81 100644 --- a/app/core/gimpimage.c +++ b/app/core/gimpimage.c @@ -112,6 +112,8 @@ static gsize gimp_image_get_memsize (GimpObject *object); static void gimp_image_invalidate_preview (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, 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_preview = gimp_image_get_preview; viewable_class->get_new_preview = gimp_image_get_new_preview; + viewable_class->get_description = gimp_image_get_description; klass->mode_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))); } +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 gimp_image_real_colormap_changed (GimpImage *gimage, gint ncol) diff --git a/app/core/gimpimagefile.c b/app/core/gimpimagefile.c index c0c9dd0e53..5f5895a60e 100644 --- a/app/core/gimpimagefile.c +++ b/app/core/gimpimagefile.c @@ -61,6 +61,7 @@ #include "gimpmarshal.h" #include "file/file-open.h" +#include "file/file-utils.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, gint width, gint height); +static gchar * gimp_imagefile_get_description (GimpViewable *viewable, + gchar **tooltip); static TempBuf * gimp_imagefile_read_png_thumb (GimpImagefile *imagefile, gint thumb_size); @@ -206,6 +209,7 @@ gimp_imagefile_class_init (GimpImagefileClass *klass) viewable_class->name_changed_signal = "info_changed"; 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); @@ -678,8 +682,55 @@ gimp_imagefile_get_new_preview (GimpViewable *viewable, 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 * -gimp_imagefile_get_description (GimpImagefile *imagefile) +gimp_imagefile_get_desc_string (GimpImagefile *imagefile) { g_return_val_if_fail (GIMP_IS_IMAGEFILE (imagefile), NULL); diff --git a/app/core/gimpimagefile.h b/app/core/gimpimagefile.h index 43b896873c..96bee990e1 100644 --- a/app/core/gimpimagefile.h +++ b/app/core/gimpimagefile.h @@ -94,7 +94,7 @@ void gimp_imagefile_create_thumbnail (GimpImagefile *imagefile, gint thumb_size); gboolean gimp_imagefile_save_thumbnail (GimpImagefile *imagefile, GimpImage *gimage); -const gchar * gimp_imagefile_get_description (GimpImagefile *imagefile); +const gchar * gimp_imagefile_get_desc_string (GimpImagefile *imagefile); #endif /* __GIMP_IMAGEFILE_H__ */ diff --git a/app/core/gimppalette-load.c b/app/core/gimppalette-load.c index 30cddd9350..f39b687f28 100644 --- a/app/core/gimppalette-load.c +++ b/app/core/gimppalette-load.c @@ -63,6 +63,8 @@ static gboolean gimp_palette_get_popup_size (GimpViewable *viewable, static TempBuf * gimp_palette_get_new_preview (GimpViewable *viewable, gint width, gint height); +static gchar * gimp_palette_get_description (GimpViewable *viewable, + gchar **tooltip); static void gimp_palette_dirty (GimpData *data); static gboolean gimp_palette_save (GimpData *data, 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_popup_size = gimp_palette_get_popup_size; 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->save = gimp_palette_save; @@ -304,6 +307,22 @@ gimp_palette_get_new_preview (GimpViewable *viewable, 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 * gimp_palette_new (const gchar *name, gboolean stingy_memory_use) diff --git a/app/core/gimppalette-save.c b/app/core/gimppalette-save.c index 30cddd9350..f39b687f28 100644 --- a/app/core/gimppalette-save.c +++ b/app/core/gimppalette-save.c @@ -63,6 +63,8 @@ static gboolean gimp_palette_get_popup_size (GimpViewable *viewable, static TempBuf * gimp_palette_get_new_preview (GimpViewable *viewable, gint width, gint height); +static gchar * gimp_palette_get_description (GimpViewable *viewable, + gchar **tooltip); static void gimp_palette_dirty (GimpData *data); static gboolean gimp_palette_save (GimpData *data, 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_popup_size = gimp_palette_get_popup_size; 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->save = gimp_palette_save; @@ -304,6 +307,22 @@ gimp_palette_get_new_preview (GimpViewable *viewable, 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 * gimp_palette_new (const gchar *name, gboolean stingy_memory_use) diff --git a/app/core/gimppalette.c b/app/core/gimppalette.c index 30cddd9350..f39b687f28 100644 --- a/app/core/gimppalette.c +++ b/app/core/gimppalette.c @@ -63,6 +63,8 @@ static gboolean gimp_palette_get_popup_size (GimpViewable *viewable, static TempBuf * gimp_palette_get_new_preview (GimpViewable *viewable, gint width, gint height); +static gchar * gimp_palette_get_description (GimpViewable *viewable, + gchar **tooltip); static void gimp_palette_dirty (GimpData *data); static gboolean gimp_palette_save (GimpData *data, 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_popup_size = gimp_palette_get_popup_size; 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->save = gimp_palette_save; @@ -304,6 +307,22 @@ gimp_palette_get_new_preview (GimpViewable *viewable, 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 * gimp_palette_new (const gchar *name, gboolean stingy_memory_use) diff --git a/app/core/gimppattern-load.c b/app/core/gimppattern-load.c index 92c27153ce..cd5d8d3820 100644 --- a/app/core/gimppattern-load.c +++ b/app/core/gimppattern-load.c @@ -70,6 +70,8 @@ static gboolean gimp_pattern_get_popup_size (GimpViewable *viewable, static TempBuf * gimp_pattern_get_new_preview (GimpViewable *viewable, gint width, gint height); +static gchar * gimp_pattern_get_description (GimpViewable *viewable, + gchar **tooltip); static gchar * gimp_pattern_get_extension (GimpData *data); static GimpData * gimp_pattern_duplicate (GimpData *data, 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_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->duplicate = gimp_pattern_duplicate; @@ -216,6 +219,23 @@ gimp_pattern_get_new_preview (GimpViewable *viewable, 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 * gimp_pattern_get_extension (GimpData *data) { diff --git a/app/core/gimppattern.c b/app/core/gimppattern.c index 92c27153ce..cd5d8d3820 100644 --- a/app/core/gimppattern.c +++ b/app/core/gimppattern.c @@ -70,6 +70,8 @@ static gboolean gimp_pattern_get_popup_size (GimpViewable *viewable, static TempBuf * gimp_pattern_get_new_preview (GimpViewable *viewable, gint width, gint height); +static gchar * gimp_pattern_get_description (GimpViewable *viewable, + gchar **tooltip); static gchar * gimp_pattern_get_extension (GimpData *data); static GimpData * gimp_pattern_duplicate (GimpData *data, 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_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->duplicate = gimp_pattern_duplicate; @@ -216,6 +219,23 @@ gimp_pattern_get_new_preview (GimpViewable *viewable, 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 * gimp_pattern_get_extension (GimpData *data) { diff --git a/app/core/gimptoolinfo.c b/app/core/gimptoolinfo.c index 331b5861fb..c594bbd42f 100644 --- a/app/core/gimptoolinfo.c +++ b/app/core/gimptoolinfo.c @@ -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_finalize (GObject *object); +static gchar * gimp_tool_info_get_description (GimpViewable *viewable, + gchar **tooltip); static GimpDataClass *parent_class = NULL; @@ -73,13 +75,17 @@ gimp_tool_info_get_type (void) static void 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); - 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 @@ -150,6 +156,20 @@ gimp_tool_info_finalize (GObject *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 * gimp_tool_info_new (Gimp *gimp, GType tool_type, diff --git a/app/core/gimpviewable.c b/app/core/gimpviewable.c index 26fe9496d1..914395b87d 100644 --- a/app/core/gimpviewable.c +++ b/app/core/gimpviewable.c @@ -47,29 +47,31 @@ enum }; -static void gimp_viewable_class_init (GimpViewableClass *klass); -static void gimp_viewable_init (GimpViewable *viewable); +static void gimp_viewable_class_init (GimpViewableClass *klass); +static void gimp_viewable_init (GimpViewable *viewable); -static void gimp_viewable_finalize (GObject *object); -static void gimp_viewable_set_property (GObject *object, - guint property_id, - const GValue *value, - GParamSpec *pspec); -static void gimp_viewable_get_property (GObject *object, - guint property_id, - GValue *value, - GParamSpec *pspec); +static void gimp_viewable_finalize (GObject *object); +static void gimp_viewable_set_property (GObject *object, + guint property_id, + const GValue *value, + GParamSpec *pspec); +static void gimp_viewable_get_property (GObject *object, + guint property_id, + GValue *value, + GParamSpec *pspec); -static gsize gimp_viewable_get_memsize (GimpObject *object); +static gsize gimp_viewable_get_memsize (GimpObject *object); -static void gimp_viewable_real_invalidate_preview (GimpViewable *viewable); +static void gimp_viewable_real_invalidate_preview (GimpViewable *viewable); -static void gimp_viewable_real_get_preview_size (GimpViewable *viewable, - gint size, - gboolean popup, - gboolean dot_for_dot, - gint *width, - gint *height); +static void gimp_viewable_real_get_preview_size (GimpViewable *viewable, + gint size, + gboolean popup, + gboolean dot_for_dot, + gint *width, + gint *height); +static gchar * gimp_viewable_real_get_description (GimpViewable *viewable, + gchar **tooltip); static guint viewable_signals[LAST_SIGNAL] = { 0 }; @@ -156,6 +158,7 @@ gimp_viewable_class_init (GimpViewableClass *klass) klass->get_popup_size = NULL; klass->get_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", NULL, NULL, 0); @@ -275,6 +278,16 @@ gimp_viewable_real_get_preview_size (GimpViewable *viewable, *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 gimp_viewable_invalidate_preview (GimpViewable *viewable) { @@ -547,6 +560,16 @@ gimp_viewable_get_new_preview_pixbuf (GimpViewable *viewable, 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 * gimp_viewable_get_stock_id (GimpViewable *viewable) { diff --git a/app/core/gimpviewable.h b/app/core/gimpviewable.h index a62aaf0bcc..c21804f133 100644 --- a/app/core/gimpviewable.h +++ b/app/core/gimpviewable.h @@ -58,77 +58,83 @@ struct _GimpViewableClass const gchar *name_changed_signal; /* signals */ - void (* invalidate_preview) (GimpViewable *viewable); - void (* size_changed) (GimpViewable *viewable); + void (* invalidate_preview) (GimpViewable *viewable); + void (* size_changed) (GimpViewable *viewable); /* virtual functions */ - void (* get_preview_size) (GimpViewable *viewable, - gint size, - gboolean is_popup, - gboolean dot_for_dot, - gint *width, - gint *height); - gboolean (* get_popup_size) (GimpViewable *viewable, - gint width, - gint height, - gboolean dot_for_dot, - gint *popup_width, - gint *popup_height); - TempBuf * (* get_preview) (GimpViewable *viewable, - gint width, - gint height); - TempBuf * (* get_new_preview) (GimpViewable *viewable, - gint width, - gint height); + void (* get_preview_size) (GimpViewable *viewable, + gint size, + gboolean is_popup, + gboolean dot_for_dot, + gint *width, + gint *height); + gboolean (* get_popup_size) (GimpViewable *viewable, + gint width, + gint height, + gboolean dot_for_dot, + gint *popup_width, + gint *popup_height); + TempBuf * (* get_preview) (GimpViewable *viewable, + gint width, + gint height); + TempBuf * (* get_new_preview) (GimpViewable *viewable, + gint width, + gint height); + gchar * (* get_description) (GimpViewable *viewable, + gchar **tooltip); }; GType gimp_viewable_get_type (void) G_GNUC_CONST; -void gimp_viewable_invalidate_preview (GimpViewable *viewable); -void gimp_viewable_size_changed (GimpViewable *viewable); +void gimp_viewable_invalidate_preview (GimpViewable *viewable); +void gimp_viewable_size_changed (GimpViewable *viewable); -void gimp_viewable_calc_preview_size (GimpViewable *viewable, - gint aspect_width, - gint aspect_height, - gint width, - gint height, - gboolean dot_for_dot, - gdouble xresolution, - gdouble yresolution, - gint *return_width, - gint *return_height, - gboolean *scaling_up); +void gimp_viewable_calc_preview_size (GimpViewable *viewable, + gint aspect_width, + gint aspect_height, + gint width, + gint height, + gboolean dot_for_dot, + gdouble xresolution, + gdouble yresolution, + gint *return_width, + gint *return_height, + gboolean *scaling_up); -void gimp_viewable_get_preview_size (GimpViewable *viewable, - gint size, - gboolean popup, - gboolean dot_for_dot, - gint *width, - gint *height); -gboolean gimp_viewable_get_popup_size (GimpViewable *viewable, - gint width, - gint height, - gboolean dot_for_dot, - gint *popup_width, - gint *popup_height); +void gimp_viewable_get_preview_size (GimpViewable *viewable, + gint size, + gboolean popup, + gboolean dot_for_dot, + gint *width, + gint *height); +gboolean gimp_viewable_get_popup_size (GimpViewable *viewable, + gint width, + gint height, + gboolean dot_for_dot, + gint *popup_width, + gint *popup_height); -TempBuf * gimp_viewable_get_preview (GimpViewable *viewable, - gint width, - gint height); -TempBuf * gimp_viewable_get_new_preview (GimpViewable *viewable, - gint width, - gint height); +TempBuf * gimp_viewable_get_preview (GimpViewable *viewable, + gint width, + gint height); +TempBuf * gimp_viewable_get_new_preview (GimpViewable *viewable, + gint width, + gint height); -GdkPixbuf * gimp_viewable_get_preview_pixbuf (GimpViewable *viewable, - gint width, - gint height); -GdkPixbuf * gimp_viewable_get_new_preview_pixbuf (GimpViewable *viewable, - gint width, - gint height); -const gchar * gimp_viewable_get_stock_id (GimpViewable *viewable); -void gimp_viewable_set_stock_id (GimpViewable *viewable, - const gchar *stock_id); +GdkPixbuf * gimp_viewable_get_preview_pixbuf (GimpViewable *viewable, + gint width, + gint height); +GdkPixbuf * gimp_viewable_get_new_preview_pixbuf (GimpViewable *viewable, + gint width, + gint height); + +gchar * gimp_viewable_get_description (GimpViewable *viewable, + gchar **tooltip); + +const gchar * gimp_viewable_get_stock_id (GimpViewable *viewable); +void gimp_viewable_set_stock_id (GimpViewable *viewable, + const gchar *stock_id); #endif /* __GIMP_VIEWABLE_H__ */ diff --git a/app/dialogs/file-open-dialog.c b/app/dialogs/file-open-dialog.c index 528fa367a5..9a24ef4205 100644 --- a/app/dialogs/file-open-dialog.c +++ b/app/dialogs/file-open-dialog.c @@ -350,7 +350,7 @@ static void file_open_imagefile_info_changed (GimpImagefile *imagefile, 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 diff --git a/app/file/file-utils.c b/app/file/file-utils.c index 6ba8e43c48..ae44de1ffa 100644 --- a/app/file/file-utils.c +++ b/app/file/file-utils.c @@ -594,12 +594,13 @@ file_check_magic_list (GSList *magics_list, /* The readXVThumb function source may be re-used under - the XFree86-style license. */ + * the XFree86-style license. + */ guchar * -readXVThumb (const gchar *fnam, - gint *w, - gint *h, - gchar **imginfo /* caller frees if != NULL */) +file_utils_readXVThumb (const gchar *fnam, + gint *w, + gint *h, + gchar **imginfo /* caller frees if != NULL */) { FILE *fp; const gchar *P7_332 = "P7 332"; diff --git a/app/file/file-utils.h b/app/file/file-utils.h index 8abc19c985..7f43da9642 100644 --- a/app/file/file-utils.h +++ b/app/file/file-utils.h @@ -34,10 +34,10 @@ gchar * file_utils_uri_to_utf8_filename (const gchar *uri); /* .xvpics thumbnail stuff */ -guchar * readXVThumb (const gchar *fnam, - gint *w, - gint *h, - gchar **imginfo /* caller frees if != NULL */); +guchar * file_utils_readXVThumb (const gchar *fnam, + gint *w, + gint *h, + gchar **imginfo /* caller frees if != NULL */); #endif /* __FILE_UTILS_H__ */ diff --git a/app/gui/file-open-dialog.c b/app/gui/file-open-dialog.c index 528fa367a5..9a24ef4205 100644 --- a/app/gui/file-open-dialog.c +++ b/app/gui/file-open-dialog.c @@ -350,7 +350,7 @@ static void file_open_imagefile_info_changed (GimpImagefile *imagefile, 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 diff --git a/app/pdb/fileops_cmds.c b/app/pdb/fileops_cmds.c index ea8533e953..cf6b11e11b 100644 --- a/app/pdb/fileops_cmds.c +++ b/app/pdb/fileops_cmds.c @@ -242,7 +242,7 @@ file_load_thumbnail_invoker (Gimp *gimp, tname = g_build_filename (pname, ".xvpics", fname, NULL); g_free (pname); g_free (fname); - raw_thumb = readXVThumb (tname, &width, &height, &imginfo); + raw_thumb = file_utils_readXVThumb (tname, &width, &height, &imginfo); g_free (tname); if (raw_thumb) diff --git a/app/widgets/gimpcontainergridview.c b/app/widgets/gimpcontainergridview.c index 2b47627c2d..60786551b0 100644 --- a/app/widgets/gimpcontainergridview.c +++ b/app/widgets/gimpcontainergridview.c @@ -533,6 +533,7 @@ gimp_container_grid_view_highlight_item (GimpContainerView *view, gint item_height; gint index; gint row; + gchar *name; adj = gtk_scrolled_window_get_vadjustment (GTK_SCROLLED_WINDOW (view->scrolled_win)); @@ -557,21 +558,9 @@ gimp_container_grid_view_highlight_item (GimpContainerView *view, gimp_preview_set_border_color (preview, &black_color); gimp_preview_renderer_update (preview->renderer); - if (view->get_name_func) - { - gchar *name; - - name = view->get_name_func (G_OBJECT (preview), NULL); - - gtk_label_set_text (GTK_LABEL (grid_view->name_label), name); - - g_free (name); - } - else - { - gtk_label_set_text (GTK_LABEL (grid_view->name_label), - GIMP_OBJECT (viewable)->name); - } + name = gimp_viewable_get_description (preview->renderer->viewable, NULL); + gtk_label_set_text (GTK_LABEL (grid_view->name_label), name); + g_free (name); } else { diff --git a/app/widgets/gimpcontainermenu.c b/app/widgets/gimpcontainermenu.c index d434a3b2ce..540925e467 100644 --- a/app/widgets/gimpcontainermenu.c +++ b/app/widgets/gimpcontainermenu.c @@ -31,7 +31,7 @@ #include "core/gimpviewable.h" #include "gimpcontainermenu.h" -#include "gimpcontainerview-utils.h" +#include "gimppreviewrenderer.h" enum @@ -234,27 +234,12 @@ gimp_container_menu_real_set_container (GimpContainerMenu *menu, gimp_container_menu_context_changed, 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; 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, (GFunc) gimp_container_menu_add_foreach, menu); @@ -344,29 +329,25 @@ gimp_container_menu_set_context (GimpContainerMenu *menu, void 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 (preview_size > 0 && 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); } } -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 gimp_container_menu_select_item (GimpContainerMenu *menu, GimpViewable *viewable) diff --git a/app/widgets/gimpcontainermenu.h b/app/widgets/gimpcontainermenu.h index 4b037e4f8c..925654c814 100644 --- a/app/widgets/gimpcontainermenu.h +++ b/app/widgets/gimpcontainermenu.h @@ -42,17 +42,15 @@ typedef struct _GimpContainerMenuClass GimpContainerMenuClass; struct _GimpContainerMenu { - GtkMenu parent_instance; + GtkMenu parent_instance; - GimpContainer *container; - GimpContext *context; + GimpContainer *container; + GimpContext *context; - GHashTable *hash_table; + GHashTable *hash_table; - gint preview_size; - gint preview_border_width; - - GimpItemGetNameFunc get_name_func; + gint preview_size; + gint preview_border_width; }; struct _GimpContainerMenuClass @@ -95,9 +93,8 @@ void gimp_container_menu_set_container (GimpContainerMenu *menu, void gimp_container_menu_set_context (GimpContainerMenu *menu, GimpContext *context); void gimp_container_menu_set_preview_size (GimpContainerMenu *menu, - gint preview_size); -void gimp_container_menu_set_name_func (GimpContainerMenu *menu, - GimpItemGetNameFunc get_name_func); + gint preview_size, + gint preview_border_width); void gimp_container_menu_select_item (GimpContainerMenu *menu, GimpViewable *viewable); diff --git a/app/widgets/gimpcontainermenuimpl.c b/app/widgets/gimpcontainermenuimpl.c index e941af3ce9..7991451271 100644 --- a/app/widgets/gimpcontainermenuimpl.c +++ b/app/widgets/gimpcontainermenuimpl.c @@ -176,9 +176,6 @@ gimp_container_menu_impl_insert_item (GimpContainerMenu *menu, menu->preview_size, 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_CALLBACK (gimp_container_menu_impl_item_selected), menu); diff --git a/app/widgets/gimpcontainertreeview.c b/app/widgets/gimpcontainertreeview.c index df0469cc33..faa4387418 100644 --- a/app/widgets/gimpcontainertreeview.c +++ b/app/widgets/gimpcontainertreeview.c @@ -286,10 +286,7 @@ gimp_container_tree_view_set (GimpContainerTreeView *tree_view, view = GIMP_CONTAINER_VIEW (tree_view); - if (view->get_name_func) - name = view->get_name_func (G_OBJECT (viewable), NULL); - else - name = g_strdup (gimp_object_get_name (GIMP_OBJECT (viewable))); + name = gimp_viewable_get_description (viewable, NULL); renderer = gimp_preview_renderer_new (G_TYPE_FROM_INSTANCE (viewable), view->preview_size, @@ -883,10 +880,7 @@ gimp_container_tree_view_name_changed (GimpObject *object, { gchar *name; - if (view->get_name_func) - name = view->get_name_func (G_OBJECT (object), NULL); - else - name = g_strdup (gimp_object_get_name (object)); + name = gimp_viewable_get_description (GIMP_VIEWABLE (object), NULL); gtk_list_store_set (GTK_LIST_STORE (tree_view->model), iter, COLUMN_NAME, name, diff --git a/app/widgets/gimpcontainerview-utils.c b/app/widgets/gimpcontainerview-utils.c index 030ee87ccf..69616681cb 100644 --- a/app/widgets/gimpcontainerview-utils.c +++ b/app/widgets/gimpcontainerview-utils.c @@ -22,61 +22,10 @@ #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 "gimpcontainerview.h" #include "gimpcontainerview-utils.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 */ @@ -104,291 +53,3 @@ gimp_container_view_get_by_dockable (GimpDockable *dockable) 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"); -} diff --git a/app/widgets/gimpcontainerview-utils.h b/app/widgets/gimpcontainerview-utils.h index 6639650c4d..b15356e02a 100644 --- a/app/widgets/gimpcontainerview-utils.h +++ b/app/widgets/gimpcontainerview-utils.h @@ -23,17 +23,7 @@ #define __GIMP_CONTAINER_VIEW_UTILS_H__ -/* public */ - 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__ */ diff --git a/app/widgets/gimpcontainerview.c b/app/widgets/gimpcontainerview.c index f15b06aaa6..1a0252f49d 100644 --- a/app/widgets/gimpcontainerview.c +++ b/app/widgets/gimpcontainerview.c @@ -33,7 +33,6 @@ #include "core/gimpviewable.h" #include "gimpcontainerview.h" -#include "gimpcontainerview-utils.h" #include "gimpdnd.h" #include "gimppreviewrenderer.h" @@ -187,7 +186,6 @@ gimp_container_view_init (GimpContainerView *view, view->preview_size = 0; view->preview_border_width = 1; view->reorderable = FALSE; - view->get_name_func = NULL; view->scrolled_win = gtk_scrolled_window_new (NULL, NULL); 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); } } - - 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; 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, (GFunc) gimp_container_view_add_foreach, 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 gimp_container_view_enable_dnd (GimpContainerView *view, GtkButton *button, diff --git a/app/widgets/gimpcontainerview.h b/app/widgets/gimpcontainerview.h index 988f5daa7b..85ff33a375 100644 --- a/app/widgets/gimpcontainerview.h +++ b/app/widgets/gimpcontainerview.h @@ -38,23 +38,21 @@ typedef struct _GimpContainerViewClass GimpContainerViewClass; struct _GimpContainerView { - GimpEditor parent_instance; + GimpEditor parent_instance; - GimpContainer *container; - GimpContext *context; + GimpContainer *container; + GimpContext *context; - GHashTable *hash_table; + GHashTable *hash_table; - gint preview_size; - gint preview_border_width; - gboolean reorderable; + gint preview_size; + gint preview_border_width; + gboolean reorderable; - GimpItemGetNameFunc get_name_func; - - GtkWidget *scrolled_win; + GtkWidget *scrolled_win; /* initialized by subclass */ - GtkWidget *dnd_widget; + GtkWidget *dnd_widget; }; struct _GimpContainerViewClass @@ -109,8 +107,6 @@ void gimp_container_view_set_context (GimpContainerView *view, void gimp_container_view_set_preview_size (GimpContainerView *view, gint preview_size, 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, GtkButton *button, diff --git a/app/widgets/gimpimagedock.c b/app/widgets/gimpimagedock.c index db51b04513..8975ae24b3 100644 --- a/app/widgets/gimpimagedock.c +++ b/app/widgets/gimpimagedock.c @@ -222,7 +222,7 @@ gimp_image_dock_style_set (GtkWidget *widget, gtk_widget_set_size_request (widget, minimal_width, -1); 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, menu_preview_height + diff --git a/app/widgets/gimpmenudock.c b/app/widgets/gimpmenudock.c index db51b04513..8975ae24b3 100644 --- a/app/widgets/gimpmenudock.c +++ b/app/widgets/gimpmenudock.c @@ -222,7 +222,7 @@ gimp_image_dock_style_set (GtkWidget *widget, gtk_widget_set_size_request (widget, minimal_width, -1); 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, menu_preview_height + diff --git a/app/widgets/gimpmenuitem.c b/app/widgets/gimpmenuitem.c index 53acaee996..da10872c32 100644 --- a/app/widgets/gimpmenuitem.c +++ b/app/widgets/gimpmenuitem.c @@ -102,7 +102,6 @@ gimp_menu_item_init (GimpMenuItem *menu_item) menu_item->preview_size = 0; menu_item->preview_border_width = 1; - menu_item->get_name_func = NULL; } GtkWidget * @@ -176,47 +175,20 @@ gimp_menu_item_real_set_viewable (GimpMenuItem *menu_item, 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 gimp_menu_item_name_changed (GimpViewable *viewable, GimpMenuItem *menu_item) { - if (menu_item->get_name_func) - { - gchar *name = NULL; - gchar *tooltip = NULL; + gchar *name = 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); - gimp_help_set_help_data (GTK_WIDGET (menu_item), tooltip, NULL); + gtk_label_set_text (GTK_LABEL (menu_item->name_label), name); + gimp_help_set_help_data (GTK_WIDGET (menu_item), tooltip, NULL); - g_free (name); - g_free (tooltip); - } - else - { - gtk_label_set_text (GTK_LABEL (menu_item->name_label), - gimp_object_get_name (GIMP_OBJECT (viewable))); - } + g_free (name); + g_free (tooltip); } static GimpViewable * diff --git a/app/widgets/gimpmenuitem.h b/app/widgets/gimpmenuitem.h index 59583f86ea..0789bd94ab 100644 --- a/app/widgets/gimpmenuitem.h +++ b/app/widgets/gimpmenuitem.h @@ -37,19 +37,15 @@ typedef struct _GimpMenuItemClass GimpMenuItemClass; struct _GimpMenuItem { - GtkMenuItem parent_instance; + GtkMenuItem parent_instance; - GtkWidget *hbox; + GtkWidget *hbox; - GtkWidget *preview; - GtkWidget *name_label; + GtkWidget *preview; + GtkWidget *name_label; - /*< protected >*/ - gint preview_size; - gint preview_border_width; - - /*< private >*/ - GimpItemGetNameFunc get_name_func; + gint preview_size; + gint preview_border_width; }; struct _GimpMenuItemClass @@ -68,8 +64,5 @@ GtkWidget * gimp_menu_item_new (GimpViewable *viewable, gint preview_size, gint preview_border_width); -void gimp_menu_item_set_name_func (GimpMenuItem *menu_item, - GimpItemGetNameFunc get_name_func); - #endif /* __GIMP_MENU_ITEM_H__ */ diff --git a/app/widgets/gimpviewabledialog.c b/app/widgets/gimpviewabledialog.c index c1a6aba986..1293b49216 100644 --- a/app/widgets/gimpviewabledialog.c +++ b/app/widgets/gimpviewabledialog.c @@ -32,7 +32,6 @@ #include "file/file-utils.h" -#include "gimpcontainerview-utils.h" #include "gimppreview.h" #include "gimpviewabledialog.h" @@ -295,19 +294,9 @@ static void gimp_viewable_dialog_name_changed (GimpObject *object, 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)); - - if (get_name_func && dialog->preview) - { - name = get_name_func (G_OBJECT (dialog->preview), NULL); - } - else - { - name = g_strdup (gimp_object_get_name (object)); - } + name = gimp_viewable_get_description (GIMP_VIEWABLE (object), NULL); if (GIMP_IS_ITEM (object)) { diff --git a/app/widgets/widgets-types.h b/app/widgets/widgets-types.h index fe393356b2..9d6f83b06a 100644 --- a/app/widgets/widgets-types.h +++ b/app/widgets/widgets-types.h @@ -114,11 +114,9 @@ typedef struct _GimpItemFactoryEntry GimpItemFactoryEntry; /* function types */ -typedef void (* GimpItemFactorySetupFunc) (GimpItemFactory *factory); -typedef void (* GimpItemFactoryUpdateFunc) (GtkItemFactory *factory, - gpointer data); -typedef gchar * (* GimpItemGetNameFunc) (GObject *object, - gchar **tooltip); +typedef void (* GimpItemFactorySetupFunc) (GimpItemFactory *factory); +typedef void (* GimpItemFactoryUpdateFunc) (GtkItemFactory *factory, + gpointer data); #endif /* __WIDGETS_TYPES_H__ */ diff --git a/tools/pdbgen/pdb/fileops.pdb b/tools/pdbgen/pdb/fileops.pdb index c49538057e..bba295ea79 100644 --- a/tools/pdbgen/pdb/fileops.pdb +++ b/tools/pdbgen/pdb/fileops.pdb @@ -198,7 +198,7 @@ HELP tname = g_build_filename (pname, ".xvpics", fname, NULL); g_free (pname); g_free (fname); - raw_thumb = readXVThumb (tname, &width, &height, &imginfo); + raw_thumb = file_utils_readXVThumb (tname, &width, &height, &imginfo); g_free (tname); if (raw_thumb)