Made size of undo previews configurable. Not dynamic for now, but at least

2004-03-07  Sven Neumann  <sven@gimp.org>

	Made size of undo previews configurable. Not dynamic for now, but
	at least not hardcoded any longer. Fixes bug #119905:

	* app/config/gimpcoreconfig.[ch]
	* app/config/gimprc-blurbs.h: added "undo-preview-size" property.

	* app/core/gimpundo.[ch]: use the new property instead of a
	hardcoded value.

	* app/widgets/gimpundoeditor.[ch]: added a "preview-size"
	construct property.

	* app/gui/dialogs-constructors.c: changed accordingly.

	* app/gui/preferences-dialog.c: added a widget to control the undo
	preview size.
This commit is contained in:
Sven Neumann 2004-03-07 15:33:04 +00:00 committed by Sven Neumann
parent de4e9fbbf4
commit 28bb855aae
12 changed files with 178 additions and 68 deletions

View File

@ -1,3 +1,22 @@
2004-03-07 Sven Neumann <sven@gimp.org>
Made size of undo previews configurable. Not dynamic for now, but
at least not hardcoded any longer. Fixes bug #119905:
* app/config/gimpcoreconfig.[ch]
* app/config/gimprc-blurbs.h: added "undo-preview-size" property.
* app/core/gimpundo.[ch]: use the new property instead of a
hardcoded value.
* app/widgets/gimpundoeditor.[ch]: added a "preview-size"
construct property.
* app/gui/dialogs-constructors.c: changed accordingly.
* app/gui/preferences-dialog.c: added a widget to control the undo
preview size.
2004-03-07 Sven Neumann <sven@gimp.org>
* tools/gimp-remote.c: more cleanup.

View File

@ -99,6 +99,7 @@ enum
PROP_DEFAULT_GRID,
PROP_UNDO_LEVELS,
PROP_UNDO_SIZE,
PROP_UNDO_PREVIEW_SIZE,
PROP_PLUGINRC_PATH,
PROP_LAYER_PREVIEWS,
PROP_LAYER_PREVIEW_SIZE,
@ -283,6 +284,11 @@ gimp_core_config_class_init (GimpCoreConfigClass *klass)
"undo-size", UNDO_SIZE_BLURB,
0, GIMP_MAX_MEMSIZE, 1 << 22,
GIMP_PARAM_CONFIRM);
GIMP_CONFIG_INSTALL_PROP_ENUM (object_class, PROP_UNDO_PREVIEW_SIZE,
"undo-preview-size", UNDO_PREVIEW_SIZE_BLURB,
GIMP_TYPE_PREVIEW_SIZE,
GIMP_PREVIEW_SIZE_LARGE,
GIMP_PARAM_RESTART);
GIMP_CONFIG_INSTALL_PROP_PATH (object_class,
PROP_PLUGINRC_PATH,
"pluginrc-path", PLUGINRC_PATH_BLURB,
@ -479,6 +485,9 @@ gimp_core_config_set_property (GObject *object,
case PROP_UNDO_SIZE:
core_config->undo_size = g_value_get_uint64 (value);
break;
case PROP_UNDO_PREVIEW_SIZE:
core_config->undo_preview_size = g_value_get_enum (value);
break;
case PROP_PLUGINRC_PATH:
g_free (core_config->plug_in_rc_path);
core_config->plug_in_rc_path = g_value_dup_string (value);
@ -599,6 +608,9 @@ gimp_core_config_get_property (GObject *object,
case PROP_UNDO_SIZE:
g_value_set_uint64 (value, core_config->undo_size);
break;
case PROP_UNDO_PREVIEW_SIZE:
g_value_set_enum (value, core_config->undo_preview_size);
break;
case PROP_PLUGINRC_PATH:
g_value_set_string (value, core_config->plug_in_rc_path);
break;

View File

@ -68,6 +68,7 @@ struct _GimpCoreConfig
GimpGrid *default_grid;
gint levels_of_undo;
guint64 undo_size;
GimpPreviewSize undo_preview_size;
gchar *plug_in_rc_path;
gboolean layer_previews;
GimpPreviewSize layer_preview_size;

View File

@ -369,6 +369,9 @@ N_("Sets an upper limit to the memory that is used per image to keep " \
"operations on the undo stack. Regardless of this setting, at least " \
"as many undo-levels as configured can be undone.")
#define UNDO_PREVIEW_SIZE_BLURB \
N_("Sets the size of the previews in the Undo History.")
#define USE_HELP_BLURB \
N_("When enabled, pressing F1 will open the help browser.")

View File

@ -24,6 +24,9 @@
#include "base/temp-buf.h"
#include "config/gimpcoreconfig.h"
#include "gimp.h"
#include "gimpimage.h"
#include "gimpmarshal.h"
#include "gimpundo.h"
@ -370,10 +373,12 @@ gimp_undo_create_preview_idle (gpointer data)
return FALSE;
}
void
static void
gimp_undo_create_preview_private (GimpUndo *undo)
{
GimpImage *image = undo->gimage;
GimpViewable *preview_viewable;
GimpPreviewSize preview_size;
gint width;
gint height;
@ -382,33 +387,32 @@ gimp_undo_create_preview_private (GimpUndo *undo)
case GIMP_UNDO_GROUP_IMAGE_QMASK:
case GIMP_UNDO_GROUP_MASK:
case GIMP_UNDO_MASK:
preview_viewable = GIMP_VIEWABLE (gimp_image_get_mask (undo->gimage));
preview_viewable = GIMP_VIEWABLE (gimp_image_get_mask (image));
break;
default:
preview_viewable = GIMP_VIEWABLE (undo->gimage);
preview_viewable = GIMP_VIEWABLE (image);
break;
}
if (undo->gimage->width <= GIMP_UNDO_PREVIEW_SIZE &&
undo->gimage->height <= GIMP_UNDO_PREVIEW_SIZE)
preview_size = image->gimp->config->undo_preview_size;
if (image->width <= preview_size && image->height <= preview_size)
{
width = undo->gimage->width;
height = undo->gimage->height;
width = image->width;
height = image->height;
}
else
{
if (undo->gimage->width > undo->gimage->height)
if (image->width > image->height)
{
width = GIMP_UNDO_PREVIEW_SIZE;
height = MAX (1, (undo->gimage->height * GIMP_UNDO_PREVIEW_SIZE /
undo->gimage->width));
width = preview_size;
height = MAX (1, (image->height * preview_size / image->width));
}
else
{
height = GIMP_UNDO_PREVIEW_SIZE;
width = MAX (1, (undo->gimage->width * GIMP_UNDO_PREVIEW_SIZE /
undo->gimage->height));
height = preview_size;
width = MAX (1, (image->width * preview_size / image->height));
}
}

View File

@ -23,9 +23,6 @@
#include "gimpviewable.h"
#define GIMP_UNDO_PREVIEW_SIZE GIMP_PREVIEW_SIZE_EXTRA_LARGE
struct _GimpUndoAccumulator
{
gboolean mode_changed;

View File

@ -804,12 +804,17 @@ dialogs_undo_history_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
GtkWidget *view;
GtkWidget *editor;
GtkWidget *dockable;
GimpImage *gimage;
view = gimp_undo_editor_new (gimp_context_get_image (context));
editor = gimp_undo_editor_new (context->gimp->config);
dockable = dialogs_dockable_new (view,
gimage = gimp_context_get_image (context);
if (gimage)
gimp_image_editor_set_image (GIMP_IMAGE_EDITOR (editor), gimage);
dockable = dialogs_dockable_new (editor,
_("Undo"), _("Undo History"),
GIMP_STOCK_UNDO_HISTORY,
GIMP_HELP_UNDO_DIALOG);

View File

@ -1199,7 +1199,7 @@ prefs_dialog_new (Gimp *gimp,
_("_Enable Layer & Channel Previews"),
GTK_BOX (vbox2));
table = prefs_table_new (2, GTK_CONTAINER (vbox2), FALSE);
table = prefs_table_new (3, GTK_CONTAINER (vbox2), FALSE);
prefs_enum_option_menu_add (object, "layer-preview-size", 0, 0,
_("Default _Layer & Channel Preview Size:"),
@ -1207,6 +1207,9 @@ prefs_dialog_new (Gimp *gimp,
prefs_enum_option_menu_add (object, "navigation-preview-size", 0, 0,
_("_Navigation Preview Size:"),
GTK_TABLE (table), 1);
prefs_enum_option_menu_add (object, "undo-preview-size", 0, 0,
_("_Undo History Preview Size:"),
GTK_TABLE (table), 2);
/* Dialog Bahavior */
vbox2 = prefs_frame_new (_("Dialog Behavior"), GTK_CONTAINER (vbox), FALSE);

View File

@ -804,12 +804,17 @@ dialogs_undo_history_new (GimpDialogFactory *factory,
GimpContext *context,
gint preview_size)
{
GtkWidget *view;
GtkWidget *editor;
GtkWidget *dockable;
GimpImage *gimage;
view = gimp_undo_editor_new (gimp_context_get_image (context));
editor = gimp_undo_editor_new (context->gimp->config);
dockable = dialogs_dockable_new (view,
gimage = gimp_context_get_image (context);
if (gimage)
gimp_image_editor_set_image (GIMP_IMAGE_EDITOR (editor), gimage);
dockable = dialogs_dockable_new (editor,
_("Undo"), _("Undo History"),
GIMP_STOCK_UNDO_HISTORY,
GIMP_HELP_UNDO_DIALOG);

View File

@ -1199,7 +1199,7 @@ prefs_dialog_new (Gimp *gimp,
_("_Enable Layer & Channel Previews"),
GTK_BOX (vbox2));
table = prefs_table_new (2, GTK_CONTAINER (vbox2), FALSE);
table = prefs_table_new (3, GTK_CONTAINER (vbox2), FALSE);
prefs_enum_option_menu_add (object, "layer-preview-size", 0, 0,
_("Default _Layer & Channel Preview Size:"),
@ -1207,6 +1207,9 @@ prefs_dialog_new (Gimp *gimp,
prefs_enum_option_menu_add (object, "navigation-preview-size", 0, 0,
_("_Navigation Preview Size:"),
GTK_TABLE (table), 1);
prefs_enum_option_menu_add (object, "undo-preview-size", 0, 0,
_("_Undo History Preview Size:"),
GTK_TABLE (table), 2);
/* Dialog Bahavior */
vbox2 = prefs_frame_new (_("Dialog Behavior"), GTK_CONTAINER (vbox), FALSE);

View File

@ -24,6 +24,8 @@
#include "widgets-types.h"
#include "config/gimpcoreconfig.h"
#include "core/gimp.h"
#include "core/gimplist.h"
#include "core/gimpimage.h"
@ -37,8 +39,21 @@
#include "gimp-intl.h"
enum
{
PROP_0,
PROP_PREVIEW_SIZE
};
static void gimp_undo_editor_class_init (GimpUndoEditorClass *klass);
static void gimp_undo_editor_init (GimpUndoEditor *undo_editor);
static GObject * gimp_undo_editor_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static void gimp_undo_editor_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_undo_editor_set_image (GimpImageEditor *editor,
GimpImage *gimage);
@ -96,13 +111,27 @@ gimp_undo_editor_get_type (void)
static void
gimp_undo_editor_class_init (GimpUndoEditorClass *klass)
{
GObjectClass *object_class;
GimpImageEditorClass *image_editor_class;
object_class = G_OBJECT_CLASS (klass);
image_editor_class = GIMP_IMAGE_EDITOR_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
object_class->constructor = gimp_undo_editor_constructor;
object_class->set_property = gimp_undo_editor_set_property;
image_editor_class->set_image = gimp_undo_editor_set_image;
g_object_class_install_property (object_class,
PROP_PREVIEW_SIZE,
g_param_spec_enum ("preview-size",
NULL, NULL,
GIMP_TYPE_PREVIEW_SIZE,
GIMP_PREVIEW_SIZE_LARGE,
G_PARAM_WRITABLE |
G_PARAM_CONSTRUCT_ONLY));
}
static void
@ -110,16 +139,6 @@ gimp_undo_editor_init (GimpUndoEditor *undo_editor)
{
undo_editor->container = NULL;
undo_editor->view = gimp_container_tree_view_new (NULL, NULL,
GIMP_UNDO_PREVIEW_SIZE, 1,
FALSE);
gtk_container_add (GTK_CONTAINER (undo_editor), undo_editor->view);
gtk_widget_show (undo_editor->view);
g_signal_connect (undo_editor->view, "select_item",
G_CALLBACK (gimp_undo_editor_select_item),
undo_editor);
undo_editor->undo_button =
gimp_editor_add_button (GIMP_EDITOR (undo_editor),
GTK_STOCK_UNDO, _("Undo"),
@ -137,6 +156,50 @@ gimp_undo_editor_init (GimpUndoEditor *undo_editor)
undo_editor);
}
static GObject *
gimp_undo_editor_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
GimpUndoEditor *undo_editor;
GObject *object;
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
undo_editor = GIMP_UNDO_EDITOR (object);
undo_editor->view = gimp_container_tree_view_new (NULL, NULL,
undo_editor->preview_size,
1, FALSE);
gtk_container_add (GTK_CONTAINER (undo_editor), undo_editor->view);
gtk_widget_show (undo_editor->view);
g_signal_connect (undo_editor->view, "select_item",
G_CALLBACK (gimp_undo_editor_select_item),
undo_editor);
return object;
}
static void
gimp_undo_editor_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec)
{
GimpUndoEditor *undo_editor = GIMP_UNDO_EDITOR (object);
switch (property_id)
{
case PROP_PREVIEW_SIZE:
undo_editor->preview_size = g_value_get_enum (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
gimp_undo_editor_set_image (GimpImageEditor *image_editor,
GimpImage *gimage)
@ -168,21 +231,15 @@ gimp_undo_editor_set_image (GimpImageEditor *image_editor,
/* public functions */
GtkWidget *
gimp_undo_editor_new (GimpImage *gimage)
gimp_undo_editor_new (GimpCoreConfig *config)
{
GimpUndoEditor *editor;
g_return_val_if_fail (GIMP_IS_CORE_CONFIG (config), NULL);
g_return_val_if_fail (! gimage || GIMP_IS_IMAGE (gimage), NULL);
editor = g_object_new (GIMP_TYPE_UNDO_EDITOR, NULL);
if (gimage)
gimp_image_editor_set_image (GIMP_IMAGE_EDITOR (editor), gimage);
return GTK_WIDGET (editor);
return g_object_new (GIMP_TYPE_UNDO_EDITOR,
"preview-size", config->undo_preview_size,
NULL);
}
/* private functions */
static void

View File

@ -39,6 +39,7 @@ struct _GimpUndoEditor
GimpContainer *container;
GtkWidget *view;
GimpPreviewSize preview_size;
GimpUndo *base_item;
@ -54,7 +55,7 @@ struct _GimpUndoEditorClass
GType gimp_undo_editor_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_undo_editor_new (GimpImage *gimage);
GtkWidget * gimp_undo_editor_new (GimpCoreConfig *config);
#endif /* __GIMP_UNDO_EDITOR_H__ */