General fix for bug #478657:

2007-09-21  Sven Neumann  <sven@gimp.org>

	General fix for bug #478657:

	* libgimp/gimpaspectpreview.c
	* libgimp/gimpdrawablepreview.c
	* libgimp/gimpzoompreview.c: let all preview widgets store the
	state of the Preview toggle. Declared "toggle" parameter as unused.

	* plug-ins/common/*.c: pass NULL for "toggle" to
	gimp_drawable_preview_new() and gimp_aspect_preview_new().

svn path=/trunk/; revision=23603
This commit is contained in:
Sven Neumann 2007-09-21 13:27:33 +00:00 committed by Sven Neumann
parent 24c7fc1e8d
commit 24c4243f28
34 changed files with 254 additions and 224 deletions

View file

@ -40,6 +40,16 @@ enum
PROP_DRAWABLE
};
typedef struct
{
gboolean update;
} PreviewSettings;
static GObject * gimp_aspect_preview_constructor (GType type,
guint n_params,
GObjectConstructParam *params);
static void gimp_aspect_preview_get_property (GObject *object,
guint property_id,
@ -49,6 +59,7 @@ static void gimp_aspect_preview_set_property (GObject *object,
guint property_id,
const GValue *value,
GParamSpec *pspec);
static void gimp_aspect_preview_destroy (GtkObject *object);
static void gimp_aspect_preview_style_set (GtkWidget *widget,
GtkStyle *prev_style);
static void gimp_aspect_preview_draw (GimpPreview *preview);
@ -74,17 +85,23 @@ G_DEFINE_TYPE (GimpAspectPreview, gimp_aspect_preview, GIMP_TYPE_PREVIEW)
#define parent_class gimp_aspect_preview_parent_class
static gint gimp_aspect_preview_counter = 0;
static void
gimp_aspect_preview_class_init (GimpAspectPreviewClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GimpPreviewClass *preview_class = GIMP_PREVIEW_CLASS (klass);
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkObjectClass *gtk_object_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
GimpPreviewClass *preview_class = GIMP_PREVIEW_CLASS (klass);
object_class->constructor = gimp_aspect_preview_constructor;
object_class->get_property = gimp_aspect_preview_get_property;
object_class->set_property = gimp_aspect_preview_set_property;
gtk_object_class->destroy = gimp_aspect_preview_destroy;
widget_class->style_set = gimp_aspect_preview_style_set;
preview_class->draw = gimp_aspect_preview_draw;
@ -112,6 +129,32 @@ gimp_aspect_preview_init (GimpAspectPreview *preview)
NULL);
}
static GObject *
gimp_aspect_preview_constructor (GType type,
guint n_params,
GObjectConstructParam *params)
{
GObject *object;
gchar *data_name;
PreviewSettings settings;
data_name = g_strdup_printf ("%s-aspect-preview-%d",
g_get_prgname (),
gimp_aspect_preview_counter++);
object = G_OBJECT_CLASS (parent_class)->constructor (type, n_params, params);
if (gimp_get_data (data_name, &settings))
{
gimp_preview_set_update (GIMP_PREVIEW (object), settings.update);
}
g_object_set_data_full (object, "gimp-aspect-preview-data-name",
data_name, (GDestroyNotify) g_free);
return object;
}
static void
gimp_aspect_preview_get_property (GObject *object,
guint property_id,
@ -153,6 +196,25 @@ gimp_aspect_preview_set_property (GObject *object,
}
}
static void
gimp_aspect_preview_destroy (GtkObject *object)
{
const gchar *data_name = g_object_get_data (G_OBJECT (object),
"gimp-aspect-preview-data-name");
if (data_name)
{
GimpPreview *preview = GIMP_PREVIEW (object);
PreviewSettings settings;
settings.update = gimp_preview_get_update (preview);
gimp_set_data (data_name, &settings, sizeof (PreviewSettings));
}
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
static void
gimp_aspect_preview_style_set (GtkWidget *widget,
GtkStyle *prev_style)
@ -299,46 +361,28 @@ gimp_aspect_preview_set_drawable (GimpAspectPreview *preview,
NULL);
}
static void
gimp_aspect_preview_notify_update (GimpPreview *preview,
GParamSpec *pspec,
gboolean *toggle)
{
*toggle = gimp_preview_get_update (preview);
}
/**
* gimp_aspect_preview_new:
* @drawable: a #GimpDrawable
* @toggle: pointer to a #gboolean variable to sync with the "Preview"
* check-button or %NULL
* @toggle: unused
*
* Creates a new #GimpAspectPreview widget for @drawable. See also
* gimp_drawable_preview_new().
*
* In GIMP 2.2 the @toggle parameter was provided to conviently access
* the state of the "Preview" check-button. This is not any longer
* necessary as the preview itself now stores this state, as well as
* the scroll offset.
*
* Since: GIMP 2.2
**/
GtkWidget *
gimp_aspect_preview_new (GimpDrawable *drawable,
gboolean *toggle)
{
GtkWidget *preview;
g_return_val_if_fail (drawable != NULL, NULL);
preview = g_object_new (GIMP_TYPE_ASPECT_PREVIEW,
"drawable", drawable,
NULL);
if (toggle)
{
gimp_preview_set_update (GIMP_PREVIEW (preview), *toggle);
g_signal_connect (preview, "notify::update",
G_CALLBACK (gimp_aspect_preview_notify_update),
toggle);
}
return preview;
return g_object_new (GIMP_TYPE_ASPECT_PREVIEW,
"drawable", drawable,
NULL);
}