mirror of
https://gitlab.gnome.org/GNOME/gimp
synced 2024-10-18 05:46:11 +00:00
This fixes all our GObject Introspection issues with GimpUnit which was both an enum and an int-derived type of user-defined units *completing* the enum values. GIR clearly didn't like this! Now GimpUnit is a proper class and units are unique objects, allowing to compare them with an identity test (i.e. `unit == gimp_unit_pixel ()` tells us if unit is the pixel unit or not), which makes it easy to use, just like with int, yet adding also methods, making for nicer introspected API. As an aside, this also fixes #10738, by having all the built-in units retrievable even if libgimpbase had not been properly initialized with gimp_base_init(). I haven't checked in details how GIR works to introspect, but it looks like it loads the library to inspect and runs functions, hence triggering some CRITICALS because virtual methods (supposed to be initialized with gimp_base_init() run by libgimp) are not set. This new code won't trigger any critical because the vtable method are now not necessary, at least for all built-in units. Note that GimpUnit is still in libgimpbase. It could have been moved to libgimp in order to avoid any virtual method table (since we need to keep core and libgimp side's units in sync, PDB is required), but too many libgimpwidgets widgets were already using GimpUnit. And technically most of GimpUnit logic doesn't require PDB (only the creation/sync part). This is one of the reasons why user-created GimpUnit list is handled and stored differently from other types of objects. Globally this simplifies the code a lot too and we don't need separate implementations of various utils for core and libgimp, which means less prone to errors.
This commit is contained in:
parent
f9df980585
commit
d493f0537f
|
@ -20,6 +20,7 @@
|
|||
#include <gegl.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "actions-types.h"
|
||||
|
@ -125,7 +126,7 @@ buffers_paste_as_new_image_cmd_callback (GimpAction *action,
|
|||
GIMP_OBJECT (buffer),
|
||||
context);
|
||||
gimp_create_display (context->gimp, new_image,
|
||||
GIMP_UNIT_PIXEL, 1.0,
|
||||
gimp_unit_pixel (), 1.0,
|
||||
G_OBJECT (gimp_widget_get_monitor (widget)));
|
||||
g_object_unref (new_image);
|
||||
}
|
||||
|
|
|
@ -436,7 +436,7 @@ edit_paste_as_new_image_cmd_callback (GimpAction *action,
|
|||
|
||||
if (image)
|
||||
{
|
||||
gimp_create_display (gimp, image, GIMP_UNIT_PIXEL, 1.0,
|
||||
gimp_create_display (gimp, image, gimp_unit_pixel (), 1.0,
|
||||
G_OBJECT (gimp_widget_get_monitor (widget)));
|
||||
g_object_unref (image);
|
||||
}
|
||||
|
|
|
@ -136,12 +136,12 @@ static void image_resize_callback (GtkWidget *dialog,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
gint offset_x,
|
||||
gint offset_y,
|
||||
gdouble xres,
|
||||
gdouble yres,
|
||||
GimpUnit res_unit,
|
||||
GimpUnit *res_unit,
|
||||
GimpFillType fill_type,
|
||||
GimpItemSet layer_set,
|
||||
gboolean resize_text_layers,
|
||||
|
@ -151,18 +151,18 @@ static void image_print_size_callback (GtkWidget *dialog,
|
|||
GimpImage *image,
|
||||
gdouble xresolution,
|
||||
gdouble yresolution,
|
||||
GimpUnit resolution_unit,
|
||||
GimpUnit *resolution_unit,
|
||||
gpointer user_data);
|
||||
|
||||
static void image_scale_callback (GtkWidget *dialog,
|
||||
GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
GimpInterpolationType interpolation,
|
||||
gdouble xresolution,
|
||||
gdouble yresolution,
|
||||
GimpUnit resolution_unit,
|
||||
GimpUnit *resolution_unit,
|
||||
gpointer user_data);
|
||||
|
||||
static void image_merge_layers_callback (GtkWidget *dialog,
|
||||
|
@ -185,8 +185,8 @@ static void image_softproof_profile_callback (GtkWidget *dialo
|
|||
|
||||
/* private variables */
|
||||
|
||||
static GimpUnit image_resize_unit = GIMP_UNIT_PIXEL;
|
||||
static GimpUnit image_scale_unit = GIMP_UNIT_PIXEL;
|
||||
static GimpUnit *image_resize_unit = NULL;
|
||||
static GimpUnit *image_scale_unit = NULL;
|
||||
static GimpInterpolationType image_scale_interp = -1;
|
||||
static GimpPalette *image_convert_indexed_custom_palette = NULL;
|
||||
|
||||
|
@ -657,7 +657,7 @@ image_resize_cmd_callback (GimpAction *action,
|
|||
{
|
||||
GimpDialogConfig *config = GIMP_DIALOG_CONFIG (image->gimp->config);
|
||||
|
||||
if (image_resize_unit != GIMP_UNIT_PERCENT)
|
||||
if (image_resize_unit != gimp_unit_percent ())
|
||||
image_resize_unit = gimp_display_get_shell (display)->unit;
|
||||
|
||||
dialog = resize_dialog_new (GIMP_VIEWABLE (image),
|
||||
|
@ -786,7 +786,7 @@ image_scale_cmd_callback (GimpAction *action,
|
|||
|
||||
if (! dialog)
|
||||
{
|
||||
if (image_scale_unit != GIMP_UNIT_PERCENT)
|
||||
if (image_scale_unit != gimp_unit_percent ())
|
||||
image_scale_unit = gimp_display_get_shell (display)->unit;
|
||||
|
||||
if (image_scale_interp == -1)
|
||||
|
@ -1364,12 +1364,12 @@ image_resize_callback (GtkWidget *dialog,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
gint offset_x,
|
||||
gint offset_y,
|
||||
gdouble xres,
|
||||
gdouble yres,
|
||||
GimpUnit res_unit,
|
||||
GimpUnit *res_unit,
|
||||
GimpFillType fill_type,
|
||||
GimpItemSet layer_set,
|
||||
gboolean resize_text_layers,
|
||||
|
@ -1386,7 +1386,7 @@ image_resize_callback (GtkWidget *dialog,
|
|||
GimpProgress *progress;
|
||||
gdouble old_xres;
|
||||
gdouble old_yres;
|
||||
GimpUnit old_res_unit;
|
||||
GimpUnit *old_res_unit;
|
||||
gboolean update_resolution;
|
||||
|
||||
g_object_set (config,
|
||||
|
@ -1448,7 +1448,7 @@ image_print_size_callback (GtkWidget *dialog,
|
|||
GimpImage *image,
|
||||
gdouble xresolution,
|
||||
gdouble yresolution,
|
||||
GimpUnit resolution_unit,
|
||||
GimpUnit *resolution_unit,
|
||||
gpointer data)
|
||||
{
|
||||
gdouble xres;
|
||||
|
@ -1479,11 +1479,11 @@ image_scale_callback (GtkWidget *dialog,
|
|||
GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
GimpInterpolationType interpolation,
|
||||
gdouble xresolution,
|
||||
gdouble yresolution,
|
||||
GimpUnit resolution_unit,
|
||||
GimpUnit *resolution_unit,
|
||||
gpointer user_data)
|
||||
{
|
||||
GimpProgress *progress = user_data;
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <gegl.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
#include "actions-types.h"
|
||||
|
@ -88,7 +89,7 @@ images_new_view_cmd_callback (GimpAction *action,
|
|||
|
||||
if (image && gimp_container_have (container, GIMP_OBJECT (image)))
|
||||
{
|
||||
gimp_create_display (image->gimp, image, GIMP_UNIT_PIXEL, 1.0,
|
||||
gimp_create_display (image->gimp, image, gimp_unit_pixel (), 1.0,
|
||||
G_OBJECT (gimp_widget_get_monitor (GTK_WIDGET (editor))));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,23 +148,23 @@ static void layers_scale_callback (GtkWidget *dialog,
|
|||
GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
GimpInterpolationType interpolation,
|
||||
gdouble xresolution,
|
||||
gdouble yresolution,
|
||||
GimpUnit resolution_unit,
|
||||
GimpUnit *resolution_unit,
|
||||
gpointer user_data);
|
||||
static void layers_resize_callback (GtkWidget *dialog,
|
||||
GimpViewable *viewable,
|
||||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
gint offset_x,
|
||||
gint offset_y,
|
||||
gdouble unused0,
|
||||
gdouble unused1,
|
||||
GimpUnit unused2,
|
||||
GimpUnit *unused2,
|
||||
GimpFillType fill_type,
|
||||
GimpItemSet unused3,
|
||||
gboolean unused4,
|
||||
|
@ -177,8 +177,8 @@ static gint layers_mode_index (GimpLayerMode layer_mode
|
|||
|
||||
/* private variables */
|
||||
|
||||
static GimpUnit layer_resize_unit = GIMP_UNIT_PIXEL;
|
||||
static GimpUnit layer_scale_unit = GIMP_UNIT_PIXEL;
|
||||
static GimpUnit *layer_resize_unit = NULL;
|
||||
static GimpUnit *layer_scale_unit = NULL;
|
||||
static GimpInterpolationType layer_scale_interp = -1;
|
||||
|
||||
|
||||
|
@ -1179,7 +1179,10 @@ layers_resize_cmd_callback (GimpAction *action,
|
|||
if (GIMP_IS_IMAGE_WINDOW (data))
|
||||
display = action_data_get_display (data);
|
||||
|
||||
if (layer_resize_unit != GIMP_UNIT_PERCENT && display)
|
||||
if (layer_resize_unit == NULL)
|
||||
layer_resize_unit = gimp_unit_pixel ();
|
||||
|
||||
if (layer_resize_unit != gimp_unit_percent () && display)
|
||||
layer_resize_unit = gimp_display_get_shell (display)->unit;
|
||||
|
||||
dialog = resize_dialog_new (GIMP_VIEWABLE (layer),
|
||||
|
@ -1254,7 +1257,10 @@ layers_scale_cmd_callback (GimpAction *action,
|
|||
if (GIMP_IS_IMAGE_WINDOW (data))
|
||||
display = action_data_get_display (data);
|
||||
|
||||
if (layer_scale_unit != GIMP_UNIT_PERCENT && display)
|
||||
if (layer_scale_unit == NULL)
|
||||
layer_scale_unit = gimp_unit_pixel ();;
|
||||
|
||||
if (layer_scale_unit != gimp_unit_percent () && display)
|
||||
layer_scale_unit = gimp_display_get_shell (display)->unit;
|
||||
|
||||
if (layer_scale_interp == -1)
|
||||
|
@ -2492,11 +2498,11 @@ layers_scale_callback (GtkWidget *dialog,
|
|||
GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
GimpInterpolationType interpolation,
|
||||
gdouble xresolution, /* unused */
|
||||
gdouble yresolution, /* unused */
|
||||
GimpUnit resolution_unit,/* unused */
|
||||
GimpUnit *resolution_unit,/* unused */
|
||||
gpointer user_data)
|
||||
{
|
||||
GimpDisplay *display = GIMP_DISPLAY (user_data);
|
||||
|
@ -2553,12 +2559,12 @@ layers_resize_callback (GtkWidget *dialog,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
gint offset_x,
|
||||
gint offset_y,
|
||||
gdouble unused0,
|
||||
gdouble unused1,
|
||||
GimpUnit unused2,
|
||||
GimpUnit *unused2,
|
||||
GimpFillType fill_type,
|
||||
GimpItemSet unused3,
|
||||
gboolean unused4,
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <gegl.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpmath/gimpmath.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
|
@ -53,19 +54,19 @@
|
|||
|
||||
static void select_feather_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
gpointer data);
|
||||
static void select_border_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
gpointer data);
|
||||
static void select_grow_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
gpointer data);
|
||||
static void select_shrink_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
gpointer data);
|
||||
static void select_float (GimpAction *action,
|
||||
GVariant *value,
|
||||
|
@ -502,7 +503,7 @@ select_stroke_last_vals_cmd_callback (GimpAction *action,
|
|||
static void
|
||||
select_feather_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
gpointer data)
|
||||
{
|
||||
GimpImage *image = GIMP_IMAGE (data);
|
||||
|
@ -522,7 +523,7 @@ select_feather_callback (GtkWidget *widget,
|
|||
radius_x = config->selection_feather_radius;
|
||||
radius_y = config->selection_feather_radius;
|
||||
|
||||
if (unit != GIMP_UNIT_PIXEL)
|
||||
if (unit != gimp_unit_pixel ())
|
||||
{
|
||||
gdouble xres;
|
||||
gdouble yres;
|
||||
|
@ -548,7 +549,7 @@ select_feather_callback (GtkWidget *widget,
|
|||
static void
|
||||
select_border_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
gpointer data)
|
||||
{
|
||||
GimpImage *image = GIMP_IMAGE (data);
|
||||
|
@ -574,7 +575,7 @@ select_border_callback (GtkWidget *widget,
|
|||
radius_x = ROUND (config->selection_border_radius);
|
||||
radius_y = ROUND (config->selection_border_radius);
|
||||
|
||||
if (unit != GIMP_UNIT_PIXEL)
|
||||
if (unit != gimp_unit_pixel ())
|
||||
{
|
||||
gdouble xres;
|
||||
gdouble yres;
|
||||
|
@ -601,7 +602,7 @@ select_border_callback (GtkWidget *widget,
|
|||
static void
|
||||
select_grow_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
gpointer data)
|
||||
{
|
||||
GimpImage *image = GIMP_IMAGE (data);
|
||||
|
@ -616,7 +617,7 @@ select_grow_callback (GtkWidget *widget,
|
|||
radius_x = ROUND (config->selection_grow_radius);
|
||||
radius_y = ROUND (config->selection_grow_radius);
|
||||
|
||||
if (unit != GIMP_UNIT_PIXEL)
|
||||
if (unit != gimp_unit_pixel ())
|
||||
{
|
||||
gdouble xres;
|
||||
gdouble yres;
|
||||
|
@ -640,7 +641,7 @@ select_grow_callback (GtkWidget *widget,
|
|||
static void
|
||||
select_shrink_callback (GtkWidget *widget,
|
||||
gdouble size,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
gpointer data)
|
||||
{
|
||||
GimpImage *image = GIMP_IMAGE (data);
|
||||
|
@ -660,7 +661,7 @@ select_shrink_callback (GtkWidget *widget,
|
|||
radius_x = ROUND (config->selection_shrink_radius);
|
||||
radius_y = ROUND (config->selection_shrink_radius);
|
||||
|
||||
if (unit != GIMP_UNIT_PIXEL)
|
||||
if (unit != gimp_unit_pixel ())
|
||||
{
|
||||
gdouble xres;
|
||||
gdouble yres;
|
||||
|
|
|
@ -506,9 +506,20 @@ dump_describe_param (GParamSpec *param_spec)
|
|||
}
|
||||
else if (GIMP_IS_PARAM_SPEC_UNIT (param_spec))
|
||||
{
|
||||
values =
|
||||
"The unit can be one inches, millimeters, points or picas plus "
|
||||
"those in your user units database.";
|
||||
GimpParamSpecUnit *uspec = GIMP_PARAM_SPEC_UNIT (param_spec);
|
||||
|
||||
if (uspec->allow_pixel && uspec->allow_percent)
|
||||
values = "The unit can be one inches, millimeters, points or picas plus "
|
||||
"those in your user units database. Pixel And Percent units are allowed too.";
|
||||
else if (uspec->allow_pixel)
|
||||
values = "The unit can be one inches, millimeters, points or picas plus "
|
||||
"those in your user units database. Pixel unit is allowed too.";
|
||||
else if (uspec->allow_percent)
|
||||
values = "The unit can be one inches, millimeters, points or picas plus "
|
||||
"those in your user units database. Percent unit is allowed too.";
|
||||
else
|
||||
values = "The unit can be one inches, millimeters, points or picas plus "
|
||||
"those in your user units database.";
|
||||
}
|
||||
else if (g_type_is_a (param_spec->value_type, GIMP_TYPE_CONFIG))
|
||||
{
|
||||
|
|
|
@ -246,41 +246,11 @@ output_unknown_token (const gchar *key,
|
|||
}
|
||||
|
||||
|
||||
/* minimal dummy units implementation */
|
||||
|
||||
static const gchar *
|
||||
unit_get_identifier (GimpUnit unit)
|
||||
{
|
||||
switch (unit)
|
||||
{
|
||||
case GIMP_UNIT_PIXEL:
|
||||
return "pixels";
|
||||
case GIMP_UNIT_INCH:
|
||||
return "inches";
|
||||
case GIMP_UNIT_MM:
|
||||
return "millimeters";
|
||||
case GIMP_UNIT_POINT:
|
||||
return "points";
|
||||
case GIMP_UNIT_PICA:
|
||||
return "picas";
|
||||
default:
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static gint
|
||||
unit_get_number_of_units (void)
|
||||
{
|
||||
return GIMP_UNIT_END;
|
||||
}
|
||||
|
||||
static void
|
||||
units_init (void)
|
||||
{
|
||||
GimpUnitVtable vtable;
|
||||
|
||||
vtable.unit_get_number_of_units = unit_get_number_of_units;
|
||||
vtable.unit_get_identifier = unit_get_identifier;
|
||||
/* Empty dummy units implementation */
|
||||
GimpUnitVtable vtable = { 0 };
|
||||
|
||||
gimp_base_init (&vtable);
|
||||
}
|
||||
|
|
|
@ -339,7 +339,7 @@ gimp_get_display_window_id (Gimp *gimp,
|
|||
GimpDisplay *
|
||||
gimp_create_display (Gimp *gimp,
|
||||
GimpImage *image,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
gdouble scale,
|
||||
GObject *monitor)
|
||||
{
|
||||
|
|
|
@ -57,7 +57,7 @@ struct _GimpGui
|
|||
GBytes * (* display_get_window_id) (GimpDisplay *display);
|
||||
GimpDisplay * (* display_create) (Gimp *gimp,
|
||||
GimpImage *image,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
gdouble scale,
|
||||
GObject *monitor);
|
||||
void (* display_delete) (GimpDisplay *display);
|
||||
|
@ -127,7 +127,7 @@ GBytes * gimp_get_display_window_id (Gimp *gimp,
|
|||
GimpDisplay *display);
|
||||
GimpDisplay * gimp_create_display (Gimp *gimp,
|
||||
GimpImage *image,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
gdouble scale,
|
||||
GObject *monitor);
|
||||
void gimp_delete_display (Gimp *gimp,
|
||||
|
|
|
@ -46,126 +46,30 @@
|
|||
* or the GTokenType they would have expected but didn't get.
|
||||
*/
|
||||
|
||||
static GTokenType gimp_unitrc_unit_info_deserialize (GScanner *scanner,
|
||||
Gimp *gimp);
|
||||
static GTokenType gimp_unitrc_unit_info_deserialize (GScanner *scanner,
|
||||
Gimp *gimp);
|
||||
|
||||
static GimpUnit * gimp_units_get_user_unit (gint unit_id);
|
||||
|
||||
|
||||
static Gimp *the_unit_gimp = NULL;
|
||||
|
||||
|
||||
static gint
|
||||
gimp_units_get_number_of_units (void)
|
||||
{
|
||||
return _gimp_unit_get_number_of_units (the_unit_gimp);
|
||||
}
|
||||
|
||||
static gint
|
||||
gimp_units_get_number_of_built_in_units (void)
|
||||
{
|
||||
return GIMP_UNIT_END;
|
||||
}
|
||||
|
||||
static GimpUnit
|
||||
gimp_units_unit_new (gchar *identifier,
|
||||
gdouble factor,
|
||||
gint digits,
|
||||
gchar *symbol,
|
||||
gchar *abbreviation,
|
||||
gchar *singular,
|
||||
gchar *plural)
|
||||
{
|
||||
return _gimp_unit_new (the_unit_gimp,
|
||||
identifier,
|
||||
factor,
|
||||
digits,
|
||||
symbol,
|
||||
abbreviation,
|
||||
singular,
|
||||
plural);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
gimp_units_unit_get_deletion_flag (GimpUnit unit)
|
||||
{
|
||||
return _gimp_unit_get_deletion_flag (the_unit_gimp, unit);
|
||||
}
|
||||
|
||||
static void
|
||||
gimp_units_unit_set_deletion_flag (GimpUnit unit,
|
||||
gboolean deletion_flag)
|
||||
{
|
||||
_gimp_unit_set_deletion_flag (the_unit_gimp, unit, deletion_flag);
|
||||
}
|
||||
|
||||
static gdouble
|
||||
gimp_units_unit_get_factor (GimpUnit unit)
|
||||
{
|
||||
return _gimp_unit_get_factor (the_unit_gimp, unit);
|
||||
}
|
||||
|
||||
static gint
|
||||
gimp_units_unit_get_digits (GimpUnit unit)
|
||||
{
|
||||
return _gimp_unit_get_digits (the_unit_gimp, unit);
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
gimp_units_unit_get_identifier (GimpUnit unit)
|
||||
{
|
||||
return _gimp_unit_get_identifier (the_unit_gimp, unit);
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
gimp_units_unit_get_symbol (GimpUnit unit)
|
||||
{
|
||||
return _gimp_unit_get_symbol (the_unit_gimp, unit);
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
gimp_units_unit_get_abbreviation (GimpUnit unit)
|
||||
{
|
||||
return _gimp_unit_get_abbreviation (the_unit_gimp, unit);
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
gimp_units_unit_get_singular (GimpUnit unit)
|
||||
{
|
||||
return _gimp_unit_get_singular (the_unit_gimp, unit);
|
||||
}
|
||||
|
||||
static const gchar *
|
||||
gimp_units_unit_get_plural (GimpUnit unit)
|
||||
{
|
||||
return _gimp_unit_get_plural (the_unit_gimp, unit);
|
||||
}
|
||||
|
||||
void
|
||||
gimp_units_init (Gimp *gimp)
|
||||
{
|
||||
GimpUnitVtable vtable;
|
||||
GimpUnitVtable vtable = { 0 };
|
||||
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
g_return_if_fail (the_unit_gimp == NULL);
|
||||
|
||||
the_unit_gimp = gimp;
|
||||
|
||||
vtable.unit_get_number_of_units = gimp_units_get_number_of_units;
|
||||
vtable.unit_get_number_of_built_in_units = gimp_units_get_number_of_built_in_units;
|
||||
vtable.unit_new = gimp_units_unit_new;
|
||||
vtable.unit_get_deletion_flag = gimp_units_unit_get_deletion_flag;
|
||||
vtable.unit_set_deletion_flag = gimp_units_unit_set_deletion_flag;
|
||||
vtable.unit_get_factor = gimp_units_unit_get_factor;
|
||||
vtable.unit_get_digits = gimp_units_unit_get_digits;
|
||||
vtable.unit_get_identifier = gimp_units_unit_get_identifier;
|
||||
vtable.unit_get_symbol = gimp_units_unit_get_symbol;
|
||||
vtable.unit_get_abbreviation = gimp_units_unit_get_abbreviation;
|
||||
vtable.unit_get_singular = gimp_units_unit_get_singular;
|
||||
vtable.unit_get_plural = gimp_units_unit_get_plural;
|
||||
vtable.get_user_unit = gimp_units_get_user_unit;
|
||||
|
||||
gimp_base_init (&vtable);
|
||||
|
||||
gimp->user_units = NULL;
|
||||
gimp->n_user_units = 0;
|
||||
gimp->user_units = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -173,7 +77,10 @@ gimp_units_exit (Gimp *gimp)
|
|||
{
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
|
||||
gimp_user_units_free (gimp);
|
||||
gimp_base_exit ();
|
||||
|
||||
g_list_free_full (gimp->user_units, g_object_unref);
|
||||
gimp->user_units = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -292,7 +199,7 @@ gimp_unitrc_save (Gimp *gimp)
|
|||
{
|
||||
GimpConfigWriter *writer;
|
||||
GFile *file;
|
||||
gint i;
|
||||
GList *iter;
|
||||
GError *error = NULL;
|
||||
|
||||
g_return_if_fail (GIMP_IS_GIMP (gimp));
|
||||
|
@ -319,49 +226,48 @@ gimp_unitrc_save (Gimp *gimp)
|
|||
if (!writer)
|
||||
return;
|
||||
|
||||
/* save user defined units */
|
||||
for (i = _gimp_unit_get_number_of_built_in_units (gimp);
|
||||
i < _gimp_unit_get_number_of_units (gimp);
|
||||
i++)
|
||||
for (iter = gimp->user_units; iter; iter = iter->next)
|
||||
{
|
||||
if (_gimp_unit_get_deletion_flag (gimp, i) == FALSE)
|
||||
GimpUnit *unit = iter->data;
|
||||
|
||||
if (gimp_unit_get_deletion_flag (unit) == FALSE)
|
||||
{
|
||||
gchar buf[G_ASCII_DTOSTR_BUF_SIZE];
|
||||
|
||||
gimp_config_writer_open (writer, "unit-info");
|
||||
gimp_config_writer_string (writer,
|
||||
_gimp_unit_get_identifier (gimp, i));
|
||||
gimp_unit_get_identifier (unit));
|
||||
|
||||
gimp_config_writer_open (writer, "factor");
|
||||
gimp_config_writer_print (writer,
|
||||
g_ascii_dtostr (buf, sizeof (buf),
|
||||
_gimp_unit_get_factor (gimp, i)),
|
||||
gimp_unit_get_factor (unit)),
|
||||
-1);
|
||||
gimp_config_writer_close (writer);
|
||||
|
||||
gimp_config_writer_open (writer, "digits");
|
||||
gimp_config_writer_printf (writer,
|
||||
"%d", _gimp_unit_get_digits (gimp, i));
|
||||
"%d", gimp_unit_get_digits (unit));
|
||||
gimp_config_writer_close (writer);
|
||||
|
||||
gimp_config_writer_open (writer, "symbol");
|
||||
gimp_config_writer_string (writer,
|
||||
_gimp_unit_get_symbol (gimp, i));
|
||||
gimp_unit_get_symbol (unit));
|
||||
gimp_config_writer_close (writer);
|
||||
|
||||
gimp_config_writer_open (writer, "abbreviation");
|
||||
gimp_config_writer_string (writer,
|
||||
_gimp_unit_get_abbreviation (gimp, i));
|
||||
gimp_unit_get_abbreviation (unit));
|
||||
gimp_config_writer_close (writer);
|
||||
|
||||
gimp_config_writer_open (writer, "singular");
|
||||
gimp_config_writer_string (writer,
|
||||
_gimp_unit_get_singular (gimp, i));
|
||||
gimp_unit_get_singular (unit));
|
||||
gimp_config_writer_close (writer);
|
||||
|
||||
gimp_config_writer_open (writer, "plural");
|
||||
gimp_config_writer_string (writer,
|
||||
_gimp_unit_get_plural (gimp, i));
|
||||
gimp_unit_get_plural (unit));
|
||||
gimp_config_writer_close (writer);
|
||||
|
||||
gimp_config_writer_close (writer);
|
||||
|
@ -466,13 +372,13 @@ gimp_unitrc_unit_info_deserialize (GScanner *scanner,
|
|||
|
||||
if (g_scanner_peek_next_token (scanner) == token)
|
||||
{
|
||||
GimpUnit unit = _gimp_unit_new (gimp,
|
||||
identifier, factor, digits,
|
||||
symbol, abbreviation,
|
||||
singular, plural);
|
||||
GimpUnit *unit = _gimp_unit_new (gimp,
|
||||
identifier, factor, digits,
|
||||
symbol, abbreviation,
|
||||
singular, plural);
|
||||
|
||||
/* make the unit definition persistent */
|
||||
_gimp_unit_set_deletion_flag (gimp, unit, FALSE);
|
||||
gimp_unit_set_deletion_flag (unit, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -486,3 +392,20 @@ gimp_unitrc_unit_info_deserialize (GScanner *scanner,
|
|||
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* gimp_units_get_user_unit:
|
||||
* @unit_id:
|
||||
*
|
||||
* This function will return the user-created GimpUnit with ID @unit_id.
|
||||
*/
|
||||
static GimpUnit *
|
||||
gimp_units_get_user_unit (gint unit_id)
|
||||
{
|
||||
g_return_val_if_fail (the_unit_gimp != NULL, NULL);
|
||||
g_return_val_if_fail (unit_id >= GIMP_UNIT_END && unit_id != GIMP_UNIT_PERCENT, NULL);
|
||||
|
||||
unit_id -= GIMP_UNIT_END;
|
||||
|
||||
return g_list_nth_data (the_unit_gimp->user_units, unit_id);
|
||||
}
|
||||
|
|
|
@ -193,7 +193,7 @@ gimp_get_default_language (const gchar *category)
|
|||
return lang;
|
||||
}
|
||||
|
||||
GimpUnit
|
||||
GimpUnit *
|
||||
gimp_get_default_unit (void)
|
||||
{
|
||||
#if defined (HAVE__NL_MEASUREMENT_MEASUREMENT)
|
||||
|
@ -202,10 +202,10 @@ gimp_get_default_unit (void)
|
|||
switch (*((guchar *) measurement))
|
||||
{
|
||||
case 1: /* metric */
|
||||
return GIMP_UNIT_MM;
|
||||
return gimp_unit_mm ();
|
||||
|
||||
case 2: /* imperial */
|
||||
return GIMP_UNIT_INCH;
|
||||
return gimp_unit_inch ();
|
||||
}
|
||||
|
||||
#elif defined (G_OS_WIN32)
|
||||
|
@ -222,15 +222,15 @@ gimp_get_default_unit (void)
|
|||
switch ((guint) measurement)
|
||||
{
|
||||
case 0: /* metric */
|
||||
return GIMP_UNIT_MM;
|
||||
return gimp_unit_mm ();
|
||||
|
||||
case 1: /* imperial */
|
||||
return GIMP_UNIT_INCH;
|
||||
return gimp_unit_inch ();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return GIMP_UNIT_MM;
|
||||
return gimp_unit_mm ();
|
||||
}
|
||||
|
||||
gchar **
|
||||
|
@ -1281,7 +1281,7 @@ gimp_create_image_from_buffer (Gimp *gimp,
|
|||
NULL /* same image */);
|
||||
gimp_image_add_layer (image, layer, NULL, -1, FALSE);
|
||||
|
||||
gimp_create_display (gimp, image, GIMP_UNIT_PIXEL, 1.0, NULL);
|
||||
gimp_create_display (gimp, image, gimp_unit_pixel (), 1.0, NULL);
|
||||
|
||||
/* unref the image unconditionally, even when no display was created */
|
||||
g_object_add_weak_pointer (G_OBJECT (image), (gpointer) &image);
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
gint gimp_get_pid (void);
|
||||
guint64 gimp_get_physical_memory_size (void);
|
||||
gchar * gimp_get_default_language (const gchar *category);
|
||||
GimpUnit gimp_get_default_unit (void);
|
||||
GimpUnit * gimp_get_default_unit (void);
|
||||
|
||||
gchar ** gimp_properties_append (GType object_type,
|
||||
gint *n_properties,
|
||||
|
|
|
@ -69,7 +69,6 @@ struct _Gimp
|
|||
guint busy_idle_id;
|
||||
|
||||
GList *user_units;
|
||||
gint n_user_units;
|
||||
|
||||
GimpParasiteList *parasites;
|
||||
|
||||
|
|
|
@ -511,18 +511,18 @@ gimp_buffer_get_resolution (GimpBuffer *buffer,
|
|||
|
||||
void
|
||||
gimp_buffer_set_unit (GimpBuffer *buffer,
|
||||
GimpUnit unit)
|
||||
GimpUnit *unit)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_BUFFER (buffer));
|
||||
g_return_if_fail (unit > GIMP_UNIT_PIXEL);
|
||||
g_return_if_fail (GIMP_IS_UNIT (unit));
|
||||
|
||||
buffer->unit = unit;
|
||||
}
|
||||
|
||||
GimpUnit
|
||||
GimpUnit *
|
||||
gimp_buffer_get_unit (GimpBuffer *buffer)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_BUFFER (buffer), GIMP_UNIT_PIXEL);
|
||||
g_return_val_if_fail (GIMP_IS_BUFFER (buffer), gimp_unit_pixel ());
|
||||
|
||||
return buffer->unit;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ struct _GimpBuffer
|
|||
|
||||
gdouble resolution_x;
|
||||
gdouble resolution_y;
|
||||
GimpUnit unit;
|
||||
GimpUnit *unit;
|
||||
|
||||
GimpColorProfile *color_profile;
|
||||
GimpColorProfile *format_profile;
|
||||
|
@ -80,8 +80,8 @@ gboolean gimp_buffer_get_resolution (GimpBuffer *buffer,
|
|||
gdouble *resolution_y);
|
||||
|
||||
void gimp_buffer_set_unit (GimpBuffer *buffer,
|
||||
GimpUnit unit);
|
||||
GimpUnit gimp_buffer_get_unit (GimpBuffer *buffer);
|
||||
GimpUnit *unit);
|
||||
GimpUnit * gimp_buffer_get_unit (GimpBuffer *buffer);
|
||||
|
||||
void gimp_buffer_set_color_profile (GimpBuffer *buffer,
|
||||
GimpColorProfile *profile);
|
||||
|
|
|
@ -119,8 +119,8 @@ gimp_drawable_stroke_scan_convert (GimpDrawable *drawable,
|
|||
GimpScanConvert *scan_convert,
|
||||
gboolean push_undo)
|
||||
{
|
||||
gdouble width;
|
||||
GimpUnit unit;
|
||||
gdouble width;
|
||||
GimpUnit *unit;
|
||||
|
||||
g_return_if_fail (GIMP_IS_DRAWABLE (drawable));
|
||||
g_return_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)));
|
||||
|
@ -136,7 +136,7 @@ gimp_drawable_stroke_scan_convert (GimpDrawable *drawable,
|
|||
width = gimp_stroke_options_get_width (options);
|
||||
unit = gimp_stroke_options_get_unit (options);
|
||||
|
||||
if (unit != GIMP_UNIT_PIXEL)
|
||||
if (unit != gimp_unit_pixel ())
|
||||
{
|
||||
GimpImage *image = gimp_item_get_image (GIMP_ITEM (drawable));
|
||||
gdouble xres;
|
||||
|
|
|
@ -123,7 +123,7 @@ gimp_grid_class_init (GimpGridClass *klass)
|
|||
"spacing-unit",
|
||||
_("Spacing unit"),
|
||||
NULL,
|
||||
FALSE, FALSE, GIMP_UNIT_INCH,
|
||||
FALSE, FALSE, gimp_unit_inch (),
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_DOUBLE (object_class, PROP_XOFFSET,
|
||||
|
@ -148,7 +148,7 @@ gimp_grid_class_init (GimpGridClass *klass)
|
|||
"offset-unit",
|
||||
_("Offset unit"),
|
||||
NULL,
|
||||
FALSE, FALSE, GIMP_UNIT_INCH,
|
||||
FALSE, FALSE, gimp_unit_inch (),
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
g_object_unref (black);
|
||||
|
@ -199,7 +199,7 @@ gimp_grid_get_property (GObject *object,
|
|||
g_value_set_double (value, grid->yspacing);
|
||||
break;
|
||||
case PROP_SPACING_UNIT:
|
||||
g_value_set_int (value, grid->spacing_unit);
|
||||
g_value_set_object (value, grid->spacing_unit);
|
||||
break;
|
||||
case PROP_XOFFSET:
|
||||
g_value_set_double (value, grid->xoffset);
|
||||
|
@ -208,7 +208,7 @@ gimp_grid_get_property (GObject *object,
|
|||
g_value_set_double (value, grid->yoffset);
|
||||
break;
|
||||
case PROP_OFFSET_UNIT:
|
||||
g_value_set_int (value, grid->offset_unit);
|
||||
g_value_set_object (value, grid->offset_unit);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
|
@ -244,7 +244,7 @@ gimp_grid_set_property (GObject *object,
|
|||
grid->yspacing = g_value_get_double (value);
|
||||
break;
|
||||
case PROP_SPACING_UNIT:
|
||||
grid->spacing_unit = g_value_get_int (value);
|
||||
grid->spacing_unit = g_value_get_object (value);
|
||||
break;
|
||||
case PROP_XOFFSET:
|
||||
grid->xoffset = g_value_get_double (value);
|
||||
|
@ -253,7 +253,7 @@ gimp_grid_set_property (GObject *object,
|
|||
grid->yoffset = g_value_get_double (value);
|
||||
break;
|
||||
case PROP_OFFSET_UNIT:
|
||||
grid->offset_unit = g_value_get_int (value);
|
||||
grid->offset_unit = g_value_get_object (value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
||||
|
|
|
@ -44,10 +44,10 @@ struct _GimpGrid
|
|||
GeglColor *bgcolor;
|
||||
gdouble xspacing;
|
||||
gdouble yspacing;
|
||||
GimpUnit spacing_unit;
|
||||
GimpUnit *spacing_unit;
|
||||
gdouble xoffset;
|
||||
gdouble yoffset;
|
||||
GimpUnit offset_unit;
|
||||
GimpUnit *offset_unit;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ struct _GimpImagePrivate
|
|||
gint height; /* height in pixels */
|
||||
gdouble xresolution; /* image x-res, in dpi */
|
||||
gdouble yresolution; /* image y-res, in dpi */
|
||||
GimpUnit resolution_unit; /* resolution unit */
|
||||
GimpUnit *resolution_unit; /* resolution unit */
|
||||
gboolean resolution_set; /* resolution explicitly set */
|
||||
GimpImageBaseType base_type; /* base gimp_image type */
|
||||
GimpPrecision precision; /* image's precision */
|
||||
|
|
|
@ -750,7 +750,7 @@ gimp_image_init (GimpImage *image)
|
|||
private->xresolution = 1.0;
|
||||
private->yresolution = 1.0;
|
||||
private->resolution_set = FALSE;
|
||||
private->resolution_unit = GIMP_UNIT_INCH;
|
||||
private->resolution_unit = gimp_unit_inch ();
|
||||
private->base_type = GIMP_RGB;
|
||||
private->precision = GIMP_PRECISION_U8_NON_LINEAR;
|
||||
private->new_layer_mode = -1;
|
||||
|
@ -2539,7 +2539,7 @@ gimp_image_set_imported_file (GimpImage *image,
|
|||
*/
|
||||
private->xresolution = 72.0;
|
||||
private->yresolution = 72.0;
|
||||
private->resolution_unit = GIMP_UNIT_INCH;
|
||||
private->resolution_unit = gimp_unit_inch ();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3213,12 +3213,12 @@ gimp_image_resolution_changed (GimpImage *image)
|
|||
|
||||
void
|
||||
gimp_image_set_unit (GimpImage *image,
|
||||
GimpUnit unit)
|
||||
GimpUnit *unit)
|
||||
{
|
||||
GimpImagePrivate *private;
|
||||
|
||||
g_return_if_fail (GIMP_IS_IMAGE (image));
|
||||
g_return_if_fail (unit > GIMP_UNIT_PIXEL);
|
||||
g_return_if_fail (GIMP_IS_UNIT (unit));
|
||||
|
||||
private = GIMP_IMAGE_GET_PRIVATE (image);
|
||||
|
||||
|
@ -3232,10 +3232,10 @@ gimp_image_set_unit (GimpImage *image,
|
|||
}
|
||||
}
|
||||
|
||||
GimpUnit
|
||||
GimpUnit *
|
||||
gimp_image_get_unit (GimpImage *image)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), GIMP_UNIT_INCH);
|
||||
g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
|
||||
|
||||
return GIMP_IMAGE_GET_PRIVATE (image)->resolution_unit;
|
||||
}
|
||||
|
|
|
@ -200,8 +200,8 @@ void gimp_image_get_resolution (GimpImage *image,
|
|||
void gimp_image_resolution_changed (GimpImage *image);
|
||||
|
||||
void gimp_image_set_unit (GimpImage *image,
|
||||
GimpUnit unit);
|
||||
GimpUnit gimp_image_get_unit (GimpImage *image);
|
||||
GimpUnit *unit);
|
||||
GimpUnit * gimp_image_get_unit (GimpImage *image);
|
||||
void gimp_image_unit_changed (GimpImage *image);
|
||||
|
||||
gint gimp_image_get_width (GimpImage *image);
|
||||
|
|
|
@ -423,7 +423,7 @@ gimp_image_undo_pop (GimpUndo *undo,
|
|||
|
||||
if (image_undo->resolution_unit != gimp_image_get_unit (image))
|
||||
{
|
||||
GimpUnit unit;
|
||||
GimpUnit *unit;
|
||||
|
||||
unit = gimp_image_get_unit (image);
|
||||
private->resolution_unit = image_undo->resolution_unit;
|
||||
|
|
|
@ -47,7 +47,7 @@ struct _GimpImageUndo
|
|||
gint previous_height;
|
||||
gdouble xresolution;
|
||||
gdouble yresolution;
|
||||
GimpUnit resolution_unit;
|
||||
GimpUnit *resolution_unit;
|
||||
GimpGrid *grid;
|
||||
gint num_colors;
|
||||
guchar *colormap;
|
||||
|
|
|
@ -45,6 +45,17 @@ gimp_param_spec_boolean_desc (GParamSpec *pspec)
|
|||
return g_strconcat (blurb, " (TRUE or FALSE)", NULL);
|
||||
}
|
||||
|
||||
static gchar *
|
||||
gimp_param_spec_unit_desc (GParamSpec *pspec)
|
||||
{
|
||||
GimpParamSpecUnit *uspec = GIMP_PARAM_SPEC_UNIT (pspec);
|
||||
|
||||
return g_strdup_printf ("<i>(default %s%s%s)</i>",
|
||||
gimp_unit_get_abbreviation (uspec->default_value),
|
||||
uspec->allow_pixel ? ", pixel allowed": "",
|
||||
uspec->allow_percent ? ", percent allowed": "");
|
||||
}
|
||||
|
||||
static gchar *
|
||||
gimp_param_spec_int_desc (GParamSpec *pspec)
|
||||
{
|
||||
|
@ -169,6 +180,7 @@ gimp_param_spec_get_desc (GParamSpec *pspec)
|
|||
|
||||
if (GIMP_IS_PARAM_SPEC_UNIT (pspec))
|
||||
{
|
||||
return gimp_param_spec_unit_desc (pspec);
|
||||
}
|
||||
else if (G_IS_PARAM_SPEC_INT (pspec))
|
||||
{
|
||||
|
|
|
@ -79,7 +79,7 @@ struct _GimpStrokeOptionsPrivate
|
|||
|
||||
/* options for method == LIBART */
|
||||
gdouble width;
|
||||
GimpUnit unit;
|
||||
GimpUnit *unit;
|
||||
|
||||
GimpCapStyle cap_style;
|
||||
GimpJoinStyle join_style;
|
||||
|
@ -167,7 +167,7 @@ gimp_stroke_options_class_init (GimpStrokeOptionsClass *klass)
|
|||
"unit",
|
||||
_("Unit"),
|
||||
NULL,
|
||||
TRUE, FALSE, GIMP_UNIT_PIXEL,
|
||||
TRUE, FALSE, gimp_unit_pixel (),
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_ENUM (object_class, PROP_CAP_STYLE,
|
||||
|
@ -278,7 +278,7 @@ gimp_stroke_options_set_property (GObject *object,
|
|||
private->width = g_value_get_double (value);
|
||||
break;
|
||||
case PROP_UNIT:
|
||||
private->unit = g_value_get_int (value);
|
||||
private->unit = g_value_get_object (value);
|
||||
break;
|
||||
case PROP_CAP_STYLE:
|
||||
private->cap_style = g_value_get_enum (value);
|
||||
|
@ -336,7 +336,7 @@ gimp_stroke_options_get_property (GObject *object,
|
|||
g_value_set_double (value, private->width);
|
||||
break;
|
||||
case PROP_UNIT:
|
||||
g_value_set_int (value, private->unit);
|
||||
g_value_set_object (value, private->unit);
|
||||
break;
|
||||
case PROP_CAP_STYLE:
|
||||
g_value_set_enum (value, private->cap_style);
|
||||
|
@ -450,10 +450,10 @@ gimp_stroke_options_get_width (GimpStrokeOptions *options)
|
|||
return GET_PRIVATE (options)->width;
|
||||
}
|
||||
|
||||
GimpUnit
|
||||
GimpUnit *
|
||||
gimp_stroke_options_get_unit (GimpStrokeOptions *options)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_STROKE_OPTIONS (options), GIMP_UNIT_PIXEL);
|
||||
g_return_val_if_fail (GIMP_IS_STROKE_OPTIONS (options), gimp_unit_pixel ());
|
||||
|
||||
return GET_PRIVATE (options)->unit;
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ GimpStrokeOptions * gimp_stroke_options_new (Gimp
|
|||
GimpStrokeMethod gimp_stroke_options_get_method (GimpStrokeOptions *options);
|
||||
|
||||
gdouble gimp_stroke_options_get_width (GimpStrokeOptions *options);
|
||||
GimpUnit gimp_stroke_options_get_unit (GimpStrokeOptions *options);
|
||||
GimpUnit * gimp_stroke_options_get_unit (GimpStrokeOptions *options);
|
||||
GimpCapStyle gimp_stroke_options_get_cap_style (GimpStrokeOptions *options);
|
||||
GimpJoinStyle gimp_stroke_options_get_join_style (GimpStrokeOptions *options);
|
||||
gdouble gimp_stroke_options_get_miter_limit (GimpStrokeOptions *options);
|
||||
|
|
|
@ -77,11 +77,11 @@ struct _GimpTemplatePrivate
|
|||
{
|
||||
gint width;
|
||||
gint height;
|
||||
GimpUnit unit;
|
||||
GimpUnit *unit;
|
||||
|
||||
gdouble xresolution;
|
||||
gdouble yresolution;
|
||||
GimpUnit resolution_unit;
|
||||
GimpUnit *resolution_unit;
|
||||
|
||||
GimpImageBaseType base_type;
|
||||
GimpPrecision precision;
|
||||
|
@ -158,7 +158,7 @@ gimp_template_class_init (GimpTemplateClass *klass)
|
|||
_("Unit"),
|
||||
_("The unit used for coordinate display "
|
||||
"when not in dot-for-dot mode."),
|
||||
TRUE, FALSE, GIMP_UNIT_PIXEL,
|
||||
TRUE, FALSE, gimp_unit_pixel (),
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_RESOLUTION (object_class, PROP_XRESOLUTION,
|
||||
|
@ -181,7 +181,7 @@ gimp_template_class_init (GimpTemplateClass *klass)
|
|||
"resolution-unit",
|
||||
_("Resolution unit"),
|
||||
NULL,
|
||||
FALSE, FALSE, GIMP_UNIT_INCH,
|
||||
FALSE, FALSE, gimp_unit_inch (),
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_ENUM (object_class, PROP_BASE_TYPE,
|
||||
|
@ -310,7 +310,7 @@ gimp_template_set_property (GObject *object,
|
|||
private->height = g_value_get_int (value);
|
||||
break;
|
||||
case PROP_UNIT:
|
||||
private->unit = g_value_get_int (value);
|
||||
private->unit = g_value_get_object (value);
|
||||
break;
|
||||
case PROP_XRESOLUTION:
|
||||
private->xresolution = g_value_get_double (value);
|
||||
|
@ -319,7 +319,7 @@ gimp_template_set_property (GObject *object,
|
|||
private->yresolution = g_value_get_double (value);
|
||||
break;
|
||||
case PROP_RESOLUTION_UNIT:
|
||||
private->resolution_unit = g_value_get_int (value);
|
||||
private->resolution_unit = g_value_get_object (value);
|
||||
break;
|
||||
case PROP_BASE_TYPE:
|
||||
private->base_type = g_value_get_enum (value);
|
||||
|
@ -398,7 +398,7 @@ gimp_template_get_property (GObject *object,
|
|||
g_value_set_int (value, private->height);
|
||||
break;
|
||||
case PROP_UNIT:
|
||||
g_value_set_int (value, private->unit);
|
||||
g_value_set_object (value, private->unit);
|
||||
break;
|
||||
case PROP_XRESOLUTION:
|
||||
g_value_set_double (value, private->xresolution);
|
||||
|
@ -407,7 +407,7 @@ gimp_template_get_property (GObject *object,
|
|||
g_value_set_double (value, private->yresolution);
|
||||
break;
|
||||
case PROP_RESOLUTION_UNIT:
|
||||
g_value_set_int (value, private->resolution_unit);
|
||||
g_value_set_object (value, private->resolution_unit);
|
||||
break;
|
||||
case PROP_BASE_TYPE:
|
||||
g_value_set_enum (value, private->base_type);
|
||||
|
@ -558,10 +558,10 @@ gimp_template_get_height (GimpTemplate *template)
|
|||
return GET_PRIVATE (template)->height;
|
||||
}
|
||||
|
||||
GimpUnit
|
||||
GimpUnit *
|
||||
gimp_template_get_unit (GimpTemplate *template)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_TEMPLATE (template), GIMP_UNIT_INCH);
|
||||
g_return_val_if_fail (GIMP_IS_TEMPLATE (template), gimp_unit_inch ());
|
||||
|
||||
return GET_PRIVATE (template)->unit;
|
||||
}
|
||||
|
@ -582,10 +582,10 @@ gimp_template_get_resolution_y (GimpTemplate *template)
|
|||
return GET_PRIVATE (template)->yresolution;
|
||||
}
|
||||
|
||||
GimpUnit
|
||||
GimpUnit *
|
||||
gimp_template_get_resolution_unit (GimpTemplate *template)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_TEMPLATE (template), GIMP_UNIT_INCH);
|
||||
g_return_val_if_fail (GIMP_IS_TEMPLATE (template), gimp_unit_inch ());
|
||||
|
||||
return GET_PRIVATE (template)->resolution_unit;
|
||||
}
|
||||
|
|
|
@ -75,11 +75,11 @@ void gimp_template_set_from_image (GimpTemplate *template,
|
|||
|
||||
gint gimp_template_get_width (GimpTemplate *template);
|
||||
gint gimp_template_get_height (GimpTemplate *template);
|
||||
GimpUnit gimp_template_get_unit (GimpTemplate *template);
|
||||
GimpUnit * gimp_template_get_unit (GimpTemplate *template);
|
||||
|
||||
gdouble gimp_template_get_resolution_x (GimpTemplate *template);
|
||||
gdouble gimp_template_get_resolution_y (GimpTemplate *template);
|
||||
GimpUnit gimp_template_get_resolution_unit (GimpTemplate *template);
|
||||
GimpUnit * gimp_template_get_resolution_unit (GimpTemplate *template);
|
||||
|
||||
GimpImageBaseType gimp_template_get_base_type (GimpTemplate *template);
|
||||
GimpPrecision gimp_template_get_precision (GimpTemplate *template);
|
||||
|
|
|
@ -36,78 +36,9 @@
|
|||
#include "gimp-intl.h"
|
||||
|
||||
|
||||
/* internal structures */
|
||||
|
||||
typedef struct
|
||||
{
|
||||
gboolean delete_on_exit;
|
||||
gdouble factor;
|
||||
gint digits;
|
||||
gchar *identifier;
|
||||
gchar *symbol;
|
||||
gchar *abbreviation;
|
||||
gchar *singular;
|
||||
gchar *plural;
|
||||
} GimpUnitDef;
|
||||
|
||||
|
||||
/* these are the built-in units
|
||||
*/
|
||||
static const GimpUnitDef gimp_unit_defs[GIMP_UNIT_END] =
|
||||
{
|
||||
/* pseudo unit */
|
||||
{ FALSE, 0.0, 0, "pixels", "px", "px",
|
||||
NC_("unit-singular", "pixel"), NC_("unit-plural", "pixels") },
|
||||
|
||||
/* standard units */
|
||||
{ FALSE, 1.0, 2, "inches", "''", "in",
|
||||
NC_("unit-singular", "inch"), NC_("unit-plural", "inches") },
|
||||
|
||||
{ FALSE, 25.4, 1, "millimeters", "mm", "mm",
|
||||
NC_("unit-singular", "millimeter"), NC_("unit-plural", "millimeters") },
|
||||
|
||||
/* professional units */
|
||||
{ FALSE, 72.0, 0, "points", "pt", "pt",
|
||||
NC_("unit-singular", "point"), NC_("unit-plural", "points") },
|
||||
|
||||
{ FALSE, 6.0, 1, "picas", "pc", "pc",
|
||||
NC_("unit-singular", "pica"), NC_("unit-plural", "picas") }
|
||||
};
|
||||
|
||||
/* not a unit at all but kept here to have the strings in one place
|
||||
*/
|
||||
static const GimpUnitDef gimp_unit_percent =
|
||||
{
|
||||
FALSE, 0.0, 0, "percent", "%", "%",
|
||||
NC_("singular", "percent"), NC_("plural", "percent")
|
||||
};
|
||||
|
||||
|
||||
/* private functions */
|
||||
|
||||
static GimpUnitDef *
|
||||
_gimp_unit_get_user_unit (Gimp *gimp,
|
||||
GimpUnit unit)
|
||||
{
|
||||
return g_list_nth_data (gimp->user_units, unit - GIMP_UNIT_END);
|
||||
}
|
||||
|
||||
|
||||
/* public functions */
|
||||
|
||||
gint
|
||||
_gimp_unit_get_number_of_units (Gimp *gimp)
|
||||
{
|
||||
return GIMP_UNIT_END + gimp->n_user_units;
|
||||
}
|
||||
|
||||
gint
|
||||
_gimp_unit_get_number_of_built_in_units (Gimp *gimp)
|
||||
{
|
||||
return GIMP_UNIT_END;
|
||||
}
|
||||
|
||||
GimpUnit
|
||||
GimpUnit *
|
||||
_gimp_unit_new (Gimp *gimp,
|
||||
const gchar *identifier,
|
||||
gdouble factor,
|
||||
|
@ -117,189 +48,23 @@ _gimp_unit_new (Gimp *gimp,
|
|||
const gchar *singular,
|
||||
const gchar *plural)
|
||||
{
|
||||
GimpUnitDef *user_unit = g_slice_new0 (GimpUnitDef);
|
||||
GimpUnit *unit;
|
||||
gint unit_id;
|
||||
|
||||
user_unit->delete_on_exit = TRUE;
|
||||
user_unit->factor = factor;
|
||||
user_unit->digits = digits;
|
||||
user_unit->identifier = g_strdup (identifier);
|
||||
user_unit->symbol = g_strdup (symbol);
|
||||
user_unit->abbreviation = g_strdup (abbreviation);
|
||||
user_unit->singular = g_strdup (singular);
|
||||
user_unit->plural = g_strdup (plural);
|
||||
unit_id = GIMP_UNIT_END + g_list_length (gimp->user_units);
|
||||
unit = g_object_new (GIMP_TYPE_UNIT,
|
||||
"id", unit_id,
|
||||
"name", identifier,
|
||||
"factor", factor,
|
||||
"digits", digits,
|
||||
"symbol", symbol,
|
||||
"abbreviation", abbreviation,
|
||||
"singular", singular,
|
||||
"plural", plural,
|
||||
NULL);
|
||||
|
||||
gimp->user_units = g_list_append (gimp->user_units, user_unit);
|
||||
gimp->n_user_units++;
|
||||
gimp->user_units = g_list_append (gimp->user_units, unit);
|
||||
gimp_unit_set_deletion_flag (unit, TRUE);
|
||||
|
||||
return GIMP_UNIT_END + gimp->n_user_units - 1;
|
||||
}
|
||||
|
||||
gboolean
|
||||
_gimp_unit_get_deletion_flag (Gimp *gimp,
|
||||
GimpUnit unit)
|
||||
{
|
||||
g_return_val_if_fail (unit < (GIMP_UNIT_END + gimp->n_user_units), FALSE);
|
||||
|
||||
if (unit < GIMP_UNIT_END)
|
||||
return FALSE;
|
||||
|
||||
return _gimp_unit_get_user_unit (gimp, unit)->delete_on_exit;
|
||||
}
|
||||
|
||||
void
|
||||
_gimp_unit_set_deletion_flag (Gimp *gimp,
|
||||
GimpUnit unit,
|
||||
gboolean deletion_flag)
|
||||
{
|
||||
g_return_if_fail ((unit >= GIMP_UNIT_END) &&
|
||||
(unit < (GIMP_UNIT_END + gimp->n_user_units)));
|
||||
|
||||
_gimp_unit_get_user_unit (gimp, unit)->delete_on_exit =
|
||||
deletion_flag ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
gdouble
|
||||
_gimp_unit_get_factor (Gimp *gimp,
|
||||
GimpUnit unit)
|
||||
{
|
||||
g_return_val_if_fail (unit < (GIMP_UNIT_END + gimp->n_user_units) ||
|
||||
(unit == GIMP_UNIT_PERCENT),
|
||||
gimp_unit_defs[GIMP_UNIT_INCH].factor);
|
||||
|
||||
if (unit < GIMP_UNIT_END)
|
||||
return gimp_unit_defs[unit].factor;
|
||||
|
||||
if (unit == GIMP_UNIT_PERCENT)
|
||||
return gimp_unit_percent.factor;
|
||||
|
||||
return _gimp_unit_get_user_unit (gimp, unit)->factor;
|
||||
}
|
||||
|
||||
gint
|
||||
_gimp_unit_get_digits (Gimp *gimp,
|
||||
GimpUnit unit)
|
||||
{
|
||||
g_return_val_if_fail (unit < (GIMP_UNIT_END + gimp->n_user_units) ||
|
||||
(unit == GIMP_UNIT_PERCENT),
|
||||
gimp_unit_defs[GIMP_UNIT_INCH].digits);
|
||||
|
||||
if (unit < GIMP_UNIT_END)
|
||||
return gimp_unit_defs[unit].digits;
|
||||
|
||||
if (unit == GIMP_UNIT_PERCENT)
|
||||
return gimp_unit_percent.digits;
|
||||
|
||||
return _gimp_unit_get_user_unit (gimp, unit)->digits;
|
||||
}
|
||||
|
||||
const gchar *
|
||||
_gimp_unit_get_identifier (Gimp *gimp,
|
||||
GimpUnit unit)
|
||||
{
|
||||
g_return_val_if_fail ((unit < (GIMP_UNIT_END + gimp->n_user_units)) ||
|
||||
(unit == GIMP_UNIT_PERCENT),
|
||||
gimp_unit_defs[GIMP_UNIT_INCH].identifier);
|
||||
|
||||
if (unit < GIMP_UNIT_END)
|
||||
return gimp_unit_defs[unit].identifier;
|
||||
|
||||
if (unit == GIMP_UNIT_PERCENT)
|
||||
return gimp_unit_percent.identifier;
|
||||
|
||||
return _gimp_unit_get_user_unit (gimp, unit)->identifier;
|
||||
}
|
||||
|
||||
const gchar *
|
||||
_gimp_unit_get_symbol (Gimp *gimp,
|
||||
GimpUnit unit)
|
||||
{
|
||||
g_return_val_if_fail ((unit < (GIMP_UNIT_END + gimp->n_user_units)) ||
|
||||
(unit == GIMP_UNIT_PERCENT),
|
||||
gimp_unit_defs[GIMP_UNIT_INCH].symbol);
|
||||
|
||||
if (unit < GIMP_UNIT_END)
|
||||
return gimp_unit_defs[unit].symbol;
|
||||
|
||||
if (unit == GIMP_UNIT_PERCENT)
|
||||
return gimp_unit_percent.symbol;
|
||||
|
||||
return _gimp_unit_get_user_unit (gimp, unit)->symbol;
|
||||
}
|
||||
|
||||
const gchar *
|
||||
_gimp_unit_get_abbreviation (Gimp *gimp,
|
||||
GimpUnit unit)
|
||||
{
|
||||
g_return_val_if_fail ((unit < (GIMP_UNIT_END + gimp->n_user_units)) ||
|
||||
(unit == GIMP_UNIT_PERCENT),
|
||||
gimp_unit_defs[GIMP_UNIT_INCH].abbreviation);
|
||||
|
||||
if (unit < GIMP_UNIT_END)
|
||||
return gimp_unit_defs[unit].abbreviation;
|
||||
|
||||
if (unit == GIMP_UNIT_PERCENT)
|
||||
return gimp_unit_percent.abbreviation;
|
||||
|
||||
return _gimp_unit_get_user_unit (gimp, unit)->abbreviation;
|
||||
}
|
||||
|
||||
const gchar *
|
||||
_gimp_unit_get_singular (Gimp *gimp,
|
||||
GimpUnit unit)
|
||||
{
|
||||
g_return_val_if_fail ((unit < (GIMP_UNIT_END + gimp->n_user_units)) ||
|
||||
(unit == GIMP_UNIT_PERCENT),
|
||||
gimp_unit_defs[GIMP_UNIT_INCH].singular);
|
||||
|
||||
if (unit < GIMP_UNIT_END)
|
||||
return g_dpgettext2 (NULL, "unit-singular", gimp_unit_defs[unit].singular);
|
||||
|
||||
if (unit == GIMP_UNIT_PERCENT)
|
||||
return g_dpgettext2 (NULL, "unit-singular", gimp_unit_percent.singular);
|
||||
|
||||
return _gimp_unit_get_user_unit (gimp, unit)->singular;
|
||||
}
|
||||
|
||||
const gchar *
|
||||
_gimp_unit_get_plural (Gimp *gimp,
|
||||
GimpUnit unit)
|
||||
{
|
||||
g_return_val_if_fail ((unit < (GIMP_UNIT_END + gimp->n_user_units)) ||
|
||||
(unit == GIMP_UNIT_PERCENT),
|
||||
gimp_unit_defs[GIMP_UNIT_INCH].plural);
|
||||
|
||||
if (unit < GIMP_UNIT_END)
|
||||
return g_dpgettext2 (NULL, "unit-plural", gimp_unit_defs[unit].plural);
|
||||
|
||||
if (unit == GIMP_UNIT_PERCENT)
|
||||
return g_dpgettext2 (NULL, "unit-plural", gimp_unit_percent.plural);
|
||||
|
||||
return _gimp_unit_get_user_unit (gimp, unit)->plural;
|
||||
}
|
||||
|
||||
|
||||
/* The sole purpose of this function is to release the allocated
|
||||
* memory. It must only be used from gimp_units_exit().
|
||||
*/
|
||||
void
|
||||
gimp_user_units_free (Gimp *gimp)
|
||||
{
|
||||
GList *list;
|
||||
|
||||
for (list = gimp->user_units; list; list = g_list_next (list))
|
||||
{
|
||||
GimpUnitDef *user_unit = list->data;
|
||||
|
||||
g_free (user_unit->identifier);
|
||||
g_free (user_unit->symbol);
|
||||
g_free (user_unit->abbreviation);
|
||||
g_free (user_unit->singular);
|
||||
g_free (user_unit->plural);
|
||||
|
||||
g_slice_free (GimpUnitDef, user_unit);
|
||||
}
|
||||
|
||||
g_list_free (gimp->user_units);
|
||||
gimp->user_units = NULL;
|
||||
gimp->n_user_units = 0;
|
||||
return unit;
|
||||
}
|
||||
|
|
|
@ -19,10 +19,7 @@
|
|||
#define __APP_GIMP_UNIT_H__
|
||||
|
||||
|
||||
gint _gimp_unit_get_number_of_units (Gimp *gimp);
|
||||
gint _gimp_unit_get_number_of_built_in_units (Gimp *gimp) G_GNUC_CONST;
|
||||
|
||||
GimpUnit _gimp_unit_new (Gimp *gimp,
|
||||
GimpUnit * _gimp_unit_new (Gimp *gimp,
|
||||
const gchar *identifier,
|
||||
gdouble factor,
|
||||
gint digits,
|
||||
|
@ -31,31 +28,5 @@ GimpUnit _gimp_unit_new (Gimp *gimp,
|
|||
const gchar *singular,
|
||||
const gchar *plural);
|
||||
|
||||
gboolean _gimp_unit_get_deletion_flag (Gimp *gimp,
|
||||
GimpUnit unit);
|
||||
void _gimp_unit_set_deletion_flag (Gimp *gimp,
|
||||
GimpUnit unit,
|
||||
gboolean deletion_flag);
|
||||
|
||||
gdouble _gimp_unit_get_factor (Gimp *gimp,
|
||||
GimpUnit unit);
|
||||
|
||||
gint _gimp_unit_get_digits (Gimp *gimp,
|
||||
GimpUnit unit);
|
||||
|
||||
const gchar * _gimp_unit_get_identifier (Gimp *gimp,
|
||||
GimpUnit unit);
|
||||
|
||||
const gchar * _gimp_unit_get_symbol (Gimp *gimp,
|
||||
GimpUnit unit);
|
||||
const gchar * _gimp_unit_get_abbreviation (Gimp *gimp,
|
||||
GimpUnit unit);
|
||||
const gchar * _gimp_unit_get_singular (Gimp *gimp,
|
||||
GimpUnit unit);
|
||||
const gchar * _gimp_unit_get_plural (Gimp *gimp,
|
||||
GimpUnit unit);
|
||||
|
||||
void gimp_user_units_free (Gimp *gimp);
|
||||
|
||||
|
||||
#endif /* __APP_GIMP_UNIT_H__ */
|
||||
|
|
|
@ -26,11 +26,11 @@ typedef void (* GimpScaleCallback) (GtkWidget *dialog,
|
|||
GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
GimpInterpolationType interpolation,
|
||||
gdouble xresolution,
|
||||
gdouble yresolution,
|
||||
GimpUnit resolution_unit,
|
||||
GimpUnit *resolution_unit,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
|
|
|
@ -53,11 +53,11 @@ typedef struct
|
|||
|
||||
gint width;
|
||||
gint height;
|
||||
GimpUnit unit;
|
||||
GimpUnit *unit;
|
||||
GimpInterpolationType interpolation;
|
||||
gdouble xresolution;
|
||||
gdouble yresolution;
|
||||
GimpUnit resolution_unit;
|
||||
GimpUnit *resolution_unit;
|
||||
|
||||
GimpScaleCallback callback;
|
||||
gpointer user_data;
|
||||
|
@ -71,11 +71,11 @@ static void image_scale_callback (GtkWidget *widget,
|
|||
GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
GimpInterpolationType interpolation,
|
||||
gdouble xresolution,
|
||||
gdouble yresolution,
|
||||
GimpUnit resolution_unit,
|
||||
GimpUnit *resolution_unit,
|
||||
gpointer data);
|
||||
|
||||
static GtkWidget * image_scale_confirm_dialog (ImageScaleDialog *private);
|
||||
|
@ -94,7 +94,7 @@ GtkWidget *
|
|||
image_scale_dialog_new (GimpImage *image,
|
||||
GimpContext *context,
|
||||
GtkWidget *parent,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
GimpInterpolationType interpolation,
|
||||
GimpScaleCallback callback,
|
||||
gpointer user_data)
|
||||
|
@ -142,11 +142,11 @@ image_scale_callback (GtkWidget *widget,
|
|||
GimpViewable *viewable,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
GimpInterpolationType interpolation,
|
||||
gdouble xresolution,
|
||||
gdouble yresolution,
|
||||
GimpUnit resolution_unit,
|
||||
GimpUnit *resolution_unit,
|
||||
gpointer data)
|
||||
{
|
||||
ImageScaleDialog *private = data;
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
GtkWidget * image_scale_dialog_new (GimpImage *image,
|
||||
GimpContext *context,
|
||||
GtkWidget *parent,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
GimpInterpolationType interpolation,
|
||||
GimpScaleCallback callback,
|
||||
gpointer user_data);
|
||||
|
|
|
@ -265,7 +265,7 @@ layer_options_dialog_new (GimpImage *image,
|
|||
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
||||
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 10);
|
||||
|
||||
private->size_se = gimp_size_entry_new (1, GIMP_UNIT_PIXEL, "%a",
|
||||
private->size_se = gimp_size_entry_new (1, gimp_unit_pixel (), "%a",
|
||||
TRUE, TRUE, FALSE, 10,
|
||||
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
||||
|
||||
|
@ -278,7 +278,7 @@ layer_options_dialog_new (GimpImage *image,
|
|||
gtk_widget_show (private->size_se);
|
||||
|
||||
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (private->size_se),
|
||||
GIMP_UNIT_PIXEL);
|
||||
gimp_unit_pixel ());
|
||||
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->size_se), 0,
|
||||
xres, FALSE);
|
||||
|
@ -322,7 +322,7 @@ layer_options_dialog_new (GimpImage *image,
|
|||
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
||||
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 10);
|
||||
|
||||
private->offset_se = gimp_size_entry_new (1, GIMP_UNIT_PIXEL, "%a",
|
||||
private->offset_se = gimp_size_entry_new (1, gimp_unit_pixel (), "%a",
|
||||
TRUE, TRUE, FALSE, 10,
|
||||
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
||||
|
||||
|
@ -335,7 +335,7 @@ layer_options_dialog_new (GimpImage *image,
|
|||
gtk_widget_show (private->offset_se);
|
||||
|
||||
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (private->offset_se),
|
||||
GIMP_UNIT_PIXEL);
|
||||
gimp_unit_pixel ());
|
||||
|
||||
gimp_size_entry_set_resolution (GIMP_SIZE_ENTRY (private->offset_se), 0,
|
||||
xres, FALSE);
|
||||
|
|
|
@ -23,7 +23,7 @@ typedef void (* GimpResolutionCallback) (GtkWidget *dialog,
|
|||
GimpImage *image,
|
||||
gdouble xresolution,
|
||||
gdouble yresolution,
|
||||
GimpUnit resolution_unit,
|
||||
GimpUnit *resolution_unit,
|
||||
gpointer user_data);
|
||||
|
||||
|
||||
|
|
|
@ -62,10 +62,10 @@ struct _ResizeDialog
|
|||
|
||||
gdouble old_xres;
|
||||
gdouble old_yres;
|
||||
GimpUnit old_res_unit;
|
||||
GimpUnit *old_res_unit;
|
||||
gint old_width;
|
||||
gint old_height;
|
||||
GimpUnit old_unit;
|
||||
GimpUnit *old_unit;
|
||||
GimpFillType old_fill_type;
|
||||
GimpItemSet old_layer_set;
|
||||
gboolean old_resize_text_layers;
|
||||
|
@ -123,7 +123,7 @@ resize_dialog_new (GimpViewable *viewable,
|
|||
GtkWidget *parent,
|
||||
GimpHelpFunc help_func,
|
||||
const gchar *help_id,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
GimpFillType fill_type,
|
||||
GimpItemSet layer_set,
|
||||
gboolean resize_text_layers,
|
||||
|
@ -554,12 +554,12 @@ resize_dialog_response (GtkWidget *dialog,
|
|||
ResizeDialog *private)
|
||||
{
|
||||
GimpSizeEntry *entry = GIMP_SIZE_ENTRY (private->offset);
|
||||
GimpUnit unit;
|
||||
GimpUnit *unit;
|
||||
gint width;
|
||||
gint height;
|
||||
gdouble xres;
|
||||
gdouble yres;
|
||||
GimpUnit res_unit;
|
||||
GimpUnit *res_unit;
|
||||
|
||||
switch (response_id)
|
||||
{
|
||||
|
@ -729,7 +729,7 @@ template_changed (GimpContext *context,
|
|||
GimpTemplate *template,
|
||||
ResizeDialog *private)
|
||||
{
|
||||
GimpUnit unit = private->old_unit;
|
||||
GimpUnit *unit = private->old_unit;
|
||||
|
||||
private->template = template;
|
||||
|
||||
|
@ -738,10 +738,10 @@ template_changed (GimpContext *context,
|
|||
|
||||
if (template != NULL)
|
||||
{
|
||||
gdouble xres;
|
||||
gdouble yres;
|
||||
GimpUnit res_unit;
|
||||
gboolean resolution_mismatch;
|
||||
gdouble xres;
|
||||
gdouble yres;
|
||||
GimpUnit *res_unit;
|
||||
gboolean resolution_mismatch;
|
||||
|
||||
unit = gimp_template_get_unit (template);
|
||||
xres = gimp_template_get_resolution_x (template);
|
||||
|
@ -752,8 +752,7 @@ template_changed (GimpContext *context,
|
|||
yres != private->old_yres ||
|
||||
res_unit != private->old_res_unit;
|
||||
|
||||
if (resolution_mismatch &&
|
||||
unit != GIMP_UNIT_PIXEL)
|
||||
if (resolution_mismatch && unit != gimp_unit_pixel ())
|
||||
{
|
||||
gchar *text;
|
||||
|
||||
|
@ -785,10 +784,10 @@ ppi_select_toggled (GtkWidget *radio,
|
|||
{
|
||||
gint width;
|
||||
gint height;
|
||||
GimpUnit unit;
|
||||
GimpUnit *unit;
|
||||
gdouble xres;
|
||||
gdouble yres;
|
||||
GimpUnit res_unit;
|
||||
GimpUnit *res_unit;
|
||||
GtkToggleButton *image_button;
|
||||
gboolean use_image_ppi;
|
||||
|
||||
|
@ -812,8 +811,7 @@ ppi_select_toggled (GtkWidget *radio,
|
|||
res_unit = gimp_template_get_resolution_unit (private->template);
|
||||
}
|
||||
|
||||
if (private->template != NULL &&
|
||||
unit != GIMP_UNIT_PIXEL)
|
||||
if (private->template != NULL && unit != gimp_unit_pixel ())
|
||||
{
|
||||
if (use_image_ppi)
|
||||
{
|
||||
|
|
|
@ -24,12 +24,12 @@ typedef void (* GimpResizeCallback) (GtkWidget *dialog,
|
|||
GimpContext *context,
|
||||
gint width,
|
||||
gint height,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
gint offset_x,
|
||||
gint offset_y,
|
||||
gdouble xres,
|
||||
gdouble yres,
|
||||
GimpUnit res_unit,
|
||||
GimpUnit *res_unit,
|
||||
GimpFillType fill_type,
|
||||
GimpItemSet layer_set,
|
||||
gboolean resize_text_layers,
|
||||
|
@ -43,7 +43,7 @@ GtkWidget * resize_dialog_new (GimpViewable *viewable,
|
|||
GtkWidget *parent,
|
||||
GimpHelpFunc help_func,
|
||||
const gchar *help_id,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
GimpFillType fill_type,
|
||||
GimpItemSet layer_set,
|
||||
gboolean resize_text_layers,
|
||||
|
|
|
@ -137,7 +137,7 @@ resolution_calibrate_dialog (GtkWidget *resolution_entry,
|
|||
gimp_size_entry_get_refval (GIMP_SIZE_ENTRY (resolution_entry), 1);
|
||||
|
||||
calibrate_entry =
|
||||
gimp_coordinates_new (GIMP_UNIT_INCH, "%p",
|
||||
gimp_coordinates_new (gimp_unit_inch (), "%p",
|
||||
FALSE, FALSE, 10,
|
||||
GIMP_SIZE_ENTRY_UPDATE_SIZE,
|
||||
FALSE,
|
||||
|
|
|
@ -45,7 +45,7 @@ typedef struct _ScaleDialog ScaleDialog;
|
|||
struct _ScaleDialog
|
||||
{
|
||||
GimpViewable *viewable;
|
||||
GimpUnit unit;
|
||||
GimpUnit *unit;
|
||||
GimpInterpolationType interpolation;
|
||||
GtkWidget *box;
|
||||
GtkWidget *combo;
|
||||
|
@ -73,7 +73,7 @@ scale_dialog_new (GimpViewable *viewable,
|
|||
GtkWidget *parent,
|
||||
GimpHelpFunc help_func,
|
||||
const gchar *help_id,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
GimpInterpolationType interpolation,
|
||||
GimpScaleCallback callback,
|
||||
gpointer user_data)
|
||||
|
@ -221,9 +221,9 @@ scale_dialog_response (GtkWidget *dialog,
|
|||
gint response_id,
|
||||
ScaleDialog *private)
|
||||
{
|
||||
GimpUnit unit = private->unit;
|
||||
GimpUnit *unit = private->unit;
|
||||
gint interpolation = private->interpolation;
|
||||
GimpUnit resolution_unit;
|
||||
GimpUnit *resolution_unit;
|
||||
gint width, height;
|
||||
gdouble xres, yres;
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ GtkWidget * scale_dialog_new (GimpViewable *viewable,
|
|||
GtkWidget *parent,
|
||||
GimpHelpFunc help_func,
|
||||
const gchar *help_id,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
GimpInterpolationType interpolation,
|
||||
GimpScaleCallback callback,
|
||||
gpointer user_data);
|
||||
|
|
|
@ -87,10 +87,10 @@ struct _GimpCursorViewPrivate
|
|||
GimpDisplayShell *shell;
|
||||
GimpImage *image;
|
||||
|
||||
GimpUnit unit;
|
||||
GimpUnit *unit;
|
||||
guint cursor_idle_id;
|
||||
GimpImage *cursor_image;
|
||||
GimpUnit cursor_unit;
|
||||
GimpUnit *cursor_unit;
|
||||
gdouble cursor_x;
|
||||
gdouble cursor_y;
|
||||
};
|
||||
|
@ -128,7 +128,7 @@ static void gimp_cursor_view_diplay_changed (GimpCursorView *v
|
|||
static void gimp_cursor_view_shell_unit_changed (GimpCursorView *view,
|
||||
GParamSpec *pspec,
|
||||
GimpDisplayShell *shell);
|
||||
static void gimp_cursor_view_format_as_unit (GimpUnit unit,
|
||||
static void gimp_cursor_view_format_as_unit (GimpUnit *unit,
|
||||
gchar *output_buf,
|
||||
gint output_buf_size,
|
||||
gdouble pixel_value,
|
||||
|
@ -137,7 +137,7 @@ static void gimp_cursor_view_set_label_italic (GtkWidget *l
|
|||
gboolean italic);
|
||||
static void gimp_cursor_view_update_selection_info (GimpCursorView *view,
|
||||
GimpImage *image,
|
||||
GimpUnit unit);
|
||||
GimpUnit *unit);
|
||||
static gboolean gimp_cursor_view_cursor_idle (GimpCursorView *view);
|
||||
|
||||
|
||||
|
@ -193,7 +193,7 @@ gimp_cursor_view_init (GimpCursorView *view)
|
|||
view->priv->context = NULL;
|
||||
view->priv->shell = NULL;
|
||||
view->priv->image = NULL;
|
||||
view->priv->unit = GIMP_UNIT_PIXEL;
|
||||
view->priv->unit = gimp_unit_pixel ();
|
||||
view->priv->cursor_idle_id = 0;
|
||||
|
||||
gtk_widget_style_get (GTK_WIDGET (view),
|
||||
|
@ -510,7 +510,7 @@ gimp_cursor_view_get_aux_info (GimpDocked *docked)
|
|||
}
|
||||
|
||||
static void
|
||||
gimp_cursor_view_format_as_unit (GimpUnit unit,
|
||||
gimp_cursor_view_format_as_unit (GimpUnit *unit,
|
||||
gchar *output_buf,
|
||||
gint output_buf_size,
|
||||
gdouble pixel_value,
|
||||
|
@ -523,7 +523,7 @@ gimp_cursor_view_format_as_unit (GimpUnit unit,
|
|||
|
||||
value = gimp_pixels_to_units (pixel_value, unit, image_res);
|
||||
|
||||
if (unit != GIMP_UNIT_PIXEL)
|
||||
if (unit != gimp_unit_pixel ())
|
||||
{
|
||||
unit_digits = gimp_unit_get_scaled_digits (unit, image_res);
|
||||
unit_str = gimp_unit_get_abbreviation (unit);
|
||||
|
@ -689,7 +689,7 @@ gimp_cursor_view_shell_unit_changed (GimpCursorView *view,
|
|||
GParamSpec *pspec,
|
||||
GimpDisplayShell *shell)
|
||||
{
|
||||
GimpUnit new_unit = GIMP_UNIT_PIXEL;
|
||||
GimpUnit *new_unit = gimp_unit_pixel ();
|
||||
|
||||
if (shell)
|
||||
{
|
||||
|
@ -706,7 +706,7 @@ gimp_cursor_view_shell_unit_changed (GimpCursorView *view,
|
|||
static void
|
||||
gimp_cursor_view_update_selection_info (GimpCursorView *view,
|
||||
GimpImage *image,
|
||||
GimpUnit unit)
|
||||
GimpUnit *unit)
|
||||
{
|
||||
gint x, y, width, height;
|
||||
|
||||
|
@ -751,7 +751,7 @@ gimp_cursor_view_cursor_idle (GimpCursorView *view)
|
|||
if (view->priv->cursor_image)
|
||||
{
|
||||
GimpImage *image = view->priv->cursor_image;
|
||||
GimpUnit unit = view->priv->cursor_unit;
|
||||
GimpUnit *unit = view->priv->cursor_unit;
|
||||
gdouble x = view->priv->cursor_x;
|
||||
gdouble y = view->priv->cursor_y;
|
||||
gboolean in_image;
|
||||
|
@ -764,7 +764,7 @@ gimp_cursor_view_cursor_idle (GimpCursorView *view)
|
|||
gint int_x;
|
||||
gint int_y;
|
||||
|
||||
if (unit == GIMP_UNIT_PIXEL)
|
||||
if (unit == gimp_unit_pixel ())
|
||||
unit = gimp_image_get_unit (image);
|
||||
|
||||
gimp_image_get_resolution (image, &xres, &yres);
|
||||
|
@ -883,7 +883,7 @@ gimp_cursor_view_get_sample_merged (GimpCursorView *view)
|
|||
void
|
||||
gimp_cursor_view_update_cursor (GimpCursorView *view,
|
||||
GimpImage *image,
|
||||
GimpUnit shell_unit,
|
||||
GimpUnit *shell_unit,
|
||||
gdouble x,
|
||||
gdouble y)
|
||||
{
|
||||
|
|
|
@ -60,7 +60,7 @@ gboolean gimp_cursor_view_get_sample_merged (GimpCursorView *view);
|
|||
|
||||
void gimp_cursor_view_update_cursor (GimpCursorView *view,
|
||||
GimpImage *image,
|
||||
GimpUnit shell_unit,
|
||||
GimpUnit *shell_unit,
|
||||
gdouble x,
|
||||
gdouble y);
|
||||
void gimp_cursor_view_clear_cursor (GimpCursorView *view);
|
||||
|
|
|
@ -359,7 +359,7 @@ gimp_display_progress_canceled (GimpProgress *progress,
|
|||
GimpDisplay *
|
||||
gimp_display_new (Gimp *gimp,
|
||||
GimpImage *image,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
gdouble scale,
|
||||
GimpUIManager *popup_manager,
|
||||
GimpDialogFactory *dialog_factory,
|
||||
|
@ -682,7 +682,7 @@ gimp_display_empty (GimpDisplay *display)
|
|||
void
|
||||
gimp_display_fill (GimpDisplay *display,
|
||||
GimpImage *image,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
gdouble scale)
|
||||
{
|
||||
GimpDisplayImplPrivate *private;
|
||||
|
|
|
@ -53,7 +53,7 @@ GType gimp_display_impl_get_type (void) G_GNUC_CONST;
|
|||
|
||||
GimpDisplay * gimp_display_new (Gimp *gimp,
|
||||
GimpImage *image,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
gdouble scale,
|
||||
GimpUIManager *popup_manager,
|
||||
GimpDialogFactory *dialog_factory,
|
||||
|
@ -74,7 +74,7 @@ GimpDisplayShell * gimp_display_get_shell (GimpDisplay *display);
|
|||
void gimp_display_empty (GimpDisplay *display);
|
||||
void gimp_display_fill (GimpDisplay *display,
|
||||
GimpImage *image,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
gdouble scale);
|
||||
|
||||
void gimp_display_update_bounding_box
|
||||
|
|
|
@ -227,7 +227,7 @@ gimp_display_shell_drop_drawable (GtkWidget *widget,
|
|||
{
|
||||
image = gimp_image_new_from_drawable (shell->display->gimp,
|
||||
GIMP_DRAWABLE (viewable));
|
||||
gimp_create_display (shell->display->gimp, image, GIMP_UNIT_PIXEL, 1.0,
|
||||
gimp_create_display (shell->display->gimp, image, gimp_unit_pixel (), 1.0,
|
||||
G_OBJECT (gimp_widget_get_monitor (widget)));
|
||||
g_object_unref (image);
|
||||
|
||||
|
@ -478,7 +478,7 @@ gimp_display_shell_drop_buffer (GtkWidget *widget,
|
|||
{
|
||||
image = gimp_image_new_from_buffer (shell->display->gimp,
|
||||
GIMP_BUFFER (viewable));
|
||||
gimp_create_display (image->gimp, image, GIMP_UNIT_PIXEL, 1.0,
|
||||
gimp_create_display (image->gimp, image, gimp_unit_pixel (), 1.0,
|
||||
G_OBJECT (gimp_widget_get_monitor (widget)));
|
||||
g_object_unref (image);
|
||||
|
||||
|
@ -664,7 +664,7 @@ gimp_display_shell_drop_component (GtkWidget *widget,
|
|||
{
|
||||
dest_image = gimp_image_new_from_component (image->gimp,
|
||||
image, component);
|
||||
gimp_create_display (dest_image->gimp, dest_image, GIMP_UNIT_PIXEL, 1.0,
|
||||
gimp_create_display (dest_image->gimp, dest_image, gimp_unit_pixel (), 1.0,
|
||||
G_OBJECT (gimp_widget_get_monitor (widget)));
|
||||
g_object_unref (dest_image);
|
||||
|
||||
|
@ -721,7 +721,7 @@ gimp_display_shell_drop_pixbuf (GtkWidget *widget,
|
|||
{
|
||||
image = gimp_image_new_from_pixbuf (shell->display->gimp, pixbuf,
|
||||
_("Dropped Buffer"));
|
||||
gimp_create_display (image->gimp, image, GIMP_UNIT_PIXEL, 1.0,
|
||||
gimp_create_display (image->gimp, image, gimp_unit_pixel (), 1.0,
|
||||
G_OBJECT (gimp_widget_get_monitor (widget)));
|
||||
g_object_unref (image);
|
||||
|
||||
|
|
|
@ -659,7 +659,7 @@ gimp_display_shell_resolution_changed_handler (GimpImage *image,
|
|||
|
||||
if (shell->dot_for_dot)
|
||||
{
|
||||
if (shell->unit != GIMP_UNIT_PIXEL)
|
||||
if (shell->unit != gimp_unit_pixel ())
|
||||
{
|
||||
gimp_display_shell_rulers_update (shell);
|
||||
}
|
||||
|
|
|
@ -420,7 +420,7 @@ gimp_display_shell_format_title (GimpDisplayShell *shell,
|
|||
break;
|
||||
|
||||
case 'W': /* width in real-world units */
|
||||
if (shell->unit != GIMP_UNIT_PIXEL)
|
||||
if (shell->unit != gimp_unit_pixel ())
|
||||
{
|
||||
gdouble xres;
|
||||
gdouble yres;
|
||||
|
@ -443,7 +443,7 @@ gimp_display_shell_format_title (GimpDisplayShell *shell,
|
|||
break;
|
||||
|
||||
case 'H': /* height in real-world units */
|
||||
if (shell->unit != GIMP_UNIT_PIXEL)
|
||||
if (shell->unit != gimp_unit_pixel ())
|
||||
{
|
||||
gdouble xres;
|
||||
gdouble yres;
|
||||
|
@ -476,7 +476,7 @@ gimp_display_shell_format_title (GimpDisplayShell *shell,
|
|||
break;
|
||||
|
||||
case 'X': /* drawable width in real world units */
|
||||
if (drawable && shell->unit != GIMP_UNIT_PIXEL)
|
||||
if (drawable && shell->unit != gimp_unit_pixel ())
|
||||
{
|
||||
gdouble xres;
|
||||
gdouble yres;
|
||||
|
@ -501,7 +501,7 @@ gimp_display_shell_format_title (GimpDisplayShell *shell,
|
|||
break;
|
||||
|
||||
case 'Y': /* drawable height in real world units */
|
||||
if (drawable && shell->unit != GIMP_UNIT_PIXEL)
|
||||
if (drawable && shell->unit != gimp_unit_pixel ())
|
||||
{
|
||||
gdouble xres;
|
||||
gdouble yres;
|
||||
|
|
|
@ -155,7 +155,7 @@ gimp_display_shell_get_line_status (GimpDisplayShell *shell,
|
|||
return g_strdup (status);
|
||||
}
|
||||
|
||||
if (shell->unit == GIMP_UNIT_PIXEL)
|
||||
if (shell->unit == gimp_unit_pixel ())
|
||||
xres = yres = 1.0;
|
||||
else
|
||||
gimp_image_get_resolution (image, &xres, &yres);
|
||||
|
@ -188,7 +188,7 @@ gimp_display_shell_get_line_status (GimpDisplayShell *shell,
|
|||
angle = 0.0;
|
||||
}
|
||||
|
||||
if (shell->unit == GIMP_UNIT_PIXEL)
|
||||
if (shell->unit == gimp_unit_pixel ())
|
||||
{
|
||||
enhanced_status = g_strdup_printf ("%.1f %s, %.2f\302\260%s%s",
|
||||
pixel_dist, _("pixels"), angle,
|
||||
|
|
|
@ -280,7 +280,7 @@ gimp_display_shell_class_init (GimpDisplayShellClass *klass)
|
|||
g_object_class_install_property (object_class, PROP_UNIT,
|
||||
gimp_param_spec_unit ("unit", NULL, NULL,
|
||||
TRUE, FALSE,
|
||||
GIMP_UNIT_PIXEL,
|
||||
gimp_unit_pixel (),
|
||||
GIMP_PARAM_READWRITE));
|
||||
|
||||
g_object_class_install_property (object_class, PROP_TITLE,
|
||||
|
@ -919,7 +919,7 @@ gimp_display_shell_set_property (GObject *object,
|
|||
shell->display = g_value_get_object (value);
|
||||
break;
|
||||
case PROP_UNIT:
|
||||
gimp_display_shell_set_unit (shell, g_value_get_int (value));
|
||||
gimp_display_shell_set_unit (shell, g_value_get_object (value));
|
||||
break;
|
||||
case PROP_TITLE:
|
||||
g_free (shell->title);
|
||||
|
@ -959,7 +959,7 @@ gimp_display_shell_get_property (GObject *object,
|
|||
g_value_set_object (value, shell->display);
|
||||
break;
|
||||
case PROP_UNIT:
|
||||
g_value_set_int (value, shell->unit);
|
||||
g_value_set_object (value, shell->unit);
|
||||
break;
|
||||
case PROP_TITLE:
|
||||
g_value_set_string (value, shell->title);
|
||||
|
@ -1335,7 +1335,7 @@ gimp_display_shell_transform_overlay (GimpDisplayShell *shell,
|
|||
|
||||
GtkWidget *
|
||||
gimp_display_shell_new (GimpDisplay *display,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
gdouble scale,
|
||||
GimpUIManager *popup_manager,
|
||||
GdkMonitor *monitor)
|
||||
|
@ -1590,7 +1590,7 @@ gimp_display_shell_fill_idle (GimpDisplayShell *shell)
|
|||
void
|
||||
gimp_display_shell_fill (GimpDisplayShell *shell,
|
||||
GimpImage *image,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
gdouble scale)
|
||||
{
|
||||
GimpDisplayConfig *config;
|
||||
|
@ -1702,7 +1702,7 @@ gimp_display_shell_rotated (GimpDisplayShell *shell)
|
|||
|
||||
void
|
||||
gimp_display_shell_set_unit (GimpDisplayShell *shell,
|
||||
GimpUnit unit)
|
||||
GimpUnit *unit)
|
||||
{
|
||||
g_return_if_fail (GIMP_IS_DISPLAY_SHELL (shell));
|
||||
|
||||
|
@ -1718,10 +1718,10 @@ gimp_display_shell_set_unit (GimpDisplayShell *shell,
|
|||
}
|
||||
}
|
||||
|
||||
GimpUnit
|
||||
GimpUnit *
|
||||
gimp_display_shell_get_unit (GimpDisplayShell *shell)
|
||||
{
|
||||
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), GIMP_UNIT_PIXEL);
|
||||
g_return_val_if_fail (GIMP_IS_DISPLAY_SHELL (shell), gimp_unit_pixel ());
|
||||
|
||||
return shell->unit;
|
||||
}
|
||||
|
|
|
@ -60,7 +60,7 @@ struct _GimpDisplayShell
|
|||
GimpDisplayOptions *fullscreen_options;
|
||||
GimpDisplayOptions *no_image_options;
|
||||
|
||||
GimpUnit unit;
|
||||
GimpUnit *unit;
|
||||
|
||||
gint offset_x; /* offset of display image */
|
||||
gint offset_y;
|
||||
|
@ -269,7 +269,7 @@ struct _GimpDisplayShellClass
|
|||
GType gimp_display_shell_get_type (void) G_GNUC_CONST;
|
||||
|
||||
GtkWidget * gimp_display_shell_new (GimpDisplay *display,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
gdouble scale,
|
||||
GimpUIManager *popup_manager,
|
||||
GdkMonitor *monitor);
|
||||
|
@ -302,7 +302,7 @@ void gimp_display_shell_reconnect (GimpDisplayShell *shell);
|
|||
void gimp_display_shell_empty (GimpDisplayShell *shell);
|
||||
void gimp_display_shell_fill (GimpDisplayShell *shell,
|
||||
GimpImage *image,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
gdouble scale);
|
||||
|
||||
void gimp_display_shell_scaled (GimpDisplayShell *shell);
|
||||
|
@ -310,8 +310,8 @@ void gimp_display_shell_scrolled (GimpDisplayShell *shell);
|
|||
void gimp_display_shell_rotated (GimpDisplayShell *shell);
|
||||
|
||||
void gimp_display_shell_set_unit (GimpDisplayShell *shell,
|
||||
GimpUnit unit);
|
||||
GimpUnit gimp_display_shell_get_unit (GimpDisplayShell *shell);
|
||||
GimpUnit *unit);
|
||||
GimpUnit * gimp_display_shell_get_unit (GimpDisplayShell *shell);
|
||||
|
||||
gboolean gimp_display_shell_snap_coords (GimpDisplayShell *shell,
|
||||
GimpCoords *coords,
|
||||
|
|
|
@ -1477,7 +1477,7 @@ gimp_statusbar_push_coords (GimpStatusbar *statusbar,
|
|||
break;
|
||||
}
|
||||
|
||||
if (shell->unit == GIMP_UNIT_PIXEL)
|
||||
if (shell->unit == gimp_unit_pixel ())
|
||||
{
|
||||
if (precision == GIMP_CURSOR_PRECISION_SUBPIXEL)
|
||||
{
|
||||
|
@ -1540,7 +1540,7 @@ gimp_statusbar_push_length (GimpStatusbar *statusbar,
|
|||
|
||||
shell = statusbar->shell;
|
||||
|
||||
if (shell->unit == GIMP_UNIT_PIXEL)
|
||||
if (shell->unit == gimp_unit_pixel ())
|
||||
{
|
||||
gimp_statusbar_push (statusbar, context,
|
||||
icon_name,
|
||||
|
@ -1768,7 +1768,7 @@ gimp_statusbar_update_cursor (GimpStatusbar *statusbar,
|
|||
}
|
||||
statusbar->cursor_precision = precision;
|
||||
|
||||
if (shell->unit == GIMP_UNIT_PIXEL)
|
||||
if (shell->unit == gimp_unit_pixel ())
|
||||
{
|
||||
if (precision == GIMP_CURSOR_PRECISION_SUBPIXEL)
|
||||
{
|
||||
|
@ -1911,7 +1911,7 @@ gimp_statusbar_shell_scaled (GimpDisplayShell *shell,
|
|||
g_signal_handlers_unblock_by_func (statusbar->unit_combo,
|
||||
gimp_statusbar_unit_changed, statusbar);
|
||||
|
||||
if (shell->unit == GIMP_UNIT_PIXEL)
|
||||
if (shell->unit == gimp_unit_pixel ())
|
||||
{
|
||||
g_snprintf (statusbar->cursor_format_str,
|
||||
sizeof (statusbar->cursor_format_str),
|
||||
|
@ -2468,7 +2468,7 @@ gimp_statusbar_queue_pos_redraw (gpointer data)
|
|||
* Of course, it could still happen for people going way
|
||||
* off-canvas but that's acceptable edge-case.
|
||||
*/
|
||||
if (shell->unit == GIMP_UNIT_PIXEL)
|
||||
if (shell->unit == gimp_unit_pixel ())
|
||||
{
|
||||
label_width_chars = floor (log10 (2 * image_width)) + floor (log10 (2 * image_height)) + 6;
|
||||
|
||||
|
|
|
@ -561,7 +561,7 @@ file_open_with_proc_and_display (Gimp *gimp,
|
|||
g_free (basename);
|
||||
}
|
||||
|
||||
if (gimp_create_display (image->gimp, image, GIMP_UNIT_PIXEL, 1.0,
|
||||
if (gimp_create_display (image->gimp, image, gimp_unit_pixel (), 1.0,
|
||||
monitor))
|
||||
{
|
||||
/* the display owns the image now */
|
||||
|
|
|
@ -138,7 +138,7 @@ static GimpDisplay * gui_get_empty_display (Gimp *gimp);
|
|||
static GBytes * gui_display_get_window_id (GimpDisplay *display);
|
||||
static GimpDisplay * gui_display_create (Gimp *gimp,
|
||||
GimpImage *image,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
gdouble scale,
|
||||
GObject *monitor);
|
||||
static void gui_display_delete (GimpDisplay *display);
|
||||
|
@ -396,7 +396,7 @@ gui_display_get_window_id (GimpDisplay *display)
|
|||
static GimpDisplay *
|
||||
gui_display_create (Gimp *gimp,
|
||||
GimpImage *image,
|
||||
GimpUnit unit,
|
||||
GimpUnit *unit,
|
||||
gdouble scale,
|
||||
GObject *monitor)
|
||||
{
|
||||
|
|
|
@ -616,7 +616,7 @@ gui_restore_after_callback (Gimp *gimp,
|
|||
|
||||
/* create the empty display */
|
||||
display = GIMP_DISPLAY (gimp_create_display (gimp, NULL,
|
||||
GIMP_UNIT_PIXEL, 1.0,
|
||||
gimp_unit_pixel (), 1.0,
|
||||
G_OBJECT (initial_monitor)));
|
||||
|
||||
shell = gimp_display_get_shell (display);
|
||||
|
|
|
@ -67,7 +67,7 @@
|
|||
#define DEFAULT_FADE_LENGTH 100.0
|
||||
#define DEFAULT_FADE_REVERSE FALSE
|
||||
#define DEFAULT_FADE_REPEAT GIMP_REPEAT_NONE
|
||||
#define DEFAULT_FADE_UNIT GIMP_UNIT_PIXEL
|
||||
#define DEFAULT_FADE_UNIT gimp_unit_pixel ()
|
||||
|
||||
#define DEFAULT_GRADIENT_REVERSE FALSE
|
||||
#define DEFAULT_GRADIENT_BLEND_SPACE GIMP_GRADIENT_BLEND_RGB_PERCEPTUAL
|
||||
|
@ -627,7 +627,7 @@ gimp_paint_options_set_property (GObject *object,
|
|||
fade_options->fade_repeat = g_value_get_enum (value);
|
||||
break;
|
||||
case PROP_FADE_UNIT:
|
||||
fade_options->fade_unit = g_value_get_int (value);
|
||||
fade_options->fade_unit = g_value_get_object (value);
|
||||
break;
|
||||
|
||||
case PROP_GRADIENT_REVERSE:
|
||||
|
@ -786,7 +786,7 @@ gimp_paint_options_get_property (GObject *object,
|
|||
g_value_set_enum (value, fade_options->fade_repeat);
|
||||
break;
|
||||
case PROP_FADE_UNIT:
|
||||
g_value_set_int (value, fade_options->fade_unit);
|
||||
g_value_set_object (value, fade_options->fade_unit);
|
||||
break;
|
||||
|
||||
case PROP_GRADIENT_REVERSE:
|
||||
|
@ -983,30 +983,26 @@ gimp_paint_options_get_fade (GimpPaintOptions *paint_options,
|
|||
|
||||
fade_options = paint_options->fade_options;
|
||||
|
||||
switch (fade_options->fade_unit)
|
||||
if (fade_options->fade_unit == gimp_unit_pixel ())
|
||||
{
|
||||
case GIMP_UNIT_PIXEL:
|
||||
fade_out = fade_options->fade_length;
|
||||
break;
|
||||
|
||||
case GIMP_UNIT_PERCENT:
|
||||
}
|
||||
else if (fade_options->fade_unit == gimp_unit_percent ())
|
||||
{
|
||||
fade_out = (MAX (gimp_image_get_width (image),
|
||||
gimp_image_get_height (image)) *
|
||||
fade_options->fade_length / 100);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
gdouble xres;
|
||||
gdouble yres;
|
||||
|
||||
default:
|
||||
{
|
||||
gdouble xres;
|
||||
gdouble yres;
|
||||
gimp_image_get_resolution (image, &xres, &yres);
|
||||
|
||||
gimp_image_get_resolution (image, &xres, &yres);
|
||||
|
||||
unit_factor = gimp_unit_get_factor (fade_options->fade_unit);
|
||||
fade_out = (fade_options->fade_length *
|
||||
MAX (xres, yres) / unit_factor);
|
||||
}
|
||||
break;
|
||||
unit_factor = gimp_unit_get_factor (fade_options->fade_unit);
|
||||
fade_out = (fade_options->fade_length *
|
||||
MAX (xres, yres) / unit_factor);
|
||||
}
|
||||
|
||||
/* factor in the fade out value */
|
||||
|
|
|
@ -46,7 +46,7 @@ struct _GimpFadeOptions
|
|||
{
|
||||
gboolean fade_reverse;
|
||||
gdouble fade_length;
|
||||
GimpUnit fade_unit;
|
||||
GimpUnit *fade_unit;
|
||||
GimpRepeatMode fade_repeat;
|
||||
};
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
#include <gdk-pixbuf/gdk-pixbuf.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpcolor/gimpcolor.h"
|
||||
#include "libgimpconfig/gimpconfig.h"
|
||||
|
||||
|
@ -497,7 +498,7 @@ context_get_line_width_unit_invoker (GimpProcedure *procedure,
|
|||
GError **error)
|
||||
{
|
||||
GimpValueArray *return_vals;
|
||||
GimpUnit line_width_unit = GIMP_UNIT_PIXEL;
|
||||
GimpUnit *line_width_unit = NULL;
|
||||
|
||||
GimpStrokeOptions *options =
|
||||
gimp_pdb_context_get_stroke_options (GIMP_PDB_CONTEXT (context));
|
||||
|
@ -507,7 +508,7 @@ context_get_line_width_unit_invoker (GimpProcedure *procedure,
|
|||
NULL);
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
|
||||
g_value_set_int (gimp_value_array_index (return_vals, 1), line_width_unit);
|
||||
g_value_set_object (gimp_value_array_index (return_vals, 1), line_width_unit);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
@ -521,9 +522,9 @@ context_set_line_width_unit_invoker (GimpProcedure *procedure,
|
|||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GimpUnit line_width_unit;
|
||||
GimpUnit *line_width_unit;
|
||||
|
||||
line_width_unit = g_value_get_int (gimp_value_array_index (args, 0));
|
||||
line_width_unit = g_value_get_object (gimp_value_array_index (args, 0));
|
||||
|
||||
if (success)
|
||||
{
|
||||
|
@ -3533,9 +3534,9 @@ register_context_procs (GimpPDB *pdb)
|
|||
gimp_param_spec_unit ("line-width-unit",
|
||||
"line width unit",
|
||||
"The line width unit setting",
|
||||
TRUE,
|
||||
FALSE,
|
||||
GIMP_UNIT_PIXEL,
|
||||
FALSE,
|
||||
gimp_unit_inch (),
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
@ -3560,9 +3561,9 @@ register_context_procs (GimpPDB *pdb)
|
|||
gimp_param_spec_unit ("line-width-unit",
|
||||
"line width unit",
|
||||
"The line width setting unit",
|
||||
TRUE,
|
||||
FALSE,
|
||||
GIMP_UNIT_PIXEL,
|
||||
FALSE,
|
||||
gimp_unit_inch (),
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
|
|
@ -88,7 +88,7 @@ display_new_invoker (GimpProcedure *procedure,
|
|||
{
|
||||
gimp_image_flush (image);
|
||||
|
||||
display = gimp_create_display (gimp, image, GIMP_UNIT_PIXEL, 1.0, NULL);
|
||||
display = gimp_create_display (gimp, image, gimp_unit_pixel (), 1.0, NULL);
|
||||
|
||||
if (display)
|
||||
{
|
||||
|
|
|
@ -142,12 +142,12 @@ get_default_unit_invoker (GimpProcedure *procedure,
|
|||
GError **error)
|
||||
{
|
||||
GimpValueArray *return_vals;
|
||||
GimpUnit unit_id = GIMP_UNIT_PIXEL;
|
||||
GimpUnit *unit = NULL;
|
||||
|
||||
unit_id = gimp_get_default_unit ();
|
||||
unit = gimp_get_default_unit ();
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
|
||||
g_value_set_int (gimp_value_array_index (return_vals, 1), unit_id);
|
||||
g_value_set_object (gimp_value_array_index (return_vals, 1), unit);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
@ -312,19 +312,19 @@ register_gimprc_procs (GimpPDB *pdb)
|
|||
"gimp-get-default-unit");
|
||||
gimp_procedure_set_static_help (procedure,
|
||||
"Get the default unit (taken from the user's locale).",
|
||||
"Returns the default unit's integer ID.",
|
||||
"Returns the default unit.",
|
||||
NULL);
|
||||
gimp_procedure_set_static_attribution (procedure,
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"Spencer Kimball & Peter Mattis",
|
||||
"1995-1996");
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
gimp_param_spec_unit ("unit-id",
|
||||
"unit id",
|
||||
gimp_param_spec_unit ("unit",
|
||||
"unit",
|
||||
"Default unit",
|
||||
TRUE,
|
||||
FALSE,
|
||||
GIMP_UNIT_PIXEL,
|
||||
FALSE,
|
||||
gimp_unit_inch (),
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
|
|
@ -2484,7 +2484,7 @@ image_get_unit_invoker (GimpProcedure *procedure,
|
|||
gboolean success = TRUE;
|
||||
GimpValueArray *return_vals;
|
||||
GimpImage *image;
|
||||
GimpUnit unit = GIMP_UNIT_PIXEL;
|
||||
GimpUnit *unit = NULL;
|
||||
|
||||
image = g_value_get_object (gimp_value_array_index (args, 0));
|
||||
|
||||
|
@ -2497,7 +2497,7 @@ image_get_unit_invoker (GimpProcedure *procedure,
|
|||
error ? *error : NULL);
|
||||
|
||||
if (success)
|
||||
g_value_set_int (gimp_value_array_index (return_vals, 1), unit);
|
||||
g_value_set_object (gimp_value_array_index (return_vals, 1), unit);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
@ -2512,10 +2512,10 @@ image_set_unit_invoker (GimpProcedure *procedure,
|
|||
{
|
||||
gboolean success = TRUE;
|
||||
GimpImage *image;
|
||||
GimpUnit unit;
|
||||
GimpUnit *unit;
|
||||
|
||||
image = g_value_get_object (gimp_value_array_index (args, 0));
|
||||
unit = g_value_get_int (gimp_value_array_index (args, 1));
|
||||
unit = g_value_get_object (gimp_value_array_index (args, 1));
|
||||
|
||||
if (success)
|
||||
{
|
||||
|
@ -5195,9 +5195,9 @@ register_image_procs (GimpPDB *pdb)
|
|||
gimp_param_spec_unit ("unit",
|
||||
"unit",
|
||||
"The unit",
|
||||
TRUE,
|
||||
FALSE,
|
||||
GIMP_UNIT_PIXEL,
|
||||
FALSE,
|
||||
gimp_unit_inch (),
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
@ -5228,7 +5228,7 @@ register_image_procs (GimpPDB *pdb)
|
|||
"The new image unit",
|
||||
FALSE,
|
||||
FALSE,
|
||||
GIMP_UNIT_INCH,
|
||||
gimp_unit_inch (),
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include "internal-procs.h"
|
||||
|
||||
|
||||
/* 786 procedures registered total */
|
||||
/* 778 procedures registered total */
|
||||
|
||||
void
|
||||
internal_procs_init (GimpPDB *pdb)
|
||||
|
|
|
@ -65,14 +65,14 @@ text_layer_new_invoker (GimpProcedure *procedure,
|
|||
const gchar *text;
|
||||
GimpFont *font;
|
||||
gdouble size;
|
||||
GimpUnit unit;
|
||||
GimpUnit *unit;
|
||||
GimpTextLayer *layer = NULL;
|
||||
|
||||
image = g_value_get_object (gimp_value_array_index (args, 0));
|
||||
text = g_value_get_string (gimp_value_array_index (args, 1));
|
||||
font = g_value_get_object (gimp_value_array_index (args, 2));
|
||||
size = g_value_get_double (gimp_value_array_index (args, 3));
|
||||
unit = g_value_get_int (gimp_value_array_index (args, 4));
|
||||
unit = g_value_get_object (gimp_value_array_index (args, 4));
|
||||
|
||||
if (success)
|
||||
{
|
||||
|
@ -318,7 +318,7 @@ text_layer_get_font_size_invoker (GimpProcedure *procedure,
|
|||
GimpValueArray *return_vals;
|
||||
GimpTextLayer *layer;
|
||||
gdouble font_size = 0.0;
|
||||
GimpUnit unit = GIMP_UNIT_PIXEL;
|
||||
GimpUnit *unit = NULL;
|
||||
|
||||
layer = g_value_get_object (gimp_value_array_index (args, 0));
|
||||
|
||||
|
@ -336,7 +336,7 @@ text_layer_get_font_size_invoker (GimpProcedure *procedure,
|
|||
if (success)
|
||||
{
|
||||
g_value_set_double (gimp_value_array_index (return_vals, 1), font_size);
|
||||
g_value_set_int (gimp_value_array_index (return_vals, 2), unit);
|
||||
g_value_set_object (gimp_value_array_index (return_vals, 2), unit);
|
||||
}
|
||||
|
||||
return return_vals;
|
||||
|
@ -353,11 +353,11 @@ text_layer_set_font_size_invoker (GimpProcedure *procedure,
|
|||
gboolean success = TRUE;
|
||||
GimpTextLayer *layer;
|
||||
gdouble font_size;
|
||||
GimpUnit unit;
|
||||
GimpUnit *unit;
|
||||
|
||||
layer = g_value_get_object (gimp_value_array_index (args, 0));
|
||||
font_size = g_value_get_double (gimp_value_array_index (args, 1));
|
||||
unit = g_value_get_int (gimp_value_array_index (args, 2));
|
||||
unit = g_value_get_object (gimp_value_array_index (args, 2));
|
||||
|
||||
if (success)
|
||||
{
|
||||
|
@ -1039,9 +1039,9 @@ register_text_layer_procs (GimpPDB *pdb)
|
|||
gimp_param_spec_unit ("unit",
|
||||
"unit",
|
||||
"The units of specified size",
|
||||
TRUE,
|
||||
FALSE,
|
||||
GIMP_UNIT_PIXEL,
|
||||
FALSE,
|
||||
gimp_unit_inch (),
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
gimp_param_spec_text_layer ("layer",
|
||||
|
@ -1261,9 +1261,9 @@ register_text_layer_procs (GimpPDB *pdb)
|
|||
gimp_param_spec_unit ("unit",
|
||||
"unit",
|
||||
"The unit used for the font size",
|
||||
TRUE,
|
||||
FALSE,
|
||||
GIMP_UNIT_PIXEL,
|
||||
FALSE,
|
||||
gimp_unit_inch (),
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
@ -1298,9 +1298,9 @@ register_text_layer_procs (GimpPDB *pdb)
|
|||
gimp_param_spec_unit ("unit",
|
||||
"unit",
|
||||
"The unit to use for the font size",
|
||||
TRUE,
|
||||
FALSE,
|
||||
GIMP_UNIT_PIXEL,
|
||||
FALSE,
|
||||
gimp_unit_inch (),
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
|
|
@ -31,6 +31,7 @@
|
|||
|
||||
#include "pdb-types.h"
|
||||
|
||||
#include "core/gimp.h"
|
||||
#include "core/gimpparamspecs.h"
|
||||
#include "core/gimpunit.h"
|
||||
|
||||
|
@ -39,44 +40,6 @@
|
|||
#include "internal-procs.h"
|
||||
|
||||
|
||||
static GimpValueArray *
|
||||
unit_get_number_of_units_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
const GimpValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
GimpValueArray *return_vals;
|
||||
gint num_units = 0;
|
||||
|
||||
num_units = _gimp_unit_get_number_of_units (gimp);
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
|
||||
g_value_set_int (gimp_value_array_index (return_vals, 1), num_units);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static GimpValueArray *
|
||||
unit_get_number_of_built_in_units_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
const GimpValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
GimpValueArray *return_vals;
|
||||
gint num_units = 0;
|
||||
|
||||
num_units = _gimp_unit_get_number_of_built_in_units (gimp);
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, TRUE, NULL);
|
||||
g_value_set_int (gimp_value_array_index (return_vals, 1), num_units);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static GimpValueArray *
|
||||
unit_new_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
|
@ -94,7 +57,7 @@ unit_new_invoker (GimpProcedure *procedure,
|
|||
const gchar *abbreviation;
|
||||
const gchar *singular;
|
||||
const gchar *plural;
|
||||
GimpUnit unit_id = GIMP_UNIT_PIXEL;
|
||||
GimpUnit *unit = NULL;
|
||||
|
||||
identifier = g_value_get_string (gimp_value_array_index (args, 0));
|
||||
factor = g_value_get_double (gimp_value_array_index (args, 1));
|
||||
|
@ -106,15 +69,72 @@ unit_new_invoker (GimpProcedure *procedure,
|
|||
|
||||
if (success)
|
||||
{
|
||||
unit_id = _gimp_unit_new (gimp, identifier, factor, digits,
|
||||
symbol, abbreviation, singular, plural);
|
||||
unit = _gimp_unit_new (gimp, identifier, factor, digits,
|
||||
symbol, abbreviation, singular, plural);
|
||||
}
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
|
||||
if (success)
|
||||
g_value_set_int (gimp_value_array_index (return_vals, 1), unit_id);
|
||||
g_value_set_object (gimp_value_array_index (return_vals, 1), unit);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static GimpValueArray *
|
||||
unit_get_data_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
const GimpValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GimpValueArray *return_vals;
|
||||
gint unit_id;
|
||||
gchar *identifier = NULL;
|
||||
gdouble factor = 0.0;
|
||||
gint digits = 0;
|
||||
gchar *symbol = NULL;
|
||||
gchar *abbreviation = NULL;
|
||||
gchar *singular = NULL;
|
||||
gchar *plural = NULL;
|
||||
|
||||
unit_id = g_value_get_int (gimp_value_array_index (args, 0));
|
||||
|
||||
if (success)
|
||||
{
|
||||
if (unit_id >= 0)
|
||||
{
|
||||
GimpUnit *unit = gimp_unit_get_by_id (unit_id);
|
||||
|
||||
if (unit != NULL)
|
||||
{
|
||||
identifier = g_strdup (gimp_unit_get_identifier (unit));
|
||||
factor = gimp_unit_get_factor (unit);
|
||||
digits = gimp_unit_get_digits (unit);
|
||||
symbol = g_strdup (gimp_unit_get_symbol (unit));
|
||||
abbreviation = g_strdup (gimp_unit_get_abbreviation (unit));
|
||||
singular = g_strdup (gimp_unit_get_singular (unit));
|
||||
plural = g_strdup (gimp_unit_get_plural (unit));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
|
||||
if (success)
|
||||
{
|
||||
g_value_take_string (gimp_value_array_index (return_vals, 1), identifier);
|
||||
g_value_set_double (gimp_value_array_index (return_vals, 2), factor);
|
||||
g_value_set_int (gimp_value_array_index (return_vals, 3), digits);
|
||||
g_value_take_string (gimp_value_array_index (return_vals, 4), symbol);
|
||||
g_value_take_string (gimp_value_array_index (return_vals, 5), abbreviation);
|
||||
g_value_take_string (gimp_value_array_index (return_vals, 6), singular);
|
||||
g_value_take_string (gimp_value_array_index (return_vals, 7), plural);
|
||||
}
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
@ -129,14 +149,14 @@ unit_get_deletion_flag_invoker (GimpProcedure *procedure,
|
|||
{
|
||||
gboolean success = TRUE;
|
||||
GimpValueArray *return_vals;
|
||||
GimpUnit unit_id;
|
||||
GimpUnit *unit;
|
||||
gboolean deletion_flag = FALSE;
|
||||
|
||||
unit_id = g_value_get_int (gimp_value_array_index (args, 0));
|
||||
unit = g_value_get_object (gimp_value_array_index (args, 0));
|
||||
|
||||
if (success)
|
||||
{
|
||||
deletion_flag = _gimp_unit_get_deletion_flag (gimp, unit_id);
|
||||
deletion_flag = gimp_unit_get_deletion_flag (unit);
|
||||
}
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||
|
@ -157,275 +177,26 @@ unit_set_deletion_flag_invoker (GimpProcedure *procedure,
|
|||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GimpUnit unit_id;
|
||||
GimpUnit *unit;
|
||||
gboolean deletion_flag;
|
||||
|
||||
unit_id = g_value_get_int (gimp_value_array_index (args, 0));
|
||||
unit = g_value_get_object (gimp_value_array_index (args, 0));
|
||||
deletion_flag = g_value_get_boolean (gimp_value_array_index (args, 1));
|
||||
|
||||
if (success)
|
||||
{
|
||||
_gimp_unit_set_deletion_flag (gimp, unit_id, deletion_flag);
|
||||
gimp_unit_set_deletion_flag (unit, deletion_flag);
|
||||
}
|
||||
|
||||
return gimp_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
}
|
||||
|
||||
static GimpValueArray *
|
||||
unit_get_identifier_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
const GimpValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GimpValueArray *return_vals;
|
||||
GimpUnit unit_id;
|
||||
gchar *identifier = NULL;
|
||||
|
||||
unit_id = g_value_get_int (gimp_value_array_index (args, 0));
|
||||
|
||||
if (success)
|
||||
{
|
||||
identifier = g_strdup (_gimp_unit_get_identifier (gimp, unit_id));
|
||||
}
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
|
||||
if (success)
|
||||
g_value_take_string (gimp_value_array_index (return_vals, 1), identifier);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static GimpValueArray *
|
||||
unit_get_factor_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
const GimpValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GimpValueArray *return_vals;
|
||||
GimpUnit unit_id;
|
||||
gdouble factor = 0.0;
|
||||
|
||||
unit_id = g_value_get_int (gimp_value_array_index (args, 0));
|
||||
|
||||
if (success)
|
||||
{
|
||||
factor = _gimp_unit_get_factor (gimp, unit_id);
|
||||
}
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
|
||||
if (success)
|
||||
g_value_set_double (gimp_value_array_index (return_vals, 1), factor);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static GimpValueArray *
|
||||
unit_get_digits_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
const GimpValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GimpValueArray *return_vals;
|
||||
GimpUnit unit_id;
|
||||
gint digits = 0;
|
||||
|
||||
unit_id = g_value_get_int (gimp_value_array_index (args, 0));
|
||||
|
||||
if (success)
|
||||
{
|
||||
digits = _gimp_unit_get_digits (gimp, unit_id);
|
||||
}
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
|
||||
if (success)
|
||||
g_value_set_int (gimp_value_array_index (return_vals, 1), digits);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static GimpValueArray *
|
||||
unit_get_symbol_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
const GimpValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GimpValueArray *return_vals;
|
||||
GimpUnit unit_id;
|
||||
gchar *symbol = NULL;
|
||||
|
||||
unit_id = g_value_get_int (gimp_value_array_index (args, 0));
|
||||
|
||||
if (success)
|
||||
{
|
||||
symbol = g_strdup (_gimp_unit_get_symbol (gimp, unit_id));
|
||||
}
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
|
||||
if (success)
|
||||
g_value_take_string (gimp_value_array_index (return_vals, 1), symbol);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static GimpValueArray *
|
||||
unit_get_abbreviation_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
const GimpValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GimpValueArray *return_vals;
|
||||
GimpUnit unit_id;
|
||||
gchar *abbreviation = NULL;
|
||||
|
||||
unit_id = g_value_get_int (gimp_value_array_index (args, 0));
|
||||
|
||||
if (success)
|
||||
{
|
||||
abbreviation = g_strdup (_gimp_unit_get_abbreviation (gimp, unit_id));
|
||||
}
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
|
||||
if (success)
|
||||
g_value_take_string (gimp_value_array_index (return_vals, 1), abbreviation);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static GimpValueArray *
|
||||
unit_get_singular_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
const GimpValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GimpValueArray *return_vals;
|
||||
GimpUnit unit_id;
|
||||
gchar *singular = NULL;
|
||||
|
||||
unit_id = g_value_get_int (gimp_value_array_index (args, 0));
|
||||
|
||||
if (success)
|
||||
{
|
||||
singular = g_strdup (_gimp_unit_get_singular (gimp, unit_id));
|
||||
}
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
|
||||
if (success)
|
||||
g_value_take_string (gimp_value_array_index (return_vals, 1), singular);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
static GimpValueArray *
|
||||
unit_get_plural_invoker (GimpProcedure *procedure,
|
||||
Gimp *gimp,
|
||||
GimpContext *context,
|
||||
GimpProgress *progress,
|
||||
const GimpValueArray *args,
|
||||
GError **error)
|
||||
{
|
||||
gboolean success = TRUE;
|
||||
GimpValueArray *return_vals;
|
||||
GimpUnit unit_id;
|
||||
gchar *plural = NULL;
|
||||
|
||||
unit_id = g_value_get_int (gimp_value_array_index (args, 0));
|
||||
|
||||
if (success)
|
||||
{
|
||||
plural = g_strdup (_gimp_unit_get_plural (gimp, unit_id));
|
||||
}
|
||||
|
||||
return_vals = gimp_procedure_get_return_values (procedure, success,
|
||||
error ? *error : NULL);
|
||||
|
||||
if (success)
|
||||
g_value_take_string (gimp_value_array_index (return_vals, 1), plural);
|
||||
|
||||
return return_vals;
|
||||
}
|
||||
|
||||
void
|
||||
register_unit_procs (GimpPDB *pdb)
|
||||
{
|
||||
GimpProcedure *procedure;
|
||||
|
||||
/*
|
||||
* gimp-unit-get-number-of-units
|
||||
*/
|
||||
procedure = gimp_procedure_new (unit_get_number_of_units_invoker);
|
||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||
"gimp-unit-get-number-of-units");
|
||||
gimp_procedure_set_static_help (procedure,
|
||||
"Returns the number of units.",
|
||||
"This procedure returns the number of defined units.",
|
||||
NULL);
|
||||
gimp_procedure_set_static_attribution (procedure,
|
||||
"Michael Natterer <mitch@gimp.org>",
|
||||
"Michael Natterer",
|
||||
"1999");
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
g_param_spec_int ("num-units",
|
||||
"num units",
|
||||
"The number of units",
|
||||
G_MININT32, G_MAXINT32, 0,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-unit-get-number-of-built-in-units
|
||||
*/
|
||||
procedure = gimp_procedure_new (unit_get_number_of_built_in_units_invoker);
|
||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||
"gimp-unit-get-number-of-built-in-units");
|
||||
gimp_procedure_set_static_help (procedure,
|
||||
"Returns the number of built-in units.",
|
||||
"This procedure returns the number of defined units built-in to GIMP.",
|
||||
NULL);
|
||||
gimp_procedure_set_static_attribution (procedure,
|
||||
"Michael Natterer <mitch@gimp.org>",
|
||||
"Michael Natterer",
|
||||
"1999");
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
g_param_spec_int ("num-units",
|
||||
"num units",
|
||||
"The number of built-in units",
|
||||
G_MININT32, G_MAXINT32, 0,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-unit-new
|
||||
*/
|
||||
|
@ -433,8 +204,8 @@ register_unit_procs (GimpPDB *pdb)
|
|||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||
"gimp-unit-new");
|
||||
gimp_procedure_set_static_help (procedure,
|
||||
"Creates a new unit and returns it's integer ID.",
|
||||
"This procedure creates a new unit and returns it's integer ID. Note that the new unit will have it's deletion flag set to TRUE, so you will have to set it to FALSE with 'gimp-unit-set-deletion-flag' to make it persistent.",
|
||||
"Creates a new unit.",
|
||||
"This procedure creates a new unit and returns it. Note that the new unit will have it's deletion flag set to TRUE, so you will have to set it to FALSE with 'gimp-unit-set-deletion-flag' to make it persistent.",
|
||||
NULL);
|
||||
gimp_procedure_set_static_attribution (procedure,
|
||||
"Michael Natterer <mitch@gimp.org>",
|
||||
|
@ -488,16 +259,86 @@ register_unit_procs (GimpPDB *pdb)
|
|||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
gimp_param_spec_unit ("unit-id",
|
||||
"unit id",
|
||||
"The new unit's ID",
|
||||
TRUE,
|
||||
gimp_param_spec_unit ("unit",
|
||||
"unit",
|
||||
"The new unit",
|
||||
FALSE,
|
||||
GIMP_UNIT_PIXEL,
|
||||
FALSE,
|
||||
gimp_unit_inch (),
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-unit-get-data
|
||||
*/
|
||||
procedure = gimp_procedure_new (unit_get_data_invoker);
|
||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||
"gimp-unit-get-data");
|
||||
gimp_procedure_set_static_help (procedure,
|
||||
"Returns the various data pertaining to a given unit ID.",
|
||||
"This procedure returns all properties making up an unit. It is only meant for internal usage to query non built-in units and it is a programming error to use it directly, in particular for any of the built-in units.",
|
||||
NULL);
|
||||
gimp_procedure_set_static_attribution (procedure,
|
||||
"Jehan",
|
||||
"Jehan",
|
||||
"2023");
|
||||
gimp_procedure_add_argument (procedure,
|
||||
g_param_spec_int ("unit-id",
|
||||
"unit id",
|
||||
"The unit's integer ID",
|
||||
G_MININT32, G_MAXINT32, 0,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
gimp_param_spec_string ("identifier",
|
||||
"identifier",
|
||||
"The unit's textual identifier",
|
||||
FALSE, FALSE, FALSE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
g_param_spec_double ("factor",
|
||||
"factor",
|
||||
"The unit's factor",
|
||||
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
g_param_spec_int ("digits",
|
||||
"digits",
|
||||
"The unit's number of digits",
|
||||
G_MININT32, G_MAXINT32, 0,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
gimp_param_spec_string ("symbol",
|
||||
"symbol",
|
||||
"The unit's symbol",
|
||||
FALSE, FALSE, FALSE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
gimp_param_spec_string ("abbreviation",
|
||||
"abbreviation",
|
||||
"The unit's abbreviation",
|
||||
FALSE, FALSE, FALSE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
gimp_param_spec_string ("singular",
|
||||
"singular",
|
||||
"The unit's singular form",
|
||||
FALSE, FALSE, FALSE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
gimp_param_spec_string ("plural",
|
||||
"plural",
|
||||
"The unit's plural form",
|
||||
FALSE, FALSE, FALSE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-unit-get-deletion-flag
|
||||
*/
|
||||
|
@ -513,12 +354,12 @@ register_unit_procs (GimpPDB *pdb)
|
|||
"Michael Natterer",
|
||||
"1999");
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_unit ("unit-id",
|
||||
"unit id",
|
||||
"The unit's integer ID",
|
||||
TRUE,
|
||||
gimp_param_spec_unit ("unit",
|
||||
"unit",
|
||||
"The unit",
|
||||
FALSE,
|
||||
GIMP_UNIT_PIXEL,
|
||||
FALSE,
|
||||
gimp_unit_inch (),
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
g_param_spec_boolean ("deletion-flag",
|
||||
|
@ -544,12 +385,12 @@ register_unit_procs (GimpPDB *pdb)
|
|||
"Michael Natterer",
|
||||
"1999");
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_unit ("unit-id",
|
||||
"unit id",
|
||||
"The unit's integer ID",
|
||||
TRUE,
|
||||
gimp_param_spec_unit ("unit",
|
||||
"unit",
|
||||
"The unit",
|
||||
FALSE,
|
||||
GIMP_UNIT_PIXEL,
|
||||
FALSE,
|
||||
gimp_unit_inch (),
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_argument (procedure,
|
||||
g_param_spec_boolean ("deletion-flag",
|
||||
|
@ -559,226 +400,4 @@ register_unit_procs (GimpPDB *pdb)
|
|||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-unit-get-identifier
|
||||
*/
|
||||
procedure = gimp_procedure_new (unit_get_identifier_invoker);
|
||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||
"gimp-unit-get-identifier");
|
||||
gimp_procedure_set_static_help (procedure,
|
||||
"Returns the textual identifier of the unit.",
|
||||
"This procedure returns the textual identifier of the unit. For built-in units it will be the english singular form of the unit's name. For user-defined units this should equal to the singular form.",
|
||||
NULL);
|
||||
gimp_procedure_set_static_attribution (procedure,
|
||||
"Michael Natterer <mitch@gimp.org>",
|
||||
"Michael Natterer",
|
||||
"1999");
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_unit ("unit-id",
|
||||
"unit id",
|
||||
"The unit's integer ID",
|
||||
TRUE,
|
||||
FALSE,
|
||||
GIMP_UNIT_PIXEL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
gimp_param_spec_string ("identifier",
|
||||
"identifier",
|
||||
"The unit's textual identifier",
|
||||
FALSE, FALSE, FALSE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-unit-get-factor
|
||||
*/
|
||||
procedure = gimp_procedure_new (unit_get_factor_invoker);
|
||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||
"gimp-unit-get-factor");
|
||||
gimp_procedure_set_static_help (procedure,
|
||||
"Returns the factor of the unit.",
|
||||
"This procedure returns the unit's factor which indicates how many units make up an inch. Note that asking for the factor of \"pixels\" will produce an error.",
|
||||
NULL);
|
||||
gimp_procedure_set_static_attribution (procedure,
|
||||
"Michael Natterer <mitch@gimp.org>",
|
||||
"Michael Natterer",
|
||||
"1999");
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_unit ("unit-id",
|
||||
"unit id",
|
||||
"The unit's integer ID",
|
||||
TRUE,
|
||||
FALSE,
|
||||
GIMP_UNIT_PIXEL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
g_param_spec_double ("factor",
|
||||
"factor",
|
||||
"The unit's factor",
|
||||
-G_MAXDOUBLE, G_MAXDOUBLE, 0,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-unit-get-digits
|
||||
*/
|
||||
procedure = gimp_procedure_new (unit_get_digits_invoker);
|
||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||
"gimp-unit-get-digits");
|
||||
gimp_procedure_set_static_help (procedure,
|
||||
"Returns the number of digits of the unit.",
|
||||
"This procedure returns the number of digits you should provide in input or output functions to get approximately the same accuracy as with two digits and inches. Note that asking for the digits of \"pixels\" will produce an error.",
|
||||
NULL);
|
||||
gimp_procedure_set_static_attribution (procedure,
|
||||
"Michael Natterer <mitch@gimp.org>",
|
||||
"Michael Natterer",
|
||||
"1999");
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_unit ("unit-id",
|
||||
"unit id",
|
||||
"The unit's integer ID",
|
||||
TRUE,
|
||||
FALSE,
|
||||
GIMP_UNIT_PIXEL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
g_param_spec_int ("digits",
|
||||
"digits",
|
||||
"The unit's number of digits",
|
||||
G_MININT32, G_MAXINT32, 0,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-unit-get-symbol
|
||||
*/
|
||||
procedure = gimp_procedure_new (unit_get_symbol_invoker);
|
||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||
"gimp-unit-get-symbol");
|
||||
gimp_procedure_set_static_help (procedure,
|
||||
"Returns the symbol of the unit.",
|
||||
"This procedure returns the symbol of the unit (\"''\" for inches).",
|
||||
NULL);
|
||||
gimp_procedure_set_static_attribution (procedure,
|
||||
"Michael Natterer <mitch@gimp.org>",
|
||||
"Michael Natterer",
|
||||
"1999");
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_unit ("unit-id",
|
||||
"unit id",
|
||||
"The unit's integer ID",
|
||||
TRUE,
|
||||
FALSE,
|
||||
GIMP_UNIT_PIXEL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
gimp_param_spec_string ("symbol",
|
||||
"symbol",
|
||||
"The unit's symbol",
|
||||
FALSE, FALSE, FALSE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-unit-get-abbreviation
|
||||
*/
|
||||
procedure = gimp_procedure_new (unit_get_abbreviation_invoker);
|
||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||
"gimp-unit-get-abbreviation");
|
||||
gimp_procedure_set_static_help (procedure,
|
||||
"Returns the abbreviation of the unit.",
|
||||
"This procedure returns the abbreviation of the unit (\"in\" for inches).",
|
||||
NULL);
|
||||
gimp_procedure_set_static_attribution (procedure,
|
||||
"Michael Natterer <mitch@gimp.org>",
|
||||
"Michael Natterer",
|
||||
"1999");
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_unit ("unit-id",
|
||||
"unit id",
|
||||
"The unit's integer ID",
|
||||
TRUE,
|
||||
FALSE,
|
||||
GIMP_UNIT_PIXEL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
gimp_param_spec_string ("abbreviation",
|
||||
"abbreviation",
|
||||
"The unit's abbreviation",
|
||||
FALSE, FALSE, FALSE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-unit-get-singular
|
||||
*/
|
||||
procedure = gimp_procedure_new (unit_get_singular_invoker);
|
||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||
"gimp-unit-get-singular");
|
||||
gimp_procedure_set_static_help (procedure,
|
||||
"Returns the singular form of the unit.",
|
||||
"This procedure returns the singular form of the unit.",
|
||||
NULL);
|
||||
gimp_procedure_set_static_attribution (procedure,
|
||||
"Michael Natterer <mitch@gimp.org>",
|
||||
"Michael Natterer",
|
||||
"1999");
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_unit ("unit-id",
|
||||
"unit id",
|
||||
"The unit's integer ID",
|
||||
TRUE,
|
||||
FALSE,
|
||||
GIMP_UNIT_PIXEL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
gimp_param_spec_string ("singular",
|
||||
"singular",
|
||||
"The unit's singular form",
|
||||
FALSE, FALSE, FALSE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
|
||||
/*
|
||||
* gimp-unit-get-plural
|
||||
*/
|
||||
procedure = gimp_procedure_new (unit_get_plural_invoker);
|
||||
gimp_object_set_static_name (GIMP_OBJECT (procedure),
|
||||
"gimp-unit-get-plural");
|
||||
gimp_procedure_set_static_help (procedure,
|
||||
"Returns the plural form of the unit.",
|
||||
"This procedure returns the plural form of the unit.",
|
||||
NULL);
|
||||
gimp_procedure_set_static_attribution (procedure,
|
||||
"Michael Natterer <mitch@gimp.org>",
|
||||
"Michael Natterer",
|
||||
"1999");
|
||||
gimp_procedure_add_argument (procedure,
|
||||
gimp_param_spec_unit ("unit-id",
|
||||
"unit id",
|
||||
"The unit's integer ID",
|
||||
TRUE,
|
||||
FALSE,
|
||||
GIMP_UNIT_PIXEL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_procedure_add_return_value (procedure,
|
||||
gimp_param_spec_string ("plural",
|
||||
"plural",
|
||||
"The unit's plural form",
|
||||
FALSE, FALSE, FALSE,
|
||||
NULL,
|
||||
GIMP_PARAM_READWRITE));
|
||||
gimp_pdb_register_procedure (pdb, procedure);
|
||||
g_object_unref (procedure);
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@
|
|||
#include "core/gimppalette.h"
|
||||
#include "core/gimppattern.h"
|
||||
#include "core/gimpselection.h"
|
||||
#include "core/gimpunit.h"
|
||||
|
||||
#include "text/gimpfont.h"
|
||||
#include "text/gimptextlayer.h"
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
#include <gegl.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
|
||||
#include "display/display-types.h"
|
||||
|
||||
#include "display/gimpdisplay.h"
|
||||
|
@ -196,7 +198,7 @@ gimp_test_utils_create_image (Gimp *gimp,
|
|||
|
||||
gimp_create_display (gimp,
|
||||
image,
|
||||
GIMP_UNIT_PIXEL,
|
||||
gimp_unit_pixel (),
|
||||
1.0 /*scale*/,
|
||||
NULL);
|
||||
}
|
||||
|
|
|
@ -126,7 +126,7 @@
|
|||
"manually and may thus look weird if "\
|
||||
"opened and inspected in GIMP."
|
||||
|
||||
#define GIMP_MAINIMAGE_UNIT GIMP_UNIT_PICA
|
||||
#define GIMP_MAINIMAGE_UNIT gimp_unit_pica ()
|
||||
|
||||
#define GIMP_MAINIMAGE_GRIDXSPACING 25.0
|
||||
#define GIMP_MAINIMAGE_GRIDYSPACING 27.0
|
||||
|
@ -903,9 +903,7 @@ gimp_assert_mainimage (GimpImage *image,
|
|||
g_free (parasite_data);
|
||||
|
||||
/* Unit */
|
||||
g_assert_cmpint (gimp_image_get_unit (image),
|
||||
==,
|
||||
GIMP_MAINIMAGE_UNIT);
|
||||
g_assert_true (gimp_image_get_unit (image) == GIMP_MAINIMAGE_UNIT);
|
||||
|
||||
/* Grid */
|
||||
grid = gimp_image_get_grid (image);
|
||||
|
|
|
@ -144,9 +144,9 @@ gimp_text_font_name_from_xlfd (const gchar *xlfd)
|
|||
* Returns: %TRUE on success, %FALSE otherwise.
|
||||
**/
|
||||
gboolean
|
||||
gimp_text_font_size_from_xlfd (const gchar *xlfd,
|
||||
gdouble *size,
|
||||
GimpUnit *size_unit)
|
||||
gimp_text_font_size_from_xlfd (const gchar *xlfd,
|
||||
gdouble *size,
|
||||
GimpUnit **size_unit)
|
||||
{
|
||||
gchar buffer[XLFD_MAX_FIELD_LEN];
|
||||
gchar *field;
|
||||
|
@ -158,7 +158,7 @@ gimp_text_font_size_from_xlfd (const gchar *xlfd,
|
|||
if (field)
|
||||
{
|
||||
*size = atoi (field);
|
||||
*size_unit = GIMP_UNIT_PIXEL;
|
||||
*size_unit = gimp_unit_pixel ();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ gimp_text_font_size_from_xlfd (const gchar *xlfd,
|
|||
if (field)
|
||||
{
|
||||
*size = atoi (field) / 10.0;
|
||||
*size_unit = GIMP_UNIT_POINT;
|
||||
*size_unit = gimp_unit_point ();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -185,10 +185,10 @@ void
|
|||
gimp_text_set_font_from_xlfd (GimpText *text,
|
||||
const gchar *xlfd)
|
||||
{
|
||||
gchar *font_name;
|
||||
GimpFont *font = NULL;
|
||||
gdouble size;
|
||||
GimpUnit size_unit;
|
||||
gchar *font_name;
|
||||
GimpFont *font = NULL;
|
||||
gdouble size;
|
||||
GimpUnit *size_unit;
|
||||
|
||||
g_return_if_fail (GIMP_IS_TEXT (text));
|
||||
|
||||
|
|
|
@ -24,13 +24,13 @@
|
|||
|
||||
/* handle X Logical Font Descriptions for compat */
|
||||
|
||||
gchar * gimp_text_font_name_from_xlfd (const gchar *xlfd);
|
||||
gboolean gimp_text_font_size_from_xlfd (const gchar *xlfd,
|
||||
gdouble *size,
|
||||
GimpUnit *size_unit);
|
||||
gchar * gimp_text_font_name_from_xlfd (const gchar *xlfd);
|
||||
gboolean gimp_text_font_size_from_xlfd (const gchar *xlfd,
|
||||
gdouble *size,
|
||||
GimpUnit **size_unit);
|
||||
|
||||
void gimp_text_set_font_from_xlfd (GimpText *text,
|
||||
const gchar *xlfd);
|
||||
void gimp_text_set_font_from_xlfd (GimpText *text,
|
||||
const gchar *xlfd);
|
||||
|
||||
|
||||
#endif /* __GIMP_TEXT_COMPAT_H__ */
|
||||
|
|
|
@ -192,7 +192,7 @@ gimp_text_class_init (GimpTextClass *klass)
|
|||
GIMP_CONFIG_PROP_UNIT (object_class, PROP_UNIT,
|
||||
"font-size-unit",
|
||||
NULL, NULL,
|
||||
TRUE, FALSE, GIMP_UNIT_PIXEL,
|
||||
TRUE, FALSE, gimp_unit_pixel (),
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_ANTIALIAS,
|
||||
|
@ -299,7 +299,7 @@ gimp_text_class_init (GimpTextClass *klass)
|
|||
GIMP_CONFIG_PROP_UNIT (object_class, PROP_BOX_UNIT,
|
||||
"box-unit",
|
||||
NULL, NULL,
|
||||
TRUE, FALSE, GIMP_UNIT_PIXEL,
|
||||
TRUE, FALSE, gimp_unit_pixel (),
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
|
||||
GIMP_CONFIG_PROP_MATRIX2 (object_class, PROP_TRANSFORMATION,
|
||||
|
@ -448,7 +448,7 @@ gimp_text_get_property (GObject *object,
|
|||
g_value_set_double (value, text->font_size);
|
||||
break;
|
||||
case PROP_UNIT:
|
||||
g_value_set_int (value, text->unit);
|
||||
g_value_set_object (value, text->unit);
|
||||
break;
|
||||
case PROP_ANTIALIAS:
|
||||
g_value_set_boolean (value, text->antialias);
|
||||
|
@ -493,7 +493,7 @@ gimp_text_get_property (GObject *object,
|
|||
g_value_set_double (value, text->box_height);
|
||||
break;
|
||||
case PROP_BOX_UNIT:
|
||||
g_value_set_int (value, text->box_unit);
|
||||
g_value_set_object (value, text->box_unit);
|
||||
break;
|
||||
case PROP_TRANSFORMATION:
|
||||
g_value_set_boxed (value, &text->transformation);
|
||||
|
@ -593,7 +593,7 @@ gimp_text_set_property (GObject *object,
|
|||
text->font_size = g_value_get_double (value);
|
||||
break;
|
||||
case PROP_UNIT:
|
||||
text->unit = g_value_get_int (value);
|
||||
text->unit = g_value_get_object (value);
|
||||
break;
|
||||
case PROP_ANTIALIAS:
|
||||
text->antialias = g_value_get_boolean (value);
|
||||
|
@ -639,7 +639,7 @@ gimp_text_set_property (GObject *object,
|
|||
text->box_height = g_value_get_double (value);
|
||||
break;
|
||||
case PROP_BOX_UNIT:
|
||||
text->box_unit = g_value_get_int (value);
|
||||
text->box_unit = g_value_get_object (value);
|
||||
break;
|
||||
case PROP_TRANSFORMATION:
|
||||
matrix = g_value_get_boxed (value);
|
||||
|
|
|
@ -42,7 +42,7 @@ struct _GimpText
|
|||
gchar *text;
|
||||
gchar *markup;
|
||||
GimpFont *font;
|
||||
GimpUnit unit;
|
||||
GimpUnit *unit;
|
||||
gdouble font_size;
|
||||
gboolean antialias;
|
||||
GimpTextHintStyle hint_style;
|
||||
|
@ -68,7 +68,7 @@ struct _GimpText
|
|||
GimpTextBoxMode box_mode;
|
||||
gdouble box_width;
|
||||
gdouble box_height;
|
||||
GimpUnit box_unit;
|
||||
GimpUnit *box_unit;
|
||||
GimpMatrix2 transformation;
|
||||
gdouble offset_x;
|
||||
gdouble offset_y;
|
||||
|
|
|
@ -638,7 +638,7 @@ gimp_edit_selection_tool_draw (GimpDrawTool *draw_tool)
|
|||
GimpDisplay *display = GIMP_TOOL (draw_tool)->display;
|
||||
GimpImage *image = gimp_display_get_image (display);
|
||||
GimpDisplayShell *shell = gimp_display_get_shell (display);
|
||||
GimpUnit unit = gimp_display_shell_get_unit (shell);
|
||||
GimpUnit *unit = gimp_display_shell_get_unit (shell);
|
||||
const gchar *abbreviation = gimp_unit_get_abbreviation (unit);
|
||||
GList *selected_items;
|
||||
GList *iter;
|
||||
|
|
|
@ -1304,7 +1304,7 @@ gimp_gradient_tool_editor_init_endpoint_gui (GimpGradientTool *gradient_tool)
|
|||
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 6);
|
||||
|
||||
gradient_tool->endpoint_se =
|
||||
se = gimp_size_entry_new (1, GIMP_UNIT_PIXEL, "%a",
|
||||
se = gimp_size_entry_new (1, gimp_unit_pixel (), "%a",
|
||||
TRUE, TRUE, FALSE, 6,
|
||||
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
||||
gtk_grid_set_row_spacing (GTK_GRID (se), 4);
|
||||
|
@ -1391,7 +1391,7 @@ gimp_gradient_tool_editor_init_stop_gui (GimpGradientTool *gradient_tool)
|
|||
|
||||
/* the position size entry */
|
||||
gradient_tool->stop_se =
|
||||
se = gimp_size_entry_new (1, GIMP_UNIT_PERCENT, "%a",
|
||||
se = gimp_size_entry_new (1, gimp_unit_percent (), "%a",
|
||||
FALSE, TRUE, FALSE, 6,
|
||||
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
||||
gimp_size_entry_show_unit_menu (GIMP_SIZE_ENTRY (se), FALSE);
|
||||
|
@ -1490,7 +1490,7 @@ gimp_gradient_tool_editor_init_midpoint_gui (GimpGradientTool *gradient_tool)
|
|||
|
||||
/* the position size entry */
|
||||
gradient_tool->midpoint_se =
|
||||
se = gimp_size_entry_new (1, GIMP_UNIT_PERCENT, "%a",
|
||||
se = gimp_size_entry_new (1, gimp_unit_percent (), "%a",
|
||||
FALSE, TRUE, FALSE, 6,
|
||||
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
||||
gimp_size_entry_show_unit_menu (GIMP_SIZE_ENTRY (se), FALSE);
|
||||
|
|
|
@ -591,7 +591,7 @@ gimp_measure_tool_dialog_update (GimpMeasureTool *measure,
|
|||
pixel_distance = sqrt (SQR (ax - bx) + SQR (ay - by));
|
||||
inch_distance = sqrt (SQR ((gdouble) (ax - bx) / xres) +
|
||||
SQR ((gdouble) (ay - by) / yres));
|
||||
unit_distance = gimp_unit_get_factor (shell->unit) * inch_distance;
|
||||
unit_distance = gimp_unit_get_factor (shell->unit) * inch_distance;
|
||||
|
||||
g_object_get (measure->widget,
|
||||
"pixel-angle", &pixel_angle,
|
||||
|
@ -611,7 +611,7 @@ gimp_measure_tool_dialog_update (GimpMeasureTool *measure,
|
|||
unit_width_digits = gimp_unit_get_scaled_digits (shell->unit, xres);
|
||||
unit_height_digits = gimp_unit_get_scaled_digits (shell->unit, yres);
|
||||
|
||||
if (shell->unit == GIMP_UNIT_PIXEL)
|
||||
if (shell->unit == gimp_unit_pixel ())
|
||||
{
|
||||
gimp_tool_replace_status (GIMP_TOOL (measure), display,
|
||||
"%.1f %s, %.2f\302\260 (%d × %d)",
|
||||
|
@ -640,7 +640,7 @@ gimp_measure_tool_dialog_update (GimpMeasureTool *measure,
|
|||
g_snprintf (buf, sizeof (buf), "%.1f", pixel_distance);
|
||||
gtk_label_set_text (GTK_LABEL (measure->distance_label[0]), buf);
|
||||
|
||||
if (shell->unit != GIMP_UNIT_PIXEL)
|
||||
if (shell->unit != gimp_unit_pixel ())
|
||||
{
|
||||
g_snprintf (format, sizeof (format), "%%.%df",
|
||||
unit_distance_digits);
|
||||
|
@ -677,7 +677,7 @@ gimp_measure_tool_dialog_update (GimpMeasureTool *measure,
|
|||
g_snprintf (buf, sizeof (buf), "%d", pixel_width);
|
||||
gtk_label_set_text (GTK_LABEL (measure->width_label[0]), buf);
|
||||
|
||||
if (shell->unit != GIMP_UNIT_PIXEL)
|
||||
if (shell->unit != gimp_unit_pixel ())
|
||||
{
|
||||
g_snprintf (format, sizeof (format), "%%.%df",
|
||||
unit_width_digits);
|
||||
|
@ -697,7 +697,7 @@ gimp_measure_tool_dialog_update (GimpMeasureTool *measure,
|
|||
gtk_label_set_text (GTK_LABEL (measure->height_label[0]), buf);
|
||||
|
||||
/* Height */
|
||||
if (shell->unit != GIMP_UNIT_PIXEL)
|
||||
if (shell->unit != gimp_unit_pixel ())
|
||||
{
|
||||
g_snprintf (format, sizeof (format), "%%.%df",
|
||||
unit_height_digits);
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <gegl.h>
|
||||
#include <gtk/gtk.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpmath/gimpmath.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
|
@ -484,7 +485,7 @@ gimp_offset_tool_dialog (GimpFilterTool *filter_tool)
|
|||
gtk_spin_button_set_numeric (GTK_SPIN_BUTTON (spinbutton), TRUE);
|
||||
gtk_entry_set_width_chars (GTK_ENTRY (spinbutton), 10);
|
||||
|
||||
offset_tool->offset_se = gimp_size_entry_new (1, GIMP_UNIT_PIXEL, "%a",
|
||||
offset_tool->offset_se = gimp_size_entry_new (1, gimp_unit_pixel (), "%a",
|
||||
TRUE, TRUE, FALSE, 10,
|
||||
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
||||
|
||||
|
@ -502,7 +503,7 @@ gimp_offset_tool_dialog (GimpFilterTool *filter_tool)
|
|||
gtk_widget_show (offset_tool->offset_se);
|
||||
|
||||
gimp_size_entry_set_unit (GIMP_SIZE_ENTRY (offset_tool->offset_se),
|
||||
GIMP_UNIT_PIXEL);
|
||||
gimp_unit_pixel ());
|
||||
|
||||
g_signal_connect (offset_tool->offset_se, "refval-changed",
|
||||
G_CALLBACK (gimp_offset_tool_offset_changed),
|
||||
|
|
|
@ -148,7 +148,7 @@ gimp_rectangle_options_default_init (GimpRectangleOptionsInterface *iface)
|
|||
NULL,
|
||||
_("Unit of top left corner coordinate"),
|
||||
TRUE, TRUE,
|
||||
GIMP_UNIT_PIXEL,
|
||||
gimp_unit_pixel (),
|
||||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
|
||||
|
@ -157,7 +157,7 @@ gimp_rectangle_options_default_init (GimpRectangleOptionsInterface *iface)
|
|||
NULL,
|
||||
_("Unit of selection size"),
|
||||
TRUE, TRUE,
|
||||
GIMP_UNIT_PIXEL,
|
||||
gimp_unit_pixel (),
|
||||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
|
||||
|
@ -287,7 +287,7 @@ gimp_rectangle_options_default_init (GimpRectangleOptionsInterface *iface)
|
|||
NULL,
|
||||
_("Unit of fixed width, height or size"),
|
||||
TRUE, TRUE,
|
||||
GIMP_UNIT_PIXEL,
|
||||
gimp_unit_pixel (),
|
||||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
|
||||
|
@ -483,10 +483,10 @@ gimp_rectangle_options_set_property (GObject *object,
|
|||
private->height = g_value_get_double (value);
|
||||
break;
|
||||
case GIMP_RECTANGLE_OPTIONS_PROP_POSITION_UNIT:
|
||||
private->position_unit = g_value_get_int (value);
|
||||
private->position_unit = g_value_get_object (value);
|
||||
break;
|
||||
case GIMP_RECTANGLE_OPTIONS_PROP_SIZE_UNIT:
|
||||
private->size_unit = g_value_get_int (value);
|
||||
private->size_unit = g_value_get_object (value);
|
||||
break;
|
||||
|
||||
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_RULE_ACTIVE:
|
||||
|
@ -535,7 +535,7 @@ gimp_rectangle_options_set_property (GObject *object,
|
|||
private->use_string_current = g_value_get_boolean (value);
|
||||
break;
|
||||
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_UNIT:
|
||||
private->fixed_unit = g_value_get_int (value);
|
||||
private->fixed_unit = g_value_get_object (value);
|
||||
break;
|
||||
|
||||
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_CENTER:
|
||||
|
@ -590,10 +590,10 @@ gimp_rectangle_options_get_property (GObject *object,
|
|||
g_value_set_double (value, private->height);
|
||||
break;
|
||||
case GIMP_RECTANGLE_OPTIONS_PROP_POSITION_UNIT:
|
||||
g_value_set_int (value, private->position_unit);
|
||||
g_value_set_object (value, private->position_unit);
|
||||
break;
|
||||
case GIMP_RECTANGLE_OPTIONS_PROP_SIZE_UNIT:
|
||||
g_value_set_int (value, private->size_unit);
|
||||
g_value_set_object (value, private->size_unit);
|
||||
break;
|
||||
|
||||
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_RULE_ACTIVE:
|
||||
|
@ -642,7 +642,7 @@ gimp_rectangle_options_get_property (GObject *object,
|
|||
g_value_set_boolean (value, private->use_string_current);
|
||||
break;
|
||||
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_UNIT:
|
||||
g_value_set_int (value, private->fixed_unit);
|
||||
g_value_set_object (value, private->fixed_unit);
|
||||
break;
|
||||
|
||||
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_CENTER:
|
||||
|
@ -763,7 +763,7 @@ gimp_rectangle_options_prop_dimension_frame_new (GObject *config,
|
|||
GtkSizeGroup *label_group,
|
||||
GtkWidget **entry)
|
||||
{
|
||||
GimpUnit unit_value;
|
||||
GimpUnit *unit_value;
|
||||
GtkWidget *frame;
|
||||
GtkWidget *hbox;
|
||||
GtkWidget *label;
|
||||
|
|
|
@ -89,8 +89,8 @@ struct _GimpRectangleOptionsPrivate
|
|||
gdouble width;
|
||||
gdouble height;
|
||||
|
||||
GimpUnit position_unit;
|
||||
GimpUnit size_unit;
|
||||
GimpUnit *position_unit;
|
||||
GimpUnit *size_unit;
|
||||
|
||||
gboolean fixed_rule_active;
|
||||
GimpRectangleFixedRule fixed_rule;
|
||||
|
@ -119,7 +119,7 @@ struct _GimpRectangleOptionsPrivate
|
|||
*/
|
||||
gboolean use_string_current;
|
||||
|
||||
GimpUnit fixed_unit;
|
||||
GimpUnit *fixed_unit;
|
||||
|
||||
/* options gui */
|
||||
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpmath/gimpmath.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
|
@ -302,7 +303,7 @@ gimp_rotate_tool_dialog (GimpTransformGridTool *tg_tool)
|
|||
gimp_grid_attach_aligned (GTK_GRID (grid), 0, 2, _("Center _X:"),
|
||||
0.0, 0.5, button, 1);
|
||||
|
||||
rotate->sizeentry = gimp_size_entry_new (1, GIMP_UNIT_PIXEL, "%a",
|
||||
rotate->sizeentry = gimp_size_entry_new (1, gimp_unit_pixel (), "%a",
|
||||
TRUE, TRUE, FALSE, SB_WIDTH,
|
||||
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
||||
gimp_size_entry_add_field (GIMP_SIZE_ENTRY (rotate->sizeentry),
|
||||
|
|
|
@ -163,7 +163,7 @@ gimp_text_options_class_init (GimpTextOptionsClass *klass)
|
|||
"font-size-unit",
|
||||
_("Unit"),
|
||||
_("Font size unit"),
|
||||
TRUE, FALSE, GIMP_UNIT_PIXEL,
|
||||
TRUE, FALSE, gimp_unit_pixel (),
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
GIMP_CONFIG_PROP_DOUBLE (object_class, PROP_FONT_SIZE,
|
||||
"font-size",
|
||||
|
@ -306,7 +306,7 @@ gimp_text_options_class_init (GimpTextOptionsClass *klass)
|
|||
"outline-unit",
|
||||
_("Unit"),
|
||||
_("Outline width unit"),
|
||||
TRUE, FALSE, GIMP_UNIT_PIXEL,
|
||||
TRUE, FALSE, gimp_unit_pixel (),
|
||||
GIMP_PARAM_STATIC_STRINGS);
|
||||
GIMP_CONFIG_PROP_ENUM (object_class, PROP_OUTLINE_CAP_STYLE,
|
||||
"outline-cap-style",
|
||||
|
@ -397,7 +397,7 @@ gimp_text_options_get_property (GObject *object,
|
|||
g_value_set_double (value, options->font_size);
|
||||
break;
|
||||
case PROP_UNIT:
|
||||
g_value_set_int (value, options->unit);
|
||||
g_value_set_object (value, options->unit);
|
||||
break;
|
||||
case PROP_ANTIALIAS:
|
||||
g_value_set_boolean (value, options->antialias);
|
||||
|
@ -443,7 +443,7 @@ gimp_text_options_get_property (GObject *object,
|
|||
g_value_set_double (value, options->outline_width);
|
||||
break;
|
||||
case PROP_OUTLINE_UNIT:
|
||||
g_value_set_int (value, options->outline_unit);
|
||||
g_value_set_object (value, options->outline_unit);
|
||||
break;
|
||||
case PROP_OUTLINE_CAP_STYLE:
|
||||
g_value_set_enum (value, options->outline_cap_style);
|
||||
|
@ -503,7 +503,7 @@ gimp_text_options_set_property (GObject *object,
|
|||
options->font_size = g_value_get_double (value);
|
||||
break;
|
||||
case PROP_UNIT:
|
||||
options->unit = g_value_get_int (value);
|
||||
options->unit = g_value_get_object (value);
|
||||
break;
|
||||
case PROP_ANTIALIAS:
|
||||
options->antialias = g_value_get_boolean (value);
|
||||
|
@ -560,7 +560,7 @@ gimp_text_options_set_property (GObject *object,
|
|||
options->outline_width = g_value_get_double (value);
|
||||
break;
|
||||
case PROP_OUTLINE_UNIT:
|
||||
options->outline_unit = g_value_get_int (value);
|
||||
options->outline_unit = g_value_get_object (value);
|
||||
break;
|
||||
case PROP_OUTLINE_CAP_STYLE:
|
||||
options->outline_cap_style = g_value_get_enum (value);
|
||||
|
|
|
@ -37,7 +37,7 @@ struct _GimpTextOptions
|
|||
{
|
||||
GimpToolOptions tool_options;
|
||||
|
||||
GimpUnit unit;
|
||||
GimpUnit *unit;
|
||||
gdouble font_size;
|
||||
gboolean antialias;
|
||||
GimpTextHintStyle hint_style;
|
||||
|
@ -54,7 +54,7 @@ struct _GimpTextOptions
|
|||
GeglColor *outline_foreground;
|
||||
GimpPattern *outline_pattern;
|
||||
gdouble outline_width;
|
||||
GimpUnit outline_unit;
|
||||
GimpUnit *outline_unit;
|
||||
GimpCapStyle outline_cap_style;
|
||||
GimpJoinStyle outline_join_style;
|
||||
gdouble outline_miter_limit;
|
||||
|
|
|
@ -1163,7 +1163,7 @@ gimp_text_tool_rectangle_change_complete (GimpToolRectangle *rectangle,
|
|||
if ((x2 - x1) != gimp_item_get_width (item) ||
|
||||
(y2 - y1) != gimp_item_get_height (item))
|
||||
{
|
||||
GimpUnit box_unit = text_tool->proxy->box_unit;
|
||||
GimpUnit *box_unit = text_tool->proxy->box_unit;
|
||||
gdouble xres, yres;
|
||||
gboolean push_undo = TRUE;
|
||||
GimpUndo *undo;
|
||||
|
@ -1681,8 +1681,8 @@ gimp_text_tool_create_layer (GimpTextTool *text_tool,
|
|||
|
||||
if (text_tool->text_box_fixed)
|
||||
{
|
||||
GimpUnit box_unit = text_tool->proxy->box_unit;
|
||||
gdouble xres, yres;
|
||||
GimpUnit *box_unit = text_tool->proxy->box_unit;
|
||||
gdouble xres, yres;
|
||||
|
||||
gimp_image_get_resolution (image, &xres, &yres);
|
||||
|
||||
|
|
|
@ -250,7 +250,7 @@ gimp_transform_3d_tool_dialog (GimpTransformGridTool *tg_tool)
|
|||
gtk_widget_show (vbox2);
|
||||
|
||||
/* vanishing-point size entry */
|
||||
se = gimp_size_entry_new (1, GIMP_UNIT_PIXEL, "%a", TRUE, TRUE, FALSE, 6,
|
||||
se = gimp_size_entry_new (1, gimp_unit_pixel (), "%a", TRUE, TRUE, FALSE, 6,
|
||||
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
||||
gtk_grid_set_row_spacing (GTK_GRID (se), 2);
|
||||
gtk_grid_set_column_spacing (GTK_GRID (se), 2);
|
||||
|
@ -298,7 +298,7 @@ gimp_transform_3d_tool_dialog (GimpTransformGridTool *tg_tool)
|
|||
gtk_widget_show (vbox2);
|
||||
|
||||
/* focal-length size entry */
|
||||
se = gimp_size_entry_new (1, GIMP_UNIT_PIXEL, "%a", TRUE, FALSE, FALSE, 6,
|
||||
se = gimp_size_entry_new (1, gimp_unit_pixel (), "%a", TRUE, FALSE, FALSE, 6,
|
||||
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
||||
gtk_grid_set_row_spacing (GTK_GRID (se), 2);
|
||||
gtk_box_pack_start (GTK_BOX (vbox2), se, FALSE, FALSE, 0);
|
||||
|
@ -348,7 +348,7 @@ gimp_transform_3d_tool_dialog (GimpTransformGridTool *tg_tool)
|
|||
gtk_widget_show (vbox2);
|
||||
|
||||
/* offset size entry */
|
||||
se = gimp_size_entry_new (1, GIMP_UNIT_PIXEL, "%a", TRUE, TRUE, FALSE, 6,
|
||||
se = gimp_size_entry_new (1, gimp_unit_pixel (), "%a", TRUE, TRUE, FALSE, 6,
|
||||
GIMP_SIZE_ENTRY_UPDATE_SIZE);
|
||||
gtk_grid_set_row_spacing (GTK_GRID (se), 2);
|
||||
gtk_grid_set_column_spacing (GTK_GRID (se), 2);
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkkeysyms.h>
|
||||
|
||||
#include "libgimpbase/gimpbase.h"
|
||||
#include "libgimpmath/gimpmath.h"
|
||||
#include "libgimpwidgets/gimpwidgets.h"
|
||||
|
||||
|
@ -1529,7 +1530,7 @@ gimp_warp_tool_animate (GimpWarpTool *wt)
|
|||
gimp_warp_tool_update_stroke (wt, NULL);
|
||||
|
||||
widget = GTK_WIDGET (gimp_display_get_shell (tool->display));
|
||||
gimp_create_display (orig_image->gimp, image, GIMP_UNIT_PIXEL, 1.0,
|
||||
gimp_create_display (orig_image->gimp, image, gimp_unit_pixel (), 1.0,
|
||||
G_OBJECT (gimp_widget_get_monitor (widget)));
|
||||
g_object_unref (image);
|
||||
}
|
||||
|
|
|
@ -173,7 +173,7 @@ static void
|
|||
gimp_path_export_image_size (GimpImage *image,
|
||||
GString *str)
|
||||
{
|
||||
GimpUnit unit;
|
||||
GimpUnit *unit;
|
||||
const gchar *abbrev;
|
||||
gchar wbuf[G_ASCII_DTOSTR_BUF_SIZE];
|
||||
gchar hbuf[G_ASCII_DTOSTR_BUF_SIZE];
|
||||
|
@ -188,14 +188,14 @@ gimp_path_export_image_size (GimpImage *image,
|
|||
|
||||
/* FIXME: should probably use the display unit here */
|
||||
unit = gimp_image_get_unit (image);
|
||||
switch (unit)
|
||||
switch (gimp_unit_get_id (unit))
|
||||
{
|
||||
case GIMP_UNIT_INCH: abbrev = "in"; break;
|
||||
case GIMP_UNIT_MM: abbrev = "mm"; break;
|
||||
case GIMP_UNIT_POINT: abbrev = "pt"; break;
|
||||
case GIMP_UNIT_PICA: abbrev = "pc"; break;
|
||||
default: abbrev = "cm";
|
||||
unit = GIMP_UNIT_MM;
|
||||
unit = gimp_unit_mm ();
|
||||
w /= 10.0;
|
||||
h /= 10.0;
|
||||
break;
|
||||
|
|
|
@ -1063,7 +1063,7 @@ parse_svg_length (const gchar *value,
|
|||
gdouble resolution,
|
||||
gdouble *length)
|
||||
{
|
||||
GimpUnit unit = GIMP_UNIT_PIXEL;
|
||||
GimpUnit *unit = gimp_unit_pixel ();
|
||||
gdouble len;
|
||||
gchar *ptr;
|
||||
|
||||
|
@ -1081,8 +1081,8 @@ parse_svg_length (const gchar *value,
|
|||
switch (ptr[1])
|
||||
{
|
||||
case 'x': break;
|
||||
case 't': unit = GIMP_UNIT_POINT; break;
|
||||
case 'c': unit = GIMP_UNIT_PICA; break;
|
||||
case 't': unit = gimp_unit_point (); break;
|
||||
case 'c': unit = gimp_unit_pica (); break;
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
@ -1091,7 +1091,7 @@ parse_svg_length (const gchar *value,
|
|||
|
||||
case 'c':
|
||||
if (ptr[1] == 'm')
|
||||
len *= 10.0, unit = GIMP_UNIT_MM;
|
||||
len *= 10.0, unit = gimp_unit_mm ();
|
||||
else
|
||||
return FALSE;
|
||||
ptr += 2;
|
||||
|
@ -1099,7 +1099,7 @@ parse_svg_length (const gchar *value,
|
|||
|
||||
case 'm':
|
||||
if (ptr[1] == 'm')
|
||||
unit = GIMP_UNIT_MM;
|
||||
unit = gimp_unit_mm ();
|
||||
else
|
||||
return FALSE;
|
||||
ptr += 2;
|
||||
|
@ -1107,14 +1107,14 @@ parse_svg_length (const gchar *value,
|
|||
|
||||
case 'i':
|
||||
if (ptr[1] == 'n')
|
||||
unit = GIMP_UNIT_INCH;
|
||||
unit = gimp_unit_inch ();
|
||||
else
|
||||
return FALSE;
|
||||
ptr += 2;
|
||||
break;
|
||||
|
||||
case '%':
|
||||
unit = GIMP_UNIT_PERCENT;
|
||||
unit = gimp_unit_percent ();
|
||||
ptr += 1;
|
||||
break;
|
||||
|
||||
|
@ -1128,7 +1128,7 @@ parse_svg_length (const gchar *value,
|
|||
if (*ptr)
|
||||
return FALSE;
|
||||
|
||||
switch (unit)
|
||||
switch (gimp_unit_get_id (unit))
|
||||
{
|
||||
case GIMP_UNIT_PERCENT:
|
||||
*length = len * reference / 100.0;
|
||||
|
|
|
@ -424,7 +424,7 @@ gimp_image_prop_view_update (GimpImagePropView *view)
|
|||
GimpColorProfile *profile;
|
||||
GimpImageBaseType type;
|
||||
GimpPrecision precision;
|
||||
GimpUnit unit;
|
||||
GimpUnit *unit;
|
||||
gdouble unit_factor;
|
||||
const gchar *desc;
|
||||
gchar format_buf[32];
|
||||
|
@ -463,7 +463,7 @@ gimp_image_prop_view_update (GimpImagePropView *view)
|
|||
g_snprintf (buf, sizeof (buf), _("%g × %g %s"),
|
||||
xres / unit_factor,
|
||||
yres / unit_factor,
|
||||
unit == GIMP_UNIT_INCH ? _("ppi") : format_buf);
|
||||
unit == gimp_unit_inch () ? _("ppi") : format_buf);
|
||||
gtk_label_set_text (GTK_LABEL (view->resolution_label), buf);
|
||||
|
||||
/* color space */
|
||||
|
|
|
@ -115,7 +115,7 @@ gimp_size_box_class_init (GimpSizeBoxClass *klass)
|
|||
g_object_class_install_property (object_class, PROP_UNIT,
|
||||
gimp_param_spec_unit ("unit", NULL, NULL,
|
||||
TRUE, TRUE,
|
||||
GIMP_UNIT_PIXEL,
|
||||
gimp_unit_pixel (),
|
||||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
g_object_class_install_property (object_class, PROP_XRESOLUTION,
|
||||
|
@ -138,7 +138,7 @@ gimp_size_box_class_init (GimpSizeBoxClass *klass)
|
|||
gimp_param_spec_unit ("resolution-unit",
|
||||
NULL, NULL,
|
||||
FALSE, FALSE,
|
||||
GIMP_UNIT_INCH,
|
||||
gimp_unit_inch (),
|
||||
GIMP_PARAM_READWRITE |
|
||||
G_PARAM_CONSTRUCT));
|
||||
g_object_class_install_property (object_class, PROP_KEEP_ASPECT,
|
||||
|
@ -330,7 +330,7 @@ gimp_size_box_set_property (GObject *object,
|
|||
break;
|
||||
|
||||
case PROP_UNIT:
|
||||
box->unit = g_value_get_int (value);
|
||||
box->unit = g_value_get_object (value);
|
||||
break;
|
||||
|
||||
case PROP_XRESOLUTION:
|
||||
|
@ -350,7 +350,7 @@ gimp_size_box_set_property (GObject *object,
|
|||
break;
|
||||
|
||||
case PROP_RESOLUTION_UNIT:
|
||||
box->resolution_unit = g_value_get_int (value);
|
||||
box->resolution_unit = g_value_get_object (value);
|
||||
break;
|
||||
|
||||
case PROP_KEEP_ASPECT:
|
||||
|
@ -389,7 +389,7 @@ gimp_size_box_get_property (GObject *object,
|
|||
break;
|
||||
|
||||
case PROP_UNIT:
|
||||
g_value_set_int (value, box->unit);
|
||||
g_value_set_object (value, box->unit);
|
||||
break;
|
||||
|
||||
case PROP_XRESOLUTION:
|
||||
|
@ -401,7 +401,7 @@ gimp_size_box_get_property (GObject *object,
|
|||
break;
|
||||
|
||||
case PROP_RESOLUTION_UNIT:
|
||||
g_value_set_int (value, box->resolution_unit);
|
||||
g_value_set_object (value, box->resolution_unit);
|
||||
break;
|
||||
|
||||
case PROP_KEEP_ASPECT:
|
||||
|
|
|
@ -42,10 +42,10 @@ struct _GimpSizeBox
|
|||
|
||||
gint width;
|
||||
gint height;
|
||||
GimpUnit unit;
|
||||
GimpUnit *unit;
|
||||
gdouble xresolution;
|
||||
gdouble yresolution;
|
||||
GimpUnit resolution_unit;
|
||||
GimpUnit *resolution_unit;
|
||||
|
||||
gboolean edit_resolution;
|
||||
};
|
||||
|
|
|
@ -569,7 +569,7 @@ gimp_text_style_editor_list_tags (GimpTextStyleEditor *editor,
|
|||
gdouble points;
|
||||
|
||||
points = gimp_units_to_points (pixels,
|
||||
GIMP_UNIT_PIXEL,
|
||||
gimp_unit_pixel (),
|
||||
editor->resolution_y);
|
||||
tag = gimp_text_buffer_get_size_tag (editor->buffer,
|
||||
PANGO_SCALE * points);
|
||||
|
@ -857,7 +857,7 @@ gimp_text_style_editor_size_changed (GimpSizeEntry *entry,
|
|||
gdouble points;
|
||||
|
||||
points = gimp_units_to_points (gimp_size_entry_get_refval (entry, 0),
|
||||
GIMP_UNIT_PIXEL, editor->resolution_y);
|
||||
gimp_unit_pixel (), editor->resolution_y);
|
||||
|
||||
if (gtk_text_buffer_get_has_selection (buffer))
|
||||
{
|
||||
|
@ -891,7 +891,7 @@ gimp_text_style_editor_set_size (GimpTextStyleEditor *editor,
|
|||
editor);
|
||||
|
||||
pixels = gimp_units_to_pixels ((gdouble) size / PANGO_SCALE,
|
||||
GIMP_UNIT_POINT,
|
||||
gimp_unit_point (),
|
||||
editor->resolution_y);
|
||||
gimp_size_entry_set_refval (GIMP_SIZE_ENTRY (editor->size_entry), 0, pixels);
|
||||
|
||||
|
|
|
@ -199,7 +199,7 @@ gimp_toolbox_drop_drawable (GtkWidget *widget,
|
|||
|
||||
new_image = gimp_image_new_from_drawable (context->gimp,
|
||||
GIMP_DRAWABLE (viewable));
|
||||
gimp_create_display (context->gimp, new_image, GIMP_UNIT_PIXEL, 1.0,
|
||||
gimp_create_display (context->gimp, new_image, gimp_unit_pixel (), 1.0,
|
||||
G_OBJECT (gimp_widget_get_monitor (widget)));
|
||||
g_object_unref (new_image);
|
||||
}
|
||||
|
@ -234,7 +234,7 @@ gimp_toolbox_drop_buffer (GtkWidget *widget,
|
|||
|
||||
image = gimp_image_new_from_buffer (context->gimp,
|
||||
GIMP_BUFFER (viewable));
|
||||
gimp_create_display (image->gimp, image, GIMP_UNIT_PIXEL, 1.0,
|
||||
gimp_create_display (image->gimp, image, gimp_unit_pixel (), 1.0,
|
||||
G_OBJECT (gimp_widget_get_monitor (widget)));
|
||||
g_object_unref (image);
|
||||
}
|
||||
|
@ -255,7 +255,7 @@ gimp_toolbox_drop_component (GtkWidget *widget,
|
|||
|
||||
new_image = gimp_image_new_from_component (context->gimp,
|
||||
image, component);
|
||||
gimp_create_display (new_image->gimp, new_image, GIMP_UNIT_PIXEL, 1.0,
|
||||
gimp_create_display (new_image->gimp, new_image, gimp_unit_pixel (), 1.0,
|
||||
G_OBJECT (gimp_widget_get_monitor (widget)));
|
||||
g_object_unref (new_image);
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ gimp_toolbox_drop_pixbuf (GtkWidget *widget,
|
|||
|
||||
new_image = gimp_image_new_from_pixbuf (context->gimp, pixbuf,
|
||||
_("Dropped Buffer"));
|
||||
gimp_create_display (new_image->gimp, new_image, GIMP_UNIT_PIXEL, 1.0,
|
||||
gimp_create_display (new_image->gimp, new_image, gimp_unit_pixel (), 1.0,
|
||||
G_OBJECT (gimp_widget_get_monitor (widget)));
|
||||
g_object_unref (new_image);
|
||||
}
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
#include "core/gimpselection.h"
|
||||
#include "core/gimpsymmetry.h"
|
||||
#include "core/gimptemplate.h"
|
||||
#include "core/gimpunit.h"
|
||||
|
||||
#include "operations/layer-modes/gimp-layer-modes.h"
|
||||
|
||||
|
@ -1418,23 +1419,22 @@ xcf_load_image_props (XcfInfo *info,
|
|||
|
||||
case PROP_UNIT:
|
||||
{
|
||||
guint32 unit;
|
||||
guint32 unit_index;
|
||||
|
||||
xcf_read_int32 (info, &unit, 1);
|
||||
xcf_read_int32 (info, &unit_index, 1);
|
||||
|
||||
GIMP_LOG (XCF, "prop unit=%d", unit);
|
||||
GIMP_LOG (XCF, "prop unit=%d", unit_index);
|
||||
|
||||
if ((unit <= GIMP_UNIT_PIXEL) ||
|
||||
(unit >= gimp_unit_get_number_of_built_in_units ()))
|
||||
if (unit_index <= GIMP_UNIT_PIXEL || unit_index >= GIMP_UNIT_END)
|
||||
{
|
||||
gimp_message_literal (info->gimp, G_OBJECT (info->progress),
|
||||
GIMP_MESSAGE_WARNING,
|
||||
"Warning, unit out of range in XCF file, "
|
||||
"falling back to inches");
|
||||
unit = GIMP_UNIT_INCH;
|
||||
unit_index = GIMP_UNIT_INCH;
|
||||
}
|
||||
|
||||
gimp_image_set_unit (image, unit);
|
||||
gimp_image_set_unit (image, gimp_unit_get_by_id (unit_index));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1455,12 +1455,12 @@ xcf_load_image_props (XcfInfo *info,
|
|||
|
||||
case PROP_USER_UNIT:
|
||||
{
|
||||
gchar *unit_strings[5];
|
||||
float factor;
|
||||
guint32 digits;
|
||||
GimpUnit unit;
|
||||
gint num_units;
|
||||
gint i;
|
||||
gchar *unit_strings[5];
|
||||
float factor;
|
||||
guint32 digits;
|
||||
GimpUnit *unit;
|
||||
GList *iter;
|
||||
gint i;
|
||||
|
||||
xcf_read_float (info, &factor, 1);
|
||||
xcf_read_int32 (info, &digits, 1);
|
||||
|
@ -1470,11 +1470,9 @@ xcf_load_image_props (XcfInfo *info,
|
|||
if (unit_strings[i] == NULL)
|
||||
unit_strings[i] = g_strdup ("");
|
||||
|
||||
num_units = gimp_unit_get_number_of_units ();
|
||||
|
||||
for (unit = gimp_unit_get_number_of_built_in_units ();
|
||||
unit < num_units; unit++)
|
||||
for (iter = info->gimp->user_units; iter; iter = iter->next)
|
||||
{
|
||||
unit = iter->data;
|
||||
/* if the factor and the identifier match some unit
|
||||
* in unitrc, use the unitrc unit
|
||||
*/
|
||||
|
@ -1486,15 +1484,18 @@ xcf_load_image_props (XcfInfo *info,
|
|||
}
|
||||
}
|
||||
|
||||
/* no match */
|
||||
if (unit == num_units)
|
||||
unit = gimp_unit_new (unit_strings[0],
|
||||
factor,
|
||||
digits,
|
||||
unit_strings[1],
|
||||
unit_strings[2],
|
||||
unit_strings[3],
|
||||
unit_strings[4]);
|
||||
if (iter == NULL)
|
||||
/* No match. Create a temporary unit set with deletion
|
||||
* flag.
|
||||
*/
|
||||
unit = _gimp_unit_new (info->gimp,
|
||||
unit_strings[0],
|
||||
(gdouble) factor,
|
||||
digits,
|
||||
unit_strings[1],
|
||||
unit_strings[2],
|
||||
unit_strings[3],
|
||||
unit_strings[4]);
|
||||
|
||||
gimp_image_set_unit (image, unit);
|
||||
|
||||
|
|
|
@ -478,7 +478,7 @@ xcf_save_image_props (XcfInfo *info,
|
|||
GimpParasite *meta_parasite = NULL;
|
||||
GList *symmetry_parasites = NULL;
|
||||
GList *iter;
|
||||
GimpUnit unit = gimp_image_get_unit (image);
|
||||
GimpUnit *unit = gimp_image_get_unit (image);
|
||||
gdouble xres;
|
||||
gdouble yres;
|
||||
|
||||
|
@ -519,7 +519,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 ())
|
||||
if (gimp_unit_is_built_in (unit))
|
||||
xcf_check_error (xcf_save_prop (info, image, PROP_UNIT, error, unit), ;);
|
||||
|
||||
if (gimp_container_get_n_children (gimp_image_get_paths (image)) > 0 &&
|
||||
|
@ -531,7 +531,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 ())
|
||||
if (! gimp_unit_is_built_in (unit))
|
||||
xcf_check_error (xcf_save_prop (info, image, PROP_USER_UNIT, error, unit), ;);
|
||||
|
||||
if (gimp_image_get_grid (image))
|
||||
|
@ -1539,14 +1539,15 @@ xcf_save_prop (XcfInfo *info,
|
|||
|
||||
case PROP_UNIT:
|
||||
{
|
||||
guint32 unit = va_arg (args, guint32);
|
||||
GimpUnit *unit = va_arg (args, GimpUnit *);
|
||||
guint32 unit_index = gimp_unit_get_id (unit);
|
||||
|
||||
size = 4;
|
||||
|
||||
xcf_write_prop_type_check_error (info, prop_type, va_end (args));
|
||||
xcf_write_int32_check_error (info, &size, 1, va_end (args));
|
||||
|
||||
xcf_write_int32_check_error (info, &unit, 1, va_end (args));
|
||||
xcf_write_int32_check_error (info, &unit_index, 1, va_end (args));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1581,7 +1582,7 @@ xcf_save_prop (XcfInfo *info,
|
|||
|
||||
case PROP_USER_UNIT:
|
||||
{
|
||||
GimpUnit unit = va_arg (args, guint32);
|
||||
GimpUnit *unit = va_arg (args, GimpUnit *);
|
||||
const gchar *unit_strings[5];
|
||||
gfloat factor;
|
||||
guint32 digits;
|
||||
|
|
|
@ -94,7 +94,6 @@
|
|||
#include "gimpgpparams.h"
|
||||
#include "gimppdb-private.h"
|
||||
#include "gimpplugin-private.h"
|
||||
#include "gimpunitcache.h"
|
||||
|
||||
#include "libgimp-intl.h"
|
||||
|
||||
|
@ -462,21 +461,11 @@ gimp_main (GType plug_in_type,
|
|||
|
||||
/* initialize units */
|
||||
{
|
||||
GimpUnitVtable vtable;
|
||||
GimpUnitVtable vtable = { 0 };
|
||||
|
||||
vtable.unit_get_number_of_units = _gimp_unit_cache_get_number_of_units;
|
||||
vtable.unit_get_number_of_built_in_units =
|
||||
_gimp_unit_cache_get_number_of_built_in_units;
|
||||
vtable.unit_new = _gimp_unit_cache_new;
|
||||
vtable.unit_get_deletion_flag = _gimp_unit_cache_get_deletion_flag;
|
||||
vtable.unit_set_deletion_flag = _gimp_unit_cache_set_deletion_flag;
|
||||
vtable.unit_get_factor = _gimp_unit_cache_get_factor;
|
||||
vtable.unit_get_digits = _gimp_unit_cache_get_digits;
|
||||
vtable.unit_get_identifier = _gimp_unit_cache_get_identifier;
|
||||
vtable.unit_get_symbol = _gimp_unit_cache_get_symbol;
|
||||
vtable.unit_get_abbreviation = _gimp_unit_cache_get_abbreviation;
|
||||
vtable.unit_get_singular = _gimp_unit_cache_get_singular;
|
||||
vtable.unit_get_plural = _gimp_unit_cache_get_plural;
|
||||
vtable.get_deletion_flag = _gimp_unit_get_deletion_flag;
|
||||
vtable.set_deletion_flag = _gimp_unit_set_deletion_flag;
|
||||
vtable.get_data = _gimp_unit_get_data;
|
||||
|
||||
gimp_base_init (&vtable);
|
||||
}
|
||||
|
@ -949,6 +938,8 @@ gimp_close (void)
|
|||
if (_gimp_get_debug_flags () & GIMP_DEBUG_QUIT)
|
||||
_gimp_debug_stop ();
|
||||
|
||||
gimp_base_exit ();
|
||||
|
||||
_gimp_plug_in_quit (PLUG_IN);
|
||||
|
||||
if (PDB)
|
||||
|
|
|
@ -1016,6 +1016,7 @@ EXPORTS
|
|||
gimp_thumbnail_procedure_new
|
||||
gimp_tile_height
|
||||
gimp_tile_width
|
||||
gimp_unit_new
|
||||
gimp_user_time
|
||||
gimp_vector_load_procedure_extract_dimensions
|
||||
gimp_vector_load_procedure_get_type
|
||||
|
|
|
@ -79,5 +79,6 @@
|
|||
#include <libgimp/gimpselection_pdb.h>
|
||||
#include <libgimp/gimptextlayer_pdb.h>
|
||||
#include <libgimp/gimptexttool_pdb.h>
|
||||
#include <libgimp/gimpunit_pdb.h>
|
||||
|
||||
#endif /* __GIMP_PDB_HEADERS_H__ */
|
||||
|
|
|
@ -767,12 +767,12 @@ gimp_context_set_line_width (gdouble line_width)
|
|||
*
|
||||
* Since: 2.10
|
||||
**/
|
||||
GimpUnit
|
||||
GimpUnit *
|
||||
gimp_context_get_line_width_unit (void)
|
||||
{
|
||||
GimpValueArray *args;
|
||||
GimpValueArray *return_vals;
|
||||
GimpUnit line_width_unit = GIMP_UNIT_PIXEL;
|
||||
GimpUnit *line_width_unit = NULL;
|
||||
|
||||
args = gimp_value_array_new_from_types (NULL,
|
||||
G_TYPE_NONE);
|
||||
|
@ -783,7 +783,7 @@ gimp_context_get_line_width_unit (void)
|
|||
gimp_value_array_unref (args);
|
||||
|
||||
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
|
||||
line_width_unit = GIMP_VALUES_GET_INT (return_vals, 1);
|
||||
line_width_unit = GIMP_VALUES_GET_UNIT (return_vals, 1);
|
||||
|
||||
gimp_value_array_unref (return_vals);
|
||||
|
||||
|
@ -807,7 +807,7 @@ gimp_context_get_line_width_unit (void)
|
|||
* Since: 2.10
|
||||
**/
|
||||
gboolean
|
||||
gimp_context_set_line_width_unit (GimpUnit line_width_unit)
|
||||
gimp_context_set_line_width_unit (GimpUnit *line_width_unit)
|
||||
{
|
||||
GimpValueArray *args;
|
||||
GimpValueArray *return_vals;
|
||||
|
|
|
@ -52,8 +52,8 @@ GimpLayerMode gimp_context_get_paint_mode (void)
|
|||
gboolean gimp_context_set_paint_mode (GimpLayerMode paint_mode);
|
||||
gdouble gimp_context_get_line_width (void);
|
||||
gboolean gimp_context_set_line_width (gdouble line_width);
|
||||
GimpUnit gimp_context_get_line_width_unit (void);
|
||||
gboolean gimp_context_set_line_width_unit (GimpUnit line_width_unit);
|
||||
GimpUnit* gimp_context_get_line_width_unit (void);
|
||||
gboolean gimp_context_set_line_width_unit (GimpUnit *line_width_unit);
|
||||
GimpCapStyle gimp_context_get_line_cap_style (void);
|
||||
gboolean gimp_context_set_line_cap_style (GimpCapStyle cap_style);
|
||||
GimpJoinStyle gimp_context_get_line_join_style (void);
|
||||
|
|
|
@ -157,18 +157,18 @@ gimp_get_default_comment (void)
|
|||
*
|
||||
* Get the default unit (taken from the user's locale).
|
||||
*
|
||||
* Returns the default unit's integer ID.
|
||||
* Returns the default unit.
|
||||
*
|
||||
* Returns: (transfer none): Default unit.
|
||||
*
|
||||
* Since: 2.4
|
||||
**/
|
||||
GimpUnit
|
||||
GimpUnit *
|
||||
gimp_get_default_unit (void)
|
||||
{
|
||||
GimpValueArray *args;
|
||||
GimpValueArray *return_vals;
|
||||
GimpUnit unit_id = GIMP_UNIT_PIXEL;
|
||||
GimpUnit *unit = NULL;
|
||||
|
||||
args = gimp_value_array_new_from_types (NULL,
|
||||
G_TYPE_NONE);
|
||||
|
@ -179,11 +179,11 @@ gimp_get_default_unit (void)
|
|||
gimp_value_array_unref (args);
|
||||
|
||||
if (GIMP_VALUES_GET_ENUM (return_vals, 0) == GIMP_PDB_SUCCESS)
|
||||
unit_id = GIMP_VALUES_GET_INT (return_vals, 1);
|
||||
unit = GIMP_VALUES_GET_UNIT (return_vals, 1);
|
||||
|
||||
gimp_value_array_unref (return_vals);
|
||||
|
||||
return unit_id;
|
||||
return unit;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -36,7 +36,7 @@ gchar* gimp_gimprc_query (const gchar *token);
|
|||
gboolean gimp_gimprc_set (const gchar *token,
|
||||
const gchar *value);
|
||||
gchar* gimp_get_default_comment (void);
|
||||
GimpUnit gimp_get_default_unit (void);
|
||||
GimpUnit* gimp_get_default_unit (void);
|
||||
gboolean gimp_get_monitor_resolution (gdouble *xres,
|
||||
gdouble *yres);
|
||||
G_GNUC_INTERNAL gchar* _gimp_get_color_configuration (void);
|
||||
|
|
|
@ -109,7 +109,7 @@ _gimp_gp_param_def_to_param_spec (const GPParamDef *param_def)
|
|||
return gimp_param_spec_unit (name, nick, blurb,
|
||||
param_def->meta.m_unit.allow_pixels,
|
||||
param_def->meta.m_unit.allow_percent,
|
||||
param_def->meta.m_unit.default_val,
|
||||
gimp_unit_get_by_id (param_def->meta.m_unit.default_val),
|
||||
flags);
|
||||
break;
|
||||
|
||||
|
@ -349,14 +349,13 @@ _gimp_param_spec_to_gp_param_def (GParamSpec *pspec,
|
|||
}
|
||||
else if (pspec_type == GIMP_TYPE_PARAM_UNIT)
|
||||
{
|
||||
GParamSpecInt *ispec = G_PARAM_SPEC_INT (pspec);
|
||||
GimpParamSpecUnit *uspec = GIMP_PARAM_SPEC_UNIT (pspec);
|
||||
|
||||
param_def->param_def_type = GP_PARAM_DEF_TYPE_UNIT;
|
||||
|
||||
param_def->meta.m_unit.allow_pixels = (ispec->minimum < GIMP_UNIT_INCH);
|
||||
param_def->meta.m_unit.allow_pixels = uspec->allow_pixel;
|
||||
param_def->meta.m_unit.allow_percent = uspec->allow_percent;
|
||||
param_def->meta.m_unit.default_val = ispec->default_value;
|
||||
param_def->meta.m_unit.default_val = gimp_unit_get_id (uspec->default_value);
|
||||
}
|
||||
else if (G_IS_PARAM_SPEC_ENUM (pspec))
|
||||
{
|
||||
|
@ -643,6 +642,13 @@ get_resource_id (GObject *resource)
|
|||
#endif
|
||||
}
|
||||
|
||||
static GimpUnit *
|
||||
get_unit_by_id (gpointer gimp,
|
||||
gint id)
|
||||
{
|
||||
return gimp_unit_get_by_id (id);
|
||||
}
|
||||
|
||||
|
||||
/* Deserialize a gp_param (from the wire) to an instance of object or
|
||||
* primitive type.
|
||||
|
@ -682,8 +688,7 @@ gimp_gp_param_to_value (gpointer gimp,
|
|||
|
||||
g_value_init (value, type);
|
||||
|
||||
if (type == G_TYPE_INT ||
|
||||
type == GIMP_TYPE_UNIT)
|
||||
if (type == G_TYPE_INT)
|
||||
{
|
||||
g_value_set_int (value, param->data.d_int);
|
||||
}
|
||||
|
@ -915,6 +920,10 @@ gimp_gp_param_to_value (gpointer gimp,
|
|||
{
|
||||
g_value_set_object (value, get_resource_by_id (param->data.d_int));
|
||||
}
|
||||
else if (GIMP_VALUE_HOLDS_UNIT (value))
|
||||
{
|
||||
g_value_set_object (value, get_unit_by_id (gimp, param->data.d_int));
|
||||
}
|
||||
else if (G_VALUE_HOLDS_PARAM (value))
|
||||
{
|
||||
GParamSpec *pspec =
|
||||
|
@ -1032,8 +1041,7 @@ gimp_value_to_gp_param (const GValue *value,
|
|||
else
|
||||
param->type_name = (gchar *) g_type_name (type);
|
||||
|
||||
if (type == G_TYPE_INT ||
|
||||
type == GIMP_TYPE_UNIT)
|
||||
if (type == G_TYPE_INT)
|
||||
{
|
||||
param->param_type = GP_PARAM_TYPE_INT;
|
||||
|
||||
|
@ -1343,6 +1351,14 @@ gimp_value_to_gp_param (const GValue *value,
|
|||
|
||||
param->data.d_int = resource ? get_resource_id (resource) : -1;
|
||||
}
|
||||
else if (GIMP_VALUE_HOLDS_UNIT (value))
|
||||
{
|
||||
GimpUnit *unit = g_value_get_object (value);
|
||||
|
||||
param->param_type = GP_PARAM_TYPE_INT;
|
||||
|
||||
param->data.d_int = unit ? gimp_unit_get_id (unit) : -1;
|
||||
}
|
||||
else if (G_VALUE_HOLDS_PARAM (value))
|
||||
{
|
||||
param->param_type = GP_PARAM_TYPE_PARAM_DEF;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue