2006-12-09 21:33:38 +00:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2003-06-23 19:34:48 +00:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
2003-06-23 22:27:54 +00:00
|
|
|
* GimpGrid
|
|
|
|
* Copyright (C) 2003 Henrik Brix Andersen <brix@gimp.org>
|
|
|
|
*
|
2009-01-17 22:28:01 +00:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2003-06-23 19:34:48 +00:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-17 22:28:01 +00:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2003-06-23 19:34:48 +00:00
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2018-07-11 23:27:07 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2003-06-23 19:34:48 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2011-04-28 15:50:39 +02:00
|
|
|
#include <string.h>
|
2003-10-10 14:11:47 +00:00
|
|
|
|
2011-04-28 15:50:39 +02:00
|
|
|
#include <cairo.h>
|
2012-03-30 15:08:54 +02:00
|
|
|
#include <gegl.h>
|
2012-05-03 03:36:22 +02:00
|
|
|
#include <gdk-pixbuf/gdk-pixbuf.h>
|
2003-06-23 19:34:48 +00:00
|
|
|
|
2014-05-21 21:25:41 +02:00
|
|
|
#include "libgimpmath/gimpmath.h"
|
2003-10-10 14:11:47 +00:00
|
|
|
#include "libgimpbase/gimpbase.h"
|
2005-01-25 19:11:26 +00:00
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
2003-10-10 14:11:47 +00:00
|
|
|
|
2003-06-23 19:34:48 +00:00
|
|
|
#include "libgimpcolor/gimpcolor.h"
|
|
|
|
|
|
|
|
#include "core-types.h"
|
|
|
|
|
|
|
|
#include "gimpgrid.h"
|
|
|
|
|
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
2003-10-19 00:33:25 +00:00
|
|
|
PROP_STYLE,
|
|
|
|
PROP_FGCOLOR,
|
|
|
|
PROP_BGCOLOR,
|
2003-06-23 19:34:48 +00:00
|
|
|
PROP_XSPACING,
|
|
|
|
PROP_YSPACING,
|
|
|
|
PROP_SPACING_UNIT,
|
|
|
|
PROP_XOFFSET,
|
|
|
|
PROP_YOFFSET,
|
2003-10-19 00:33:25 +00:00
|
|
|
PROP_OFFSET_UNIT
|
2003-06-23 19:34:48 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2023-12-21 15:46:15 +09:00
|
|
|
static void gimp_grid_finalize (GObject *object);
|
2005-12-10 19:24:36 +00:00
|
|
|
static void gimp_grid_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gimp_grid_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
2003-06-23 19:34:48 +00:00
|
|
|
|
|
|
|
|
2005-12-10 19:24:36 +00:00
|
|
|
G_DEFINE_TYPE_WITH_CODE (GimpGrid, gimp_grid, GIMP_TYPE_OBJECT,
|
2006-05-15 09:46:31 +00:00
|
|
|
G_IMPLEMENT_INTERFACE (GIMP_TYPE_CONFIG, NULL))
|
2003-06-23 19:34:48 +00:00
|
|
|
|
2023-12-21 15:46:15 +09:00
|
|
|
#define parent_class gimp_grid_parent_class
|
|
|
|
|
2003-06-23 19:34:48 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_grid_class_init (GimpGridClass *klass)
|
|
|
|
{
|
2005-12-10 19:24:36 +00:00
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
2023-12-21 15:46:15 +09:00
|
|
|
GeglColor *black = gegl_color_new ("black");
|
|
|
|
GeglColor *white = gegl_color_new ("white");
|
2003-06-23 19:34:48 +00:00
|
|
|
|
2023-12-21 15:46:15 +09:00
|
|
|
object_class->finalize = gimp_grid_finalize;
|
2003-06-23 19:34:48 +00:00
|
|
|
object_class->get_property = gimp_grid_get_property;
|
|
|
|
object_class->set_property = gimp_grid_set_property;
|
|
|
|
|
2016-02-11 23:44:07 +01:00
|
|
|
GIMP_CONFIG_PROP_ENUM (object_class, PROP_STYLE,
|
|
|
|
"style",
|
|
|
|
_("Line style"),
|
|
|
|
_("Line style used for the grid."),
|
|
|
|
GIMP_TYPE_GRID_STYLE,
|
|
|
|
GIMP_GRID_SOLID,
|
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
|
|
|
|
2023-12-21 15:46:15 +09:00
|
|
|
GIMP_CONFIG_PROP_COLOR (object_class, PROP_FGCOLOR,
|
|
|
|
"fgcolor",
|
|
|
|
_("Foreground color"),
|
|
|
|
_("The foreground color of the grid."),
|
2024-04-19 23:02:29 +02:00
|
|
|
TRUE, black,
|
2023-12-21 15:46:15 +09:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
GIMP_CONFIG_PROP_COLOR (object_class, PROP_BGCOLOR,
|
|
|
|
"bgcolor",
|
|
|
|
_("Background color"),
|
|
|
|
_("The background color of the grid; "
|
|
|
|
"only used in double dashed line style."),
|
2024-04-19 23:02:29 +02:00
|
|
|
TRUE, white,
|
2023-12-21 15:46:15 +09:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2016-02-11 23:44:07 +01:00
|
|
|
|
|
|
|
GIMP_CONFIG_PROP_DOUBLE (object_class, PROP_XSPACING,
|
|
|
|
"xspacing",
|
|
|
|
_("Spacing X"),
|
|
|
|
_("Horizontal spacing of grid lines."),
|
2017-02-19 18:03:02 -05:00
|
|
|
0.0, GIMP_MAX_IMAGE_SIZE, 10.0,
|
2016-02-11 23:44:07 +01:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
GIMP_CONFIG_PROP_DOUBLE (object_class, PROP_YSPACING,
|
|
|
|
"yspacing",
|
|
|
|
_("Spacing Y"),
|
|
|
|
_("Vertical spacing of grid lines."),
|
2017-02-19 18:03:02 -05:00
|
|
|
0.0, GIMP_MAX_IMAGE_SIZE, 10.0,
|
2016-02-11 23:44:07 +01:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
GIMP_CONFIG_PROP_UNIT (object_class, PROP_SPACING_UNIT,
|
|
|
|
"spacing-unit",
|
|
|
|
_("Spacing unit"),
|
|
|
|
NULL,
|
Issue #8900 and #9923: reimplementing GimpUnit as a proper class.
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.
2024-07-25 20:55:21 +02:00
|
|
|
FALSE, FALSE, gimp_unit_inch (),
|
2016-02-11 23:44:07 +01:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
GIMP_CONFIG_PROP_DOUBLE (object_class, PROP_XOFFSET,
|
|
|
|
"xoffset",
|
|
|
|
_("Offset X"),
|
|
|
|
_("Horizontal offset of the first grid "
|
|
|
|
"line; this may be a negative number."),
|
|
|
|
- GIMP_MAX_IMAGE_SIZE,
|
|
|
|
GIMP_MAX_IMAGE_SIZE, 0.0,
|
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
GIMP_CONFIG_PROP_DOUBLE (object_class, PROP_YOFFSET,
|
|
|
|
"yoffset",
|
|
|
|
_("Offset Y"),
|
|
|
|
_("Vertical offset of the first grid "
|
|
|
|
"line; this may be a negative number."),
|
|
|
|
- GIMP_MAX_IMAGE_SIZE,
|
|
|
|
GIMP_MAX_IMAGE_SIZE, 0.0,
|
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
|
|
|
|
|
|
|
GIMP_CONFIG_PROP_UNIT (object_class, PROP_OFFSET_UNIT,
|
|
|
|
"offset-unit",
|
|
|
|
_("Offset unit"),
|
|
|
|
NULL,
|
Issue #8900 and #9923: reimplementing GimpUnit as a proper class.
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.
2024-07-25 20:55:21 +02:00
|
|
|
FALSE, FALSE, gimp_unit_inch (),
|
2016-02-11 23:44:07 +01:00
|
|
|
GIMP_PARAM_STATIC_STRINGS);
|
2023-12-21 15:46:15 +09:00
|
|
|
|
|
|
|
g_object_unref (black);
|
|
|
|
g_object_unref (white);
|
2003-06-23 19:34:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2005-12-10 19:24:36 +00:00
|
|
|
gimp_grid_init (GimpGrid *grid)
|
2003-06-23 19:34:48 +00:00
|
|
|
{
|
2023-12-21 15:46:15 +09:00
|
|
|
grid->fgcolor = gegl_color_new ("black");
|
|
|
|
grid->bgcolor = gegl_color_new ("white");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_grid_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GimpGrid *grid = GIMP_GRID (object);
|
|
|
|
|
|
|
|
g_object_unref (grid->fgcolor);
|
|
|
|
g_object_unref (grid->bgcolor);
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2003-06-23 19:34:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_grid_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpGrid *grid = GIMP_GRID (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
2003-10-19 00:33:25 +00:00
|
|
|
case PROP_STYLE:
|
|
|
|
g_value_set_enum (value, grid->style);
|
|
|
|
break;
|
|
|
|
case PROP_FGCOLOR:
|
2023-12-21 15:46:15 +09:00
|
|
|
g_value_set_object (value, grid->fgcolor);
|
2003-10-19 00:33:25 +00:00
|
|
|
break;
|
|
|
|
case PROP_BGCOLOR:
|
2023-12-21 15:46:15 +09:00
|
|
|
g_value_set_object (value, grid->bgcolor);
|
2003-10-19 00:33:25 +00:00
|
|
|
break;
|
2003-06-23 19:34:48 +00:00
|
|
|
case PROP_XSPACING:
|
|
|
|
g_value_set_double (value, grid->xspacing);
|
|
|
|
break;
|
|
|
|
case PROP_YSPACING:
|
|
|
|
g_value_set_double (value, grid->yspacing);
|
|
|
|
break;
|
|
|
|
case PROP_SPACING_UNIT:
|
Issue #8900 and #9923: reimplementing GimpUnit as a proper class.
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.
2024-07-25 20:55:21 +02:00
|
|
|
g_value_set_object (value, grid->spacing_unit);
|
2003-06-23 19:34:48 +00:00
|
|
|
break;
|
|
|
|
case PROP_XOFFSET:
|
|
|
|
g_value_set_double (value, grid->xoffset);
|
|
|
|
break;
|
|
|
|
case PROP_YOFFSET:
|
|
|
|
g_value_set_double (value, grid->yoffset);
|
|
|
|
break;
|
|
|
|
case PROP_OFFSET_UNIT:
|
Issue #8900 and #9923: reimplementing GimpUnit as a proper class.
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.
2024-07-25 20:55:21 +02:00
|
|
|
g_value_set_object (value, grid->offset_unit);
|
2003-06-23 19:34:48 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_grid_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpGrid *grid = GIMP_GRID (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
2003-10-19 00:33:25 +00:00
|
|
|
case PROP_STYLE:
|
|
|
|
grid->style = g_value_get_enum (value);
|
|
|
|
break;
|
|
|
|
case PROP_FGCOLOR:
|
2023-12-21 15:46:15 +09:00
|
|
|
g_clear_object (&grid->fgcolor);
|
|
|
|
grid->fgcolor = gegl_color_duplicate (g_value_get_object (value));
|
2003-10-19 00:33:25 +00:00
|
|
|
break;
|
|
|
|
case PROP_BGCOLOR:
|
2023-12-21 15:46:15 +09:00
|
|
|
g_clear_object (&grid->bgcolor);
|
|
|
|
grid->bgcolor = gegl_color_duplicate (g_value_get_object (value));
|
2003-10-19 00:33:25 +00:00
|
|
|
break;
|
2003-06-23 19:34:48 +00:00
|
|
|
case PROP_XSPACING:
|
|
|
|
grid->xspacing = g_value_get_double (value);
|
|
|
|
break;
|
|
|
|
case PROP_YSPACING:
|
|
|
|
grid->yspacing = g_value_get_double (value);
|
|
|
|
break;
|
|
|
|
case PROP_SPACING_UNIT:
|
Issue #8900 and #9923: reimplementing GimpUnit as a proper class.
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.
2024-07-25 20:55:21 +02:00
|
|
|
grid->spacing_unit = g_value_get_object (value);
|
2003-06-23 19:34:48 +00:00
|
|
|
break;
|
|
|
|
case PROP_XOFFSET:
|
|
|
|
grid->xoffset = g_value_get_double (value);
|
|
|
|
break;
|
|
|
|
case PROP_YOFFSET:
|
|
|
|
grid->yoffset = g_value_get_double (value);
|
|
|
|
break;
|
|
|
|
case PROP_OFFSET_UNIT:
|
Issue #8900 and #9923: reimplementing GimpUnit as a proper class.
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.
2024-07-25 20:55:21 +02:00
|
|
|
grid->offset_unit = g_value_get_object (value);
|
2003-06-23 19:34:48 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2003-10-10 14:11:47 +00:00
|
|
|
|
2014-05-21 21:44:28 +02:00
|
|
|
|
|
|
|
/* public functions */
|
|
|
|
|
|
|
|
GimpGridStyle
|
|
|
|
gimp_grid_get_style (GimpGrid *grid)
|
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_GRID (grid), GIMP_GRID_SOLID);
|
|
|
|
|
|
|
|
return grid->style;
|
|
|
|
}
|
|
|
|
|
2023-12-21 15:46:15 +09:00
|
|
|
GeglColor *
|
|
|
|
gimp_grid_get_fgcolor (GimpGrid *grid)
|
2014-05-21 21:44:28 +02:00
|
|
|
{
|
2023-12-21 15:46:15 +09:00
|
|
|
g_return_val_if_fail (GIMP_IS_GRID (grid), NULL);
|
2014-05-21 21:44:28 +02:00
|
|
|
|
2023-12-21 15:46:15 +09:00
|
|
|
return grid->fgcolor;
|
2014-05-21 21:44:28 +02:00
|
|
|
}
|
|
|
|
|
2023-12-21 15:46:15 +09:00
|
|
|
GeglColor *
|
|
|
|
gimp_grid_get_bgcolor (GimpGrid *grid)
|
2014-05-21 21:44:28 +02:00
|
|
|
{
|
2023-12-21 15:46:15 +09:00
|
|
|
g_return_val_if_fail (GIMP_IS_GRID (grid), NULL);
|
2014-05-21 21:44:28 +02:00
|
|
|
|
2023-12-21 15:46:15 +09:00
|
|
|
return grid->bgcolor;
|
2014-05-21 21:44:28 +02:00
|
|
|
}
|
|
|
|
|
2014-05-21 21:25:41 +02:00
|
|
|
void
|
|
|
|
gimp_grid_get_spacing (GimpGrid *grid,
|
|
|
|
gdouble *xspacing,
|
|
|
|
gdouble *yspacing)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_GRID (grid));
|
|
|
|
|
2017-02-19 18:03:02 -05:00
|
|
|
if (xspacing) *xspacing = grid->xspacing;
|
|
|
|
if (yspacing) *yspacing = grid->yspacing;
|
2014-05-21 21:25:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_grid_get_offset (GimpGrid *grid,
|
|
|
|
gdouble *xoffset,
|
|
|
|
gdouble *yoffset)
|
|
|
|
{
|
|
|
|
g_return_if_fail (GIMP_IS_GRID (grid));
|
|
|
|
|
2017-02-19 18:03:02 -05:00
|
|
|
if (xoffset) *xoffset = grid->xoffset;
|
|
|
|
if (yoffset) *yoffset = grid->yoffset;
|
2014-05-21 21:25:41 +02:00
|
|
|
}
|
|
|
|
|
2003-10-10 14:11:47 +00:00
|
|
|
const gchar *
|
|
|
|
gimp_grid_parasite_name (void)
|
|
|
|
{
|
|
|
|
return "gimp-image-grid";
|
|
|
|
}
|
|
|
|
|
|
|
|
GimpParasite *
|
2016-05-19 23:51:44 +02:00
|
|
|
gimp_grid_to_parasite (GimpGrid *grid)
|
2003-10-10 14:11:47 +00:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_GRID (grid), NULL);
|
|
|
|
|
2019-09-21 12:21:31 +02:00
|
|
|
return gimp_config_serialize_to_parasite (GIMP_CONFIG (grid),
|
|
|
|
gimp_grid_parasite_name (),
|
|
|
|
GIMP_PARASITE_PERSISTENT,
|
|
|
|
NULL);
|
2003-10-10 14:11:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
GimpGrid *
|
|
|
|
gimp_grid_from_parasite (const GimpParasite *parasite)
|
|
|
|
{
|
2019-09-21 12:21:31 +02:00
|
|
|
GimpGrid *grid;
|
|
|
|
GError *error = NULL;
|
2003-10-10 14:11:47 +00:00
|
|
|
|
|
|
|
g_return_val_if_fail (parasite != NULL, NULL);
|
2021-04-05 18:36:44 +02:00
|
|
|
g_return_val_if_fail (strcmp (gimp_parasite_get_name (parasite),
|
2003-10-10 14:11:47 +00:00
|
|
|
gimp_grid_parasite_name ()) == 0, NULL);
|
|
|
|
|
2021-01-29 23:52:03 +01:00
|
|
|
if (! gimp_parasite_get_data (parasite, NULL))
|
2018-07-05 22:35:07 -04:00
|
|
|
{
|
|
|
|
g_warning ("Empty grid parasite");
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
2003-10-10 14:11:47 +00:00
|
|
|
|
|
|
|
grid = g_object_new (GIMP_TYPE_GRID, NULL);
|
|
|
|
|
2019-09-21 12:21:31 +02:00
|
|
|
if (! gimp_config_deserialize_parasite (GIMP_CONFIG (grid),
|
|
|
|
parasite,
|
|
|
|
NULL,
|
|
|
|
&error))
|
2003-10-10 14:11:47 +00:00
|
|
|
{
|
|
|
|
g_warning ("Failed to deserialize grid parasite: %s", error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
return grid;
|
|
|
|
}
|