mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-21 03:52:33 +00:00
app/core/Makefile.am added small wrappers to ease handling of image units
2003-10-01 Sven Neumann <sven@gimp.org> * app/core/Makefile.am * app/core/gimpimage-unit.[ch]: added small wrappers to ease handling of image units and to hide the core GimpUnit API. * app/display/gimpdisplayshell-scale.c * app/display/gimpdisplayshell-title.c * app/display/gimpstatusbar.c * app/gui/info-window.c: * app/tools/gimpmeasuretool.c * app/tools/gimppainttool.c * app/tools/gimprectselecttool.c * app/tools/gimpscaletool.c: use the new functions. * app/core/gimp-units.c * app/vectors/gimpvectors-export.c: use the core GimpUnit API. * app/vectors/gimpvectors.c: no need to include gimpunit.h here.
This commit is contained in:
parent
e49cc1893b
commit
69f7bd131c
20
ChangeLog
20
ChangeLog
|
@ -1,3 +1,23 @@
|
|||
2003-10-01 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/core/Makefile.am
|
||||
* app/core/gimpimage-unit.[ch]: added small wrappers to ease
|
||||
handling of image units and to hide the core GimpUnit API.
|
||||
|
||||
* app/display/gimpdisplayshell-scale.c
|
||||
* app/display/gimpdisplayshell-title.c
|
||||
* app/display/gimpstatusbar.c
|
||||
* app/gui/info-window.c:
|
||||
* app/tools/gimpmeasuretool.c
|
||||
* app/tools/gimppainttool.c
|
||||
* app/tools/gimprectselecttool.c
|
||||
* app/tools/gimpscaletool.c: use the new functions.
|
||||
|
||||
* app/core/gimp-units.c
|
||||
* app/vectors/gimpvectors-export.c: use the core GimpUnit API.
|
||||
|
||||
* app/vectors/gimpvectors.c: no need to include gimpunit.h here.
|
||||
|
||||
2003-10-01 Sven Neumann <sven@gimp.org>
|
||||
|
||||
* app/config/gimpconfig-utils.c (gimp_config_diff): make it handle
|
||||
|
|
|
@ -145,6 +145,8 @@ libappcore_a_sources = \
|
|||
gimpimage-undo.h \
|
||||
gimpimage-undo-push.c \
|
||||
gimpimage-undo-push.h \
|
||||
gimpimage-unit.c \
|
||||
gimpimage-unit.h \
|
||||
gimpimagefile.c \
|
||||
gimpimagefile.h \
|
||||
gimpimagemap.c \
|
||||
|
|
|
@ -103,19 +103,19 @@ gimp_unitrc_load (Gimp *gimp)
|
|||
if (! scanner)
|
||||
return;
|
||||
|
||||
g_scanner_scope_add_symbol (scanner, 0,
|
||||
g_scanner_scope_add_symbol (scanner, 0,
|
||||
"unit-info", GINT_TO_POINTER (UNIT_INFO));
|
||||
g_scanner_scope_add_symbol (scanner, UNIT_INFO,
|
||||
g_scanner_scope_add_symbol (scanner, UNIT_INFO,
|
||||
"factor", GINT_TO_POINTER (UNIT_FACTOR));
|
||||
g_scanner_scope_add_symbol (scanner, UNIT_INFO,
|
||||
g_scanner_scope_add_symbol (scanner, UNIT_INFO,
|
||||
"digits", GINT_TO_POINTER (UNIT_DIGITS));
|
||||
g_scanner_scope_add_symbol (scanner, UNIT_INFO,
|
||||
g_scanner_scope_add_symbol (scanner, UNIT_INFO,
|
||||
"symbol", GINT_TO_POINTER (UNIT_SYMBOL));
|
||||
g_scanner_scope_add_symbol (scanner, UNIT_INFO,
|
||||
g_scanner_scope_add_symbol (scanner, UNIT_INFO,
|
||||
"abbreviation", GINT_TO_POINTER (UNIT_ABBREV));
|
||||
g_scanner_scope_add_symbol (scanner, UNIT_INFO,
|
||||
g_scanner_scope_add_symbol (scanner, UNIT_INFO,
|
||||
"singular", GINT_TO_POINTER (UNIT_SINGULAR));
|
||||
g_scanner_scope_add_symbol (scanner, UNIT_INFO,
|
||||
g_scanner_scope_add_symbol (scanner, UNIT_INFO,
|
||||
"plural", GINT_TO_POINTER (UNIT_PLURAL));
|
||||
|
||||
token = G_TOKEN_LEFT_PAREN;
|
||||
|
@ -192,42 +192,48 @@ gimp_unitrc_save (Gimp *gimp)
|
|||
return;
|
||||
|
||||
/* save user defined units */
|
||||
for (i = gimp_unit_get_number_of_built_in_units ();
|
||||
i < gimp_unit_get_number_of_units ();
|
||||
for (i = _gimp_unit_get_number_of_built_in_units (gimp);
|
||||
i < _gimp_unit_get_number_of_units (gimp);
|
||||
i++)
|
||||
{
|
||||
if (gimp_unit_get_deletion_flag (i) == FALSE)
|
||||
if (_gimp_unit_get_deletion_flag (gimp, i) == FALSE)
|
||||
{
|
||||
gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
|
||||
|
||||
gimp_config_writer_open (writer, "unit-info");
|
||||
gimp_config_writer_string (writer, gimp_unit_get_identifier (i));
|
||||
gimp_config_writer_string (writer,
|
||||
_gimp_unit_get_identifier (gimp, i));
|
||||
|
||||
gimp_config_writer_open (writer, "factor");
|
||||
gimp_config_writer_print (writer,
|
||||
g_ascii_formatd (buf, sizeof (buf), "%f",
|
||||
gimp_unit_get_factor (i)),
|
||||
_gimp_unit_get_factor (gimp, i)),
|
||||
-1);
|
||||
gimp_config_writer_close (writer);
|
||||
|
||||
gimp_config_writer_open (writer, "digits");
|
||||
gimp_config_writer_printf (writer, "%d", gimp_unit_get_digits (i));
|
||||
gimp_config_writer_printf (writer,
|
||||
"%d", _gimp_unit_get_digits (gimp, i));
|
||||
gimp_config_writer_close (writer);
|
||||
|
||||
gimp_config_writer_open (writer, "symbol");
|
||||
gimp_config_writer_string (writer, gimp_unit_get_symbol (i));
|
||||
gimp_config_writer_string (writer,
|
||||
_gimp_unit_get_symbol (gimp, i));
|
||||
gimp_config_writer_close (writer);
|
||||
|
||||
|
||||
gimp_config_writer_open (writer, "abbreviation");
|
||||
gimp_config_writer_string (writer, gimp_unit_get_abbreviation (i));
|
||||
gimp_config_writer_string (writer,
|
||||
_gimp_unit_get_abbreviation (gimp, i));
|
||||
gimp_config_writer_close (writer);
|
||||
|
||||
gimp_config_writer_open (writer, "singular");
|
||||
gimp_config_writer_string (writer, gimp_unit_get_singular (i));
|
||||
gimp_config_writer_string (writer,
|
||||
_gimp_unit_get_singular (gimp, i));
|
||||
gimp_config_writer_close (writer);
|
||||
|
||||
|
||||
gimp_config_writer_open (writer, "plural");
|
||||
gimp_config_writer_string (writer, gimp_unit_get_plural (i));
|
||||
gimp_config_writer_string (writer,
|
||||
_gimp_unit_get_plural (gimp, i));
|
||||
gimp_config_writer_close (writer);
|
||||
|
||||
gimp_config_writer_close (writer);
|
||||
|
@ -333,7 +339,7 @@ gimp_unitrc_unit_info_deserialize (GScanner *scanner,
|
|||
symbol, abbreviation, singular, plural);
|
||||
|
||||
/* make the unit definition persistent */
|
||||
gimp_unit_set_deletion_flag (unit, FALSE);
|
||||
_gimp_unit_set_deletion_flag (gimp, unit, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
70
app/core/gimpimage-unit.c
Normal file
70
app/core/gimpimage-unit.c
Normal file
|
@ -0,0 +1,70 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattisbvf
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "core-types.h"
|
||||
|
||||
#include "gimpimage.h"
|
||||
#include "gimpimage-unit.h"
|
||||
#include "gimpunit.h"
|
||||
|
||||
|
||||
gdouble
|
||||
gimp_image_unit_get_factor (GimpImage *gimage)
|
||||
{
|
||||
return _gimp_unit_get_factor (gimage->gimp, gimage->unit);
|
||||
}
|
||||
|
||||
gint
|
||||
gimp_image_unit_get_digits (GimpImage *gimage)
|
||||
{
|
||||
return _gimp_unit_get_digits (gimage->gimp, gimage->unit);
|
||||
}
|
||||
|
||||
const gchar *
|
||||
gimp_image_unit_get_identifier (GimpImage *gimage)
|
||||
{
|
||||
return _gimp_unit_get_identifier (gimage->gimp, gimage->unit);
|
||||
}
|
||||
|
||||
const gchar *
|
||||
gimp_image_unit_get_symbol (GimpImage *gimage)
|
||||
{
|
||||
return _gimp_unit_get_symbol (gimage->gimp, gimage->unit);
|
||||
}
|
||||
|
||||
const gchar *
|
||||
gimp_image_unit_get_abbreviation (GimpImage *gimage)
|
||||
{
|
||||
return _gimp_unit_get_abbreviation (gimage->gimp, gimage->unit);
|
||||
}
|
||||
|
||||
const gchar *
|
||||
gimp_image_unit_get_singular (GimpImage *gimage)
|
||||
{
|
||||
return _gimp_unit_get_singular (gimage->gimp, gimage->unit);
|
||||
}
|
||||
|
||||
const gchar *
|
||||
gimp_image_unit_get_plural (GimpImage *gimage)
|
||||
{
|
||||
return _gimp_unit_get_plural (gimage->gimp, gimage->unit);
|
||||
}
|
32
app/core/gimpimage-unit.h
Normal file
32
app/core/gimpimage-unit.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/* The GIMP -- an image manipulation program
|
||||
* Copyright (C) 1995 Spencer Kimball and Peter Mattisbvf
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef __GIMP_IMAGE_UNIT_H__
|
||||
#define __GIMP_IMAGE_UNIT_H__
|
||||
|
||||
|
||||
gdouble gimp_image_unit_get_factor (GimpImage *gimage);
|
||||
gint gimp_image_unit_get_digits (GimpImage *gimage);
|
||||
const gchar * gimp_image_unit_get_identifier (GimpImage *gimage);
|
||||
const gchar * gimp_image_unit_get_symbol (GimpImage *gimage);
|
||||
const gchar * gimp_image_unit_get_abbreviation (GimpImage *gimage);
|
||||
const gchar * gimp_image_unit_get_singular (GimpImage *gimage);
|
||||
const gchar * gimp_image_unit_get_plural (GimpImage *gimage);
|
||||
|
||||
|
||||
#endif /* __GIMP_IMAGE_UNIT_H__ */
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
|
@ -33,6 +32,7 @@
|
|||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-projection.h"
|
||||
#include "core/gimpimage-unit.h"
|
||||
#include "core/gimpunit.h"
|
||||
|
||||
#include "file/file-utils.h"
|
||||
|
@ -538,16 +538,12 @@ info_window_update_extended (GimpDisplay *gdisp,
|
|||
else
|
||||
{
|
||||
/* width and height */
|
||||
unit_factor = _gimp_unit_get_factor (gdisp->gimage->gimp,
|
||||
gdisp->gimage->unit);
|
||||
unit_digits = _gimp_unit_get_digits (gdisp->gimage->gimp,
|
||||
gdisp->gimage->unit);
|
||||
unit_factor = gimp_image_unit_get_factor (gdisp->gimage);
|
||||
unit_digits = gimp_image_unit_get_digits (gdisp->gimage);
|
||||
|
||||
if (iwd->unit_str != _gimp_unit_get_abbreviation (gdisp->gimage->gimp,
|
||||
gdisp->gimage->unit))
|
||||
if (iwd->unit_str != gimp_image_unit_get_abbreviation (gdisp->gimage))
|
||||
{
|
||||
iwd->unit_str = _gimp_unit_get_abbreviation (gdisp->gimage->gimp,
|
||||
gdisp->gimage->unit);
|
||||
iwd->unit_str = gimp_image_unit_get_abbreviation (gdisp->gimage);
|
||||
|
||||
gtk_label_set_text (GTK_LABEL (iwd->unit_labels[0]), iwd->unit_str);
|
||||
gtk_label_set_text (GTK_LABEL (iwd->unit_labels[1]), iwd->unit_str);
|
||||
|
@ -703,21 +699,20 @@ info_window_update (GimpDisplay *gdisp)
|
|||
gimage = gdisp->gimage;
|
||||
|
||||
/* width and height */
|
||||
unit_factor = _gimp_unit_get_factor (gimage->gimp, gimage->unit);
|
||||
unit_digits = _gimp_unit_get_digits (gimage->gimp, gimage->unit);
|
||||
unit_factor = gimp_image_unit_get_factor (gimage);
|
||||
unit_digits = gimp_image_unit_get_digits (gimage);
|
||||
|
||||
g_snprintf (iwd->dimensions_str, MAX_BUF, _("%d x %d pixels"),
|
||||
(int) gimage->width, (int) gimage->height);
|
||||
gimage->width, gimage->height);
|
||||
g_snprintf (format_buf, sizeof (format_buf), "%%.%df x %%.%df %s",
|
||||
unit_digits + 1, unit_digits + 1,
|
||||
_gimp_unit_get_plural (gimage->gimp, gimage->unit));
|
||||
gimp_image_unit_get_plural (gimage));
|
||||
g_snprintf (iwd->real_dimensions_str, MAX_BUF, format_buf,
|
||||
gimage->width * unit_factor / gimage->xresolution,
|
||||
gimage->height * unit_factor / gimage->yresolution);
|
||||
|
||||
/* image resolution */
|
||||
res_unit = gimage->gimp->config->default_resolution_unit;
|
||||
|
||||
res_unit_factor = _gimp_unit_get_factor (gimage->gimp, res_unit);
|
||||
|
||||
g_snprintf (format_buf, sizeof (format_buf), _("pixels/%s"),
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "display-types.h"
|
||||
|
@ -31,6 +30,7 @@
|
|||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-unit.h"
|
||||
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
#include "widgets/gimpviewabledialog.h"
|
||||
|
@ -563,13 +563,13 @@ gimp_display_shell_scale_dialog_cancel (GtkWidget *widget,
|
|||
static gdouble
|
||||
img2real (GimpDisplayShell *shell,
|
||||
gboolean xdir,
|
||||
gdouble a)
|
||||
gdouble len)
|
||||
{
|
||||
GimpImage *gimage;
|
||||
gdouble res;
|
||||
|
||||
if (shell->dot_for_dot)
|
||||
return a;
|
||||
return len;
|
||||
|
||||
gimage = shell->gdisp->gimage;
|
||||
|
||||
|
@ -578,5 +578,5 @@ img2real (GimpDisplayShell *shell,
|
|||
else
|
||||
res = gimage->yresolution;
|
||||
|
||||
return a * gimp_unit_get_factor (gimage->unit) / res;
|
||||
return len * gimp_image_unit_get_factor (gimage) / res;
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "core/gimp.h"
|
||||
#include "core/gimpcontainer.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-unit.h"
|
||||
|
||||
#include "file/file-utils.h"
|
||||
|
||||
|
@ -304,10 +305,10 @@ gimp_display_shell_format_title (GimpDisplayShell *shell,
|
|||
|
||||
case 'W': /* width in real-world units */
|
||||
g_snprintf (unit_format, sizeof (unit_format), "%%.%df",
|
||||
gimp_unit_get_digits (gimage->unit) + 1);
|
||||
gimp_image_unit_get_digits (gimage) + 1);
|
||||
i += print (title, title_len, i, unit_format,
|
||||
(gimage->width *
|
||||
gimp_unit_get_factor (gimage->unit) /
|
||||
gimp_image_unit_get_factor (gimage) /
|
||||
gimage->xresolution));
|
||||
break;
|
||||
|
||||
|
@ -317,21 +318,21 @@ gimp_display_shell_format_title (GimpDisplayShell *shell,
|
|||
|
||||
case 'H': /* height in real-world units */
|
||||
g_snprintf (unit_format, sizeof (unit_format), "%%.%df",
|
||||
gimp_unit_get_digits (gimage->unit) + 1);
|
||||
gimp_image_unit_get_digits (gimage) + 1);
|
||||
i += print (title, title_len, i, unit_format,
|
||||
(gimage->height *
|
||||
gimp_unit_get_factor (gimage->unit) /
|
||||
gimp_image_unit_get_factor (gimage) /
|
||||
gimage->yresolution));
|
||||
break;
|
||||
|
||||
case 'u': /* unit symbol */
|
||||
i += print (title, title_len, i, "%s",
|
||||
gimp_unit_get_symbol (gimage->unit));
|
||||
gimp_image_unit_get_symbol (gimage));
|
||||
break;
|
||||
|
||||
case 'U': /* unit abbreviation */
|
||||
i += print (title, title_len, i, "%s",
|
||||
gimp_unit_get_abbreviation (gimage->unit));
|
||||
gimp_image_unit_get_abbreviation (gimage));
|
||||
break;
|
||||
|
||||
/* Other cool things to be added:
|
||||
|
|
|
@ -20,11 +20,10 @@
|
|||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
|
||||
#include "display-types.h"
|
||||
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-unit.h"
|
||||
|
||||
#include "gimpdisplay.h"
|
||||
#include "gimpdisplayshell.h"
|
||||
|
@ -50,7 +49,7 @@ static void gimp_statusbar_update (GtkStatusbar *gtk_statusbar,
|
|||
static GtkStatusbarClass *parent_class = NULL;
|
||||
|
||||
|
||||
GType
|
||||
GType
|
||||
gimp_statusbar_get_type (void)
|
||||
{
|
||||
static GType statusbar_type = 0;
|
||||
|
@ -135,7 +134,6 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
|
|||
gtk_box_pack_start (box, statusbar->cancelbutton, FALSE, FALSE, 0);
|
||||
gtk_widget_show (statusbar->cancelbutton);
|
||||
|
||||
|
||||
/* Update the statusbar once to work around a canvas size problem:
|
||||
*
|
||||
* The first update of the statusbar used to queue a resize which
|
||||
|
@ -146,7 +144,7 @@ gimp_statusbar_init (GimpStatusbar *statusbar)
|
|||
*/
|
||||
|
||||
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (statusbar->progressbar),
|
||||
"GIMP");
|
||||
"GIMP");
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -164,7 +162,7 @@ gimp_statusbar_update (GtkStatusbar *gtk_statusbar,
|
|||
gtk_progress_bar_set_text (GTK_PROGRESS_BAR (statusbar->progressbar), text);
|
||||
}
|
||||
|
||||
GtkWidget *
|
||||
GtkWidget *
|
||||
gimp_statusbar_new (GimpDisplayShell *shell)
|
||||
{
|
||||
GimpStatusbar *statusbar;
|
||||
|
@ -201,7 +199,7 @@ gimp_statusbar_push_coords (GimpStatusbar *statusbar,
|
|||
const gchar *separator,
|
||||
gdouble y)
|
||||
{
|
||||
gchar buf[256];
|
||||
gchar buf[256];
|
||||
|
||||
g_return_if_fail (GIMP_IS_STATUSBAR (statusbar));
|
||||
g_return_if_fail (title != NULL);
|
||||
|
@ -217,15 +215,17 @@ gimp_statusbar_push_coords (GimpStatusbar *statusbar,
|
|||
}
|
||||
else /* show real world units */
|
||||
{
|
||||
gdouble unit_factor;
|
||||
GimpImage *gimage;
|
||||
gdouble unit_factor;
|
||||
|
||||
unit_factor = gimp_unit_get_factor (statusbar->shell->gdisp->gimage->unit);
|
||||
gimage = statusbar->shell->gdisp->gimage;
|
||||
unit_factor = gimp_image_unit_get_factor (gimage);
|
||||
|
||||
g_snprintf (buf, sizeof (buf), statusbar->cursor_format_str,
|
||||
title,
|
||||
x * unit_factor / statusbar->shell->gdisp->gimage->xresolution,
|
||||
x * unit_factor / gimage->xresolution,
|
||||
separator,
|
||||
y * unit_factor / statusbar->shell->gdisp->gimage->yresolution);
|
||||
y * unit_factor / gimage->yresolution);
|
||||
}
|
||||
|
||||
gimp_statusbar_push (statusbar, context_id, buf);
|
||||
|
@ -262,8 +262,8 @@ gimp_statusbar_update_cursor (GimpStatusbar *statusbar,
|
|||
y >= shell->gdisp->gimage->height)
|
||||
{
|
||||
gtk_label_set_text (GTK_LABEL (statusbar->cursor_label), "");
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
gchar buffer[CURSOR_STR_LENGTH];
|
||||
|
||||
|
@ -277,15 +277,17 @@ gimp_statusbar_update_cursor (GimpStatusbar *statusbar,
|
|||
}
|
||||
else /* show real world units */
|
||||
{
|
||||
gdouble unit_factor;
|
||||
GimpImage *gimage;
|
||||
gdouble unit_factor;
|
||||
|
||||
gimage = statusbar->shell->gdisp->gimage;
|
||||
unit_factor = gimp_image_unit_get_factor (gimage);
|
||||
|
||||
unit_factor = gimp_unit_get_factor (shell->gdisp->gimage->unit);
|
||||
|
||||
g_snprintf (buffer, sizeof (buffer), statusbar->cursor_format_str,
|
||||
"",
|
||||
x * unit_factor / shell->gdisp->gimage->xresolution,
|
||||
x * unit_factor / gimage->xresolution,
|
||||
", ",
|
||||
y * unit_factor / shell->gdisp->gimage->yresolution);
|
||||
y * unit_factor / gimage->yresolution);
|
||||
}
|
||||
|
||||
gtk_label_set_text (GTK_LABEL (statusbar->cursor_label), buffer);
|
||||
|
@ -318,26 +320,24 @@ gimp_statusbar_resize_cursor (GimpStatusbar *statusbar)
|
|||
}
|
||||
else /* show real world units */
|
||||
{
|
||||
GimpUnit unit;
|
||||
gdouble unit_factor;
|
||||
GimpImage *gimage;
|
||||
gdouble unit_factor;
|
||||
|
||||
unit = shell->gdisp->gimage->unit;
|
||||
unit_factor = gimp_unit_get_factor (unit);
|
||||
gimage = shell->gdisp->gimage;
|
||||
unit_factor = gimp_image_unit_get_factor (gimage);
|
||||
|
||||
g_snprintf (statusbar->cursor_format_str,
|
||||
sizeof (statusbar->cursor_format_str),
|
||||
"%%s%%.%df%%s%%.%df %s",
|
||||
gimp_unit_get_digits (unit),
|
||||
gimp_unit_get_digits (unit),
|
||||
gimp_unit_get_symbol (unit));
|
||||
gimp_image_unit_get_digits (gimage),
|
||||
gimp_image_unit_get_digits (gimage),
|
||||
gimp_image_unit_get_symbol (gimage));
|
||||
|
||||
g_snprintf (buffer, sizeof (buffer), statusbar->cursor_format_str,
|
||||
"",
|
||||
(gdouble) shell->gdisp->gimage->width * unit_factor /
|
||||
shell->gdisp->gimage->xresolution,
|
||||
(gdouble) gimage->width * unit_factor / gimage->xresolution,
|
||||
", ",
|
||||
(gdouble) shell->gdisp->gimage->height * unit_factor /
|
||||
shell->gdisp->gimage->yresolution);
|
||||
(gdouble) gimage->height * unit_factor / gimage->yresolution);
|
||||
}
|
||||
|
||||
/* one static layout for all displays should be fine */
|
||||
|
@ -347,7 +347,7 @@ gimp_statusbar_resize_cursor (GimpStatusbar *statusbar)
|
|||
pango_layout_set_text (layout, buffer, -1);
|
||||
|
||||
pango_layout_get_pixel_size (layout, &cursor_label_width, NULL);
|
||||
|
||||
|
||||
/* find out how many pixels the label's parent frame is bigger than
|
||||
* the label itself
|
||||
*/
|
||||
|
@ -355,7 +355,7 @@ gimp_statusbar_resize_cursor (GimpStatusbar *statusbar)
|
|||
statusbar->cursor_label->allocation.width);
|
||||
|
||||
gtk_widget_set_size_request (statusbar->cursor_label, cursor_label_width, -1);
|
||||
|
||||
|
||||
/* don't resize if this is a new display */
|
||||
if (label_frame_size_difference)
|
||||
gtk_widget_set_size_request (statusbar->cursor_frame,
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
|
@ -33,6 +32,7 @@
|
|||
#include "core/gimpcontext.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-projection.h"
|
||||
#include "core/gimpimage-unit.h"
|
||||
#include "core/gimpunit.h"
|
||||
|
||||
#include "file/file-utils.h"
|
||||
|
@ -538,16 +538,12 @@ info_window_update_extended (GimpDisplay *gdisp,
|
|||
else
|
||||
{
|
||||
/* width and height */
|
||||
unit_factor = _gimp_unit_get_factor (gdisp->gimage->gimp,
|
||||
gdisp->gimage->unit);
|
||||
unit_digits = _gimp_unit_get_digits (gdisp->gimage->gimp,
|
||||
gdisp->gimage->unit);
|
||||
unit_factor = gimp_image_unit_get_factor (gdisp->gimage);
|
||||
unit_digits = gimp_image_unit_get_digits (gdisp->gimage);
|
||||
|
||||
if (iwd->unit_str != _gimp_unit_get_abbreviation (gdisp->gimage->gimp,
|
||||
gdisp->gimage->unit))
|
||||
if (iwd->unit_str != gimp_image_unit_get_abbreviation (gdisp->gimage))
|
||||
{
|
||||
iwd->unit_str = _gimp_unit_get_abbreviation (gdisp->gimage->gimp,
|
||||
gdisp->gimage->unit);
|
||||
iwd->unit_str = gimp_image_unit_get_abbreviation (gdisp->gimage);
|
||||
|
||||
gtk_label_set_text (GTK_LABEL (iwd->unit_labels[0]), iwd->unit_str);
|
||||
gtk_label_set_text (GTK_LABEL (iwd->unit_labels[1]), iwd->unit_str);
|
||||
|
@ -703,21 +699,20 @@ info_window_update (GimpDisplay *gdisp)
|
|||
gimage = gdisp->gimage;
|
||||
|
||||
/* width and height */
|
||||
unit_factor = _gimp_unit_get_factor (gimage->gimp, gimage->unit);
|
||||
unit_digits = _gimp_unit_get_digits (gimage->gimp, gimage->unit);
|
||||
unit_factor = gimp_image_unit_get_factor (gimage);
|
||||
unit_digits = gimp_image_unit_get_digits (gimage);
|
||||
|
||||
g_snprintf (iwd->dimensions_str, MAX_BUF, _("%d x %d pixels"),
|
||||
(int) gimage->width, (int) gimage->height);
|
||||
gimage->width, gimage->height);
|
||||
g_snprintf (format_buf, sizeof (format_buf), "%%.%df x %%.%df %s",
|
||||
unit_digits + 1, unit_digits + 1,
|
||||
_gimp_unit_get_plural (gimage->gimp, gimage->unit));
|
||||
gimp_image_unit_get_plural (gimage));
|
||||
g_snprintf (iwd->real_dimensions_str, MAX_BUF, format_buf,
|
||||
gimage->width * unit_factor / gimage->xresolution,
|
||||
gimage->height * unit_factor / gimage->yresolution);
|
||||
|
||||
/* image resolution */
|
||||
res_unit = gimage->gimp->config->default_resolution_unit;
|
||||
|
||||
res_unit_factor = _gimp_unit_get_factor (gimage->gimp, res_unit);
|
||||
|
||||
g_snprintf (format_buf, sizeof (format_buf), _("pixels/%s"),
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "core/gimpcontainer.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-unit.h"
|
||||
#include "core/gimppaintinfo.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
||||
|
@ -677,10 +678,10 @@ gimp_paint_tool_oper_update (GimpTool *tool,
|
|||
gchar format_str[64];
|
||||
|
||||
g_snprintf (format_str, sizeof (format_str), "%%.%df %s",
|
||||
gimp_unit_get_digits (gdisp->gimage->unit),
|
||||
gimp_unit_get_symbol (gdisp->gimage->unit));
|
||||
gimp_image_unit_get_digits (gdisp->gimage),
|
||||
gimp_image_unit_get_symbol (gdisp->gimage));
|
||||
|
||||
dist = (gimp_unit_get_factor (gdisp->gimage->unit) *
|
||||
dist = (gimp_image_unit_get_factor (gdisp->gimage) *
|
||||
sqrt (SQR (dx / gdisp->gimage->xresolution) +
|
||||
SQR (dy / gdisp->gimage->yresolution)));
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpmath/gimpmath.h"
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "tools-types.h"
|
||||
|
@ -40,6 +39,7 @@
|
|||
#include "core/gimpimage-guides.h"
|
||||
#include "core/gimpimage-undo.h"
|
||||
#include "core/gimpimage-undo-push.h"
|
||||
#include "core/gimpimage-unit.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
||||
#include "widgets/gimpdialogfactory.h"
|
||||
|
@ -587,12 +587,12 @@ gimp_measure_tool_motion (GimpTool *tool,
|
|||
else /* show real world units */
|
||||
{
|
||||
gchar *format_str =
|
||||
g_strdup_printf ("%%.%df %s, %%.2f %s",
|
||||
gimp_unit_get_digits (gdisp->gimage->unit),
|
||||
gimp_unit_get_symbol (gdisp->gimage->unit),
|
||||
g_strdup_printf ("%%.%df %s, %%.2f %s",
|
||||
gimp_image_unit_get_digits (gdisp->gimage),
|
||||
gimp_image_unit_get_symbol (gdisp->gimage),
|
||||
_("degrees"));
|
||||
|
||||
distance = gimp_unit_get_factor (gdisp->gimage->unit) *
|
||||
distance = gimp_image_unit_get_factor (gdisp->gimage) *
|
||||
sqrt (SQR ((gdouble)(ax - bx) / gdisp->gimage->xresolution) +
|
||||
SQR ((gdouble)(ay - by) / gdisp->gimage->yresolution));
|
||||
|
||||
|
@ -615,8 +615,8 @@ gimp_measure_tool_motion (GimpTool *tool,
|
|||
|
||||
format_str =
|
||||
g_strdup_printf ("%%.%df %s",
|
||||
gimp_unit_get_digits (gdisp->gimage->unit),
|
||||
gimp_unit_get_symbol (gdisp->gimage->unit));
|
||||
gimp_image_unit_get_digits (gdisp->gimage),
|
||||
gimp_image_unit_get_symbol (gdisp->gimage));
|
||||
g_snprintf (distance_buf, sizeof (distance_buf), format_str,
|
||||
distance);
|
||||
g_snprintf (angle_buf, sizeof (angle_buf), "%.2f %s",
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "core/gimpcontainer.h"
|
||||
#include "core/gimpdrawable.h"
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-unit.h"
|
||||
#include "core/gimppaintinfo.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
|
||||
|
@ -677,10 +678,10 @@ gimp_paint_tool_oper_update (GimpTool *tool,
|
|||
gchar format_str[64];
|
||||
|
||||
g_snprintf (format_str, sizeof (format_str), "%%.%df %s",
|
||||
gimp_unit_get_digits (gdisp->gimage->unit),
|
||||
gimp_unit_get_symbol (gdisp->gimage->unit));
|
||||
gimp_image_unit_get_digits (gdisp->gimage),
|
||||
gimp_image_unit_get_symbol (gdisp->gimage));
|
||||
|
||||
dist = (gimp_unit_get_factor (gdisp->gimage->unit) *
|
||||
dist = (gimp_image_unit_get_factor (gdisp->gimage) *
|
||||
sqrt (SQR (dx / gdisp->gimage->xresolution) +
|
||||
SQR (dy / gdisp->gimage->yresolution)));
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@
|
|||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "tools-types.h"
|
||||
|
@ -32,9 +31,11 @@
|
|||
#include "core/gimpimage.h"
|
||||
#include "core/gimpimage-crop.h"
|
||||
#include "core/gimpimage-mask-select.h"
|
||||
#include "core/gimpimage-unit.h"
|
||||
#include "core/gimplayer-floating-sel.h"
|
||||
#include "core/gimpmarshal.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
#include "core/gimpunit.h"
|
||||
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
|
||||
|
@ -207,7 +208,7 @@ gimp_rect_select_tool_button_press (GimpTool *tool,
|
|||
gdisp->gimage->height * rect_sel->fixed_height / 100;
|
||||
break;
|
||||
default:
|
||||
unit_factor = gimp_unit_get_factor (unit);
|
||||
unit_factor = _gimp_unit_get_factor (tool->tool_info->gimp, unit);
|
||||
rect_sel->fixed_width =
|
||||
rect_sel->fixed_width * gdisp->gimage->xresolution / unit_factor;
|
||||
rect_sel->fixed_height =
|
||||
|
@ -606,15 +607,14 @@ gimp_rect_select_tool_update_options (GimpRectSelectTool *rect_sel,
|
|||
}
|
||||
else
|
||||
{
|
||||
GimpImage *gimage;
|
||||
gdouble unit_factor;
|
||||
|
||||
gimage = gdisp->gimage;
|
||||
GimpImage *gimage = gdisp->gimage;
|
||||
|
||||
unit = gimage->unit;
|
||||
unit_factor = gimp_unit_get_factor (unit);
|
||||
width = (gdouble) abs (rect_sel->w) * unit_factor / gimage->xresolution;
|
||||
height = (gdouble) abs (rect_sel->h) * unit_factor / gimage->yresolution;
|
||||
|
||||
width = ((gdouble) abs (rect_sel->w) *
|
||||
gimp_image_unit_get_factor (gimage) / gimage->xresolution);
|
||||
height = ((gdouble) abs (rect_sel->h) *
|
||||
gimp_image_unit_get_factor (gimage) / gimage->yresolution);
|
||||
}
|
||||
|
||||
g_object_set (GIMP_TOOL (rect_sel)->tool_info->tool_options,
|
||||
|
|
|
@ -20,8 +20,8 @@
|
|||
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpmath/gimpmath.h"
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpmath/gimpmath.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "tools-types.h"
|
||||
|
@ -30,6 +30,7 @@
|
|||
#include "core/gimpimage.h"
|
||||
#include "core/gimpdrawable-transform.h"
|
||||
#include "core/gimptoolinfo.h"
|
||||
#include "core/gimpunit.h"
|
||||
|
||||
#include "widgets/gimphelp-ids.h"
|
||||
|
||||
|
@ -411,6 +412,7 @@ gimp_scale_tool_recalc (GimpTransformTool *tr_tool,
|
|||
static void
|
||||
gimp_scale_tool_info_update (GimpTransformTool *tr_tool)
|
||||
{
|
||||
Gimp *gimp;
|
||||
GimpTool *tool;
|
||||
gdouble ratio_x, ratio_y;
|
||||
gint x1, y1, x2, y2, x3, y3, x4, y4;
|
||||
|
@ -433,13 +435,15 @@ gimp_scale_tool_info_update (GimpTransformTool *tr_tool)
|
|||
if (unit != GIMP_UNIT_PERCENT)
|
||||
label_unit = unit;
|
||||
|
||||
unit_factor = gimp_unit_get_factor (label_unit);
|
||||
gimp = tool->tool_info->gimp;
|
||||
|
||||
unit_factor = _gimp_unit_get_factor (gimp, label_unit);
|
||||
|
||||
if (label_unit) /* unit != GIMP_UNIT_PIXEL */
|
||||
{
|
||||
g_snprintf (format_buf, sizeof (format_buf), "%%.%df %s",
|
||||
gimp_unit_get_digits (label_unit) + 1,
|
||||
gimp_unit_get_symbol (label_unit));
|
||||
_gimp_unit_get_digits (gimp, label_unit) + 1,
|
||||
_gimp_unit_get_symbol (gimp, label_unit));
|
||||
g_snprintf (orig_width_buf, MAX_INFO_BUF, format_buf,
|
||||
(x2 - x1) * unit_factor / tool->gdisp->gimage->xresolution);
|
||||
g_snprintf (orig_height_buf, MAX_INFO_BUF, format_buf,
|
||||
|
|
|
@ -24,13 +24,12 @@
|
|||
|
||||
#include <glib-object.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
|
||||
#include "vectors-types.h"
|
||||
|
||||
#include "core/gimpimage.h"
|
||||
#include "core/gimpitem.h"
|
||||
#include "core/gimplist.h"
|
||||
#include "core/gimpunit.h"
|
||||
|
||||
#include "gimpanchor.h"
|
||||
#include "gimpstroke.h"
|
||||
|
@ -145,8 +144,10 @@ gimp_vectors_export_image_size (const GimpImage *image)
|
|||
break;
|
||||
}
|
||||
|
||||
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_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));
|
||||
|
||||
return g_strdup_printf ("width=\"%s%s\" height=\"%s%s\"",
|
||||
wbuf, abbrev, hbuf, abbrev);
|
||||
|
|
|
@ -34,7 +34,6 @@
|
|||
#include "core/gimpmarshal.h"
|
||||
#include "core/gimppaintinfo.h"
|
||||
#include "core/gimpstrokeoptions.h"
|
||||
#include "core/gimpunit.h"
|
||||
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "paint/gimppaintcore-stroke.h"
|
||||
|
@ -204,9 +203,9 @@ gimp_vectors_class_init (GimpVectorsClass *klass)
|
|||
G_TYPE_NONE, 0);
|
||||
|
||||
object_class->finalize = gimp_vectors_finalize;
|
||||
|
||||
|
||||
gimp_object_class->get_memsize = gimp_vectors_get_memsize;
|
||||
|
||||
|
||||
viewable_class->get_new_preview = gimp_vectors_get_new_preview;
|
||||
viewable_class->default_stock_id = "gimp-path";
|
||||
|
||||
|
@ -221,23 +220,23 @@ gimp_vectors_class_init (GimpVectorsClass *klass)
|
|||
item_class->stroke = gimp_vectors_stroke;
|
||||
item_class->default_name = _("Path");
|
||||
item_class->rename_desc = _("Rename Path");
|
||||
|
||||
|
||||
klass->freeze = NULL;
|
||||
klass->thaw = gimp_vectors_real_thaw;
|
||||
|
||||
|
||||
klass->stroke_add = gimp_vectors_real_stroke_add;
|
||||
klass->stroke_remove = gimp_vectors_real_stroke_remove;
|
||||
klass->stroke_get = gimp_vectors_real_stroke_get;
|
||||
klass->stroke_get_next = gimp_vectors_real_stroke_get_next;
|
||||
klass->stroke_get_length = gimp_vectors_real_stroke_get_length;
|
||||
|
||||
|
||||
klass->anchor_get = gimp_vectors_real_anchor_get;
|
||||
klass->anchor_delete = gimp_vectors_real_anchor_delete;
|
||||
|
||||
|
||||
klass->get_length = gimp_vectors_real_get_length;
|
||||
klass->get_distance = gimp_vectors_real_get_distance;
|
||||
klass->interpolate = gimp_vectors_real_interpolate;
|
||||
|
||||
|
||||
klass->make_bezier = gimp_vectors_real_make_bezier;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue