gimp r25836 - in trunk: . app/dialogs app/display libgimpwidgets plug-ins/gfig plug-ins/imagemap
- From: neo svn gnome org
- To: svn-commits-list gnome org
- Subject: gimp r25836 - in trunk: . app/dialogs app/display libgimpwidgets plug-ins/gfig plug-ins/imagemap
- Date: Wed, 28 May 2008 10:18:43 +0000 (UTC)
Author: neo
Date: Wed May 28 10:18:43 2008
New Revision: 25836
URL: http://svn.gnome.org/viewvc/gimp?rev=25836&view=rev
Log:
2008-05-28 Sven Neumann <sven gimp org>
* libgimpwidgets/gimpruler.[ch]: started to sanitize the ruler
API.
* app/dialogs/resolution-calibrate-dialog.c
* app/display/gimpdisplayshell-scale.c
* plug-ins/gfig/gfig-preview.c
* plug-ins/imagemap/imap_preview.c
* libgimpwidgets/gimpwidgets.def: updated.
Modified:
trunk/ChangeLog
trunk/app/dialogs/resolution-calibrate-dialog.c
trunk/app/display/gimpdisplayshell-scale.c
trunk/libgimpwidgets/gimphruler.c
trunk/libgimpwidgets/gimpruler.c
trunk/libgimpwidgets/gimpruler.h
trunk/libgimpwidgets/gimpvruler.c
trunk/libgimpwidgets/gimpwidgets.def
trunk/plug-ins/gfig/gfig-preview.c
trunk/plug-ins/imagemap/imap_preview.c
Modified: trunk/app/dialogs/resolution-calibrate-dialog.c
==============================================================================
--- trunk/app/dialogs/resolution-calibrate-dialog.c (original)
+++ trunk/app/dialogs/resolution-calibrate-dialog.c Wed May 28 10:18:43 2008
@@ -107,14 +107,14 @@
ruler = gimp_hruler_new ();
gtk_widget_set_size_request (ruler, ruler_width, 32);
- gimp_ruler_set_range (GIMP_RULER (ruler), 0, ruler_width, 0, ruler_width);
+ gimp_ruler_set_range (GIMP_RULER (ruler), 0, ruler_width, ruler_width);
gtk_table_attach (GTK_TABLE (table), ruler, 1, 3, 0, 1,
GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_widget_show (ruler);
ruler = gimp_vruler_new ();
gtk_widget_set_size_request (ruler, 32, ruler_height);
- gimp_ruler_set_range (GIMP_RULER (ruler), 0, ruler_height, 0, ruler_height);
+ gimp_ruler_set_range (GIMP_RULER (ruler), 0, ruler_height, ruler_height);
gtk_table_attach (GTK_TABLE (table), ruler, 0, 1, 1, 3,
GTK_SHRINK, GTK_SHRINK, 0, 0);
gtk_widget_show (ruler);
Modified: trunk/app/display/gimpdisplayshell-scale.c
==============================================================================
--- trunk/app/display/gimpdisplayshell-scale.c (original)
+++ trunk/app/display/gimpdisplayshell-scale.c Wed May 28 10:18:43 2008
@@ -91,7 +91,6 @@
GimpImage *image;
gdouble lower;
gdouble upper;
- gdouble position;
gdouble max_size;
gfloat sx, sy;
gint image_width;
@@ -138,8 +137,6 @@
/* horizontal ruler */
- gimp_ruler_get_range (GIMP_RULER (shell->hrule),
- &lower, &upper, &position, &max_size);
lower = 0;
if (image)
@@ -176,13 +173,10 @@
shell->disp_xoffset = 0;
}
- gimp_ruler_set_range (GIMP_RULER (shell->hrule),
- lower, upper, position, max_size);
+ gimp_ruler_set_range (GIMP_RULER (shell->hrule), lower, upper, max_size);
/* vertical ruler */
- gimp_ruler_get_range (GIMP_RULER (shell->vrule),
- &lower, &upper, &position, &max_size);
lower = 0;
if (image)
@@ -219,8 +213,7 @@
shell->disp_yoffset = 0;
}
- gimp_ruler_set_range (GIMP_RULER (shell->vrule),
- lower, upper, position, max_size);
+ gimp_ruler_set_range (GIMP_RULER (shell->vrule), lower, upper, max_size);
#if 0
Modified: trunk/libgimpwidgets/gimphruler.c
==============================================================================
--- trunk/libgimpwidgets/gimphruler.c (original)
+++ trunk/libgimpwidgets/gimphruler.c Wed May 28 10:18:43 2008
@@ -97,7 +97,7 @@
gdk_event_request_motions (event);
x = event->x;
- gimp_ruler_get_range (ruler, &lower, &upper, NULL, NULL);
+ gimp_ruler_get_range (ruler, &lower, &upper, NULL);
position = lower + ((upper - lower) * x) / widget->allocation.width;
@@ -165,13 +165,10 @@
widget->allocation.width - 2 * xthickness,
1);
- gimp_ruler_get_range (ruler, &lower, &upper, NULL, &max_size);
+ gimp_ruler_get_range (ruler, &lower, &upper, &max_size);
metric = _gimp_ruler_get_metric (ruler);
- upper = upper / metric->pixels_per_unit;
- lower = lower / metric->pixels_per_unit;
-
if ((upper - lower) == 0)
goto out;
@@ -182,7 +179,7 @@
* text_width = gdk_string_width(font, unit_str), so that the result
* for the scale looks consistent with an accompanying vruler
*/
- scale = ceil (max_size / metric->pixels_per_unit);
+ scale = ceil (max_size);
g_snprintf (unit_str, sizeof (unit_str), "%d", scale);
text_width = strlen (unit_str) * digit_height + 1;
@@ -300,7 +297,9 @@
priv->xsrc, priv->ysrc,
bs_width, bs_height);
- gimp_ruler_get_range (ruler, &lower, &upper, &position, NULL);
+ position = gimp_ruler_get_position (ruler);
+
+ gimp_ruler_get_range (ruler, &lower, &upper, NULL);
increment = (gdouble) width / (upper - lower);
Modified: trunk/libgimpwidgets/gimpruler.c
==============================================================================
--- trunk/libgimpwidgets/gimpruler.c (original)
+++ trunk/libgimpwidgets/gimpruler.c Wed May 28 10:18:43 2008
@@ -31,18 +31,17 @@
*/
typedef struct
{
- GdkPixmap *backing_store;
- GdkGC *non_gr_exp_gc;
- GimpRulerMetric *metric;
+ GdkPixmap *backing_store;
+ GdkGC *non_gr_exp_gc;
/* The upper limit of the ruler (in points) */
- gdouble lower;
+ gdouble lower;
/* The lower limit of the ruler */
- gdouble upper;
+ gdouble upper;
/* The position of the mark on the ruler */
- gdouble position;
+ gdouble position;
/* The maximum size of the ruler */
- gdouble max_size;
+ gdouble max_size;
} GimpRulerPrivate;
enum
@@ -51,8 +50,7 @@
PROP_LOWER,
PROP_UPPER,
PROP_POSITION,
- PROP_MAX_SIZE,
- PROP_METRIC
+ PROP_MAX_SIZE
};
static void gimp_ruler_realize (GtkWidget *widget);
@@ -71,22 +69,11 @@
GValue *value,
GParamSpec *pspec);
-static const GimpRulerMetric const ruler_metrics[] =
+static const GimpRulerMetric ruler_metric =
{
{
- "Pixel", "Pi", 1.0,
{ 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000, 2500, 5000, 10000, 25000, 50000, 100000 },
{ 1, 5, 10, 50, 100 }
- },
- {
- "Inches", "In", 72.0,
- { 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768 },
- { 1, 2, 4, 8, 16 }
- },
- {
- "Centimeters", "Cm", 28.35,
- { 1, 2, 5, 10, 25, 50, 100, 250, 500, 1000, 2550, 5000, 10000, 25000, 50000, 100000 },
- { 1, 5, 10, 50, 100 }
}
};
@@ -154,14 +141,6 @@
G_MAXDOUBLE,
0.0,
GIMP_PARAM_READWRITE));
- g_object_class_install_property (object_class,
- PROP_METRIC,
- g_param_spec_enum ("metric",
- "Metric",
- "The metric used for the ruler",
- GTK_TYPE_METRIC_TYPE,
- GTK_PIXELS,
- GIMP_PARAM_READWRITE));
}
static void
@@ -174,8 +153,6 @@
priv->upper = 0;
priv->position = 0;
priv->max_size = 0;
-
- gimp_ruler_set_metric (ruler, GTK_PIXELS);
}
static void
@@ -190,23 +167,25 @@
switch (prop_id)
{
case PROP_LOWER:
- gimp_ruler_set_range (ruler, g_value_get_double (value), priv->upper,
- priv->position, priv->max_size);
+ gimp_ruler_set_range (ruler,
+ g_value_get_double (value),
+ priv->upper,
+ priv->max_size);
break;
case PROP_UPPER:
- gimp_ruler_set_range (ruler, priv->lower, g_value_get_double (value),
- priv->position, priv->max_size);
+ gimp_ruler_set_range (ruler,
+ priv->lower,
+ g_value_get_double (value),
+ priv->max_size);
break;
case PROP_POSITION:
- gimp_ruler_set_range (ruler, priv->lower, priv->upper,
- g_value_get_double (value), priv->max_size);
+ gimp_ruler_set_position (ruler, g_value_get_double (value));
break;
case PROP_MAX_SIZE:
- gimp_ruler_set_range (ruler, priv->lower, priv->upper,
- priv->position, g_value_get_double (value));
- break;
- case PROP_METRIC:
- gimp_ruler_set_metric (ruler, g_value_get_enum (value));
+ gimp_ruler_set_range (ruler,
+ priv->lower,
+ priv->upper,
+ g_value_get_double (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -237,9 +216,6 @@
case PROP_MAX_SIZE:
g_value_set_double (value, priv->max_size);
break;
- case PROP_METRIC:
- g_value_set_enum (value, gimp_ruler_get_metric (ruler));
- break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
@@ -247,8 +223,8 @@
}
void
-gimp_ruler_set_metric (GimpRuler *ruler,
- GtkMetricType metric)
+gimp_ruler_set_position (GimpRuler *ruler,
+ gdouble position)
{
GimpRulerPrivate *priv;
@@ -256,41 +232,23 @@
priv = GIMP_RULER_GET_PRIVATE (ruler);
- priv->metric = (GimpRulerMetric *) &ruler_metrics[metric];
+ if (priv->position != position)
+ {
+ priv->position = position;
+ g_object_notify (G_OBJECT (ruler), "position");
+ }
if (GTK_WIDGET_DRAWABLE (ruler))
gtk_widget_queue_draw (GTK_WIDGET (ruler));
-
- g_object_notify (G_OBJECT (ruler), "metric");
}
-/**
- * gimp_ruler_get_metric:
- * @ruler: a #GimpRuler
- *
- * Gets the units used for a #GimpRuler. See gimp_ruler_set_metric().
- *
- * Return value: the units currently used for @ruler
- *
- * Since: GIMP 2.8
- **/
-GtkMetricType
-gimp_ruler_get_metric (GimpRuler *ruler)
-{
- GimpRulerPrivate *priv;
- gint i;
-
- g_return_val_if_fail (GIMP_IS_RULER (ruler), 0);
-
- priv = GIMP_RULER_GET_PRIVATE (ruler);
-
- for (i = 0; i < G_N_ELEMENTS (ruler_metrics); i++)
- if (priv->metric == &ruler_metrics[i])
- return i;
- g_assert_not_reached ();
+gdouble
+gimp_ruler_get_position (GimpRuler *ruler)
+{
+ g_return_val_if_fail (GIMP_IS_RULER (ruler), 0.0);
- return 0;
+ return GIMP_RULER_GET_PRIVATE (ruler)->position;
}
/**
@@ -298,7 +256,6 @@
* @ruler: the gtkruler
* @lower: the lower limit of the ruler
* @upper: the upper limit of the ruler
- * @position: the mark on the ruler
* @max_size: the maximum size of the ruler used when calculating the space to
* leave for the text
*
@@ -310,7 +267,6 @@
gimp_ruler_set_range (GimpRuler *ruler,
gdouble lower,
gdouble upper,
- gdouble position,
gdouble max_size)
{
GimpRulerPrivate *priv;
@@ -330,11 +286,6 @@
priv->upper = upper;
g_object_notify (G_OBJECT (ruler), "upper");
}
- if (priv->position != position)
- {
- priv->position = position;
- g_object_notify (G_OBJECT (ruler), "position");
- }
if (priv->max_size != max_size)
{
priv->max_size = max_size;
@@ -351,7 +302,6 @@
* @ruler: a #GimpRuler
* @lower: location to store lower limit of the ruler, or %NULL
* @upper: location to store upper limit of the ruler, or %NULL
- * @position: location to store the current position of the mark on the ruler, or %NULL
* @max_size: location to store the maximum size of the ruler used when calculating
* the space to leave for the text, or %NULL.
*
@@ -364,7 +314,6 @@
gimp_ruler_get_range (GimpRuler *ruler,
gdouble *lower,
gdouble *upper,
- gdouble *position,
gdouble *max_size)
{
GimpRulerPrivate *priv;
@@ -377,8 +326,6 @@
*lower = priv->lower;
if (upper)
*upper = priv->upper;
- if (position)
- *position = priv->position;
if (max_size)
*max_size = priv->max_size;
}
@@ -411,7 +358,7 @@
const GimpRulerMetric *
_gimp_ruler_get_metric (GimpRuler *ruler)
{
- return GIMP_RULER_GET_PRIVATE (ruler)->metric;
+ return &ruler_metric;
}
PangoLayout *
Modified: trunk/libgimpwidgets/gimpruler.h
==============================================================================
--- trunk/libgimpwidgets/gimpruler.h (original)
+++ trunk/libgimpwidgets/gimpruler.h Wed May 28 10:18:43 2008
@@ -55,39 +55,35 @@
struct _GimpRulerMetric
{
- const gchar *metric_name;
- const gchar *abbrev;
- /* This should be points_per_unit. This is the size of the unit
- * in 1/72nd's of an inch and has nothing to do with screen pixels */
- gdouble pixels_per_unit;
- gdouble ruler_scale[16];
- gint subdivide[5]; /* five possible modes of subdivision */
+ gdouble ruler_scale[16];
+ gint subdivide[5]; /* five possible modes of subdivision */
};
-GType gimp_ruler_get_type (void) G_GNUC_CONST;
-void gimp_ruler_set_metric (GimpRuler *ruler,
- GtkMetricType metric);
-void gimp_ruler_set_range (GimpRuler *ruler,
- gdouble lower,
- gdouble upper,
- gdouble position,
- gdouble max_size);
-void gimp_ruler_draw_ticks (GimpRuler *ruler);
-void gimp_ruler_draw_pos (GimpRuler *ruler);
-
-GtkMetricType gimp_ruler_get_metric (GimpRuler *ruler);
-void gimp_ruler_get_range (GimpRuler *ruler,
- gdouble *lower,
- gdouble *upper,
- gdouble *position,
- gdouble *max_size);
+GType gimp_ruler_get_type (void) G_GNUC_CONST;
+
+void gimp_ruler_set_position (GimpRuler *ruler,
+ gdouble position);
+gdouble gimp_ruler_get_position (GimpRuler *ruler);
+void gimp_ruler_set_range (GimpRuler *ruler,
+ gdouble lower,
+ gdouble upper,
+ gdouble max_size);
+void gimp_ruler_get_range (GimpRuler *ruler,
+ gdouble *lower,
+ gdouble *upper,
+ gdouble *max_size);
+
+void gimp_ruler_draw_ticks (GimpRuler *ruler);
+void gimp_ruler_draw_pos (GimpRuler *ruler);
+
GdkDrawable * _gimp_ruler_get_backing_store (GimpRuler *ruler) G_GNUC_INTERNAL;
const GimpRulerMetric * _gimp_ruler_get_metric (GimpRuler *ruler) G_GNUC_INTERNAL;
PangoLayout * _gimp_ruler_create_pango_layout (GtkWidget *widget,
const gchar *text) G_GNUC_INTERNAL;
+
G_END_DECLS
#endif /* __GIMP_RULER_H__ */
Modified: trunk/libgimpwidgets/gimpvruler.c
==============================================================================
--- trunk/libgimpwidgets/gimpvruler.c (original)
+++ trunk/libgimpwidgets/gimpvruler.c Wed May 28 10:18:43 2008
@@ -98,7 +98,7 @@
gdk_event_request_motions (event);
y = event->y;
- gimp_ruler_get_range (ruler, &lower, &upper, NULL, NULL);
+ gimp_ruler_get_range (ruler, &lower, &upper, NULL);
position = lower + ((upper - lower) * y) / widget->allocation.height;
g_object_set (ruler, "position", position, NULL);
@@ -165,12 +165,12 @@
1,
widget->allocation.height - 2 * ythickness);
- gimp_ruler_get_range (ruler, &lower, &upper, NULL, &max_size);
+ gimp_ruler_get_range (ruler, &lower, &upper, &max_size);
metric = _gimp_ruler_get_metric (ruler);
- upper = upper / metric->pixels_per_unit;
- lower = lower / metric->pixels_per_unit;
+ upper = upper;
+ lower = lower;
if ((upper - lower) == 0)
goto out;
@@ -183,7 +183,7 @@
* of this displayed text. Use this height to find a scale which
* leaves sufficient room for drawing the ruler.
*/
- scale = ceil (max_size / metric->pixels_per_unit);
+ scale = ceil (max_size);
g_snprintf (unit_str, sizeof (unit_str), "%d", scale);
text_height = strlen (unit_str) * digit_height + 1;
@@ -304,7 +304,9 @@
priv->xsrc, priv->ysrc,
bs_width, bs_height);
- gimp_ruler_get_range (ruler, &lower, &upper, &position, NULL);
+ position = gimp_ruler_get_position (ruler);
+
+ gimp_ruler_get_range (ruler, &lower, &upper, NULL);
increment = (gdouble) height / (upper - lower);
Modified: trunk/libgimpwidgets/gimpwidgets.def
==============================================================================
--- trunk/libgimpwidgets/gimpwidgets.def (original)
+++ trunk/libgimpwidgets/gimpwidgets.def Wed May 28 10:18:43 2008
@@ -305,10 +305,10 @@
gimp_random_seed_new
gimp_ruler_draw_pos
gimp_ruler_draw_ticks
- gimp_ruler_get_metric
+ gimp_ruler_get_position
gimp_ruler_get_range
gimp_ruler_get_type
- gimp_ruler_set_metric
+ gimp_ruler_set_position
gimp_ruler_set_range
gimp_scale_entry_get_logarithmic
gimp_scale_entry_new
Modified: trunk/plug-ins/gfig/gfig-preview.c
==============================================================================
--- trunk/plug-ins/gfig/gfig-preview.c (original)
+++ trunk/plug-ins/gfig/gfig-preview.c Wed May 28 10:18:43 2008
@@ -100,7 +100,7 @@
gtk_container_add (GTK_CONTAINER (frame), table);
ruler = gimp_hruler_new ();
- gimp_ruler_set_range (GIMP_RULER (ruler), 0, preview_width, 0, PREVIEW_SIZE);
+ gimp_ruler_set_range (GIMP_RULER (ruler), 0, preview_width, PREVIEW_SIZE);
g_signal_connect_swapped (gfig_context->preview, "motion-notify-event",
G_CALLBACK (GTK_WIDGET_CLASS (G_OBJECT_GET_CLASS (ruler))->motion_notify_event),
ruler);
@@ -109,7 +109,7 @@
gtk_widget_show (ruler);
ruler = gimp_vruler_new ();
- gimp_ruler_set_range (GIMP_RULER (ruler), 0, preview_height, 0, PREVIEW_SIZE);
+ gimp_ruler_set_range (GIMP_RULER (ruler), 0, preview_height, PREVIEW_SIZE);
g_signal_connect_swapped (gfig_context->preview, "motion-notify-event",
G_CALLBACK (GTK_WIDGET_CLASS (G_OBJECT_GET_CLASS (ruler))->motion_notify_event),
ruler);
Modified: trunk/plug-ins/imagemap/imap_preview.c
==============================================================================
--- trunk/plug-ins/imagemap/imap_preview.c (original)
+++ trunk/plug-ins/imagemap/imap_preview.c Wed May 28 10:18:43 2008
@@ -404,7 +404,7 @@
{
Preview_t * preview = preview_void;
- render_preview(preview, &preview->src_rgn);
+ render_preview (preview, &preview->src_rgn);
}
static void
@@ -412,8 +412,7 @@
GtkRuler *ruler)
{
gimp_ruler_set_range (ruler,
- adj->value, adj->value + adj->page_size,
- G_MAXDOUBLE, adj->page_size);
+ adj->value, adj->value + adj->page_size, adj->upper);
}
Preview_t*
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]