app: use the new unit conversion functions

and get rid of the brainfuck idea that app/ has to use _gimp_unit_foo()
functions, passing a gimp pointer. Instead, simply use the libgimpbase
API all over the place. Should we ever allow more than one gimp instance,
they will simply have to share one unit database.
This commit is contained in:
Michael Natterer
2010-02-21 16:46:39 +01:00
parent 52041715a9
commit 0908e53148
14 changed files with 123 additions and 191 deletions

View File

@ -22,6 +22,7 @@
#include <gegl.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpmath/gimpmath.h"
#include "libgimpcolor/gimpcolor.h"
@ -42,7 +43,6 @@
#include "gimppattern.h"
#include "gimpscanconvert.h"
#include "gimpstrokeoptions.h"
#include "gimpunit.h"
#include "vectors/gimpstroke.h"
#include "vectors/gimpvectors.h"
@ -358,8 +358,8 @@ gimp_drawable_stroke_scan_convert (GimpDrawable *drawable,
gimp_scan_convert_set_pixel_ratio (scan_convert, yres / xres);
width *= (yres /
_gimp_unit_get_factor (image->gimp, stroke_options->unit));
width = gimp_units_to_pixels (stroke_options->width,
stroke_options->unit, yres);
}
gimp_scan_convert_stroke (scan_convert, width,

View File

@ -37,7 +37,6 @@
#include "core/gimpimage.h"
#include "core/gimpimage-pick-color.h"
#include "core/gimpitem.h"
#include "core/gimpunit.h"
#include "widgets/gimpcolorframe.h"
#include "widgets/gimpdocked.h"
@ -118,7 +117,6 @@ static void gimp_cursor_view_shell_unit_changed (GimpCursorView *view,
GParamSpec *pspec,
GimpDisplayShell *shell);
static void gimp_cursor_view_format_as_unit (GimpUnit unit,
Gimp *gimp,
gchar *output_buf,
gint output_buf_size,
gdouble pixel_value,
@ -443,7 +441,6 @@ gimp_cursor_view_get_aux_info (GimpDocked *docked)
static void
gimp_cursor_view_format_as_unit (GimpUnit unit,
Gimp *gimp,
gchar *output_buf,
gint output_buf_size,
gdouble pixel_value,
@ -454,22 +451,16 @@ gimp_cursor_view_format_as_unit (GimpUnit unit,
gint unit_digits = 0;
const gchar *unit_str = "";
value = gimp_pixels_to_units (pixel_value, unit, image_res);
if (unit != GIMP_UNIT_PIXEL)
{
gdouble unit_factor;
unit_factor = _gimp_unit_get_factor (gimp, unit);
unit_digits = _gimp_unit_get_digits (gimp, unit);
unit_str = _gimp_unit_get_abbreviation (gimp, unit);
value = pixel_value * unit_factor / image_res;
}
else
{
value = pixel_value;
unit_digits = gimp_unit_get_digits (unit);
unit_str = gimp_unit_get_abbreviation (unit);
}
g_snprintf (format_buf, sizeof (format_buf), "%%.%df %s", unit_digits, unit_str);
g_snprintf (format_buf, sizeof (format_buf),
"%%.%df %s", unit_digits, unit_str);
g_snprintf (output_buf, output_buf_size, format_buf, value);
}
@ -578,7 +569,9 @@ static void
gimp_cursor_view_mask_changed (GimpCursorView *view,
GimpImage *image)
{
gimp_cursor_view_update_selection_info (view, view->priv->image, view->priv->unit);
gimp_cursor_view_update_selection_info (view,
view->priv->image,
view->priv->unit);
}
static void
@ -645,26 +638,25 @@ static void gimp_cursor_view_update_selection_info (GimpCursorView *view,
if (bounds_exist)
{
Gimp *gimp = image->gimp;
gint width, height;
gdouble xres, yres;
gchar buf[32];
gint width, height;
gdouble xres, yres;
gchar buf[32];
width = x2 - x1;
height = y2 - y1;
gimp_image_get_resolution (image, &xres, &yres);
gimp_cursor_view_format_as_unit (unit, gimp, buf, sizeof (buf), x1, xres);
gimp_cursor_view_format_as_unit (unit, buf, sizeof (buf), x1, xres);
gtk_label_set_text (GTK_LABEL (view->priv->selection_x_label), buf);
gimp_cursor_view_format_as_unit (unit, gimp, buf, sizeof (buf), y1, yres);
gimp_cursor_view_format_as_unit (unit, buf, sizeof (buf), y1, yres);
gtk_label_set_text (GTK_LABEL (view->priv->selection_y_label), buf);
gimp_cursor_view_format_as_unit (unit, gimp, buf, sizeof (buf), width, xres);
gimp_cursor_view_format_as_unit (unit, buf, sizeof (buf), width, xres);
gtk_label_set_text (GTK_LABEL (view->priv->selection_width_label), buf);
gimp_cursor_view_format_as_unit (unit, gimp, buf, sizeof (buf), height, yres);
gimp_cursor_view_format_as_unit (unit, buf, sizeof (buf), height, yres);
gtk_label_set_text (GTK_LABEL (view->priv->selection_height_label), buf);
}
else
@ -750,11 +742,11 @@ gimp_cursor_view_update_cursor (GimpCursorView *view,
gtk_label_set_text (GTK_LABEL (view->priv->pixel_y_label), buf);
gimp_cursor_view_set_label_italic (view->priv->pixel_y_label, ! in_image);
gimp_cursor_view_format_as_unit (unit, image->gimp, buf, sizeof (buf), x, xres);
gimp_cursor_view_format_as_unit (unit, buf, sizeof (buf), x, xres);
gtk_label_set_text (GTK_LABEL (view->priv->unit_x_label), buf);
gimp_cursor_view_set_label_italic (view->priv->unit_x_label, ! in_image);
gimp_cursor_view_format_as_unit (unit, image->gimp, buf, sizeof (buf), y, yres);
gimp_cursor_view_format_as_unit (unit, buf, sizeof (buf), y, yres);
gtk_label_set_text (GTK_LABEL (view->priv->unit_y_label), buf);
gimp_cursor_view_set_label_italic (view->priv->unit_y_label, ! in_image);
@ -794,5 +786,7 @@ gimp_cursor_view_clear_cursor (GimpCursorView *view)
gimp_color_frame_set_invalid (GIMP_COLOR_FRAME (view->priv->color_frame_2));
/* Start showing selection info from the active image again */
gimp_cursor_view_update_selection_info (view, view->priv->image, view->priv->unit);
gimp_cursor_view_update_selection_info (view,
view->priv->image,
view->priv->unit);
}

View File

@ -20,6 +20,7 @@
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpmath/gimpmath.h"
#include "libgimpwidgets/gimpwidgets.h"
@ -29,7 +30,6 @@
#include "core/gimp.h"
#include "core/gimpimage.h"
#include "core/gimpunit.h"
#include "gimpdisplay.h"
#include "gimpdisplayshell.h"
@ -1122,18 +1122,10 @@ img2real (GimpDisplayShell *shell,
{
gdouble xres;
gdouble yres;
gdouble res;
if (shell->unit == GIMP_UNIT_PIXEL)
return len;
gimp_image_get_resolution (gimp_display_get_image (shell->display),
&xres, &yres);
if (xdir)
res = xres;
else
res = yres;
return len * _gimp_unit_get_factor (shell->display->gimp, shell->unit) / res;
return gimp_pixels_to_units (len, gimp_unit_get_factor (shell->unit),
xdir ? xres : yres);
}

View File

@ -22,6 +22,7 @@
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpwidgets/gimpwidgets.h"
#include "libgimpbase/gimpbase.h"
@ -34,7 +35,6 @@
#include "core/gimpdrawable.h"
#include "core/gimpimage.h"
#include "core/gimpitem.h"
#include "core/gimpunit.h"
#include "file/file-utils.h"
#include "file/gimp-file.h"
@ -380,11 +380,10 @@ gimp_display_shell_format_title (GimpDisplayShell *shell,
gimp_image_get_resolution (image, &xres, &yres);
g_snprintf (unit_format, sizeof (unit_format), "%%.%df",
_gimp_unit_get_digits (gimp, shell->unit) + 1);
gimp_unit_get_digits (shell->unit) + 1);
i += print (title, title_len, i, unit_format,
(gimp_image_get_width (image) *
_gimp_unit_get_factor (gimp, shell->unit) /
xres));
gimp_pixels_to_units (gimp_image_get_width (image),
shell->unit, xres));
break;
}
/* else fallthru */
@ -403,11 +402,10 @@ gimp_display_shell_format_title (GimpDisplayShell *shell,
gimp_image_get_resolution (image, &xres, &yres);
g_snprintf (unit_format, sizeof (unit_format), "%%.%df",
_gimp_unit_get_digits (gimp, shell->unit) + 1);
gimp_unit_get_digits (shell->unit) + 1);
i += print (title, title_len, i, unit_format,
(gimp_image_get_height (image) *
_gimp_unit_get_factor (gimp, shell->unit) /
yres));
gimp_pixels_to_units (gimp_image_get_height (image),
shell->unit, yres));
break;
}
/* else fallthru */
@ -418,12 +416,12 @@ gimp_display_shell_format_title (GimpDisplayShell *shell,
case 'u': /* unit symbol */
i += print (title, title_len, i, "%s",
_gimp_unit_get_symbol (gimp, shell->unit));
gimp_unit_get_symbol (shell->unit));
break;
case 'U': /* unit abbreviation */
i += print (title, title_len, i, "%s",
_gimp_unit_get_abbreviation (gimp, shell->unit));
gimp_unit_get_abbreviation (shell->unit));
break;
/* Other cool things to be added:

View File

@ -24,6 +24,7 @@
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpmath/gimpmath.h"
#include "libgimpwidgets/gimpwidgets.h"
@ -32,7 +33,6 @@
#include "config/gimpdisplayconfig.h"
#include "core/gimpimage.h"
#include "core/gimpunit.h"
#include "core/gimpprogress.h"
#include "widgets/gimpunitstore.h"
@ -944,8 +944,6 @@ gimp_statusbar_push_coords (GimpStatusbar *statusbar,
{
gdouble xres;
gdouble yres;
gdouble unit_factor = _gimp_unit_get_factor (shell->display->gimp,
shell->unit);
gimp_image_get_resolution (gimp_display_get_image (shell->display),
&xres, &yres);
@ -954,9 +952,9 @@ gimp_statusbar_push_coords (GimpStatusbar *statusbar,
stock_id,
statusbar->cursor_format_str,
title,
x * unit_factor / xres,
gimp_pixels_to_units (x, shell->unit, xres),
separator,
y * unit_factor / yres,
gimp_pixels_to_units (y, shell->unit, yres),
help);
}
}
@ -994,8 +992,6 @@ gimp_statusbar_push_length (GimpStatusbar *statusbar,
gdouble xres;
gdouble yres;
gdouble resolution;
gdouble unit_factor = _gimp_unit_get_factor (shell->display->gimp,
shell->unit);
gimp_image_get_resolution (gimp_display_get_image (shell->display),
&xres, &yres);
@ -1019,7 +1015,7 @@ gimp_statusbar_push_length (GimpStatusbar *statusbar,
stock_id,
statusbar->length_format_str,
title,
value * unit_factor / resolution,
gimp_pixels_to_units (value, shell->unit, resolution),
help);
}
}
@ -1441,13 +1437,13 @@ gimp_statusbar_shell_scaled (GimpDisplayShell *shell,
g_snprintf (statusbar->cursor_format_str,
sizeof (statusbar->cursor_format_str),
"%%s%%.%df%%s%%.%df%%s",
_gimp_unit_get_digits (shell->display->gimp, shell->unit),
_gimp_unit_get_digits (shell->display->gimp, shell->unit));
gimp_unit_get_digits (shell->unit),
gimp_unit_get_digits (shell->unit));
strcpy (statusbar->cursor_format_str_f, statusbar->cursor_format_str);
g_snprintf (statusbar->length_format_str,
sizeof (statusbar->length_format_str),
"%%s%%.%df%%s",
_gimp_unit_get_digits (shell->display->gimp, shell->unit));
gimp_unit_get_digits (shell->unit));
}
gimp_statusbar_update_cursor (statusbar, GIMP_CURSOR_PRECISION_SUBPIXEL,

View File

@ -23,12 +23,12 @@
#include <gegl.h>
#include <pango/pangocairo.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpmath/gimpmath.h"
#include "text-types.h"
#include "core/gimpimage.h"
#include "core/gimpunit.h"
#include "gimptext.h"
#include "gimptextlayout.h"
@ -54,12 +54,10 @@ static PangoContext * gimp_text_get_pango_context (GimpText *text,
gdouble xres,
gdouble yres);
static gint gimp_text_layout_pixel_size (Gimp *gimp,
gdouble value,
static gint gimp_text_layout_pixel_size (gdouble value,
GimpUnit unit,
gdouble res);
static gint gimp_text_layout_point_size (Gimp *gimp,
gdouble value,
static gint gimp_text_layout_point_size (gdouble value,
GimpUnit unit,
gdouble res);
@ -123,8 +121,7 @@ gimp_text_layout_new (GimpText *text,
gimp_image_get_resolution (image, &xres, &yres);
size = gimp_text_layout_point_size (image->gimp,
text->font_size,
size = gimp_text_layout_point_size (text->font_size,
text->unit,
yres);
@ -176,21 +173,18 @@ gimp_text_layout_new (GimpText *text,
break;
case GIMP_TEXT_BOX_FIXED:
pango_layout_set_width (layout->layout,
gimp_text_layout_pixel_size (image->gimp,
text->box_width,
gimp_text_layout_pixel_size (text->box_width,
text->box_unit,
xres));
break;
}
pango_layout_set_indent (layout->layout,
gimp_text_layout_pixel_size (image->gimp,
text->indent,
gimp_text_layout_pixel_size (text->indent,
text->unit,
xres));
pango_layout_set_spacing (layout->layout,
gimp_text_layout_pixel_size (image->gimp,
text->line_spacing,
gimp_text_layout_pixel_size (text->line_spacing,
text->unit,
yres));
if (fabs (text->letter_spacing) > 0.1)
@ -217,13 +211,11 @@ gimp_text_layout_new (GimpText *text,
break;
case GIMP_TEXT_BOX_FIXED:
layout->extents.width =
PANGO_PIXELS (gimp_text_layout_pixel_size (image->gimp,
text->box_width,
PANGO_PIXELS (gimp_text_layout_pixel_size (text->box_width,
text->box_unit,
xres));
layout->extents.height =
PANGO_PIXELS (gimp_text_layout_pixel_size (image->gimp,
text->box_height,
PANGO_PIXELS (gimp_text_layout_pixel_size (text->box_height,
text->box_unit,
yres));
break;
@ -596,10 +588,9 @@ gimp_text_get_pango_context (GimpText *text,
}
static gint
gimp_text_layout_pixel_size (Gimp *gimp,
gdouble value,
GimpUnit unit,
gdouble res)
gimp_text_layout_pixel_size (gdouble value,
GimpUnit unit,
gdouble res)
{
gdouble factor;
@ -609,7 +600,7 @@ gimp_text_layout_pixel_size (Gimp *gimp,
return PANGO_SCALE * value;
default:
factor = _gimp_unit_get_factor (gimp, unit);
factor = gimp_unit_get_factor (unit);
g_return_val_if_fail (factor > 0.0, 0);
return PANGO_SCALE * value * res / factor;
@ -617,10 +608,9 @@ gimp_text_layout_pixel_size (Gimp *gimp,
}
static gint
gimp_text_layout_point_size (Gimp *gimp,
gdouble value,
GimpUnit unit,
gdouble res)
gimp_text_layout_point_size (gdouble value,
GimpUnit unit,
gdouble res)
{
gdouble factor;
@ -632,13 +622,13 @@ gimp_text_layout_point_size (Gimp *gimp,
case GIMP_UNIT_PIXEL:
g_return_val_if_fail (res > 0.0, 0);
return (PANGO_SCALE * value *
_gimp_unit_get_factor (gimp, GIMP_UNIT_POINT) / res);
gimp_unit_get_factor (GIMP_UNIT_POINT) / res);
default:
factor = _gimp_unit_get_factor (gimp, unit);
factor = gimp_unit_get_factor (unit);
g_return_val_if_fail (factor > 0.0, 0);
return (PANGO_SCALE * value *
_gimp_unit_get_factor (gimp, GIMP_UNIT_POINT) / factor);
gimp_unit_get_factor (GIMP_UNIT_POINT) / factor);
}
}

View File

@ -26,6 +26,7 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpmath/gimpmath.h"
#include "libgimpwidgets/gimpwidgets.h"
@ -36,7 +37,6 @@
#include "core/gimpimage-guides.h"
#include "core/gimpimage-undo.h"
#include "core/gimpimage-undo-push.h"
#include "core/gimpunit.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimptooldialog.h"
@ -849,15 +849,13 @@ gimp_measure_tool_dialog_update (GimpMeasureTool *measure,
gimp_image_get_resolution (image, &xres, &yres);
unit_width = (_gimp_unit_get_factor (image->gimp, shell->unit) *
pixel_width / xres);
unit_height = (_gimp_unit_get_factor (image->gimp, shell->unit) *
pixel_height / yres);
unit_width = gimp_pixels_to_units (pixel_width, shell->unit, xres);
unit_height = gimp_pixels_to_units (pixel_height, shell->unit, yres);
pixel_distance = sqrt (SQR (ax - bx) + SQR (ay - by));
unit_distance = (_gimp_unit_get_factor (image->gimp, shell->unit) *
sqrt (SQR ((gdouble)(ax - bx) / xres) +
SQR ((gdouble)(ay - by) / yres)));
unit_distance = (gimp_unit_get_factor (shell->unit) *
sqrt (SQR ((gdouble) (ax - bx) / xres) +
SQR ((gdouble) (ay - by) / yres)));
if (measure->num_points != 3)
bx = ax > 0 ? 1 : -1;
@ -890,10 +888,10 @@ gimp_measure_tool_dialog_update (GimpMeasureTool *measure,
{
g_snprintf (format, sizeof (format),
"%%.%df %s, %%.2f\302\260 (%%.%df × %%.%df)",
_gimp_unit_get_digits (image->gimp, shell->unit),
_gimp_unit_get_plural (image->gimp, shell->unit),
_gimp_unit_get_digits (image->gimp, shell->unit),
_gimp_unit_get_digits (image->gimp, shell->unit));
gimp_unit_get_digits (shell->unit),
gimp_unit_get_plural (shell->unit),
gimp_unit_get_digits (shell->unit),
gimp_unit_get_digits (shell->unit));
gimp_tool_replace_status (GIMP_TOOL (measure), display, format,
unit_distance, unit_angle,
@ -906,7 +904,8 @@ gimp_measure_tool_dialog_update (GimpMeasureTool *measure,
gchar buf[128];
g_snprintf (format, sizeof (format), "%%.%df",
_gimp_unit_get_digits (image->gimp, shell->unit));
gimp_unit_get_digits (shell->unit));
/* Distance */
g_snprintf (buf, sizeof (buf), "%.1f", pixel_distance);
gtk_label_set_text (GTK_LABEL (measure->distance_label[0]), buf);
@ -917,7 +916,7 @@ gimp_measure_tool_dialog_update (GimpMeasureTool *measure,
gtk_label_set_text (GTK_LABEL (measure->distance_label[1]), buf);
gtk_label_set_text (GTK_LABEL (measure->unit_label[0]),
_gimp_unit_get_plural (image->gimp, shell->unit));
gimp_unit_get_plural (shell->unit));
}
else
{
@ -952,7 +951,7 @@ gimp_measure_tool_dialog_update (GimpMeasureTool *measure,
gtk_label_set_text (GTK_LABEL (measure->width_label[1]), buf);
gtk_label_set_text (GTK_LABEL (measure->unit_label[2]),
_gimp_unit_get_plural (image->gimp, shell->unit));
gimp_unit_get_plural (shell->unit));
}
else
{
@ -970,7 +969,7 @@ gimp_measure_tool_dialog_update (GimpMeasureTool *measure,
gtk_label_set_text (GTK_LABEL (measure->height_label[1]), buf);
gtk_label_set_text (GTK_LABEL (measure->unit_label[3]),
_gimp_unit_get_plural (image->gimp, shell->unit));
gimp_unit_get_plural (shell->unit));
}
else
{

View File

@ -20,6 +20,7 @@
#include <gegl.h>
#include <gtk/gtk.h>
#include "libgimpbase/gimpbase.h"
#include "libgimpmath/gimpmath.h"
#include "tools-types.h"
@ -32,7 +33,6 @@
#include "core/gimppaintinfo.h"
#include "core/gimpprojection.h"
#include "core/gimptoolinfo.h"
#include "core/gimpunit.h"
#include "paint/gimppaintcore.h"
#include "paint/gimppaintoptions.h"
@ -651,10 +651,10 @@ gimp_paint_tool_oper_update (GimpTool *tool,
gimp_image_get_resolution (image, &xres, &yres);
g_snprintf (format_str, sizeof (format_str), "%%.%df %s. %%s",
_gimp_unit_get_digits (image->gimp, shell->unit),
_gimp_unit_get_symbol (image->gimp, shell->unit));
gimp_unit_get_digits (shell->unit),
gimp_unit_get_symbol (shell->unit));
dist = (_gimp_unit_get_factor (image->gimp, shell->unit) *
dist = (gimp_unit_get_factor (shell->unit) *
sqrt (SQR (dx / xres) +
SQR (dy / yres)));

View File

@ -30,7 +30,6 @@
#include "core/gimp-transform-utils.h"
#include "core/gimpimage.h"
#include "core/gimpdrawable-transform.h"
#include "core/gimpunit.h"
#include "widgets/gimphelp-ids.h"
#include "widgets/gimpsizebox.h"

View File

@ -38,7 +38,6 @@
#include "core/gimplayer-floating-sel.h"
#include "core/gimpmarshal.h"
#include "core/gimptoolinfo.h"
#include "core/gimpunit.h"
#include "text/gimptext.h"
#include "text/gimptext-vectors.h"
@ -866,27 +865,6 @@ gimp_text_tool_frame_item (GimpTextTool *text_tool)
text_tool->handle_rectangle_change_complete = TRUE;
}
static gdouble
pixels_to_units (Gimp *gimp,
gdouble pixels,
GimpUnit unit,
gdouble resolution)
{
gdouble factor;
switch (unit)
{
case GIMP_UNIT_PIXEL:
return pixels;
default:
factor = _gimp_unit_get_factor (gimp, unit);
return pixels * factor / resolution;
break;
}
}
static gboolean
gimp_text_tool_rectangle_change_complete (GimpRectangleTool *rect_tool)
{
@ -928,14 +906,12 @@ gimp_text_tool_rectangle_change_complete (GimpRectangleTool *rect_tool)
g_object_set (text_tool->proxy,
"box-mode", GIMP_TEXT_BOX_FIXED,
"box-width", pixels_to_units (text_tool->image->gimp,
x2 - x1,
text_tool->proxy->unit,
xres),
"box-height", pixels_to_units (text_tool->image->gimp,
y2 - y1,
text_tool->proxy->unit,
yres),
"box-width", gimp_pixels_to_units (x2 - x1,
text_tool->proxy->unit,
xres),
"box-height", gimp_pixels_to_units (y2 - y1,
text_tool->proxy->unit,
yres),
NULL);
gimp_image_undo_group_start (text_tool->image, GIMP_UNDO_GROUP_TEXT,
@ -1350,14 +1326,12 @@ gimp_text_tool_create_layer (GimpTextTool *text_tool,
g_object_set (text_tool->proxy,
"box-mode", GIMP_TEXT_BOX_FIXED,
"box-width", pixels_to_units (image->gimp,
x2 - x1,
text_tool->proxy->unit,
xres),
"box-height", pixels_to_units (image->gimp,
y2 - y1,
text_tool->proxy->unit,
yres),
"box-width", gimp_pixels_to_units (x2 - x1,
text_tool->proxy->unit,
xres),
"box-height", gimp_pixels_to_units (y2 - y1,
text_tool->proxy->unit,
yres),
NULL);
}
else

View File

@ -29,7 +29,6 @@
#include "core/gimpimage.h"
#include "core/gimpitem.h"
#include "core/gimpunit.h"
#include "gimpanchor.h"
#include "gimpstroke.h"
@ -195,10 +194,8 @@ gimp_vectors_export_image_size (const GimpImage *image,
break;
}
g_ascii_formatd (wbuf, sizeof (wbuf),
"%g", w * _gimp_unit_get_factor (image->gimp, unit));
g_ascii_formatd (hbuf, sizeof (hbuf),
"%g", h * _gimp_unit_get_factor (image->gimp, unit));
g_ascii_formatd (wbuf, sizeof (wbuf), "%g", w * gimp_unit_get_factor (unit));
g_ascii_formatd (hbuf, sizeof (hbuf), "%g", h * gimp_unit_get_factor (unit));
g_string_append_printf (str,
"width=\"%s%s\" height=\"%s%s\"",

View File

@ -42,7 +42,6 @@
#include "core/gimpimage-colormap.h"
#include "core/gimpimage-undo.h"
#include "core/gimpundostack.h"
#include "core/gimpunit.h"
#include "core/gimp-utils.h"
#include "file/file-procedure.h"
@ -454,23 +453,22 @@ gimp_image_prop_view_update (GimpImagePropView *view)
/* print size */
unit = gimp_get_default_unit ();
unit_factor = _gimp_unit_get_factor (image->gimp, unit);
unit_digits = _gimp_unit_get_digits (image->gimp, unit);
unit_digits = gimp_unit_get_digits (unit);
g_snprintf (format_buf, sizeof (format_buf), "%%.%df × %%.%df %s",
unit_digits + 1, unit_digits + 1,
_gimp_unit_get_plural (image->gimp, unit));
gimp_unit_get_plural (unit));
g_snprintf (buf, sizeof (buf), format_buf,
gimp_image_get_width (image) * unit_factor / xres,
gimp_image_get_height (image) * unit_factor / yres);
gimp_pixels_to_units (gimp_image_get_width (image), unit, xres),
gimp_pixels_to_units (gimp_image_get_height (image), unit, yres));
gtk_label_set_text (GTK_LABEL (view->print_size_label), buf);
/* resolution */
unit = gimp_image_get_unit (image);
unit_factor = _gimp_unit_get_factor (image->gimp, unit);
unit = gimp_image_get_unit (image);
unit_factor = gimp_unit_get_factor (unit);
g_snprintf (format_buf, sizeof (format_buf), _("pixels/%s"),
_gimp_unit_get_abbreviation (image->gimp, unit));
gimp_unit_get_abbreviation (unit));
g_snprintf (buf, sizeof (buf), _("%g × %g %s"),
xres / unit_factor,
yres / unit_factor,

View File

@ -52,7 +52,6 @@
#include "core/gimpprogress.h"
#include "core/gimpselection.h"
#include "core/gimptemplate.h"
#include "core/gimpunit.h"
#include "text/gimptextlayer.h"
#include "text/gimptextlayer-xcf.h"
@ -566,7 +565,7 @@ xcf_load_image_props (XcfInfo *info,
info->cp += xcf_read_int32 (info->fp, &unit, 1);
if ((unit <= GIMP_UNIT_PIXEL) ||
(unit >= _gimp_unit_get_number_of_built_in_units (image->gimp)))
(unit >= gimp_unit_get_number_of_built_in_units ()))
{
gimp_message_literal (info->gimp, G_OBJECT (info->progress),
GIMP_MESSAGE_WARNING,
@ -600,19 +599,17 @@ xcf_load_image_props (XcfInfo *info,
if (unit_strings[i] == NULL)
unit_strings[i] = g_strdup ("");
num_units = _gimp_unit_get_number_of_units (image->gimp);
num_units = gimp_unit_get_number_of_units ();
for (unit = _gimp_unit_get_number_of_built_in_units (image->gimp);
for (unit = gimp_unit_get_number_of_built_in_units ();
unit < num_units; unit++)
{
/* if the factor and the identifier match some unit
* in unitrc, use the unitrc unit
*/
if ((ABS (_gimp_unit_get_factor (image->gimp,
unit) - factor) < 1e-5) &&
if ((ABS (gimp_unit_get_factor (unit) - factor) < 1e-5) &&
(strcmp (unit_strings[0],
_gimp_unit_get_identifier (image->gimp,
unit)) == 0))
gimp_unit_get_identifier (unit)) == 0))
{
break;
}
@ -620,14 +617,13 @@ xcf_load_image_props (XcfInfo *info,
/* no match */
if (unit == num_units)
unit = _gimp_unit_new (image->gimp,
unit_strings[0],
factor,
digits,
unit_strings[1],
unit_strings[2],
unit_strings[3],
unit_strings[4]);
unit = gimp_unit_new (unit_strings[0],
factor,
digits,
unit_strings[1],
unit_strings[2],
unit_strings[3],
unit_strings[4]);
gimp_image_set_unit (image, unit);

View File

@ -48,7 +48,6 @@
#include "core/gimpparasitelist.h"
#include "core/gimpprogress.h"
#include "core/gimpsamplepoint.h"
#include "core/gimpunit.h"
#include "text/gimptextlayer.h"
#include "text/gimptextlayer-xcf.h"
@ -405,7 +404,7 @@ xcf_save_image_props (XcfInfo *info,
xcf_check_error (xcf_save_prop (info, image, PROP_TATTOO, error,
gimp_image_get_tattoo_state (image)));
if (unit < _gimp_unit_get_number_of_built_in_units (image->gimp))
if (unit < gimp_unit_get_number_of_built_in_units ())
xcf_check_error (xcf_save_prop (info, image, PROP_UNIT, error, unit));
if (gimp_container_get_n_children (gimp_image_get_vectors (image)) > 0)
@ -416,7 +415,7 @@ xcf_save_image_props (XcfInfo *info,
xcf_check_error (xcf_save_prop (info, image, PROP_VECTORS, error));
}
if (unit >= _gimp_unit_get_number_of_built_in_units (image->gimp))
if (unit >= gimp_unit_get_number_of_built_in_units ())
xcf_check_error (xcf_save_prop (info, image, PROP_USER_UNIT, error, unit));
if (gimp_image_get_grid (image))
@ -1019,13 +1018,13 @@ xcf_save_prop (XcfInfo *info,
unit = va_arg (args, guint32);
/* write the entire unit definition */
unit_strings[0] = _gimp_unit_get_identifier (image->gimp, unit);
factor = _gimp_unit_get_factor (image->gimp, unit);
digits = _gimp_unit_get_digits (image->gimp, unit);
unit_strings[1] = _gimp_unit_get_symbol (image->gimp, unit);
unit_strings[2] = _gimp_unit_get_abbreviation (image->gimp, unit);
unit_strings[3] = _gimp_unit_get_singular (image->gimp, unit);
unit_strings[4] = _gimp_unit_get_plural (image->gimp, unit);
unit_strings[0] = gimp_unit_get_identifier (unit);
factor = gimp_unit_get_factor (unit);
digits = gimp_unit_get_digits (unit);
unit_strings[1] = gimp_unit_get_symbol (unit);
unit_strings[2] = gimp_unit_get_abbreviation (unit);
unit_strings[3] = gimp_unit_get_singular (unit);
unit_strings[4] = gimp_unit_get_plural (unit);
size =
2 * 4 +