added gimp_undo_stack_get_depth().

2005-07-29  Sven Neumann  <sven@gimp.org>

	* app/core/gimpundostack.[ch]: added gimp_undo_stack_get_depth().

	* app/widgets/gimpimagepropview.[ch]: display number and memory
	usage of undo/redo steps.

	* app/core/gimpimage-merge.c: fixed signedness issue.
This commit is contained in:
Sven Neumann 2005-07-28 22:40:32 +00:00 committed by Sven Neumann
parent b82d4c46c7
commit 0728f76b35
6 changed files with 97 additions and 15 deletions

View File

@ -1,3 +1,12 @@
2005-07-29 Sven Neumann <sven@gimp.org>
* app/core/gimpundostack.[ch]: added gimp_undo_stack_get_depth().
* app/widgets/gimpimagepropview.[ch]: display number and memory
usage of undo/redo steps.
* app/core/gimpimage-merge.c: fixed signedness issue.
2005-07-28 Sven Neumann <sven@gimp.org>
* app/base/siox.[ch]: accept an offset between pixels and mask,

View File

@ -521,7 +521,7 @@ gimp_image_merge_visible_vectors (GimpImage *gimage)
GSList *cur_item = NULL;
GimpVectors *vectors = NULL;
GimpVectors *target_vectors = NULL;
guchar *name = NULL;
gchar *name = NULL;
gint pos = 0;
g_return_val_if_fail (GIMP_IS_IMAGE (gimage), NULL);

View File

@ -246,3 +246,11 @@ gimp_undo_stack_peek (GimpUndoStack *stack)
return (object ? GIMP_UNDO (object) : NULL);
}
gint
gimp_undo_stack_get_depth (GimpUndoStack *stack)
{
g_return_val_if_fail (GIMP_IS_UNDO_STACK (stack), 0);
return gimp_container_num_children (stack->undos);
}

View File

@ -36,7 +36,7 @@ typedef struct _GimpUndoStackClass GimpUndoStackClass;
struct _GimpUndoStack
{
GimpUndo parent_instance;
GimpContainer *undos;
};
@ -50,7 +50,7 @@ GType gimp_undo_stack_get_type (void) G_GNUC_CONST;
GimpUndoStack * gimp_undo_stack_new (GimpImage *gimage);
void gimp_undo_stack_push_undo (GimpUndoStack *stack,
void gimp_undo_stack_push_undo (GimpUndoStack *stack,
GimpUndo *undo);
GimpUndo * gimp_undo_stack_pop_undo (GimpUndoStack *stack,
GimpUndoMode undo_mode,
@ -59,6 +59,7 @@ GimpUndo * gimp_undo_stack_pop_undo (GimpUndoStack *stack,
GimpUndo * gimp_undo_stack_free_bottom (GimpUndoStack *stack,
GimpUndoMode undo_mode);
GimpUndo * gimp_undo_stack_peek (GimpUndoStack *stack);
gint gimp_undo_stack_get_depth (GimpUndoStack *stack);
#endif /* __GIMP_UNDO_STACK_H__ */

View File

@ -30,6 +30,7 @@
#include "core/gimpcontainer.h"
#include "core/gimpimage.h"
#include "core/gimpundostack.h"
#include "core/gimpunit.h"
#include "gimpimagepropview.h"
@ -63,6 +64,10 @@ static void gimp_image_prop_view_get_property (GObject *object,
static GtkWidget * gimp_image_prop_view_add_label (GtkTable *table,
gint row,
const gchar *text);
static void gimp_image_prop_view_undo_event (GimpImage *gimage,
GimpUndoEvent event,
GimpUndo *undo,
GimpImagePropView *view);
static void gimp_image_prop_view_update (GimpImagePropView *view);
@ -118,8 +123,8 @@ gimp_image_prop_view_class_init (GimpImagePropViewClass *klass)
static void
gimp_image_prop_view_init (GimpImagePropView *view)
{
gtk_table_set_col_spacing (GTK_TABLE (view), 0, 6);
gtk_table_set_row_spacings (GTK_TABLE (view), 4);
gtk_table_set_col_spacings (GTK_TABLE (view), 6);
gtk_table_set_row_spacings (GTK_TABLE (view), 3);
}
static void
@ -192,6 +197,12 @@ gimp_image_prop_view_constructor (GType type,
view->memsize_label =
gimp_image_prop_view_add_label (table, row++, _("Size in memory:"));
view->undo_label =
gimp_image_prop_view_add_label (table, row++, _("Undo steps:"));
view->redo_label =
gimp_image_prop_view_add_label (table, row++, _("Redo steps:"));
view->pixels_label =
gimp_image_prop_view_add_label (table, row++, _("Number of pixels:"));
@ -220,6 +231,10 @@ gimp_image_prop_view_constructor (GType type,
G_CALLBACK (gimp_image_prop_view_update),
G_OBJECT (view),
G_CONNECT_SWAPPED);
g_signal_connect_object (view->image, "undo-event",
G_CALLBACK (gimp_image_prop_view_undo_event),
G_OBJECT (view),
0);
gimp_image_prop_view_update (view);
@ -263,8 +278,9 @@ gimp_image_prop_view_add_label (GtkTable *table,
gtk_widget_show (desc);
label = g_object_new (GTK_TYPE_LABEL,
"xalign", 0.0,
"yalign", 0.5,
"xalign", 0.0,
"yalign", 0.5,
"selectable", TRUE,
NULL);
gtk_table_attach (table, label,
1, 2, row, row + 1, GTK_FILL, GTK_FILL, 0, 0);
@ -273,6 +289,50 @@ gimp_image_prop_view_add_label (GtkTable *table,
return label;
}
static void
gimp_image_prop_view_label_set_memsize (GtkWidget *label,
GimpObject *object)
{
gchar *str = gimp_memsize_to_string (gimp_object_get_memsize (object, NULL));
gtk_label_set_text (GTK_LABEL (label), str);
g_free (str);
}
static void
gimp_image_prop_view_label_set_undo (GtkWidget *label,
GimpUndoStack *stack)
{
gint steps = gimp_undo_stack_get_depth (stack);
if (steps > 0)
{
GimpObject *object = GIMP_OBJECT (stack);
gchar *str;
gchar buf[256];
str = gimp_memsize_to_string (gimp_object_get_memsize (object, NULL));
g_snprintf (buf, sizeof (buf), "%d (%s)", steps, str);
g_free (str);
gtk_label_set_text (GTK_LABEL (label), buf);
}
else
{
/* no undo (or redo) steps available */
gtk_label_set_text (GTK_LABEL (label), _("None"));
}
}
static void
gimp_image_prop_view_undo_event (GimpImage *gimage,
GimpUndoEvent event,
GimpUndo *undo,
GimpImagePropView *view)
{
gimp_image_prop_view_update (view);
}
static void
gimp_image_prop_view_update (GimpImagePropView *view)
{
@ -341,15 +401,17 @@ gimp_image_prop_view_update (GimpImagePropView *view)
gtk_label_set_text (GTK_LABEL (view->colorspace_label), buf);
/* size in memory */
{
GimpObject *object = GIMP_OBJECT (image);
gchar *str;
gtk_table_set_row_spacing (GTK_TABLE (view), 3, 6);
str = gimp_memsize_to_string (gimp_object_get_memsize (object, NULL));
gtk_label_set_text (GTK_LABEL (view->memsize_label), str);
g_free (str);
}
/* size in memory */
gimp_image_prop_view_label_set_memsize (view->memsize_label,
GIMP_OBJECT (image));
/* undo / redo */
gimp_image_prop_view_label_set_undo (view->undo_label, image->undo_stack);
gimp_image_prop_view_label_set_undo (view->redo_label, image->redo_stack);
gtk_table_set_row_spacing (GTK_TABLE (view), 6, 6);
/* number of layers */
g_snprintf (buf, sizeof (buf), "%d", image->width * image->height);

View File

@ -47,6 +47,8 @@ struct _GimpImagePropView
GtkWidget *resolution_label;
GtkWidget *colorspace_label;
GtkWidget *memsize_label;
GtkWidget *undo_label;
GtkWidget *redo_label;
GtkWidget *pixels_label;
GtkWidget *layers_label;
GtkWidget *channels_label;