libgimp/gimpdrawablepreview.[ch] always show the "Preview" check button.

2004-09-01  Sven Neumann  <sven@gimp.org>

	* libgimp/gimpdrawablepreview.[ch]
	* libgimpwidgets/gimppreview.[ch]: always show the "Preview" check
	button. Simplified the preview APIs, moved the "size" style
	property to the GimpPreview class.

	* etc/gtkrc: changed the example accordingly.

	* plug-ins/common/despeckle.c
	* plug-ins/common/gauss.c
	* plug-ins/common/neon.c
	* plug-ins/common/sobel.c
	* plug-ins/common/softglow.c
	* plug-ins/common/spread.c
	* plug-ins/common/unsharp.c: follow change in GimpDrawablePreview API.
This commit is contained in:
Sven Neumann 2004-09-01 14:01:10 +00:00 committed by Sven Neumann
parent aeb2888657
commit 3155d682a5
21 changed files with 261 additions and 188 deletions

View File

@ -1,3 +1,20 @@
2004-09-01 Sven Neumann <sven@gimp.org>
* libgimp/gimpdrawablepreview.[ch]
* libgimpwidgets/gimppreview.[ch]: always show the "Preview" check
button. Simplified the preview APIs, moved the "size" style
property to the GimpPreview class.
* etc/gtkrc: changed the example accordingly.
* plug-ins/common/despeckle.c
* plug-ins/common/gauss.c
* plug-ins/common/neon.c
* plug-ins/common/sobel.c
* plug-ins/common/softglow.c
* plug-ins/common/spread.c
* plug-ins/common/unsharp.c: follow change in GimpDrawablePreview API.
2004-09-01 Michael Natterer <mitch@gimp.org>
* plug-ins/script-fu/script-fu-types.h (struct SFOptions): changed

View File

@ -1,3 +1,14 @@
2004-09-01 Sven Neumann <sven@gimp.org>
* libgimp/tmpl/gimpprogressbar.sgml
* libgimp/libgimp-docs.sgml
* libgimp/libgimp-sections.txt
* libgimp/libgimp.types
* libgimp/tmpl/gimpdrawablepreview.sgml
* libgimpwidgets/libgimpwidgets-sections.txt
* libgimpwidgets/tmpl/gimppreview.sgml: updated for GimpProgressBar
and GimpPreview API changes.
2004-08-31 Sven Neumann <sven@gimp.org>
* libgimp/Makefile.am

View File

@ -83,6 +83,7 @@
<xi:include href="xml/gimpdrawablecombobox.xml" />
<xi:include href="xml/gimpimagecombobox.xml" />
<xi:include href="xml/gimppixbuf.xml" />
<xi:include href="xml/gimpprogressbar.xml" />
<xi:include href="xml/gimpmenu.xml" />
<xi:include href="xml/gimpbrushmenu.xml" />
<xi:include href="xml/gimpfontmenu.xml" />

View File

@ -687,7 +687,6 @@ gimp_drawable_get_thumbnail
<TITLE>GimpDrawablePreview</TITLE>
GimpDrawablePreview
gimp_drawable_preview_new
gimp_drawable_preview_new_with_toggle
gimp_drawable_preview_draw
<SUBSECTION Standard>
GimpDrawablePreviewClass
@ -714,6 +713,22 @@ GimpImageConstraintFunc
gimp_image_combo_box_new
</SECTION>
<SECTION>
<FILE>gimpprogressbar</FILE>
<TITLE>GimpProgressBar</TITLE>
GimpProgressBar
gimp_progress_bar_new
<SUBSECTION Standard>
GimpProgressBarClass
GIMP_PROGRESS_BAR
GIMP_IS_PROGRESS_BAR
GIMP_TYPE_PROGRESS_BAR
gimp_progress_bar_get_type
GIMP_PROGRESS_BAR_CLASS
GIMP_IS_PROGRESS_BAR_CLASS
GIMP_PROGRESS_BAR_GET_CLASS
</SECTION>
<SECTION>
<FILE>gimpmenu</FILE>
GimpConstraintFunc

View File

@ -3,3 +3,4 @@
#include <libgimp/gimpui.h>
gimp_drawable_preview_get_type
gimp_progress_bar_get_type

View File

@ -25,15 +25,6 @@ GimpDrawablePreview
</para>
@drawable:
@Returns:
<!-- ##### FUNCTION gimp_drawable_preview_new_with_toggle ##### -->
<para>
</para>
@drawable:
@toggle:
@Returns:

View File

@ -0,0 +1,30 @@
<!-- ##### SECTION Title ##### -->
GimpProgressBar
<!-- ##### SECTION Short_Description ##### -->
<!-- ##### SECTION Long_Description ##### -->
<para>
</para>
<!-- ##### SECTION See_Also ##### -->
<para>
</para>
<!-- ##### STRUCT GimpProgressBar ##### -->
<para>
</para>
<!-- ##### FUNCTION gimp_progress_bar_new ##### -->
<para>
</para>
@Returns:

View File

@ -798,9 +798,10 @@ GIMP_PREVIEW_AREA_GET_CLASS
<FILE>gimppreview</FILE>
<TITLE>GimpPreview</TITLE>
GimpPreview
gimp_preview_get_update
gimp_preview_set_update
gimp_preview_get_size
gimp_preview_get_position
gimp_preview_show_update_toggle
gimp_preview_invalidate
<SUBSECTION Standard>
GimpPreviewClass

View File

@ -27,16 +27,34 @@ GimpPreview
@gimppreview: the object which received the signal.
<!-- ##### ARG GimpPreview:show-update-toggle ##### -->
<para>
</para>
<!-- ##### ARG GimpPreview:update ##### -->
<para>
</para>
<!-- ##### ARG GimpPreview:size ##### -->
<para>
</para>
<!-- ##### FUNCTION gimp_preview_get_update ##### -->
<para>
</para>
@preview:
@Returns:
<!-- ##### FUNCTION gimp_preview_set_update ##### -->
<para>
</para>
@preview:
@update:
<!-- ##### FUNCTION gimp_preview_get_size ##### -->
<para>
@ -57,15 +75,6 @@ GimpPreview
@y:
<!-- ##### FUNCTION gimp_preview_show_update_toggle ##### -->
<para>
</para>
@preview:
@show_update:
<!-- ##### FUNCTION gimp_preview_invalidate ##### -->
<para>

View File

@ -30,14 +30,14 @@ binding "gimp-help-binding"
#
# Adjust the size of drawable previews in plug-in dialogs:
# Adjust the size of previews in plug-in dialogs:
#
style "gimp-large-preview"
{
GimpDrawablePreview::size = 256
GimpPreview::size = 256
}
# class "GimpDrawablePreview" style "gimp-large-preview"
# class "GimpPreview" style "gimp-large-preview"
#

View File

@ -32,7 +32,6 @@
#include "gimpdrawablepreview.h"
#define DEFAULT_SIZE 150
#define SELECTION_BORDER 2
@ -85,13 +84,6 @@ gimp_drawable_preview_class_init (GimpDrawablePreviewClass *klass)
widget_class->style_set = gimp_drawable_preview_style_set;
preview_class->draw = gimp_drawable_preview_draw_original;
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("size",
NULL, NULL,
1, 1024,
DEFAULT_SIZE,
G_PARAM_READABLE));
}
static void
@ -173,18 +165,34 @@ gimp_drawable_preview_set_drawable (GimpDrawablePreview *drawable_preview,
preview->ymax = MIN (y2 + SELECTION_BORDER, height);
}
static void
gimp_drawable_preview_notify_update (GimpPreview *preview,
GParamSpec *pspec,
gboolean *toggle)
{
*toggle = gimp_preview_get_update (preview);
}
/**
* gimp_drawable_preview_new:
* @drawable: a #GimpDrawable
* @toggle: pointer to a #gboolean variable to sync with the "Preview"
* check-button or %NULL
*
* Creates a new #GimpDrawablePreview widget for @drawable.
* Creates a new #GimpDrawablePreview widget for @drawable. If
* updating the preview takes considerable time, you will want to
* store the state of the "Preview" check-button in the plug-in
* data. For convenience you can pass a pointer to the #gboolean as
* @toggle.
*
* Returns: A pointer to the new #GimpDrawablePreview widget.
*
* Since: GIMP 2.2
**/
GtkWidget *
gimp_drawable_preview_new (GimpDrawable *drawable)
gimp_drawable_preview_new (GimpDrawable *drawable,
gboolean *toggle)
{
GimpDrawablePreview *preview;
@ -192,35 +200,14 @@ gimp_drawable_preview_new (GimpDrawable *drawable)
preview = g_object_new (GIMP_TYPE_DRAWABLE_PREVIEW, NULL);
gimp_drawable_preview_set_drawable (preview, drawable);
if (toggle)
{
gimp_preview_set_update (GIMP_PREVIEW (preview), *toggle);
return GTK_WIDGET (preview);
}
/**
* gimp_drawable_preview_new_with_toggle:
* @drawable: a #GimpDrawable
* @toggle:
*
* Creates a new #GimpDrawablePreview widget for @drawable.
*
* Returns: A pointer to the new #GimpDrawablePreview widget.
*
* Since: GIMP 2.2
**/
GtkWidget *
gimp_drawable_preview_new_with_toggle (GimpDrawable *drawable,
gboolean *toggle)
{
GimpDrawablePreview *preview;
g_return_val_if_fail (drawable != NULL, NULL);
g_return_val_if_fail (toggle != NULL, NULL);
preview = g_object_new (GIMP_TYPE_DRAWABLE_PREVIEW,
"show_update_toggle", TRUE,
"update", *toggle,
NULL);
g_signal_connect (preview, "notify::update",
G_CALLBACK (gimp_drawable_preview_notify_update),
toggle);
}
gimp_drawable_preview_set_drawable (preview, drawable);

View File

@ -55,8 +55,7 @@ struct _GimpDrawablePreviewClass
GType gimp_drawable_preview_get_type (void) G_GNUC_CONST;
GtkWidget * gimp_drawable_preview_new (GimpDrawable *drawable);
GtkWidget * gimp_drawable_preview_new_with_toggle (GimpDrawable *drawable,
GtkWidget * gimp_drawable_preview_new (GimpDrawable *drawable,
gboolean *toggle);
void gimp_drawable_preview_draw (GimpDrawablePreview *preview,

View File

@ -30,6 +30,7 @@
#include "libgimp/libgimp-intl.h"
#define DEFAULT_SIZE 150
#define PREVIEW_TIMEOUT 200
@ -42,8 +43,7 @@ enum
enum
{
PROP_0,
PROP_UPDATE,
PROP_SHOW_UPDATE_TOGGLE
PROP_UPDATE
};
@ -116,6 +116,7 @@ static void
gimp_preview_class_init (GimpPreviewClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
parent_class = g_type_class_peek_parent (klass);
@ -140,16 +141,14 @@ gimp_preview_class_init (GimpPreviewClass *klass)
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
g_object_class_install_property (object_class,
PROP_SHOW_UPDATE_TOGGLE,
g_param_spec_boolean ("show_update_toggle",
NULL, NULL,
FALSE,
G_PARAM_READWRITE |
G_PARAM_CONSTRUCT));
klass->draw = NULL;
gtk_widget_class_install_style_property (widget_class,
g_param_spec_int ("size",
NULL, NULL,
1, 1024,
DEFAULT_SIZE,
G_PARAM_READABLE));
}
static void
@ -157,6 +156,7 @@ gimp_preview_init (GimpPreview *preview)
{
GtkTable *table = GTK_TABLE (preview);
GtkWidget *frame;
GtkObject *adj;
gtk_table_resize (table, 3, 2);
gtk_table_set_homogeneous (table, FALSE);
@ -172,27 +172,27 @@ gimp_preview_init (GimpPreview *preview)
preview->width = preview->xmax - preview->xmin;
preview->height = preview->ymax - preview->ymin;
preview->hadj = gtk_adjustment_new (0, 0, preview->width - 1, 1.0,
adj = gtk_adjustment_new (0, 0, preview->width - 1, 1.0,
preview->width, preview->width);
g_signal_connect (preview->hadj, "value_changed",
g_signal_connect (adj, "value_changed",
G_CALLBACK (gimp_preview_h_scroll),
preview);
preview->hscr = gtk_hscrollbar_new (GTK_ADJUSTMENT (preview->hadj));
preview->hscr = gtk_hscrollbar_new (GTK_ADJUSTMENT (adj));
gtk_range_set_update_policy (GTK_RANGE (preview->hscr),
GTK_UPDATE_CONTINUOUS);
gtk_table_attach (table, preview->hscr, 0,1, 1,2,
GTK_EXPAND | GTK_SHRINK | GTK_FILL, GTK_FILL, 0, 0);
preview->vadj = gtk_adjustment_new (0, 0, preview->height - 1, 1.0,
adj = gtk_adjustment_new (0, 0, preview->height - 1, 1.0,
preview->height, preview->height);
g_signal_connect (preview->vadj, "value_changed",
g_signal_connect (adj, "value_changed",
G_CALLBACK (gimp_preview_v_scroll),
preview);
preview->vscr = gtk_vscrollbar_new (GTK_ADJUSTMENT (preview->vadj));
preview->vscr = gtk_vscrollbar_new (GTK_ADJUSTMENT (adj));
gtk_range_set_update_policy (GTK_RANGE (preview->vscr),
GTK_UPDATE_CONTINUOUS);
gtk_table_attach (table, preview->vscr, 1,2, 0,1,
@ -231,15 +231,16 @@ gimp_preview_init (GimpPreview *preview)
/* a toggle button to (des)activate the instant preview */
preview->toggle_update = gtk_check_button_new_with_mnemonic (_("_Preview"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (preview->toggle_update),
preview->toggle = gtk_check_button_new_with_mnemonic (_("_Preview"));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (preview->toggle),
preview->update_preview);
gtk_table_set_row_spacing (GTK_TABLE (preview), 1, 6);
gtk_table_attach (table, preview->toggle_update,
gtk_table_attach (table, preview->toggle,
0, 2, 2, 3, GTK_FILL, GTK_FILL, 0, 0);
gtk_widget_show (preview->toggle);
g_signal_connect (preview->toggle_update, "toggled",
g_signal_connect (preview->toggle, "toggled",
G_CALLBACK (gimp_preview_toggle_callback),
preview);
}
@ -272,10 +273,6 @@ gimp_preview_get_property (GObject *object,
g_value_set_boolean (value, preview->update_preview);
break;
case PROP_SHOW_UPDATE_TOGGLE:
g_value_set_boolean (value, GTK_WIDGET_VISIBLE (preview->toggle_update));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@ -293,17 +290,10 @@ gimp_preview_set_property (GObject *object,
switch (property_id)
{
case PROP_UPDATE:
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (preview->toggle_update),
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (preview->toggle),
g_value_get_boolean (value));
break;
case PROP_SHOW_UPDATE_TOGGLE:
if (g_value_get_boolean (value))
gtk_widget_show (preview->toggle_update);
else
gtk_widget_hide (preview->toggle_update);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
@ -467,8 +457,8 @@ gimp_preview_area_event (GtkWidget *area,
if (preview->xoff != xoff || preview->yoff != yoff)
{
gtk_adjustment_set_value (GTK_ADJUSTMENT (preview->hadj), xoff);
gtk_adjustment_set_value (GTK_ADJUSTMENT (preview->vadj), yoff);
gtk_range_set_value (GTK_RANGE (preview->hscr), xoff);
gtk_range_set_value (GTK_RANGE (preview->vscr), yoff);
gimp_preview_draw (preview);
gimp_preview_invalidate (preview);
@ -569,6 +559,40 @@ gimp_preview_invalidate_now (GimpPreview *preview)
return FALSE;
}
/**
* gimp_preview_set_update:
* @preview: a #GimpPreview widget
* @update:
*
* Since: GIMP 2.2
**/
void
gimp_preview_set_update (GimpPreview *preview,
gboolean update)
{
g_return_if_fail (GIMP_IS_PREVIEW (preview));
g_object_set (preview,
"update", update,
NULL);
}
/**
* gimp_preview_get_update:
* @preview: a #GimpPreview widget
*
* Return value: the state of the "Preview" check button.
*
* Since: GIMP 2.2
**/
gboolean
gimp_preview_get_update (GimpPreview *preview)
{
g_return_val_if_fail (GIMP_IS_PREVIEW (preview), FALSE);
return preview->update_preview;
}
/**
* gimp_preview_get_size:
* @preview: a #GimpPreview widget
@ -613,24 +637,6 @@ gimp_preview_get_position (GimpPreview *preview,
*y = preview->yoff + preview->ymin;
}
/**
* gimp_preview_show_update_toggle:
* @preview: a #GimpPreview widget
* @show_update: whether to show the "Update Preview" toggle button
*
* Since: GIMP 2.2
**/
void
gimp_preview_show_update_toggle (GimpPreview *preview,
gboolean show_update)
{
g_return_if_fail (GIMP_IS_PREVIEW (preview));
g_object_set (preview,
"show_update_toggle", show_update,
NULL);
}
/*
* gimp_preview_invalidate:
* @preview: a #GimpPreview widget

View File

@ -44,23 +44,26 @@ struct _GimpPreview
{
GtkTable parent_instance;
gboolean update_preview;
/*< protected >*/
GtkWidget *area;
GtkWidget *hscr;
GtkWidget *vscr;
GtkWidget *toggle;
GdkCursor *cursor_move;
GdkCursor *cursor_busy;
/*< private >*/
gint xoff, yoff;
gint xmin, xmax, ymin, ymax;
gint drag_x, drag_y;
gint drag_xoff, drag_yoff;
gint width, height;
GtkObject *hadj, *vadj;
GtkWidget *hscr, *vscr;
gboolean in_drag;
GtkWidget *area;
GtkWidget *toggle_update;
gboolean update_preview;
guint timeout_id;
GdkCursor *cursor_move;
GdkCursor *cursor_busy;
};
gboolean in_drag;
guint timeout_id;
};
struct _GimpPreviewClass
{
GtkTableClass parent_class;
@ -75,19 +78,20 @@ struct _GimpPreviewClass
GType gimp_preview_get_type (void) G_GNUC_CONST;
void gimp_preview_set_update (GimpPreview *preview,
gboolean update);
gboolean gimp_preview_get_update (GimpPreview *preview);
void gimp_preview_get_size (GimpPreview *preview,
gint *width,
gint *height);
void gimp_preview_get_position (GimpPreview *preview,
gint *x,
gint *y);
void gimp_preview_show_update_toggle (GimpPreview *preview,
gboolean show_update);
void gimp_preview_invalidate (GimpPreview *preview);
G_END_DECLS
#endif /* __GIMP_PREVIEW_H__ */

View File

@ -598,7 +598,7 @@ despeckle_dialog (void)
gtk_box_pack_start (GTK_BOX (main_vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
preview = gimp_drawable_preview_new (drawable);
preview = gimp_drawable_preview_new (drawable, NULL);
gtk_box_pack_start (GTK_BOX (hbox), preview, FALSE, FALSE, 0);
gtk_widget_show (preview);
g_signal_connect (preview, "invalidated",

View File

@ -476,7 +476,7 @@ gauss_dialog (gint32 image_ID,
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
preview = gimp_drawable_preview_new (drawable);
preview = gimp_drawable_preview_new (drawable, NULL);
gtk_box_pack_start (GTK_BOX (hbox), preview, FALSE, FALSE, 0);
gtk_widget_show (preview);

View File

@ -703,7 +703,7 @@ neon_dialog (GimpDrawable *drawable)
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
preview = gimp_drawable_preview_new (drawable);
preview = gimp_drawable_preview_new (drawable, NULL);
gtk_box_pack_start (GTK_BOX (hbox), preview, FALSE, FALSE, 0);
gtk_widget_show (preview);
g_signal_connect (preview, "invalidated",

View File

@ -245,7 +245,7 @@ sobel_dialog (GimpDrawable *drawable)
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
preview = gimp_drawable_preview_new (drawable);
preview = gimp_drawable_preview_new (drawable, NULL);
gtk_box_pack_start (GTK_BOX (hbox), preview, FALSE, FALSE, 0);
gtk_widget_show (preview);
g_signal_connect (preview, "invalidated",

View File

@ -471,7 +471,8 @@ softglow (GimpDrawable *drawable,
}
else
{
gimp_pixel_rgn_init (&dest_rgn, drawable, x1, y1, width, height, TRUE, TRUE);
gimp_pixel_rgn_init (&dest_rgn,
drawable, x1, y1, width, height, TRUE, TRUE);
for (pr = gimp_pixel_rgns_register (2, &src_rgn, &dest_rgn);
pr != NULL;
@ -674,7 +675,7 @@ softglow_dialog (GimpDrawable *drawable)
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
preview = gimp_drawable_preview_new (drawable);
preview = gimp_drawable_preview_new (drawable, NULL);
gtk_box_pack_start (GTK_BOX (hbox), preview, FALSE, FALSE, 0);
gtk_widget_show (preview);
g_signal_connect_swapped (preview, "invalidated",

View File

@ -284,7 +284,8 @@ spread (GimpDrawable *drawable)
}
static void
spread_updating_preview (GimpPreview *preview, GtkWidget *size)
spread_updating_preview (GimpPreview *preview,
GtkWidget *size)
{
SpreadParam_t param;
gint x, y, bpp;
@ -356,7 +357,7 @@ spread_dialog (gint32 image_ID,
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
preview = gimp_drawable_preview_new (drawable);
preview = gimp_drawable_preview_new (drawable, NULL);
gtk_box_pack_start (GTK_BOX (hbox), preview, FALSE, FALSE, 0);
gtk_widget_show (preview);

View File

@ -676,8 +676,7 @@ unsharp_mask_dialog (GimpDrawable *drawable)
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
preview =
gimp_drawable_preview_new_with_toggle (drawable,
preview = gimp_drawable_preview_new (drawable,
&unsharp_params.update_preview);
gtk_box_pack_start (GTK_BOX (hbox), preview, FALSE, FALSE, 0);
gtk_widget_show (preview);