diff --git a/ChangeLog b/ChangeLog index d0925efc6b..5db5ec5c53 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,50 @@ +2003-08-25 Michael Natterer + + * app/core/gimpobject.[ch]: changed GimpObject::get_memsize() to + return a second value named "gui_size", where the primary return + value is the "constant" actual size (as long as no operation is + performed on the object), and the second "gui_size" return value + is the size of temporary stuff like preview caches or boundary + segments (which may change asynchronously, even if the object is + on the undo stack). + + * app/core/gimp.c + * app/core/gimpbrush.c + * app/core/gimpbrushpipe.c + * app/core/gimpbuffer.c + * app/core/gimpchannel.c + * app/core/gimpcontainer.c + * app/core/gimpcontext.c + * app/core/gimpdata.c + * app/core/gimpdatafactory.c + * app/core/gimpdrawable.c + * app/core/gimpgradient.c + * app/core/gimpimage-undo.c + * app/core/gimpimage.c + * app/core/gimpitem.c + * app/core/gimplayer.c + * app/core/gimplist.c + * app/core/gimppalette.c + * app/core/gimpparasitelist.c + * app/core/gimppattern.c + * app/core/gimpundo.c + * app/core/gimpundostack.c + * app/core/gimpviewable.c + * app/text/gimptextlayer.c + * app/vectors/gimpstroke.c + * app/vectors/gimpvectors.c: changed get_memsize() implementations + accordingly. + + * app/display/gimpdisplayshell-title.c + * app/gui/debug-commands.c + * app/widgets/gimppreview.c: changed callers accordingly. + + * app/core/gimpimage-undo-push.c: changed layer, channel, vectors + and layer_mask undo steps to add/subtract the size of the + resp. objects whenever they take/drop ownership of them. Ignore + the objects' "gui_size" to get identical sizes on + adding/subtracting. Fixes bug #120429. + 2003-08-25 Michael Natterer * app/display/gimpnavigationview.c: forgot this one. diff --git a/app/actions/debug-commands.c b/app/actions/debug-commands.c index 04be617426..df779fc9ea 100644 --- a/app/actions/debug-commands.c +++ b/app/actions/debug-commands.c @@ -93,7 +93,7 @@ debug_mem_profile_cmd_callback (GtkWidget *widget, gimp_debug_memsize = TRUE; - gimp_object_get_memsize (GIMP_OBJECT (data)); + gimp_object_get_memsize (GIMP_OBJECT (data), NULL); gimp_debug_memsize = FALSE; } @@ -111,73 +111,33 @@ debug_dump_menus_recurse_menu (GtkWidget *menu, GList *list; const gchar *label; gchar *help_page; - gchar *help_path; - gchar *factory_path; - gchar *hash; gchar *full_path; gchar *format_str; for (list = GTK_MENU_SHELL (menu)->children; list; list = g_list_next (list)) { menu_item = GTK_WIDGET (list->data); - + if (GTK_IS_LABEL (GTK_BIN (menu_item)->child)) { label = gtk_label_get_text (GTK_LABEL (GTK_BIN (menu_item)->child)); full_path = g_strconcat (path, "/", label, NULL); item_factory = GTK_ITEM_FACTORY (gimp_item_factory_from_path (path)); - help_page = g_object_get_data (G_OBJECT (menu_item), "help_page"); + help_page = g_object_get_data (G_OBJECT (menu_item), + "gimp-help-id"); - if (item_factory) - { - factory_path = g_object_get_data (G_OBJECT (item_factory), - "factory_path"); + help_page = g_strdup (help_page); - if (factory_path) - { - help_page = g_build_filename (factory_path, help_page, NULL); - } - else - { - help_page = g_strdup (help_page); - } - } - else - { - help_page = g_strdup (help_page); - } - - if (help_page) - { - help_path = g_build_filename (gimp_data_directory (), - "help", "C", help_page, NULL); - - if ((hash = strchr (help_path, '#')) != NULL) - *hash = '\0'; - - if (g_file_test (help_path, G_FILE_TEST_EXISTS)) - { - g_free (help_path); - help_path = g_strconcat ("! ", help_page, NULL); - g_free (help_page); - help_page = help_path; - } - else - { - g_free (help_path); - } - } - - format_str = g_strdup_printf ("%%%ds%%%ds %%-20s %%s\n", + format_str = g_strdup_printf ("%%%ds%%%ds %%-20s %%s\n", depth * 2, depth * 2 - 40); - g_print (format_str, + g_print (format_str, "", label, "", help_page ? help_page : ""); g_free (format_str); g_free (help_page); if (GTK_MENU_ITEM (menu_item)->submenu) - debug_dump_menus_recurse_menu (GTK_MENU_ITEM (menu_item)->submenu, + debug_dump_menus_recurse_menu (GTK_MENU_ITEM (menu_item)->submenu, depth + 1, full_path); g_free (full_path); diff --git a/app/core/gimp.c b/app/core/gimp.c index 71dc51c96b..6983e03457 100644 --- a/app/core/gimp.c +++ b/app/core/gimp.c @@ -82,7 +82,8 @@ static void gimp_init (Gimp *gimp); static void gimp_dispose (GObject *object); static void gimp_finalize (GObject *object); -static gsize gimp_get_memsize (GimpObject *object); +static gsize gimp_get_memsize (GimpObject *object, + gsize *gui_size); static gboolean gimp_real_exit (Gimp *gimp, gboolean kill_it); @@ -100,7 +101,7 @@ static GimpObjectClass *parent_class = NULL; static guint gimp_signals[LAST_SIGNAL] = { 0, }; -GType +GType gimp_get_type (void) { static GType object_type = 0; @@ -121,7 +122,7 @@ gimp_get_type (void) }; object_type = g_type_register_static (GIMP_TYPE_OBJECT, - "Gimp", + "Gimp", &object_info, 0); } @@ -202,8 +203,8 @@ gimp_init (Gimp *gimp) paint_init (gimp); gimp_modules_init (gimp); - - gimp->environ_table = gimp_environ_table_new (); + + gimp->environ_table = gimp_environ_table_new (); gimp->plug_in_debug = NULL; @@ -441,7 +442,8 @@ gimp_finalize (GObject *object) } static gsize -gimp_get_memsize (GimpObject *object) +gimp_get_memsize (GimpObject *object, + gsize *gui_size) { Gimp *gimp; gsize memsize = 0; @@ -450,7 +452,8 @@ gimp_get_memsize (GimpObject *object) memsize += g_list_length (gimp->user_units) * sizeof (GList); /* FIXME */ - memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->parasites)); + memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->parasites), + gui_size); memsize += gimp_g_object_get_memsize (G_OBJECT (gimp->module_db)); @@ -459,17 +462,24 @@ gimp_get_memsize (GimpObject *object) memsize += (g_hash_table_size (gimp->item_table) * 3 * sizeof (gpointer)); /* FIXME */ - memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->displays)); + memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->displays), gui_size); if (gimp->global_buffer) - memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->global_buffer)); + memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->global_buffer), + gui_size); - memsize += (gimp_object_get_memsize (GIMP_OBJECT (gimp->named_buffers)) + - gimp_object_get_memsize (GIMP_OBJECT (gimp->fonts)) + - gimp_object_get_memsize (GIMP_OBJECT (gimp->brush_factory)) + - gimp_object_get_memsize (GIMP_OBJECT (gimp->pattern_factory)) + - gimp_object_get_memsize (GIMP_OBJECT (gimp->gradient_factory)) + - gimp_object_get_memsize (GIMP_OBJECT (gimp->palette_factory))); + memsize += (gimp_object_get_memsize (GIMP_OBJECT (gimp->named_buffers), + gui_size) + + gimp_object_get_memsize (GIMP_OBJECT (gimp->fonts), + gui_size) + + gimp_object_get_memsize (GIMP_OBJECT (gimp->brush_factory), + gui_size) + + gimp_object_get_memsize (GIMP_OBJECT (gimp->pattern_factory), + gui_size) + + gimp_object_get_memsize (GIMP_OBJECT (gimp->gradient_factory), + gui_size) + + gimp_object_get_memsize (GIMP_OBJECT (gimp->palette_factory), + gui_size)); memsize += (g_hash_table_size (gimp->procedural_ht) * 3 * sizeof (gpointer)); /* FIXME */ @@ -480,19 +490,28 @@ gimp_get_memsize (GimpObject *object) memsize += g_slist_length (gimp->load_procs) * sizeof (GSList); /* FIXME */ memsize += g_slist_length (gimp->save_procs) * sizeof (GSList); /* FIXME */ - memsize += (gimp_object_get_memsize (GIMP_OBJECT (gimp->tool_info_list)) + - gimp_object_get_memsize (GIMP_OBJECT (gimp->standard_tool_info)) + - gimp_object_get_memsize (GIMP_OBJECT (gimp->documents)) + - gimp_object_get_memsize (GIMP_OBJECT (gimp->templates)) + - gimp_object_get_memsize (GIMP_OBJECT (gimp->image_new_last_template))); + memsize += (gimp_object_get_memsize (GIMP_OBJECT (gimp->tool_info_list), + gui_size) + + gimp_object_get_memsize (GIMP_OBJECT (gimp->standard_tool_info), + gui_size) + + gimp_object_get_memsize (GIMP_OBJECT (gimp->documents), + gui_size) + + gimp_object_get_memsize (GIMP_OBJECT (gimp->templates), + gui_size) + + gimp_object_get_memsize (GIMP_OBJECT (gimp->image_new_last_template), + gui_size)); memsize += g_list_length (gimp->context_list) * sizeof (GList); - memsize += (gimp_object_get_memsize (GIMP_OBJECT (gimp->standard_context)) + - gimp_object_get_memsize (GIMP_OBJECT (gimp->default_context)) + - gimp_object_get_memsize (GIMP_OBJECT (gimp->user_context))); + memsize += (gimp_object_get_memsize (GIMP_OBJECT (gimp->standard_context), + gui_size) + + gimp_object_get_memsize (GIMP_OBJECT (gimp->default_context), + gui_size) + + gimp_object_get_memsize (GIMP_OBJECT (gimp->user_context), + gui_size)); - return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); + return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, + gui_size); } static gboolean @@ -759,19 +778,19 @@ gimp_restore (Gimp *gimp, /* initialize the list of gimp brushes */ (* status_callback) (NULL, _("Brushes"), 0.15); - gimp_data_factory_data_init (gimp->brush_factory, no_data); + gimp_data_factory_data_init (gimp->brush_factory, no_data); /* initialize the list of gimp patterns */ (* status_callback) (NULL, _("Patterns"), 0.30); - gimp_data_factory_data_init (gimp->pattern_factory, no_data); + gimp_data_factory_data_init (gimp->pattern_factory, no_data); /* initialize the list of gimp palettes */ (* status_callback) (NULL, _("Palettes"), 0.45); - gimp_data_factory_data_init (gimp->palette_factory, no_data); + gimp_data_factory_data_init (gimp->palette_factory, no_data); /* initialize the list of gimp gradients */ (* status_callback) (NULL, _("Gradients"), 0.60); - gimp_data_factory_data_init (gimp->gradient_factory, no_data); + gimp_data_factory_data_init (gimp->gradient_factory, no_data); /* initialize the list of gimp fonts */ (* status_callback) (NULL, _("Fonts"), 0.70); diff --git a/app/core/gimpbrush-load.c b/app/core/gimpbrush-load.c index a9b355e54b..239eb35e6b 100644 --- a/app/core/gimpbrush-load.c +++ b/app/core/gimpbrush-load.c @@ -69,7 +69,8 @@ static void gimp_brush_init (GimpBrush *brush); static void gimp_brush_finalize (GObject *object); -static gsize gimp_brush_get_memsize (GimpObject *object); +static gsize gimp_brush_get_memsize (GimpObject *object, + gsize *gui_size); static gboolean gimp_brush_get_popup_size (GimpViewable *viewable, gint width, @@ -200,7 +201,8 @@ gimp_brush_finalize (GObject *object) } static gsize -gimp_brush_get_memsize (GimpObject *object) +gimp_brush_get_memsize (GimpObject *object, + gsize *gui_size) { GimpBrush *brush; gsize memsize = 0; @@ -213,7 +215,8 @@ gimp_brush_get_memsize (GimpObject *object) if (brush->pixmap) memsize += temp_buf_get_memsize (brush->pixmap); - return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); + return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, + gui_size); } static gboolean diff --git a/app/core/gimpbrush.c b/app/core/gimpbrush.c index a9b355e54b..239eb35e6b 100644 --- a/app/core/gimpbrush.c +++ b/app/core/gimpbrush.c @@ -69,7 +69,8 @@ static void gimp_brush_init (GimpBrush *brush); static void gimp_brush_finalize (GObject *object); -static gsize gimp_brush_get_memsize (GimpObject *object); +static gsize gimp_brush_get_memsize (GimpObject *object, + gsize *gui_size); static gboolean gimp_brush_get_popup_size (GimpViewable *viewable, gint width, @@ -200,7 +201,8 @@ gimp_brush_finalize (GObject *object) } static gsize -gimp_brush_get_memsize (GimpObject *object) +gimp_brush_get_memsize (GimpObject *object, + gsize *gui_size) { GimpBrush *brush; gsize memsize = 0; @@ -213,7 +215,8 @@ gimp_brush_get_memsize (GimpObject *object) if (brush->pixmap) memsize += temp_buf_get_memsize (brush->pixmap); - return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); + return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, + gui_size); } static gboolean diff --git a/app/core/gimpbrushpipe-load.c b/app/core/gimpbrushpipe-load.c index 8b1b009837..a122925c91 100644 --- a/app/core/gimpbrushpipe-load.c +++ b/app/core/gimpbrushpipe-load.c @@ -58,23 +58,24 @@ static void gimp_brush_pipe_class_init (GimpBrushPipeClass *klass); static void gimp_brush_pipe_init (GimpBrushPipe *pipe); -static void gimp_brush_pipe_finalize (GObject *object); +static void gimp_brush_pipe_finalize (GObject *object); -static gsize gimp_brush_pipe_get_memsize (GimpObject *object); +static gsize gimp_brush_pipe_get_memsize (GimpObject *object, + gsize *gui_size); -static gboolean gimp_brush_pipe_get_popup_size (GimpViewable *viewable, - gint width, - gint height, - gboolean dot_for_dot, - gint *popup_width, - gint *popup_height); +static gboolean gimp_brush_pipe_get_popup_size (GimpViewable *viewable, + gint width, + gint height, + gboolean dot_for_dot, + gint *popup_width, + gint *popup_height); -static GimpBrush * gimp_brush_pipe_select_brush (GimpBrush *brush, - GimpCoords *last_coords, - GimpCoords *cur_coords); -static gboolean gimp_brush_pipe_want_null_motion (GimpBrush *brush, - GimpCoords *last_coords, - GimpCoords *cur_coords); +static GimpBrush * gimp_brush_pipe_select_brush (GimpBrush *brush, + GimpCoords *last_coords, + GimpCoords *cur_coords); +static gboolean gimp_brush_pipe_want_null_motion (GimpBrush *brush, + GimpCoords *last_coords, + GimpCoords *cur_coords); static GimpBrushClass *parent_class = NULL; @@ -101,7 +102,7 @@ gimp_brush_pipe_get_type (void) }; brush_type = g_type_register_static (GIMP_TYPE_BRUSH, - "GimpBrushPipe", + "GimpBrushPipe", &brush_info, 0); } @@ -196,7 +197,8 @@ gimp_brush_pipe_finalize (GObject *object) } static gsize -gimp_brush_pipe_get_memsize (GimpObject *object) +gimp_brush_pipe_get_memsize (GimpObject *object, + gsize *gui_size) { GimpBrushPipe *pipe; gsize memsize = 0; @@ -209,11 +211,11 @@ gimp_brush_pipe_get_memsize (GimpObject *object) sizeof (PipeSelectModes)); for (i = 0; i < pipe->nbrushes; i++) - { - memsize += gimp_object_get_memsize (GIMP_OBJECT (pipe->brushes[i])); - } + memsize += gimp_object_get_memsize (GIMP_OBJECT (pipe->brushes[i]), + gui_size); - return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); + return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, + gui_size); } static gboolean @@ -358,7 +360,7 @@ gimp_brush_pipe_load (const gchar *filename, buffer = g_string_new (NULL); while (read (fd, &c, 1) == 1 && c != '\n' && buffer->len < 1024) g_string_append_c (buffer, c); - + if (buffer->len > 0 && buffer->len < 1024) { pipe = GIMP_BRUSH_PIPE (g_object_new (GIMP_TYPE_BRUSH_PIPE, NULL)); @@ -369,7 +371,7 @@ gimp_brush_pipe_load (const gchar *filename, } else { - g_message (_("Invalid UTF-8 string in brush file '%s'."), + g_message (_("Invalid UTF-8 string in brush file '%s'."), filename); gimp_object_set_name (GIMP_OBJECT (pipe), _("Unnamed")); } @@ -496,7 +498,7 @@ gimp_brush_pipe_load (const gchar *filename, g_object_unref (pipe); return NULL; } - + pipe->nbrushes++; } diff --git a/app/core/gimpbrushpipe.c b/app/core/gimpbrushpipe.c index 8b1b009837..a122925c91 100644 --- a/app/core/gimpbrushpipe.c +++ b/app/core/gimpbrushpipe.c @@ -58,23 +58,24 @@ static void gimp_brush_pipe_class_init (GimpBrushPipeClass *klass); static void gimp_brush_pipe_init (GimpBrushPipe *pipe); -static void gimp_brush_pipe_finalize (GObject *object); +static void gimp_brush_pipe_finalize (GObject *object); -static gsize gimp_brush_pipe_get_memsize (GimpObject *object); +static gsize gimp_brush_pipe_get_memsize (GimpObject *object, + gsize *gui_size); -static gboolean gimp_brush_pipe_get_popup_size (GimpViewable *viewable, - gint width, - gint height, - gboolean dot_for_dot, - gint *popup_width, - gint *popup_height); +static gboolean gimp_brush_pipe_get_popup_size (GimpViewable *viewable, + gint width, + gint height, + gboolean dot_for_dot, + gint *popup_width, + gint *popup_height); -static GimpBrush * gimp_brush_pipe_select_brush (GimpBrush *brush, - GimpCoords *last_coords, - GimpCoords *cur_coords); -static gboolean gimp_brush_pipe_want_null_motion (GimpBrush *brush, - GimpCoords *last_coords, - GimpCoords *cur_coords); +static GimpBrush * gimp_brush_pipe_select_brush (GimpBrush *brush, + GimpCoords *last_coords, + GimpCoords *cur_coords); +static gboolean gimp_brush_pipe_want_null_motion (GimpBrush *brush, + GimpCoords *last_coords, + GimpCoords *cur_coords); static GimpBrushClass *parent_class = NULL; @@ -101,7 +102,7 @@ gimp_brush_pipe_get_type (void) }; brush_type = g_type_register_static (GIMP_TYPE_BRUSH, - "GimpBrushPipe", + "GimpBrushPipe", &brush_info, 0); } @@ -196,7 +197,8 @@ gimp_brush_pipe_finalize (GObject *object) } static gsize -gimp_brush_pipe_get_memsize (GimpObject *object) +gimp_brush_pipe_get_memsize (GimpObject *object, + gsize *gui_size) { GimpBrushPipe *pipe; gsize memsize = 0; @@ -209,11 +211,11 @@ gimp_brush_pipe_get_memsize (GimpObject *object) sizeof (PipeSelectModes)); for (i = 0; i < pipe->nbrushes; i++) - { - memsize += gimp_object_get_memsize (GIMP_OBJECT (pipe->brushes[i])); - } + memsize += gimp_object_get_memsize (GIMP_OBJECT (pipe->brushes[i]), + gui_size); - return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); + return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, + gui_size); } static gboolean @@ -358,7 +360,7 @@ gimp_brush_pipe_load (const gchar *filename, buffer = g_string_new (NULL); while (read (fd, &c, 1) == 1 && c != '\n' && buffer->len < 1024) g_string_append_c (buffer, c); - + if (buffer->len > 0 && buffer->len < 1024) { pipe = GIMP_BRUSH_PIPE (g_object_new (GIMP_TYPE_BRUSH_PIPE, NULL)); @@ -369,7 +371,7 @@ gimp_brush_pipe_load (const gchar *filename, } else { - g_message (_("Invalid UTF-8 string in brush file '%s'."), + g_message (_("Invalid UTF-8 string in brush file '%s'."), filename); gimp_object_set_name (GIMP_OBJECT (pipe), _("Unnamed")); } @@ -496,7 +498,7 @@ gimp_brush_pipe_load (const gchar *filename, g_object_unref (pipe); return NULL; } - + pipe->nbrushes++; } diff --git a/app/core/gimpbuffer.c b/app/core/gimpbuffer.c index 704b16a227..dced604f6a 100644 --- a/app/core/gimpbuffer.c +++ b/app/core/gimpbuffer.c @@ -38,7 +38,8 @@ static void gimp_buffer_init (GimpBuffer *buffer); static void gimp_buffer_finalize (GObject *object); -static gsize gimp_buffer_get_memsize (GimpObject *object); +static gsize gimp_buffer_get_memsize (GimpObject *object, + gsize *gui_size); static void gimp_buffer_get_preview_size (GimpViewable *viewable, gint size, @@ -136,7 +137,8 @@ gimp_buffer_finalize (GObject *object) } static gsize -gimp_buffer_get_memsize (GimpObject *object) +gimp_buffer_get_memsize (GimpObject *object, + gsize *gui_size) { GimpBuffer *buffer; gsize memsize = 0; @@ -146,7 +148,8 @@ gimp_buffer_get_memsize (GimpObject *object) if (buffer->tiles) memsize += tile_manager_get_memsize (buffer->tiles); - return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); + return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, + gui_size); } static void diff --git a/app/core/gimpchannel-combine.c b/app/core/gimpchannel-combine.c index 2e1322fa3d..953d0c0a1d 100644 --- a/app/core/gimpchannel-combine.c +++ b/app/core/gimpchannel-combine.c @@ -55,7 +55,8 @@ static void gimp_channel_init (GimpChannel *channel); static void gimp_channel_finalize (GObject *object); -static gsize gimp_channel_get_memsize (GimpObject *object); +static gsize gimp_channel_get_memsize (GimpObject *object, + gsize *gui_size); static GimpItem * gimp_channel_duplicate (GimpItem *item, GType new_type, @@ -205,17 +206,17 @@ gimp_channel_finalize (GObject *object) } static gsize -gimp_channel_get_memsize (GimpObject *object) +gimp_channel_get_memsize (GimpObject *object, + gsize *gui_size) { GimpChannel *channel; - gsize memsize = 0; channel = GIMP_CHANNEL (object); - memsize += channel->num_segs_in * sizeof (BoundSeg); - memsize += channel->num_segs_out * sizeof (BoundSeg); + *gui_size += channel->num_segs_in * sizeof (BoundSeg); + *gui_size += channel->num_segs_out * sizeof (BoundSeg); - return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); + return GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, gui_size); } static GimpItem * diff --git a/app/core/gimpchannel.c b/app/core/gimpchannel.c index 2e1322fa3d..953d0c0a1d 100644 --- a/app/core/gimpchannel.c +++ b/app/core/gimpchannel.c @@ -55,7 +55,8 @@ static void gimp_channel_init (GimpChannel *channel); static void gimp_channel_finalize (GObject *object); -static gsize gimp_channel_get_memsize (GimpObject *object); +static gsize gimp_channel_get_memsize (GimpObject *object, + gsize *gui_size); static GimpItem * gimp_channel_duplicate (GimpItem *item, GType new_type, @@ -205,17 +206,17 @@ gimp_channel_finalize (GObject *object) } static gsize -gimp_channel_get_memsize (GimpObject *object) +gimp_channel_get_memsize (GimpObject *object, + gsize *gui_size) { GimpChannel *channel; - gsize memsize = 0; channel = GIMP_CHANNEL (object); - memsize += channel->num_segs_in * sizeof (BoundSeg); - memsize += channel->num_segs_out * sizeof (BoundSeg); + *gui_size += channel->num_segs_in * sizeof (BoundSeg); + *gui_size += channel->num_segs_out * sizeof (BoundSeg); - return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); + return GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, gui_size); } static GimpItem * diff --git a/app/core/gimpcontainer.c b/app/core/gimpcontainer.c index 5e32e5db02..9de1077841 100644 --- a/app/core/gimpcontainer.c +++ b/app/core/gimpcontainer.c @@ -98,7 +98,8 @@ static void gimp_container_get_property (GObject *object, GValue *value, GParamSpec *pspec); -static gsize gimp_container_get_memsize (GimpObject *object); +static gsize gimp_container_get_memsize (GimpObject *object, + gsize *gui_size); static gboolean gimp_container_serialize (GObject *object, GimpConfigWriter *writer, @@ -360,7 +361,8 @@ gimp_container_get_property (GObject *object, } static gsize -gimp_container_get_memsize (GimpObject *object) +gimp_container_get_memsize (GimpObject *object, + gsize *gui_size) { GimpContainer *container; GList *list; @@ -379,7 +381,8 @@ gimp_container_get_memsize (GimpObject *object) strlen (handler->signame)); } - return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); + return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, + gui_size); } typedef struct diff --git a/app/core/gimpcontext.c b/app/core/gimpcontext.c index 23c46000f0..de9aae70b9 100644 --- a/app/core/gimpcontext.c +++ b/app/core/gimpcontext.c @@ -56,7 +56,7 @@ #include "text/gimpfont.h" -#include "gimp-intl.h" +#include "gimp-intl.h" typedef void (* GimpContextCopyPropFunc) (GimpContext *src, @@ -87,7 +87,8 @@ static void gimp_context_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); -static gsize gimp_context_get_memsize (GimpObject *object); +static gsize gimp_context_get_memsize (GimpObject *object, + gsize *gui_size); static gboolean gimp_context_serialize (GObject *object, GimpConfigWriter *writer, @@ -340,7 +341,7 @@ gimp_context_get_type (void) 0, /* n_preallocs */ (GInstanceInitFunc) gimp_context_init, }; - static const GInterfaceInfo config_iface_info = + static const GInterfaceInfo config_iface_info = { (GInterfaceInitFunc) gimp_context_config_iface_init, NULL, /* iface_finalize */ @@ -348,7 +349,7 @@ gimp_context_get_type (void) }; context_type = g_type_register_static (GIMP_TYPE_OBJECT, - "GimpContext", + "GimpContext", &context_info, 0); g_type_add_interface_static (context_type, @@ -1073,7 +1074,8 @@ gimp_context_get_property (GObject *object, } static gsize -gimp_context_get_memsize (GimpObject *object) +gimp_context_get_memsize (GimpObject *object, + gsize *gui_size) { GimpContext *context; gsize memsize = 0; @@ -1095,7 +1097,8 @@ gimp_context_get_memsize (GimpObject *object) if (context->font_name) memsize += strlen (context->font_name) + 1; - return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); + return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, + gui_size); } static gboolean @@ -2207,7 +2210,7 @@ gimp_context_brush_list_thaw (GimpContainer *container, } if (gimp_container_num_children (container)) - gimp_context_real_set_brush + gimp_context_real_set_brush (context, GIMP_BRUSH (gimp_container_get_child_by_index (container, 0))); else gimp_context_real_set_brush (context, diff --git a/app/core/gimpdata.c b/app/core/gimpdata.c index 15197bc240..229eab7953 100644 --- a/app/core/gimpdata.c +++ b/app/core/gimpdata.c @@ -63,7 +63,8 @@ static void gimp_data_init (GimpData *data); static void gimp_data_finalize (GObject *object); static void gimp_data_name_changed (GimpObject *object); -static gsize gimp_data_get_memsize (GimpObject *object); +static gsize gimp_data_get_memsize (GimpObject *object, + gsize *gui_size); static void gimp_data_real_dirty (GimpData *data); @@ -112,7 +113,7 @@ gimp_data_class_init (GimpDataClass *klass) parent_class = g_type_class_peek_parent (klass); - data_signals[DIRTY] = + data_signals[DIRTY] = g_signal_new ("dirty", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, @@ -167,7 +168,8 @@ gimp_data_name_changed (GimpObject *object) } static gsize -gimp_data_get_memsize (GimpObject *object) +gimp_data_get_memsize (GimpObject *object, + gsize *gui_size) { GimpData *data; gsize memsize = 0; @@ -177,7 +179,8 @@ gimp_data_get_memsize (GimpObject *object) if (data->filename) memsize += strlen (data->filename) + 1; - return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); + return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, + gui_size); } gboolean diff --git a/app/core/gimpdatafactory.c b/app/core/gimpdatafactory.c index fae6c0d72d..d28cd1b8f6 100644 --- a/app/core/gimpdatafactory.c +++ b/app/core/gimpdatafactory.c @@ -47,7 +47,8 @@ static void gimp_data_factory_init (GimpDataFactory *factory); static void gimp_data_factory_finalize (GObject *object); -static gsize gimp_data_factory_get_memsize (GimpObject *object); +static gsize gimp_data_factory_get_memsize (GimpObject *object, + gsize *gui_size); static void gimp_data_factory_load_data (const GimpDatafileData *file_data, gpointer user_data); @@ -135,16 +136,19 @@ gimp_data_factory_finalize (GObject *object) } static gsize -gimp_data_factory_get_memsize (GimpObject *object) +gimp_data_factory_get_memsize (GimpObject *object, + gsize *gui_size) { GimpDataFactory *factory; gsize memsize = 0; factory = GIMP_DATA_FACTORY (object); - memsize += gimp_object_get_memsize (GIMP_OBJECT (factory->container)); + memsize += gimp_object_get_memsize (GIMP_OBJECT (factory->container), + gui_size); - return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); + return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, + gui_size); } GimpDataFactory * diff --git a/app/core/gimpdrawable.c b/app/core/gimpdrawable.c index 4b81f475f6..455eb37569 100644 --- a/app/core/gimpdrawable.c +++ b/app/core/gimpdrawable.c @@ -70,7 +70,8 @@ static void gimp_drawable_init (GimpDrawable *drawable) static void gimp_drawable_finalize (GObject *object); -static gsize gimp_drawable_get_memsize (GimpObject *object); +static gsize gimp_drawable_get_memsize (GimpObject *object, + gsize *gui_size); static void gimp_drawable_invalidate_preview (GimpViewable *viewable); @@ -228,7 +229,8 @@ gimp_drawable_finalize (GObject *object) } static gsize -gimp_drawable_get_memsize (GimpObject *object) +gimp_drawable_get_memsize (GimpObject *object, + gsize *gui_size) { GimpDrawable *drawable; gsize memsize = 0; @@ -239,9 +241,10 @@ gimp_drawable_get_memsize (GimpObject *object) memsize += tile_manager_get_memsize (drawable->tiles); if (drawable->preview_cache) - memsize += gimp_preview_cache_get_memsize (drawable->preview_cache); + *gui_size += gimp_preview_cache_get_memsize (drawable->preview_cache); - return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); + return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, + gui_size); } static void diff --git a/app/core/gimpgradient.c b/app/core/gimpgradient.c index 4b090ee74c..ba4da96124 100644 --- a/app/core/gimpgradient.c +++ b/app/core/gimpgradient.c @@ -47,7 +47,8 @@ static void gimp_gradient_init (GimpGradient *gradient); static void gimp_gradient_finalize (GObject *object); -static gsize gimp_gradient_get_memsize (GimpObject *object); +static gsize gimp_gradient_get_memsize (GimpObject *object, + gsize *gui_size); static void gimp_gradient_get_preview_size (GimpViewable *viewable, gint size, @@ -167,7 +168,8 @@ gimp_gradient_finalize (GObject *object) } static gsize -gimp_gradient_get_memsize (GimpObject *object) +gimp_gradient_get_memsize (GimpObject *object, + gsize *gui_size) { GimpGradient *gradient; GimpGradientSegment *segment; @@ -176,11 +178,10 @@ gimp_gradient_get_memsize (GimpObject *object) gradient = GIMP_GRADIENT (object); for (segment = gradient->segments; segment; segment = segment->next) - { - memsize += sizeof (GimpGradientSegment); - } + memsize += sizeof (GimpGradientSegment); - return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); + return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, + gui_size); } static void diff --git a/app/core/gimpimage-undo-push.c b/app/core/gimpimage-undo-push.c index 049f5ac888..30f9a286d4 100644 --- a/app/core/gimpimage-undo-push.c +++ b/app/core/gimpimage-undo-push.c @@ -269,7 +269,7 @@ undo_pop_image (GimpUndo *undo, tile_data_pointer (dest_tile, 0, 0), tile_size (src_tile)); #endif - + tile_release (dest_tile, FALSE /* TRUE */); tile_release (src_tile, FALSE /* TRUE */); } @@ -1109,7 +1109,7 @@ static void undo_free_item_rename (GimpUndo *undo, GimpUndoMode undo_mode); gboolean -gimp_image_undo_push_item_rename (GimpImage *gimage, +gimp_image_undo_push_item_rename (GimpImage *gimage, const gchar *undo_desc, GimpItem *item) { @@ -1357,7 +1357,7 @@ static void undo_free_drawable_visibility (GimpUndo *undo, GimpUndoMode undo_mode); gboolean -gimp_image_undo_push_drawable_visibility (GimpImage *gimage, +gimp_image_undo_push_drawable_visibility (GimpImage *gimage, const gchar *undo_desc, GimpDrawable *drawable) { @@ -1478,7 +1478,10 @@ undo_push_layer (GimpImage *gimage, g_return_val_if_fail (type == GIMP_UNDO_LAYER_ADD || type == GIMP_UNDO_LAYER_REMOVE, FALSE); - size = sizeof (LayerUndo) + gimp_object_get_memsize (GIMP_OBJECT (layer)); + size = sizeof (LayerUndo); + + if (type == GIMP_UNDO_LAYER_REMOVE) + size += gimp_object_get_memsize (GIMP_OBJECT (layer), NULL); if ((new = gimp_image_undo_push_item (gimage, GIMP_ITEM (layer), size, sizeof (LayerUndo), @@ -1519,9 +1522,14 @@ undo_pop_layer (GimpUndo *undo, { /* remove layer */ + g_print ("undo_pop_layer: taking ownership, size += %d\n", + gimp_object_get_memsize (GIMP_OBJECT (layer), NULL)); + + undo->size += gimp_object_get_memsize (GIMP_OBJECT (layer), NULL); + /* Make sure we're not caching any old selection info */ gimp_layer_invalidate_boundary (layer); - + /* record the current position */ lu->prev_position = gimp_image_get_layer_index (undo->gimage, layer); @@ -1570,6 +1578,11 @@ undo_pop_layer (GimpUndo *undo, { /* restore layer */ + g_print ("undo_pop_layer: dropping ownership, size -= %d\n", + gimp_object_get_memsize (GIMP_OBJECT (layer), NULL)); + + undo->size -= gimp_object_get_memsize (GIMP_OBJECT (layer), NULL); + /* record the active layer */ lu->prev_layer = gimp_image_get_active_layer (undo->gimage); @@ -1588,7 +1601,7 @@ undo_pop_layer (GimpUndo *undo, } /* add the new layer */ - gimp_container_insert (undo->gimage->layers, + gimp_container_insert (undo->gimage->layers, GIMP_OBJECT (layer), lu->prev_position); gimp_image_set_active_layer (undo->gimage, layer); @@ -1738,7 +1751,7 @@ undo_pop_layer_mod (GimpUndo *undo, /* Issue the second update */ gimp_drawable_update (GIMP_DRAWABLE (layer), - 0, 0, + 0, 0, GIMP_ITEM (layer)->width, GIMP_ITEM (layer)->height); @@ -1816,7 +1829,10 @@ undo_push_layer_mask (GimpImage *gimage, g_return_val_if_fail (type == GIMP_UNDO_LAYER_MASK_ADD || type == GIMP_UNDO_LAYER_MASK_REMOVE, FALSE); - size = sizeof (LayerMaskUndo) + gimp_object_get_memsize (GIMP_OBJECT (mask)); + size = sizeof (LayerMaskUndo); + + if (type == GIMP_UNDO_LAYER_MASK_REMOVE) + size += gimp_object_get_memsize (GIMP_OBJECT (mask), NULL); if ((new = gimp_image_undo_push_item (gimage, GIMP_ITEM (layer), size, @@ -1857,12 +1873,16 @@ undo_pop_layer_mask (GimpUndo *undo, { /* remove layer mask */ + undo->size += gimp_object_get_memsize (GIMP_OBJECT (lmu->mask), NULL); + gimp_layer_apply_mask (layer, GIMP_MASK_DISCARD, FALSE); } else { /* restore layer */ + undo->size -= gimp_object_get_memsize (GIMP_OBJECT (lmu->mask), NULL); + gimp_layer_add_mask (layer, lmu->mask, FALSE); } @@ -1900,7 +1920,7 @@ static void undo_free_layer_reposition (GimpUndo *undo, GimpUndoMode undo_mode); gboolean -gimp_image_undo_push_layer_reposition (GimpImage *gimage, +gimp_image_undo_push_layer_reposition (GimpImage *gimage, const gchar *undo_desc, GimpLayer *layer) { @@ -1911,7 +1931,7 @@ gimp_image_undo_push_layer_reposition (GimpImage *gimage, if ((new = gimp_image_undo_push_item (gimage, GIMP_ITEM (layer), sizeof (LayerRepositionUndo), - sizeof (LayerRepositionUndo), + sizeof (LayerRepositionUndo), GIMP_UNDO_LAYER_REPOSITION, undo_desc, TRUE, undo_pop_layer_reposition, @@ -2154,7 +2174,10 @@ undo_push_channel (GimpImage *gimage, g_return_val_if_fail (type == GIMP_UNDO_CHANNEL_ADD || type == GIMP_UNDO_CHANNEL_REMOVE, FALSE); - size = sizeof (ChannelUndo) + gimp_object_get_memsize (GIMP_OBJECT (channel)); + size = sizeof (ChannelUndo); + + if (type == GIMP_UNDO_CHANNEL_REMOVE) + size += gimp_object_get_memsize (GIMP_OBJECT (channel), NULL); if ((new = gimp_image_undo_push_item (gimage, GIMP_ITEM (channel), size, @@ -2196,6 +2219,8 @@ undo_pop_channel (GimpUndo *undo, { /* remove channel */ + undo->size += gimp_object_get_memsize (GIMP_OBJECT (channel), NULL); + /* record the current position */ cu->prev_position = gimp_image_get_channel_index (undo->gimage, channel); @@ -2215,7 +2240,7 @@ undo_pop_channel (GimpUndo *undo, /* update the area */ gimp_drawable_update (GIMP_DRAWABLE (channel), - 0, 0, + 0, 0, GIMP_ITEM (channel)->width, GIMP_ITEM (channel)->height); } @@ -2223,17 +2248,19 @@ undo_pop_channel (GimpUndo *undo, { /* restore channel */ + undo->size -= gimp_object_get_memsize (GIMP_OBJECT (channel), NULL); + /* record the active channel */ cu->prev_channel = gimp_image_get_active_channel (undo->gimage); /* add the new channel */ - gimp_container_insert (undo->gimage->channels, + gimp_container_insert (undo->gimage->channels, GIMP_OBJECT (channel), cu->prev_position); gimp_image_set_active_channel (undo->gimage, channel); /* update the area */ gimp_drawable_update (GIMP_DRAWABLE (channel), - 0, 0, + 0, 0, GIMP_ITEM (channel)->width, GIMP_ITEM (channel)->height); } @@ -2393,7 +2420,7 @@ static void undo_free_channel_reposition (GimpUndo *undo, GimpUndoMode undo_mode); gboolean -gimp_image_undo_push_channel_reposition (GimpImage *gimage, +gimp_image_undo_push_channel_reposition (GimpImage *gimage, const gchar *undo_desc, GimpChannel *channel) { @@ -2469,7 +2496,7 @@ static void undo_free_channel_color (GimpUndo *undo, GimpUndoMode undo_mode); gboolean -gimp_image_undo_push_channel_color (GimpImage *gimage, +gimp_image_undo_push_channel_color (GimpImage *gimage, const gchar *undo_desc, GimpChannel *channel) { @@ -2590,7 +2617,10 @@ undo_push_vectors (GimpImage *gimage, g_return_val_if_fail (type == GIMP_UNDO_VECTORS_ADD || type == GIMP_UNDO_VECTORS_REMOVE, FALSE); - size = sizeof (VectorsUndo) + gimp_object_get_memsize (GIMP_OBJECT (vectors)); + size = sizeof (VectorsUndo); + + if (type == GIMP_UNDO_VECTORS_REMOVE) + size += gimp_object_get_memsize (GIMP_OBJECT (vectors), NULL); if ((new = gimp_image_undo_push_item (gimage, GIMP_ITEM (vectors), size, @@ -2632,6 +2662,8 @@ undo_pop_vectors (GimpUndo *undo, { /* remove vectors */ + undo->size += gimp_object_get_memsize (GIMP_OBJECT (vectors), NULL); + /* record the current position */ vu->prev_position = gimp_image_get_vectors_index (undo->gimage, vectors); @@ -2658,11 +2690,13 @@ undo_pop_vectors (GimpUndo *undo, { /* restore vectors */ + undo->size -= gimp_object_get_memsize (GIMP_OBJECT (vectors), NULL); + /* record the active vectors */ vu->prev_vectors = gimp_image_get_active_vectors (undo->gimage); /* add the new vectors */ - gimp_container_insert (undo->gimage->vectors, + gimp_container_insert (undo->gimage->vectors, GIMP_OBJECT (vectors), vu->prev_position); gimp_image_set_active_vectors (undo->gimage, vectors); } @@ -2707,7 +2741,7 @@ gimp_image_undo_push_vectors_mod (GimpImage *gimage, g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE); size = (sizeof (VectorsModUndo) + - gimp_object_get_memsize (GIMP_OBJECT (vectors))); + gimp_object_get_memsize (GIMP_OBJECT (vectors), NULL)); if ((new = gimp_image_undo_push_item (gimage, GIMP_ITEM (vectors), size, @@ -2798,7 +2832,7 @@ static void undo_free_vectors_reposition (GimpUndo *undo, GimpUndoMode undo_mode); gboolean -gimp_image_undo_push_vectors_reposition (GimpImage *gimage, +gimp_image_undo_push_vectors_reposition (GimpImage *gimage, const gchar *undo_desc, GimpVectors *vectors) { @@ -2931,10 +2965,10 @@ undo_pop_fs_to_layer (GimpUndo *undo, undo->gimage->floating_sel = fsu->floating_layer; /* restore the contents of the drawable */ - floating_sel_store (fsu->floating_layer, - GIMP_ITEM (fsu->floating_layer)->offset_x, + floating_sel_store (fsu->floating_layer, + GIMP_ITEM (fsu->floating_layer)->offset_x, GIMP_ITEM (fsu->floating_layer)->offset_y, - GIMP_ITEM (fsu->floating_layer)->width, + GIMP_ITEM (fsu->floating_layer)->width, GIMP_ITEM (fsu->floating_layer)->height); fsu->floating_layer->fs.initial = TRUE; @@ -2947,10 +2981,10 @@ undo_pop_fs_to_layer (GimpUndo *undo, case GIMP_UNDO_MODE_REDO: /* restore the contents of the drawable */ - floating_sel_restore (fsu->floating_layer, - GIMP_ITEM (fsu->floating_layer)->offset_x, + floating_sel_restore (fsu->floating_layer, + GIMP_ITEM (fsu->floating_layer)->offset_x, GIMP_ITEM (fsu->floating_layer)->offset_y, - GIMP_ITEM (fsu->floating_layer)->width, + GIMP_ITEM (fsu->floating_layer)->width, GIMP_ITEM (fsu->floating_layer)->height); /* Update the preview for the gimage and underlying drawable */ diff --git a/app/core/gimpimage-undo.c b/app/core/gimpimage-undo.c index 9f2596fe91..4aca89cc86 100644 --- a/app/core/gimpimage-undo.c +++ b/app/core/gimpimage-undo.c @@ -348,14 +348,14 @@ gimp_image_undo_free_space (GimpImage *gimage) #if 0 g_print ("undo_steps: %d undo_bytes: %d\n", gimp_container_num_children (container), - gimp_object_get_memsize (GIMP_OBJECT (container))); + gimp_object_get_memsize (GIMP_OBJECT (container), NULL)); #endif /* keep at least min_undo_levels undo steps */ if (gimp_container_num_children (container) <= min_undo_levels) return; - while ((gimp_object_get_memsize (GIMP_OBJECT (container)) > undo_size) || + while ((gimp_object_get_memsize (GIMP_OBJECT (container), NULL) > undo_size) || (gimp_container_num_children (container) > max_undo_levels)) { GimpUndo *freed; @@ -366,7 +366,7 @@ gimp_image_undo_free_space (GimpImage *gimage) #if 0 g_print ("freed one step: undo_steps: %d undo_bytes: %d\n", gimp_container_num_children (container), - gimp_object_get_memsize (GIMP_OBJECT (container))); + gimp_object_get_memsize (GIMP_OBJECT (container), NULL)); #endif gimp_image_undo_event (gimage, GIMP_UNDO_EVENT_UNDO_EXPIRED, freed); @@ -388,7 +388,7 @@ gimp_image_undo_free_redo (GimpImage *gimage) #if 0 g_print ("redo_steps: %d redo_bytes: %d\n", gimp_container_num_children (container), - gimp_object_get_memsize (GIMP_OBJECT (container))); + gimp_object_get_memsize (GIMP_OBJECT (container)), NULL); #endif while (gimp_container_num_children (container) > 0) @@ -401,7 +401,7 @@ gimp_image_undo_free_redo (GimpImage *gimage) #if 0 g_print ("freed one step: redo_steps: %d redo_bytes: %d\n", gimp_container_num_children (container), - gimp_object_get_memsize (GIMP_OBJECT (container))); + gimp_object_get_memsize (GIMP_OBJECT (container)), NULL); #endif gimp_image_undo_event (gimage, GIMP_UNDO_EVENT_REDO_EXPIRED, freed); diff --git a/app/core/gimpimage.c b/app/core/gimpimage.c index 622e7a2502..7a80dcc931 100644 --- a/app/core/gimpimage.c +++ b/app/core/gimpimage.c @@ -107,7 +107,8 @@ static void gimp_image_dispose (GObject *object); static void gimp_image_finalize (GObject *object); static void gimp_image_name_changed (GimpObject *object); -static gsize gimp_image_get_memsize (GimpObject *object); +static gsize gimp_image_get_memsize (GimpObject *object, + gsize *gui_size); static void gimp_image_invalidate_preview (GimpViewable *viewable); static void gimp_image_size_changed (GimpViewable *viewable); @@ -142,8 +143,8 @@ static guint gimp_image_signals[LAST_SIGNAL] = { 0 }; static GimpViewableClass *parent_class = NULL; -GType -gimp_image_get_type (void) +GType +gimp_image_get_type (void) { static GType image_type = 0; @@ -260,7 +261,7 @@ gimp_image_class_init (GimpImageClass *klass) G_TYPE_NONE, 1, GIMP_TYPE_CHANNEL_TYPE); - gimp_image_signals[GRID_CHANGED] = + gimp_image_signals[GRID_CHANGED] = g_signal_new ("grid_changed", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, @@ -375,7 +376,7 @@ gimp_image_class_init (GimpImageClass *klass) gimp_marshal_VOID__VOID, G_TYPE_NONE, 0); - gimp_image_signals[UNDO_EVENT] = + gimp_image_signals[UNDO_EVENT] = g_signal_new ("undo_event", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, @@ -433,7 +434,7 @@ gimp_image_class_init (GimpImageClass *klass) gimp_image_color_hash_init (); } -static void +static void gimp_image_init (GimpImage *gimage) { gimage->ID = 0; @@ -468,9 +469,9 @@ gimp_image_init (GimpImage *gimage) gimage->grid = NULL; - gimage->layers = gimp_list_new (GIMP_TYPE_LAYER, + gimage->layers = gimp_list_new (GIMP_TYPE_LAYER, GIMP_CONTAINER_POLICY_STRONG); - gimage->channels = gimp_list_new (GIMP_TYPE_CHANNEL, + gimage->channels = gimp_list_new (GIMP_TYPE_CHANNEL, GIMP_CONTAINER_POLICY_STRONG); gimage->vectors = gimp_list_new (GIMP_TYPE_VECTORS, GIMP_CONTAINER_POLICY_STRONG); @@ -626,7 +627,8 @@ gimp_image_name_changed (GimpObject *object) } static gsize -gimp_image_get_memsize (GimpObject *object) +gimp_image_get_memsize (GimpObject *object, + gsize *gui_size) { GimpImage *gimage; gsize memsize = 0; @@ -646,26 +648,34 @@ gimp_image_get_memsize (GimpObject *object) sizeof (GimpGuide))); if (gimage->grid) - memsize += gimp_object_get_memsize (GIMP_OBJECT (gimage->grid)); + memsize += gimp_object_get_memsize (GIMP_OBJECT (gimage->grid), gui_size); - memsize += gimp_object_get_memsize (GIMP_OBJECT (gimage->layers)); - memsize += gimp_object_get_memsize (GIMP_OBJECT (gimage->channels)); - memsize += gimp_object_get_memsize (GIMP_OBJECT (gimage->vectors)); + memsize += gimp_object_get_memsize (GIMP_OBJECT (gimage->layers), + gui_size); + memsize += gimp_object_get_memsize (GIMP_OBJECT (gimage->channels), + gui_size); + memsize += gimp_object_get_memsize (GIMP_OBJECT (gimage->vectors), + gui_size); memsize += g_slist_length (gimage->layer_stack) * sizeof (GSList); if (gimage->selection_mask) - memsize += gimp_object_get_memsize (GIMP_OBJECT (gimage->selection_mask)); + memsize += gimp_object_get_memsize (GIMP_OBJECT (gimage->selection_mask), + gui_size); - memsize += gimp_object_get_memsize (GIMP_OBJECT (gimage->parasites)); + memsize += gimp_object_get_memsize (GIMP_OBJECT (gimage->parasites), + gui_size); - memsize += gimp_object_get_memsize (GIMP_OBJECT (gimage->undo_stack)); - memsize += gimp_object_get_memsize (GIMP_OBJECT (gimage->redo_stack)); + memsize += gimp_object_get_memsize (GIMP_OBJECT (gimage->undo_stack), + gui_size); + memsize += gimp_object_get_memsize (GIMP_OBJECT (gimage->redo_stack), + gui_size); if (gimage->comp_preview) - memsize += temp_buf_get_memsize (gimage->comp_preview); + *gui_size += temp_buf_get_memsize (gimage->comp_preview); - return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); + return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, + gui_size); } static void @@ -698,7 +708,7 @@ gimp_image_size_changed (GimpViewable *viewable) gimage = GIMP_IMAGE (viewable); - gimp_container_foreach (gimage->layers, + gimp_container_foreach (gimage->layers, (GFunc) gimp_viewable_size_changed, NULL); gimp_container_foreach (gimage->channels, @@ -744,7 +754,7 @@ gimp_image_get_description (GimpViewable *viewable, return retval; } -static void +static void gimp_image_real_colormap_changed (GimpImage *gimage, gint ncol) { @@ -777,7 +787,7 @@ gimp_image_get_active_components (const GimpImage *gimage, { GimpLayer *layer = GIMP_LAYER (drawable); gint i; - + /* first copy the gimage active channels */ for (i = 0; i < MAX_CHANNELS; i++) active[i] = gimage->active[i]; @@ -907,7 +917,7 @@ gimp_image_get_by_ID (Gimp *gimp, if (gimp->image_table == NULL) return NULL; - return (GimpImage *) g_hash_table_lookup (gimp->image_table, + return (GimpImage *) g_hash_table_lookup (gimp->image_table, GINT_TO_POINTER (image_id)); } @@ -971,7 +981,7 @@ gimp_image_get_filename (const GimpImage *gimage) } void -gimp_image_set_save_proc (GimpImage *gimage, +gimp_image_set_save_proc (GimpImage *gimage, PlugInProcDef *proc) { g_return_if_fail (GIMP_IS_IMAGE (gimage)); @@ -1164,7 +1174,7 @@ gimp_image_get_component_index (const GimpImage *gimage, } void -gimp_image_set_component_active (GimpImage *gimage, +gimp_image_set_component_active (GimpImage *gimage, GimpChannelType channel, gboolean active) { @@ -1190,7 +1200,7 @@ gimp_image_set_component_active (GimpImage *gimage, } gboolean -gimp_image_get_component_active (const GimpImage *gimage, +gimp_image_get_component_active (const GimpImage *gimage, GimpChannelType channel) { gint index = -1; @@ -1206,7 +1216,7 @@ gimp_image_get_component_active (const GimpImage *gimage, } void -gimp_image_set_component_visible (GimpImage *gimage, +gimp_image_set_component_visible (GimpImage *gimage, GimpChannelType channel, gboolean visible) { @@ -1229,7 +1239,7 @@ gimp_image_set_component_visible (GimpImage *gimage, } gboolean -gimp_image_get_component_visible (const GimpImage *gimage, +gimp_image_get_component_visible (const GimpImage *gimage, GimpChannelType channel) { gint index = -1; @@ -1292,7 +1302,7 @@ gimp_image_update_guide (GimpImage *gimage, } void -gimp_image_colormap_changed (GimpImage *gimage, +gimp_image_colormap_changed (GimpImage *gimage, gint col) { g_return_if_fail (GIMP_IS_IMAGE (gimage)); @@ -1390,7 +1400,7 @@ gimp_image_undo_event (GimpImage *gimage, /* NOTE about the gimage->dirty counter: - * If 0, then the image is clean (ie, copy on disk is the same as the one + * If 0, then the image is clean (ie, copy on disk is the same as the one * in memory). * If positive, then that's the number of dirtying operations done * on the image since the last save. @@ -1441,9 +1451,9 @@ gimp_image_clean (GimpImage *gimage) gimage->dirty--; g_signal_emit (gimage, gimp_image_signals[CLEAN], 0); - + TRC (("clean %d -> %d\n", gimage->dirty+1, gimage->dirty)); - + return gimage->dirty; } @@ -1475,8 +1485,8 @@ gimp_image_flush (GimpImage *gimage) /* Get rid of these! A "foreground" is an UI concept.. */ void -gimp_image_get_foreground (const GimpImage *gimage, - const GimpDrawable *drawable, +gimp_image_get_foreground (const GimpImage *gimage, + const GimpDrawable *drawable, guchar *fg) { GimpRGB color; @@ -1494,8 +1504,8 @@ gimp_image_get_foreground (const GimpImage *gimage, } void -gimp_image_get_background (const GimpImage *gimage, - const GimpDrawable *drawable, +gimp_image_get_background (const GimpImage *gimage, + const GimpDrawable *drawable, guchar *bg) { GimpRGB color; @@ -1513,9 +1523,9 @@ gimp_image_get_background (const GimpImage *gimage, } void -gimp_image_get_color (const GimpImage *gimage, +gimp_image_get_color (const GimpImage *gimage, GimpImageType d_type, - guchar *rgb, + guchar *rgb, guchar *src) { g_return_if_fail (GIMP_IS_IMAGE (gimage)); @@ -1535,10 +1545,10 @@ gimp_image_get_color (const GimpImage *gimage, } void -gimp_image_transform_color (const GimpImage *gimage, +gimp_image_transform_color (const GimpImage *gimage, const GimpDrawable *drawable, - guchar *src, - guchar *dest, + guchar *src, + guchar *dest, GimpImageBaseType type) { GimpImageType drawable_type; @@ -1608,9 +1618,9 @@ gimp_image_transform_color (const GimpImage *gimage, /* shadow tiles */ TileManager * -gimp_image_shadow (GimpImage *gimage, - gint width, - gint height, +gimp_image_shadow (GimpImage *gimage, + gint width, + gint height, gint bpp) { g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL); @@ -1676,7 +1686,7 @@ gimp_image_apply_image (GimpImage *gimage, item = GIMP_ITEM (drawable); /* get the selection mask if one exists */ - mask = (gimp_image_mask_is_empty (gimage) ? + mask = (gimp_image_mask_is_empty (gimage) ? NULL : gimp_image_get_mask (gimage)); /* configure the active channel array */ @@ -1722,15 +1732,15 @@ gimp_image_apply_image (GimpImage *gimage, * If an alternative to using the drawable's data as src1 was provided... */ if (src1_tiles) - pixel_region_init (&src1PR, src1_tiles, + pixel_region_init (&src1PR, src1_tiles, x1, y1, (x2 - x1), (y2 - y1), FALSE); else - pixel_region_init (&src1PR, gimp_drawable_data (drawable), + pixel_region_init (&src1PR, gimp_drawable_data (drawable), x1, y1, (x2 - x1), (y2 - y1), FALSE); - pixel_region_init (&destPR, gimp_drawable_data (drawable), + pixel_region_init (&destPR, gimp_drawable_data (drawable), x1, y1, (x2 - x1), (y2 - y1), TRUE); - pixel_region_resize (src2PR, - src2PR->x + (x1 - x), src2PR->y + (y1 - y), + pixel_region_resize (src2PR, + src2PR->x + (x1 - x), src2PR->y + (y1 - y), (x2 - x1), (y2 - y1)); if (mask) @@ -1744,10 +1754,10 @@ gimp_image_apply_image (GimpImage *gimage, mx = x1 + offset_x; my = y1 + offset_y; - pixel_region_init (&maskPR, - gimp_drawable_data (GIMP_DRAWABLE (mask)), - mx, my, - (x2 - x1), (y2 - y1), + pixel_region_init (&maskPR, + gimp_drawable_data (GIMP_DRAWABLE (mask)), + mx, my, + (x2 - x1), (y2 - y1), FALSE); combine_regions (&src1PR, src2PR, &destPR, &maskPR, NULL, @@ -1773,14 +1783,14 @@ gimp_image_apply_image (GimpImage *gimage, Takes an additional mask pixel region as well. */ void -gimp_image_replace_image (GimpImage *gimage, - GimpDrawable *drawable, +gimp_image_replace_image (GimpImage *gimage, + GimpDrawable *drawable, PixelRegion *src2PR, - gboolean push_undo, + gboolean push_undo, const gchar *undo_desc, gdouble opacity, PixelRegion *maskPR, - gint x, + gint x, gint y) { GimpItem *item; @@ -1862,10 +1872,10 @@ gimp_image_replace_image (GimpImage *gimage, mx = x1 + offset_x; my = y1 + offset_y; - pixel_region_init (&mask2PR, - gimp_drawable_data (GIMP_DRAWABLE (mask)), - mx, my, - (x2 - x1), (y2 - y1), + pixel_region_init (&mask2PR, + gimp_drawable_data (GIMP_DRAWABLE (mask)), + mx, my, + (x2 - x1), (y2 - y1), FALSE); tempPR.bytes = 1; @@ -1914,7 +1924,7 @@ gimp_image_replace_image (GimpImage *gimage, /* parasites */ GimpParasite * -gimp_image_parasite_find (const GimpImage *gimage, +gimp_image_parasite_find (const GimpImage *gimage, const gchar *name) { g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL); @@ -1923,15 +1933,15 @@ gimp_image_parasite_find (const GimpImage *gimage, } static void -list_func (gchar *key, - GimpParasite *p, +list_func (gchar *key, + GimpParasite *p, gchar ***cur) { *(*cur)++ = (gchar *) g_strdup (key); } gchar ** -gimp_image_parasite_list (const GimpImage *gimage, +gimp_image_parasite_list (const GimpImage *gimage, gint *count) { gchar **list; @@ -1943,12 +1953,12 @@ gimp_image_parasite_list (const GimpImage *gimage, cur = list = g_new (gchar*, *count); gimp_parasite_list_foreach (gimage->parasites, (GHFunc) list_func, &cur); - + return list; } void -gimp_image_parasite_attach (GimpImage *gimage, +gimp_image_parasite_attach (GimpImage *gimage, GimpParasite *parasite) { g_return_if_fail (GIMP_IS_IMAGE (gimage) && parasite != NULL); @@ -1961,7 +1971,7 @@ gimp_image_parasite_attach (GimpImage *gimage, parasite); /* We used to push an cantundo on te stack here. This made the undo stack - unusable (NULL on the stack) and prevented people from undoing after a + unusable (NULL on the stack) and prevented people from undoing after a save (since most save plug-ins attach an undoable comment parasite). Now we simply attach the parasite without pushing an undo. That way it's undoable but does not block the undo system. --Sven @@ -1977,7 +1987,7 @@ gimp_image_parasite_attach (GimpImage *gimage, } void -gimp_image_parasite_detach (GimpImage *gimage, +gimp_image_parasite_detach (GimpImage *gimage, const gchar *parasite) { GimpParasite *p; @@ -2022,7 +2032,7 @@ gimp_image_get_tattoo_state (GimpImage *gimage) } gboolean -gimp_image_set_tattoo_state (GimpImage *gimage, +gimp_image_set_tattoo_state (GimpImage *gimage, GimpTattoo val) { GList *list; @@ -2168,7 +2178,7 @@ gimp_image_get_active_vectors (const GimpImage *gimage) } GimpLayer * -gimp_image_set_active_layer (GimpImage *gimage, +gimp_image_set_active_layer (GimpImage *gimage, GimpLayer *layer) { g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL); @@ -2209,7 +2219,7 @@ gimp_image_set_active_layer (GimpImage *gimage, } GimpChannel * -gimp_image_set_active_channel (GimpImage *gimage, +gimp_image_set_active_channel (GimpImage *gimage, GimpChannel *channel) { g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL); @@ -2275,7 +2285,7 @@ gimp_image_unset_active_channel (GimpImage *gimage) } GimpVectors * -gimp_image_set_active_vectors (GimpImage *gimage, +gimp_image_set_active_vectors (GimpImage *gimage, GimpVectors *vectors) { g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL); @@ -2322,29 +2332,29 @@ gimp_image_active_vectors_changed (GimpImage *gimage) g_signal_emit (gimage, gimp_image_signals[ACTIVE_VECTORS_CHANGED], 0); } -gint +gint gimp_image_get_layer_index (const GimpImage *gimage, const GimpLayer *layer) { g_return_val_if_fail (GIMP_IS_IMAGE (gimage), -1); g_return_val_if_fail (GIMP_IS_LAYER (layer), -1); - return gimp_container_get_child_index (gimage->layers, + return gimp_container_get_child_index (gimage->layers, GIMP_OBJECT (layer)); } -gint +gint gimp_image_get_channel_index (const GimpImage *gimage, const GimpChannel *channel) { g_return_val_if_fail (GIMP_IS_IMAGE (gimage), -1); g_return_val_if_fail (GIMP_IS_CHANNEL (channel), -1); - return gimp_container_get_child_index (gimage->channels, + return gimp_container_get_child_index (gimage->channels, GIMP_OBJECT (channel)); } -gint +gint gimp_image_get_vectors_index (const GimpImage *gimage, const GimpVectors *vectors) { @@ -2364,8 +2374,8 @@ gimp_image_get_layer_by_tattoo (const GimpImage *gimage, g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL); - for (list = GIMP_LIST (gimage->layers)->list; - list; + for (list = GIMP_LIST (gimage->layers)->list; + list; list = g_list_next (list)) { layer = (GimpLayer *) list->data; @@ -2378,7 +2388,7 @@ gimp_image_get_layer_by_tattoo (const GimpImage *gimage, } GimpChannel * -gimp_image_get_channel_by_tattoo (const GimpImage *gimage, +gimp_image_get_channel_by_tattoo (const GimpImage *gimage, GimpTattoo tattoo) { GimpChannel *channel; @@ -2386,8 +2396,8 @@ gimp_image_get_channel_by_tattoo (const GimpImage *gimage, g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL); - for (list = GIMP_LIST (gimage->channels)->list; - list; + for (list = GIMP_LIST (gimage->channels)->list; + list; list = g_list_next (list)) { channel = (GimpChannel *) list->data; @@ -2400,7 +2410,7 @@ gimp_image_get_channel_by_tattoo (const GimpImage *gimage, } GimpVectors * -gimp_image_get_vectors_by_tattoo (const GimpImage *gimage, +gimp_image_get_vectors_by_tattoo (const GimpImage *gimage, GimpTattoo tattoo) { GimpVectors *vectors; @@ -2488,8 +2498,8 @@ gimp_image_get_vectors_by_name (const GimpImage *gimage, } gboolean -gimp_image_add_layer (GimpImage *gimage, - GimpLayer *layer, +gimp_image_add_layer (GimpImage *gimage, + GimpLayer *layer, gint position) { gboolean alpha_changed = FALSE; @@ -2497,8 +2507,8 @@ gimp_image_add_layer (GimpImage *gimage, g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE); - if (GIMP_ITEM (layer)->gimage != NULL && - GIMP_ITEM (layer)->gimage != gimage) + if (GIMP_ITEM (layer)->gimage != NULL && + GIMP_ITEM (layer)->gimage != gimage) { g_warning ("%s: attempting to add layer to wrong image.", G_GNUC_PRETTY_FUNCTION); @@ -2536,7 +2546,7 @@ gimp_image_add_layer (GimpImage *gimage, if (active_layer) { - position = gimp_container_get_child_index (gimage->layers, + position = gimp_container_get_child_index (gimage->layers, GIMP_OBJECT (active_layer)); } else @@ -2584,7 +2594,7 @@ gimp_image_add_layer (GimpImage *gimage, } void -gimp_image_remove_layer (GimpImage *gimage, +gimp_image_remove_layer (GimpImage *gimage, GimpLayer *layer) { gint x, y, w, h; @@ -2596,7 +2606,7 @@ gimp_image_remove_layer (GimpImage *gimage, gimp_image_undo_push_layer_remove (gimage, _("Remove Layer"), layer, - gimp_container_get_child_index (gimage->layers, + gimp_container_get_child_index (gimage->layers, GIMP_OBJECT (layer)), gimp_image_get_active_layer (gimage)); @@ -2606,13 +2616,13 @@ gimp_image_remove_layer (GimpImage *gimage, gimp_layer_invalidate_boundary (layer); gimp_container_remove (gimage->layers, GIMP_OBJECT (layer)); - gimage->layer_stack = g_slist_remove (gimage->layer_stack, layer); + gimage->layer_stack = g_slist_remove (gimage->layer_stack, layer); /* If this was the floating selection, reset the fs pointer */ if (gimage->floating_sel == layer) { gimage->floating_sel = NULL; - + floating_sel_reset (layer); } @@ -2650,15 +2660,15 @@ gimp_image_remove_layer (GimpImage *gimage, } gboolean -gimp_image_raise_layer (GimpImage *gimage, +gimp_image_raise_layer (GimpImage *gimage, GimpLayer *layer) { gint curpos; - + g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE); - curpos = gimp_container_get_child_index (gimage->layers, + curpos = gimp_container_get_child_index (gimage->layers, GIMP_OBJECT (layer)); /* is this the top layer already? */ @@ -2667,13 +2677,13 @@ gimp_image_raise_layer (GimpImage *gimage, g_message (_("Layer cannot be raised higher.")); return FALSE; } - + return gimp_image_position_layer (gimage, layer, curpos - 1, TRUE, _("Raise Layer")); } gboolean -gimp_image_lower_layer (GimpImage *gimage, +gimp_image_lower_layer (GimpImage *gimage, GimpLayer *layer) { gint curpos; @@ -2682,9 +2692,9 @@ gimp_image_lower_layer (GimpImage *gimage, g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE); - curpos = gimp_container_get_child_index (gimage->layers, + curpos = gimp_container_get_child_index (gimage->layers, GIMP_OBJECT (layer)); - + /* is this the bottom layer already? */ length = gimp_container_num_children (gimage->layers); if (curpos >= length - 1) @@ -2692,13 +2702,13 @@ gimp_image_lower_layer (GimpImage *gimage, g_message (_("Layer cannot be lowered more.")); return FALSE; } - + return gimp_image_position_layer (gimage, layer, curpos + 1, TRUE, _("Lower Layer")); } gboolean -gimp_image_raise_layer_to_top (GimpImage *gimage, +gimp_image_raise_layer_to_top (GimpImage *gimage, GimpLayer *layer) { gint curpos; @@ -2706,27 +2716,27 @@ gimp_image_raise_layer_to_top (GimpImage *gimage, g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE); - curpos = gimp_container_get_child_index (gimage->layers, + curpos = gimp_container_get_child_index (gimage->layers, GIMP_OBJECT (layer)); - + if (curpos == 0) { g_message (_("Layer is already on top.")); return FALSE; } - + if (! gimp_drawable_has_alpha (GIMP_DRAWABLE (layer))) { g_message (_("Cannot raise a layer without alpha.")); return FALSE; } - + return gimp_image_position_layer (gimage, layer, 0, TRUE, _("Raise Layer to Top")); } gboolean -gimp_image_lower_layer_to_bottom (GimpImage *gimage, +gimp_image_lower_layer_to_bottom (GimpImage *gimage, GimpLayer *layer) { gint curpos; @@ -2735,9 +2745,9 @@ gimp_image_lower_layer_to_bottom (GimpImage *gimage, g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE); - curpos = gimp_container_get_child_index (gimage->layers, + curpos = gimp_container_get_child_index (gimage->layers, GIMP_OBJECT (layer)); - + length = gimp_container_num_children (gimage->layers); if (curpos >= length - 1) @@ -2745,13 +2755,13 @@ gimp_image_lower_layer_to_bottom (GimpImage *gimage, g_message (_("Layer is already on the bottom.")); return FALSE; } - + return gimp_image_position_layer (gimage, layer, length - 1, TRUE, _("Lower Layer to Bottom")); } gboolean -gimp_image_position_layer (GimpImage *gimage, +gimp_image_position_layer (GimpImage *gimage, GimpLayer *layer, gint new_index, gboolean push_undo, @@ -2764,7 +2774,7 @@ gimp_image_position_layer (GimpImage *gimage, g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); g_return_val_if_fail (GIMP_IS_LAYER (layer), FALSE); - index = gimp_container_get_child_index (gimage->layers, + index = gimp_container_get_child_index (gimage->layers, GIMP_OBJECT (layer)); if (index < 0) return FALSE; @@ -2784,8 +2794,8 @@ gimp_image_position_layer (GimpImage *gimage, if (new_index == num_layers - 1) { GimpLayer *tmp; - - tmp = (GimpLayer *) gimp_container_get_child_by_index (gimage->layers, + + tmp = (GimpLayer *) gimp_container_get_child_by_index (gimage->layers, num_layers - 1); if (new_index == num_layers - 1 && @@ -2815,8 +2825,8 @@ gimp_image_position_layer (GimpImage *gimage, } gboolean -gimp_image_add_channel (GimpImage *gimage, - GimpChannel *channel, +gimp_image_add_channel (GimpImage *gimage, + GimpChannel *channel, gint position) { g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); @@ -2871,22 +2881,22 @@ gimp_image_add_channel (GimpImage *gimage, /* if channel is visible, update the image */ if (gimp_drawable_get_visible (GIMP_DRAWABLE (channel))) - gimp_drawable_update (GIMP_DRAWABLE (channel), - 0, 0, - gimp_item_width (GIMP_ITEM (channel)), + gimp_drawable_update (GIMP_DRAWABLE (channel), + 0, 0, + gimp_item_width (GIMP_ITEM (channel)), gimp_item_height (GIMP_ITEM (channel))); return TRUE; } void -gimp_image_remove_channel (GimpImage *gimage, +gimp_image_remove_channel (GimpImage *gimage, GimpChannel *channel) { g_return_if_fail (GIMP_IS_IMAGE (gimage)); g_return_if_fail (GIMP_IS_CHANNEL (channel)); - g_return_if_fail (gimp_container_have (gimage->channels, + g_return_if_fail (gimp_container_have (gimage->channels, GIMP_OBJECT (channel))); gimp_image_undo_push_channel_remove (gimage, _("Remove Channel"), @@ -2925,15 +2935,15 @@ gimp_image_remove_channel (GimpImage *gimage, } gboolean -gimp_image_raise_channel (GimpImage *gimage, +gimp_image_raise_channel (GimpImage *gimage, GimpChannel *channel) { gint index; g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); - g_return_val_if_fail (GIMP_IS_CHANNEL (channel), FALSE); + g_return_val_if_fail (GIMP_IS_CHANNEL (channel), FALSE); - index = gimp_container_get_child_index (gimage->channels, + index = gimp_container_get_child_index (gimage->channels, GIMP_OBJECT (channel)); if (index == 0) { @@ -2946,15 +2956,15 @@ gimp_image_raise_channel (GimpImage *gimage, } gboolean -gimp_image_lower_channel (GimpImage *gimage, +gimp_image_lower_channel (GimpImage *gimage, GimpChannel *channel) { gint index; g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); - g_return_val_if_fail (GIMP_IS_CHANNEL (channel), FALSE); - - index = gimp_container_get_child_index (gimage->channels, + g_return_val_if_fail (GIMP_IS_CHANNEL (channel), FALSE); + + index = gimp_container_get_child_index (gimage->channels, GIMP_OBJECT (channel)); if (index == gimp_container_num_children (gimage->channels) - 1) { @@ -2967,7 +2977,7 @@ gimp_image_lower_channel (GimpImage *gimage, } gboolean -gimp_image_position_channel (GimpImage *gimage, +gimp_image_position_channel (GimpImage *gimage, GimpChannel *channel, gint new_index, gboolean push_undo, @@ -2977,9 +2987,9 @@ gimp_image_position_channel (GimpImage *gimage, gint num_channels; g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); - g_return_val_if_fail (GIMP_IS_CHANNEL (channel), FALSE); + g_return_val_if_fail (GIMP_IS_CHANNEL (channel), FALSE); - index = gimp_container_get_child_index (gimage->channels, + index = gimp_container_get_child_index (gimage->channels, GIMP_OBJECT (channel)); if (index < 0) return FALSE; @@ -2994,7 +3004,7 @@ gimp_image_position_channel (GimpImage *gimage, if (push_undo) gimp_image_undo_push_channel_reposition (gimage, undo_desc, channel); - gimp_container_reorder (gimage->channels, + gimp_container_reorder (gimage->channels, GIMP_OBJECT (channel), new_index); gimp_drawable_update (GIMP_DRAWABLE (channel), @@ -3006,7 +3016,7 @@ gimp_image_position_channel (GimpImage *gimage, } gboolean -gimp_image_add_vectors (GimpImage *gimage, +gimp_image_add_vectors (GimpImage *gimage, GimpVectors *vectors, gint position) { @@ -3066,7 +3076,7 @@ gimp_image_add_vectors (GimpImage *gimage, } void -gimp_image_remove_vectors (GimpImage *gimage, +gimp_image_remove_vectors (GimpImage *gimage, GimpVectors *vectors) { g_return_if_fail (GIMP_IS_IMAGE (gimage)); @@ -3110,13 +3120,13 @@ gimp_image_remove_vectors (GimpImage *gimage, } gboolean -gimp_image_raise_vectors (GimpImage *gimage, +gimp_image_raise_vectors (GimpImage *gimage, GimpVectors *vectors) { gint index; g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); - g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE); + g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE); index = gimp_container_get_child_index (gimage->vectors, GIMP_OBJECT (vectors)); @@ -3131,13 +3141,13 @@ gimp_image_raise_vectors (GimpImage *gimage, } gboolean -gimp_image_lower_vectors (GimpImage *gimage, +gimp_image_lower_vectors (GimpImage *gimage, GimpVectors *vectors) { gint index; g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); - g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE); + g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE); index = gimp_container_get_child_index (gimage->vectors, GIMP_OBJECT (vectors)); @@ -3152,7 +3162,7 @@ gimp_image_lower_vectors (GimpImage *gimage, } gboolean -gimp_image_position_vectors (GimpImage *gimage, +gimp_image_position_vectors (GimpImage *gimage, GimpVectors *vectors, gint new_index, gboolean push_undo, @@ -3162,7 +3172,7 @@ gimp_image_position_vectors (GimpImage *gimage, gint num_vectors; g_return_val_if_fail (GIMP_IS_IMAGE (gimage), FALSE); - g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE); + g_return_val_if_fail (GIMP_IS_VECTORS (vectors), FALSE); index = gimp_container_get_child_index (gimage->vectors, GIMP_OBJECT (vectors)); @@ -3186,8 +3196,8 @@ gimp_image_position_vectors (GimpImage *gimage, } gboolean -gimp_image_layer_boundary (const GimpImage *gimage, - BoundSeg **segs, +gimp_image_layer_boundary (const GimpImage *gimage, + BoundSeg **segs, gint *n_segs) { GimpLayer *layer; @@ -3215,8 +3225,8 @@ gimp_image_layer_boundary (const GimpImage *gimage, } GimpLayer * -gimp_image_pick_correlate_layer (const GimpImage *gimage, - gint x, +gimp_image_pick_correlate_layer (const GimpImage *gimage, + gint x, gint y) { GimpLayer *layer; @@ -3224,8 +3234,8 @@ gimp_image_pick_correlate_layer (const GimpImage *gimage, g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL); - for (list = GIMP_LIST (gimage->layers)->list; - list; + for (list = GIMP_LIST (gimage->layers)->list; + list; list = g_list_next (list)) { layer = (GimpLayer *) list->data; @@ -3242,8 +3252,8 @@ gimp_image_invalidate_layer_previews (GimpImage *gimage) { g_return_if_fail (GIMP_IS_IMAGE (gimage)); - gimp_container_foreach (gimage->layers, - (GFunc) gimp_viewable_invalidate_preview, + gimp_container_foreach (gimage->layers, + (GFunc) gimp_viewable_invalidate_preview, NULL); } @@ -3252,7 +3262,7 @@ gimp_image_invalidate_channel_previews (GimpImage *gimage) { g_return_if_fail (GIMP_IS_IMAGE (gimage)); - gimp_container_foreach (gimage->channels, - (GFunc) gimp_viewable_invalidate_preview, + gimp_container_foreach (gimage->channels, + (GFunc) gimp_viewable_invalidate_preview, NULL); } diff --git a/app/core/gimpitem.c b/app/core/gimpitem.c index 9cf0face5a..64d35eadb2 100644 --- a/app/core/gimpitem.c +++ b/app/core/gimpitem.c @@ -61,7 +61,8 @@ static void gimp_item_init (GimpItem *item); static void gimp_item_finalize (GObject *object); static void gimp_item_name_changed (GimpObject *object); -static gsize gimp_item_get_memsize (GimpObject *object); +static gsize gimp_item_get_memsize (GimpObject *object, + gsize *gui_size); static GimpItem * gimp_item_real_duplicate (GimpItem *item, GType new_type, @@ -226,16 +227,18 @@ gimp_item_name_changed (GimpObject *object) } static gsize -gimp_item_get_memsize (GimpObject *object) +gimp_item_get_memsize (GimpObject *object, + gsize *gui_size) { GimpItem *item; gsize memsize = 0; item = GIMP_ITEM (object); - memsize += gimp_object_get_memsize (GIMP_OBJECT (item->parasites)); + memsize += gimp_object_get_memsize (GIMP_OBJECT (item->parasites), gui_size); - return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); + return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, + gui_size); } static GimpItem * diff --git a/app/core/gimplayer.c b/app/core/gimplayer.c index 8fcacab0fd..c32bca3c5c 100644 --- a/app/core/gimplayer.c +++ b/app/core/gimplayer.c @@ -66,7 +66,8 @@ static void gimp_layer_init (GimpLayer *layer); static void gimp_layer_finalize (GObject *object); -static gsize gimp_layer_get_memsize (GimpObject *object); +static gsize gimp_layer_get_memsize (GimpObject *object, + gsize *gui_size); static void gimp_layer_invalidate_preview (GimpViewable *viewable); @@ -273,7 +274,8 @@ gimp_layer_finalize (GObject *object) } static gsize -gimp_layer_get_memsize (GimpObject *object) +gimp_layer_get_memsize (GimpObject *object, + gsize *gui_size) { GimpLayer *layer; gsize memsize = 0; @@ -281,14 +283,15 @@ gimp_layer_get_memsize (GimpObject *object) layer = GIMP_LAYER (object); if (layer->mask) - memsize += gimp_object_get_memsize (GIMP_OBJECT (layer->mask)); + memsize += gimp_object_get_memsize (GIMP_OBJECT (layer->mask), gui_size); if (layer->fs.backing_store) - memsize += tile_manager_get_memsize (layer->fs.backing_store); + *gui_size += tile_manager_get_memsize (layer->fs.backing_store); - memsize += layer->fs.num_segs * sizeof (BoundSeg); + *gui_size += layer->fs.num_segs * sizeof (BoundSeg); - return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); + return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, + gui_size); } static void diff --git a/app/core/gimplist.c b/app/core/gimplist.c index 9c9ca56923..02f4909418 100644 --- a/app/core/gimplist.c +++ b/app/core/gimplist.c @@ -36,7 +36,8 @@ static void gimp_list_init (GimpList *list); static void gimp_list_dispose (GObject *object); -static gsize gimp_list_get_memsize (GimpObject *object); +static gsize gimp_list_get_memsize (GimpObject *object, + gsize *gui_size); static void gimp_list_add (GimpContainer *container, GimpObject *object); @@ -82,7 +83,7 @@ gimp_list_get_type (void) }; list_type = g_type_register_static (GIMP_TYPE_CONTAINER, - "GimpList", + "GimpList", &list_info, 0); } @@ -139,7 +140,8 @@ gimp_list_dispose (GObject *object) } static gsize -gimp_list_get_memsize (GimpObject *object) +gimp_list_get_memsize (GimpObject *object, + gsize *gui_size) { GimpList *gimp_list; gsize memsize = 0; @@ -155,12 +157,11 @@ gimp_list_get_memsize (GimpObject *object) GList *list; for (list = gimp_list->list; list; list = g_list_next (list)) - { - memsize += gimp_object_get_memsize (GIMP_OBJECT (list->data)); - } + memsize += gimp_object_get_memsize (GIMP_OBJECT (list->data), gui_size); } - return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); + return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, + gui_size); } static void diff --git a/app/core/gimpobject.c b/app/core/gimpobject.c index 5c74b30c20..a410e4fed3 100644 --- a/app/core/gimpobject.c +++ b/app/core/gimpobject.c @@ -57,7 +57,8 @@ static void gimp_object_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec); -static gsize gimp_object_real_get_memsize (GimpObject *object); +static gsize gimp_object_real_get_memsize (GimpObject *object, + gsize *gui_size); static guint object_signals[LAST_SIGNAL] = { 0 }; @@ -281,8 +282,12 @@ gboolean gimp_debug_memsize = FALSE; #endif gsize -gimp_object_get_memsize (GimpObject *object) +gimp_object_get_memsize (GimpObject *object, + gsize *gui_size) { + gsize my_size = 0; + gsize my_gui_size = 0; + g_return_val_if_fail (GIMP_IS_OBJECT (object), 0); #ifdef DEBUG_MEMSIZE @@ -293,6 +298,7 @@ gimp_object_get_memsize (GimpObject *object) static gchar indent_buf[256]; gsize memsize; + gsize gui_memsize = 0; gint i; gint my_indent_level; gchar *object_size; @@ -301,7 +307,8 @@ gimp_object_get_memsize (GimpObject *object) my_indent_level = indent_level; - memsize = GIMP_OBJECT_GET_CLASS (object)->get_memsize (object); + memsize = GIMP_OBJECT_GET_CLASS (object)->get_memsize (object, + &gui_memsize); indent_level--; @@ -311,11 +318,12 @@ gimp_object_get_memsize (GimpObject *object) indent_buf[i] = '\0'; /* FIXME: are we going to ever have > 4 GB objects?? */ - object_size = g_strdup_printf ("%s%s \"%s\": %u\n", + object_size = g_strdup_printf ("%s%s \"%s\": %u (%u)\n", indent_buf, g_type_name (G_TYPE_FROM_INSTANCE (object)), object->name, - (guint) memsize); + (guint) memsize, + (guint) gui_memsize); aggregation_tree = g_list_prepend (aggregation_tree, object_size); @@ -332,7 +340,13 @@ gimp_object_get_memsize (GimpObject *object) } #endif /* DEBUG_MEMSIZE */ - return GIMP_OBJECT_GET_CLASS (object)->get_memsize (object); + my_size = GIMP_OBJECT_GET_CLASS (object)->get_memsize (object, + &my_gui_size); + + if (gui_size) + *gui_size = my_gui_size; + + return my_size; } gsize @@ -351,7 +365,8 @@ gimp_g_object_get_memsize (GObject *object) } static gsize -gimp_object_real_get_memsize (GimpObject *object) +gimp_object_real_get_memsize (GimpObject *object, + gsize *gui_size) { gsize memsize = 0; diff --git a/app/core/gimpobject.h b/app/core/gimpobject.h index fc83f9958c..d1bc50ce3a 100644 --- a/app/core/gimpobject.h +++ b/app/core/gimpobject.h @@ -46,7 +46,8 @@ struct _GimpObjectClass void (* name_changed) (GimpObject *object); /* virtual functions */ - gsize (* get_memsize) (GimpObject *object); + gsize (* get_memsize) (GimpObject *object, + gsize *gui_size); }; @@ -59,7 +60,8 @@ void gimp_object_set_name_safe (GimpObject *object, const gchar *name); void gimp_object_name_changed (GimpObject *object); -gsize gimp_object_get_memsize (GimpObject *object); +gsize gimp_object_get_memsize (GimpObject *object, + gsize *gui_size); gsize gimp_g_object_get_memsize (GObject *object); diff --git a/app/core/gimppalette-load.c b/app/core/gimppalette-load.c index f39b687f28..e9f11fc81c 100644 --- a/app/core/gimppalette-load.c +++ b/app/core/gimppalette-load.c @@ -46,7 +46,8 @@ static void gimp_palette_init (GimpPalette *palette); static void gimp_palette_finalize (GObject *object); -static gsize gimp_palette_get_memsize (GimpObject *object); +static gsize gimp_palette_get_memsize (GimpObject *object, + gsize *gui_size); static void gimp_palette_get_preview_size (GimpViewable *viewable, gint size, @@ -101,7 +102,7 @@ gimp_palette_get_type (void) }; palette_type = g_type_register_static (GIMP_TYPE_DATA, - "GimpPalette", + "GimpPalette", &palette_info, 0); } @@ -166,7 +167,8 @@ gimp_palette_finalize (GObject *object) } static gsize -gimp_palette_get_memsize (GimpObject *object) +gimp_palette_get_memsize (GimpObject *object, + gsize *gui_size) { GimpPalette *palette; GList *list; @@ -186,7 +188,8 @@ gimp_palette_get_memsize (GimpObject *object) memsize += strlen (entry->name) + 1; } - return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); + return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, + gui_size); } static void diff --git a/app/core/gimppalette-save.c b/app/core/gimppalette-save.c index f39b687f28..e9f11fc81c 100644 --- a/app/core/gimppalette-save.c +++ b/app/core/gimppalette-save.c @@ -46,7 +46,8 @@ static void gimp_palette_init (GimpPalette *palette); static void gimp_palette_finalize (GObject *object); -static gsize gimp_palette_get_memsize (GimpObject *object); +static gsize gimp_palette_get_memsize (GimpObject *object, + gsize *gui_size); static void gimp_palette_get_preview_size (GimpViewable *viewable, gint size, @@ -101,7 +102,7 @@ gimp_palette_get_type (void) }; palette_type = g_type_register_static (GIMP_TYPE_DATA, - "GimpPalette", + "GimpPalette", &palette_info, 0); } @@ -166,7 +167,8 @@ gimp_palette_finalize (GObject *object) } static gsize -gimp_palette_get_memsize (GimpObject *object) +gimp_palette_get_memsize (GimpObject *object, + gsize *gui_size) { GimpPalette *palette; GList *list; @@ -186,7 +188,8 @@ gimp_palette_get_memsize (GimpObject *object) memsize += strlen (entry->name) + 1; } - return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); + return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, + gui_size); } static void diff --git a/app/core/gimppalette.c b/app/core/gimppalette.c index f39b687f28..e9f11fc81c 100644 --- a/app/core/gimppalette.c +++ b/app/core/gimppalette.c @@ -46,7 +46,8 @@ static void gimp_palette_init (GimpPalette *palette); static void gimp_palette_finalize (GObject *object); -static gsize gimp_palette_get_memsize (GimpObject *object); +static gsize gimp_palette_get_memsize (GimpObject *object, + gsize *gui_size); static void gimp_palette_get_preview_size (GimpViewable *viewable, gint size, @@ -101,7 +102,7 @@ gimp_palette_get_type (void) }; palette_type = g_type_register_static (GIMP_TYPE_DATA, - "GimpPalette", + "GimpPalette", &palette_info, 0); } @@ -166,7 +167,8 @@ gimp_palette_finalize (GObject *object) } static gsize -gimp_palette_get_memsize (GimpObject *object) +gimp_palette_get_memsize (GimpObject *object, + gsize *gui_size) { GimpPalette *palette; GList *list; @@ -186,7 +188,8 @@ gimp_palette_get_memsize (GimpObject *object) memsize += strlen (entry->name) + 1; } - return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); + return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, + gui_size); } static void diff --git a/app/core/gimpparasitelist.c b/app/core/gimpparasitelist.c index 2c53f90cf4..12cab9762d 100644 --- a/app/core/gimpparasitelist.c +++ b/app/core/gimpparasitelist.c @@ -51,7 +51,8 @@ enum static void gimp_parasite_list_class_init (GimpParasiteListClass *klass); static void gimp_parasite_list_init (GimpParasiteList *list); static void gimp_parasite_list_finalize (GObject *object); -static gsize gimp_parasite_list_get_memsize (GimpObject *object); +static gsize gimp_parasite_list_get_memsize (GimpObject *object, + gsize *gui_size); static void gimp_parasite_list_config_iface_init (gpointer iface, gpointer iface_data); @@ -72,8 +73,8 @@ static void parasite_copy (const gchar *key, static gboolean parasite_free (const gchar *key, GimpParasite *parasite, gpointer unused); -static void parasite_count_if_persistent (const gchar *key, - GimpParasite *parasite, +static void parasite_count_if_persistent (const gchar *key, + GimpParasite *parasite, gint *count); @@ -103,15 +104,15 @@ gimp_parasite_list_get_type (void) 0, /* n_preallocs */ (GInstanceInitFunc) gimp_parasite_list_init, }; - static const GInterfaceInfo list_iface_info = - { + static const GInterfaceInfo list_iface_info = + { gimp_parasite_list_config_iface_init, - NULL, /* iface_finalize */ + NULL, /* iface_finalize */ NULL /* iface_data */ }; list_type = g_type_register_static (GIMP_TYPE_OBJECT, - "GimpParasiteList", + "GimpParasiteList", &list_info, 0); g_type_add_interface_static (list_type, GIMP_TYPE_CONFIG_INTERFACE, @@ -142,7 +143,7 @@ gimp_parasite_list_class_init (GimpParasiteListClass *klass) G_TYPE_NONE, 1, G_TYPE_POINTER); - parasite_list_signals[REMOVE] = + parasite_list_signals[REMOVE] = g_signal_new ("remove", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, @@ -212,7 +213,8 @@ gimp_parasite_list_get_memsize_foreach (gpointer key, } static gsize -gimp_parasite_list_get_memsize (GimpObject *object) +gimp_parasite_list_get_memsize (GimpObject *object, + gsize *gui_size) { GimpParasiteList *list; gsize memsize = 0; @@ -229,7 +231,8 @@ gimp_parasite_list_get_memsize (GimpObject *object) &memsize); } - return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); + return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, + gui_size); } static gboolean @@ -350,7 +353,7 @@ gimp_parasite_list_copy (const GimpParasiteList *list) } void -gimp_parasite_list_add (GimpParasiteList *list, +gimp_parasite_list_add (GimpParasiteList *list, GimpParasite *parasite) { g_return_if_fail (GIMP_IS_PARASITE_LIST (list)); @@ -368,7 +371,7 @@ gimp_parasite_list_add (GimpParasiteList *list, } void -gimp_parasite_list_remove (GimpParasiteList *list, +gimp_parasite_list_remove (GimpParasiteList *list, const gchar *name) { GimpParasite *parasite; @@ -418,8 +421,8 @@ gimp_parasite_list_persistent_length (GimpParasiteList *list) } void -gimp_parasite_list_foreach (GimpParasiteList *list, - GHFunc function, +gimp_parasite_list_foreach (GimpParasiteList *list, + GHFunc function, gpointer user_data) { g_return_if_fail (GIMP_IS_PARASITE_LIST (list)); @@ -431,7 +434,7 @@ gimp_parasite_list_foreach (GimpParasiteList *list, } GimpParasite * -gimp_parasite_list_find (GimpParasiteList *list, +gimp_parasite_list_find (GimpParasiteList *list, const gchar *name) { g_return_val_if_fail (GIMP_IS_PARASITE_LIST (list), NULL); @@ -458,7 +461,7 @@ parasite_serialize (const gchar *key, gimp_config_writer_open (writer, parasite_symbol); str = g_string_sized_new (64); - + g_string_printf (str, "\"%s\" %lu \"", gimp_parasite_name (parasite), gimp_parasite_flags (parasite)); @@ -488,7 +491,7 @@ parasite_serialize (const gchar *key, break; } } - + g_string_append (str, "\""); gimp_config_writer_print (writer, str->str, str->len); @@ -517,9 +520,9 @@ parasite_free (const gchar *key, return TRUE; } -static void -parasite_count_if_persistent (const gchar *key, - GimpParasite *parasite, +static void +parasite_count_if_persistent (const gchar *key, + GimpParasite *parasite, gint *count) { if (gimp_parasite_is_persistent (parasite)) diff --git a/app/core/gimppattern-load.c b/app/core/gimppattern-load.c index 7aed98c6a5..ad45cdccc8 100644 --- a/app/core/gimppattern-load.c +++ b/app/core/gimppattern-load.c @@ -59,7 +59,8 @@ static void gimp_pattern_init (GimpPattern *pattern); static void gimp_pattern_finalize (GObject *object); -static gsize gimp_pattern_get_memsize (GimpObject *object); +static gsize gimp_pattern_get_memsize (GimpObject *object, + gsize *gui_size); static gboolean gimp_pattern_get_popup_size (GimpViewable *viewable, gint width, @@ -158,7 +159,8 @@ gimp_pattern_finalize (GObject *object) } static gsize -gimp_pattern_get_memsize (GimpObject *object) +gimp_pattern_get_memsize (GimpObject *object, + gsize *gui_size) { GimpPattern *pattern; gsize memsize = 0; @@ -168,7 +170,8 @@ gimp_pattern_get_memsize (GimpObject *object) if (pattern->mask) memsize += temp_buf_get_memsize (pattern->mask); - return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); + return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, + gui_size); } static gboolean diff --git a/app/core/gimppattern.c b/app/core/gimppattern.c index 7aed98c6a5..ad45cdccc8 100644 --- a/app/core/gimppattern.c +++ b/app/core/gimppattern.c @@ -59,7 +59,8 @@ static void gimp_pattern_init (GimpPattern *pattern); static void gimp_pattern_finalize (GObject *object); -static gsize gimp_pattern_get_memsize (GimpObject *object); +static gsize gimp_pattern_get_memsize (GimpObject *object, + gsize *gui_size); static gboolean gimp_pattern_get_popup_size (GimpViewable *viewable, gint width, @@ -158,7 +159,8 @@ gimp_pattern_finalize (GObject *object) } static gsize -gimp_pattern_get_memsize (GimpObject *object) +gimp_pattern_get_memsize (GimpObject *object, + gsize *gui_size) { GimpPattern *pattern; gsize memsize = 0; @@ -168,7 +170,8 @@ gimp_pattern_get_memsize (GimpObject *object) if (pattern->mask) memsize += temp_buf_get_memsize (pattern->mask); - return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); + return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, + gui_size); } static gboolean diff --git a/app/core/gimpundo.c b/app/core/gimpundo.c index a14e58841a..0416cabb3d 100644 --- a/app/core/gimpundo.c +++ b/app/core/gimpundo.c @@ -43,7 +43,8 @@ static void gimp_undo_init (GimpUndo *undo); static void gimp_undo_finalize (GObject *object); -static gsize gimp_undo_get_memsize (GimpObject *object); +static gsize gimp_undo_get_memsize (GimpObject *object, + gsize *gui_size); static gboolean gimp_undo_get_popup_size (GimpViewable *viewable, gint width, @@ -111,7 +112,7 @@ gimp_undo_class_init (GimpUndoClass *klass) parent_class = g_type_class_peek_parent (klass); - undo_signals[POP] = + undo_signals[POP] = g_signal_new ("pop", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, @@ -122,7 +123,7 @@ gimp_undo_class_init (GimpUndoClass *klass) GIMP_TYPE_UNDO_MODE, G_TYPE_POINTER); - undo_signals[FREE] = + undo_signals[FREE] = g_signal_new ("free", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST, @@ -178,7 +179,8 @@ gimp_undo_finalize (GObject *object) } static gsize -gimp_undo_get_memsize (GimpObject *object) +gimp_undo_get_memsize (GimpObject *object, + gsize *gui_size) { GimpUndo *undo; gsize memsize = 0; @@ -188,9 +190,10 @@ gimp_undo_get_memsize (GimpObject *object) memsize += undo->size; if (undo->preview) - memsize += temp_buf_get_memsize (undo->preview); + *gui_size += temp_buf_get_memsize (undo->preview); - return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); + return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, + gui_size); } static gboolean diff --git a/app/core/gimpundostack.c b/app/core/gimpundostack.c index 308c0dc0f4..db24ceca29 100644 --- a/app/core/gimpundostack.c +++ b/app/core/gimpundostack.c @@ -33,7 +33,8 @@ static void gimp_undo_stack_init (GimpUndoStack *stack); static void gimp_undo_stack_finalize (GObject *object); -static gsize gimp_undo_stack_get_memsize (GimpObject *object); +static gsize gimp_undo_stack_get_memsize (GimpObject *object, + gsize *gui_size); static void gimp_undo_stack_pop (GimpUndo *undo, GimpUndoMode undo_mode, @@ -66,7 +67,7 @@ gimp_undo_stack_get_type (void) }; undo_stack_type = g_type_register_static (GIMP_TYPE_UNDO, - "GimpUndoStack", + "GimpUndoStack", &undo_stack_info, 0); } @@ -118,7 +119,8 @@ gimp_undo_stack_finalize (GObject *object) } static gsize -gimp_undo_stack_get_memsize (GimpObject *object) +gimp_undo_stack_get_memsize (GimpObject *object, + gsize *gui_size) { GimpUndoStack *stack; gsize memsize = 0; @@ -126,9 +128,10 @@ gimp_undo_stack_get_memsize (GimpObject *object) stack = GIMP_UNDO_STACK (object); if (stack->undos) - memsize += gimp_object_get_memsize (GIMP_OBJECT (stack->undos)); + memsize += gimp_object_get_memsize (GIMP_OBJECT (stack->undos), gui_size); - return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); + return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, + gui_size); } static void @@ -193,8 +196,8 @@ gimp_undo_stack_new (GimpImage *gimage) return stack; } -void -gimp_undo_stack_push_undo (GimpUndoStack *stack, +void +gimp_undo_stack_push_undo (GimpUndoStack *stack, GimpUndo *undo) { g_return_if_fail (GIMP_IS_UNDO_STACK (stack)); @@ -203,7 +206,7 @@ gimp_undo_stack_push_undo (GimpUndoStack *stack, gimp_container_add (GIMP_CONTAINER (stack->undos), GIMP_OBJECT (undo)); } -GimpUndo * +GimpUndo * gimp_undo_stack_pop_undo (GimpUndoStack *stack, GimpUndoMode undo_mode, GimpUndoAccumulator *accum) @@ -223,7 +226,7 @@ gimp_undo_stack_pop_undo (GimpUndoStack *stack, return undo; } - + return NULL; } @@ -253,7 +256,7 @@ gimp_undo_stack_free_bottom (GimpUndoStack *stack, return NULL; } -GimpUndo * +GimpUndo * gimp_undo_stack_peek (GimpUndoStack *stack) { GimpObject *object; diff --git a/app/core/gimpviewable.c b/app/core/gimpviewable.c index 9ce6fbdc52..caad9a98f7 100644 --- a/app/core/gimpviewable.c +++ b/app/core/gimpviewable.c @@ -65,7 +65,8 @@ static void gimp_viewable_get_property (GObject *object, GValue *value, GParamSpec *pspec); -static gsize gimp_viewable_get_memsize (GimpObject *object); +static gsize gimp_viewable_get_memsize (GimpObject *object, + gsize *gui_size); static void gimp_viewable_real_invalidate_preview (GimpViewable *viewable); @@ -92,7 +93,7 @@ static GQuark quark_preview_temp_buf = 0; static GQuark quark_preview_pixbuf = 0; -GType +GType gimp_viewable_get_type (void) { static GType viewable_type = 0; @@ -111,7 +112,7 @@ gimp_viewable_get_type (void) 0, /* n_preallocs */ (GInstanceInitFunc) gimp_viewable_init, }; - static const GInterfaceInfo config_iface_info = + static const GInterfaceInfo config_iface_info = { (GInterfaceInitFunc) gimp_viewable_config_iface_init, NULL, /* iface_finalize */ @@ -226,7 +227,7 @@ gimp_viewable_set_property (GObject *object, break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); - break; + break; } } @@ -245,23 +246,21 @@ gimp_viewable_get_property (GObject *object, default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; - } + } } static gsize -gimp_viewable_get_memsize (GimpObject *object) +gimp_viewable_get_memsize (GimpObject *object, + gsize *gui_size) { TempBuf *temp_buf; GdkPixbuf *pixbuf; - gsize memsize = 0; temp_buf = g_object_get_qdata (G_OBJECT (object), quark_preview_temp_buf); pixbuf = g_object_get_qdata (G_OBJECT (object), quark_preview_pixbuf); if (temp_buf) - { - memsize += temp_buf_get_memsize (temp_buf); - } + *gui_size += temp_buf_get_memsize (temp_buf); if (pixbuf) { @@ -276,12 +275,12 @@ gimp_viewable_get_memsize (GimpObject *object) pixbuf_instance_size = type_query.instance_size; } - memsize += (pixbuf_instance_size + - gdk_pixbuf_get_height (pixbuf) * - gdk_pixbuf_get_rowstride (pixbuf)); + *gui_size += (pixbuf_instance_size + + gdk_pixbuf_get_height (pixbuf) * + gdk_pixbuf_get_rowstride (pixbuf)); } - return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); + return GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, gui_size); } static void diff --git a/app/display/gimpdisplayshell-title.c b/app/display/gimpdisplayshell-title.c index 9e4b52840c..59f2bc2443 100644 --- a/app/display/gimpdisplayshell-title.c +++ b/app/display/gimpdisplayshell-title.c @@ -269,7 +269,7 @@ gimp_display_shell_format_title (GimpDisplayShell *shell, gulong memsize; gchar *memsize_str; - memsize = gimp_object_get_memsize (GIMP_OBJECT (gimage)); + memsize = gimp_object_get_memsize (GIMP_OBJECT (gimage), NULL); memsize_str = gimp_memsize_to_string (memsize); diff --git a/app/gui/debug-commands.c b/app/gui/debug-commands.c index 04be617426..df779fc9ea 100644 --- a/app/gui/debug-commands.c +++ b/app/gui/debug-commands.c @@ -93,7 +93,7 @@ debug_mem_profile_cmd_callback (GtkWidget *widget, gimp_debug_memsize = TRUE; - gimp_object_get_memsize (GIMP_OBJECT (data)); + gimp_object_get_memsize (GIMP_OBJECT (data), NULL); gimp_debug_memsize = FALSE; } @@ -111,73 +111,33 @@ debug_dump_menus_recurse_menu (GtkWidget *menu, GList *list; const gchar *label; gchar *help_page; - gchar *help_path; - gchar *factory_path; - gchar *hash; gchar *full_path; gchar *format_str; for (list = GTK_MENU_SHELL (menu)->children; list; list = g_list_next (list)) { menu_item = GTK_WIDGET (list->data); - + if (GTK_IS_LABEL (GTK_BIN (menu_item)->child)) { label = gtk_label_get_text (GTK_LABEL (GTK_BIN (menu_item)->child)); full_path = g_strconcat (path, "/", label, NULL); item_factory = GTK_ITEM_FACTORY (gimp_item_factory_from_path (path)); - help_page = g_object_get_data (G_OBJECT (menu_item), "help_page"); + help_page = g_object_get_data (G_OBJECT (menu_item), + "gimp-help-id"); - if (item_factory) - { - factory_path = g_object_get_data (G_OBJECT (item_factory), - "factory_path"); + help_page = g_strdup (help_page); - if (factory_path) - { - help_page = g_build_filename (factory_path, help_page, NULL); - } - else - { - help_page = g_strdup (help_page); - } - } - else - { - help_page = g_strdup (help_page); - } - - if (help_page) - { - help_path = g_build_filename (gimp_data_directory (), - "help", "C", help_page, NULL); - - if ((hash = strchr (help_path, '#')) != NULL) - *hash = '\0'; - - if (g_file_test (help_path, G_FILE_TEST_EXISTS)) - { - g_free (help_path); - help_path = g_strconcat ("! ", help_page, NULL); - g_free (help_page); - help_page = help_path; - } - else - { - g_free (help_path); - } - } - - format_str = g_strdup_printf ("%%%ds%%%ds %%-20s %%s\n", + format_str = g_strdup_printf ("%%%ds%%%ds %%-20s %%s\n", depth * 2, depth * 2 - 40); - g_print (format_str, + g_print (format_str, "", label, "", help_page ? help_page : ""); g_free (format_str); g_free (help_page); if (GTK_MENU_ITEM (menu_item)->submenu) - debug_dump_menus_recurse_menu (GTK_MENU_ITEM (menu_item)->submenu, + debug_dump_menus_recurse_menu (GTK_MENU_ITEM (menu_item)->submenu, depth + 1, full_path); g_free (full_path); diff --git a/app/vectors/gimpstroke.c b/app/vectors/gimpstroke.c index 7a7cf25f76..b1096134c3 100644 --- a/app/vectors/gimpstroke.c +++ b/app/vectors/gimpstroke.c @@ -38,7 +38,8 @@ static void gimp_stroke_init (GimpStroke *stroke); static void gimp_stroke_finalize (GObject *object); -static gsize gimp_stroke_get_memsize (GimpObject *object); +static gsize gimp_stroke_get_memsize (GimpObject *object, + gsize *gui_size); static GimpAnchor * gimp_stroke_real_anchor_get (const GimpStroke *stroke, const GimpCoords *coord); @@ -224,7 +225,8 @@ gimp_stroke_finalize (GObject *object) } static gsize -gimp_stroke_get_memsize (GimpObject *object) +gimp_stroke_get_memsize (GimpObject *object, + gsize *gui_size) { GimpStroke *stroke; gsize memsize = 0; @@ -234,7 +236,8 @@ gimp_stroke_get_memsize (GimpObject *object) memsize += g_list_length (stroke->anchors) * (sizeof (GList) + sizeof (GimpAnchor)); - return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); + return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, + gui_size); } @@ -253,7 +256,7 @@ gimp_stroke_nearest_point_get (const GimpStroke *stroke, const GimpCoords *coord, const gdouble precision, GimpCoords *ret_point, - GimpAnchor **ret_segment_start, + GimpAnchor **ret_segment_start, gdouble *ret_pos) { g_return_val_if_fail (GIMP_IS_STROKE (stroke), FALSE); @@ -475,7 +478,7 @@ gimp_stroke_real_anchor_delete (GimpStroke *stroke, { g_printerr ("gimp_stroke_anchor_delete: default implementation\n"); } - + GimpStroke * gimp_stroke_open (GimpStroke *stroke, GimpAnchor *end_anchor) @@ -492,7 +495,7 @@ gimp_stroke_real_open (GimpStroke *stroke, g_printerr ("gimp_stroke_open: default implementation\n"); return NULL; } - + gboolean gimp_stroke_anchor_is_insertable (GimpStroke *stroke, GimpAnchor *predec, @@ -848,7 +851,7 @@ gimp_stroke_real_rotate (GimpStroke *stroke, gboolean clip_result) { GList *list; - GimpMatrix3 matrix; + GimpMatrix3 matrix; gdouble angle = 0.0; switch (rotate_type) diff --git a/app/vectors/gimpvectors.c b/app/vectors/gimpvectors.c index 8fffd5f0bd..0ed3d91f3f 100644 --- a/app/vectors/gimpvectors.c +++ b/app/vectors/gimpvectors.c @@ -51,7 +51,8 @@ static void gimp_vectors_init (GimpVectors *vectors); static void gimp_vectors_finalize (GObject *object); -static gsize gimp_vectors_get_memsize (GimpObject *object); +static gsize gimp_vectors_get_memsize (GimpObject *object, + gsize *gui_size); static GimpItem * gimp_vectors_duplicate (GimpItem *item, GType new_type, @@ -241,7 +242,8 @@ gimp_vectors_finalize (GObject *object) } static gsize -gimp_vectors_get_memsize (GimpObject *object) +gimp_vectors_get_memsize (GimpObject *object, + gsize *gui_size) { GimpVectors *vectors; GList *list; @@ -250,10 +252,11 @@ gimp_vectors_get_memsize (GimpObject *object) vectors = GIMP_VECTORS (object); for (list = vectors->strokes; list; list = g_list_next (list)) - memsize += (gimp_object_get_memsize (GIMP_OBJECT (list->data)) + + memsize += (gimp_object_get_memsize (GIMP_OBJECT (list->data), gui_size) + sizeof (GList)); - return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object); + return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, + gui_size); } diff --git a/app/widgets/gimppreview.c b/app/widgets/gimppreview.c index e367feb071..8f9f1c87c6 100644 --- a/app/widgets/gimppreview.c +++ b/app/widgets/gimppreview.c @@ -437,7 +437,7 @@ gimp_preview_button_press_event (GtkWidget *widget, { gimp_debug_memsize = TRUE; - gimp_object_get_memsize (GIMP_OBJECT (preview->viewable)); + gimp_object_get_memsize (GIMP_OBJECT (preview->viewable), NULL); gimp_debug_memsize = FALSE; } diff --git a/app/widgets/gimpview.c b/app/widgets/gimpview.c index e367feb071..8f9f1c87c6 100644 --- a/app/widgets/gimpview.c +++ b/app/widgets/gimpview.c @@ -437,7 +437,7 @@ gimp_preview_button_press_event (GtkWidget *widget, { gimp_debug_memsize = TRUE; - gimp_object_get_memsize (GIMP_OBJECT (preview->viewable)); + gimp_object_get_memsize (GIMP_OBJECT (preview->viewable), NULL); gimp_debug_memsize = FALSE; }