2005-03-03 02:18:19 +08:00
|
|
|
/* The GIMP -- an image manipulation program
|
|
|
|
* Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpbase/gimpbase.h"
|
|
|
|
#include "libgimpconfig/gimpconfig.h"
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "tools-types.h"
|
|
|
|
|
2006-08-08 19:51:04 +08:00
|
|
|
#include "core/gimptooloptions.h"
|
|
|
|
|
2006-09-15 01:11:24 +08:00
|
|
|
#include "widgets/gimppropwidgets.h"
|
|
|
|
|
2005-03-03 02:18:19 +08:00
|
|
|
#include "gimprectangleoptions.h"
|
|
|
|
#include "gimptooloptions-gui.h"
|
|
|
|
|
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
|
|
|
2005-09-04 03:48:22 +08:00
|
|
|
#define GIMP_RECTANGLE_OPTIONS_GET_PRIVATE(obj) (gimp_rectangle_options_get_private ((GimpRectangleOptions *) (obj)))
|
|
|
|
|
|
|
|
typedef struct _GimpRectangleOptionsPrivate GimpRectangleOptionsPrivate;
|
|
|
|
|
|
|
|
struct _GimpRectangleOptionsPrivate
|
|
|
|
{
|
2006-01-22 02:20:26 +08:00
|
|
|
gboolean highlight;
|
2006-06-06 02:50:13 +08:00
|
|
|
GimpRectangleGuide guide;
|
2005-03-03 02:18:19 +08:00
|
|
|
|
2006-09-22 04:16:25 +08:00
|
|
|
gdouble x0;
|
|
|
|
gdouble y0;
|
|
|
|
|
2006-01-22 02:20:26 +08:00
|
|
|
gboolean fixed_width;
|
|
|
|
gdouble width;
|
2005-09-04 03:48:22 +08:00
|
|
|
|
2006-01-22 02:20:26 +08:00
|
|
|
gboolean fixed_height;
|
|
|
|
gdouble height;
|
2005-09-04 03:48:22 +08:00
|
|
|
|
2006-01-22 02:20:26 +08:00
|
|
|
gboolean fixed_aspect;
|
2006-09-15 01:11:24 +08:00
|
|
|
gdouble aspect_numerator;
|
|
|
|
gdouble aspect_denominator;
|
2005-09-04 03:48:22 +08:00
|
|
|
|
2006-01-22 02:20:26 +08:00
|
|
|
gboolean fixed_center;
|
|
|
|
gdouble center_x;
|
|
|
|
gdouble center_y;
|
2005-09-04 03:48:22 +08:00
|
|
|
|
2006-01-22 02:20:26 +08:00
|
|
|
GimpUnit unit;
|
2005-09-04 03:48:22 +08:00
|
|
|
};
|
2005-03-03 02:18:19 +08:00
|
|
|
|
2006-03-22 01:37:24 +08:00
|
|
|
static void gimp_rectangle_options_iface_base_init (GimpRectangleOptionsInterface *rectangle_options_iface);
|
2005-03-03 02:18:19 +08:00
|
|
|
|
2005-09-04 03:48:22 +08:00
|
|
|
static GimpRectangleOptionsPrivate *
|
2006-03-22 01:37:24 +08:00
|
|
|
gimp_rectangle_options_get_private (GimpRectangleOptions *options);
|
|
|
|
|
2005-03-03 02:18:19 +08:00
|
|
|
|
|
|
|
GType
|
2005-08-15 22:23:28 +08:00
|
|
|
gimp_rectangle_options_interface_get_type (void)
|
2005-03-03 02:18:19 +08:00
|
|
|
{
|
2006-08-08 19:51:04 +08:00
|
|
|
static GType iface_type = 0;
|
2005-03-03 02:18:19 +08:00
|
|
|
|
2006-08-08 19:51:04 +08:00
|
|
|
if (!iface_type)
|
2005-03-03 02:18:19 +08:00
|
|
|
{
|
2006-08-08 19:51:04 +08:00
|
|
|
static const GTypeInfo iface_info =
|
2005-03-03 02:18:19 +08:00
|
|
|
{
|
2005-08-15 22:23:28 +08:00
|
|
|
sizeof (GimpRectangleOptionsInterface),
|
2005-09-04 03:48:22 +08:00
|
|
|
(GBaseInitFunc) gimp_rectangle_options_iface_base_init,
|
|
|
|
(GBaseFinalizeFunc) NULL,
|
2005-03-03 02:18:19 +08:00
|
|
|
};
|
|
|
|
|
2006-08-08 19:51:04 +08:00
|
|
|
iface_type = g_type_register_static (G_TYPE_INTERFACE,
|
|
|
|
"GimpRectangleOptionsInterface",
|
|
|
|
&iface_info, 0);
|
|
|
|
|
|
|
|
g_type_interface_add_prerequisite (iface_type, GIMP_TYPE_TOOL_OPTIONS);
|
2005-03-03 02:18:19 +08:00
|
|
|
}
|
|
|
|
|
2006-08-08 19:51:04 +08:00
|
|
|
return iface_type;
|
2005-03-03 02:18:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2006-08-08 19:51:04 +08:00
|
|
|
gimp_rectangle_options_iface_base_init (GimpRectangleOptionsInterface *iface)
|
2005-03-03 02:18:19 +08:00
|
|
|
{
|
2005-08-15 22:23:28 +08:00
|
|
|
static gboolean initialized = FALSE;
|
|
|
|
|
|
|
|
if (! initialized)
|
|
|
|
{
|
2006-08-08 19:51:04 +08:00
|
|
|
g_object_interface_install_property (iface,
|
2006-01-19 04:29:40 +08:00
|
|
|
g_param_spec_boolean ("highlight",
|
|
|
|
NULL, NULL,
|
|
|
|
TRUE,
|
2006-08-13 23:59:18 +08:00
|
|
|
GIMP_CONFIG_PARAM_FLAGS |
|
|
|
|
GIMP_PARAM_STATIC_STRINGS));
|
2006-08-08 19:51:04 +08:00
|
|
|
g_object_interface_install_property (iface,
|
2006-06-06 02:50:13 +08:00
|
|
|
g_param_spec_enum ("guide",
|
|
|
|
NULL, NULL,
|
|
|
|
GIMP_TYPE_RECTANGLE_GUIDE,
|
|
|
|
GIMP_RECTANGLE_GUIDE_NONE,
|
2006-08-13 23:59:18 +08:00
|
|
|
GIMP_CONFIG_PARAM_FLAGS |
|
|
|
|
GIMP_PARAM_STATIC_STRINGS));
|
2005-09-04 03:48:22 +08:00
|
|
|
|
2006-08-08 19:51:04 +08:00
|
|
|
g_object_interface_install_property (iface,
|
2006-09-22 04:16:25 +08:00
|
|
|
g_param_spec_double ("x0",
|
|
|
|
NULL, NULL,
|
|
|
|
0.0, GIMP_MAX_IMAGE_SIZE,
|
|
|
|
0.0,
|
|
|
|
GIMP_CONFIG_PARAM_FLAGS |
|
|
|
|
GIMP_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
g_object_interface_install_property (iface,
|
|
|
|
g_param_spec_double ("y0",
|
|
|
|
NULL, NULL,
|
|
|
|
0.0, GIMP_MAX_IMAGE_SIZE,
|
|
|
|
0.0,
|
|
|
|
GIMP_CONFIG_PARAM_FLAGS |
|
|
|
|
GIMP_PARAM_STATIC_STRINGS));
|
|
|
|
|
|
|
|
g_object_interface_install_property (iface,
|
|
|
|
g_param_spec_boolean ("fixed-width",
|
2006-01-19 04:29:40 +08:00
|
|
|
NULL, NULL,
|
|
|
|
FALSE,
|
2006-08-13 23:59:18 +08:00
|
|
|
GIMP_CONFIG_PARAM_FLAGS |
|
|
|
|
GIMP_PARAM_STATIC_STRINGS));
|
2006-08-08 19:51:04 +08:00
|
|
|
g_object_interface_install_property (iface,
|
2006-01-19 04:29:40 +08:00
|
|
|
g_param_spec_double ("width",
|
|
|
|
NULL, NULL,
|
|
|
|
0.0, GIMP_MAX_IMAGE_SIZE,
|
|
|
|
0.0,
|
2006-08-13 23:59:18 +08:00
|
|
|
GIMP_CONFIG_PARAM_FLAGS |
|
|
|
|
GIMP_PARAM_STATIC_STRINGS));
|
2005-09-04 03:48:22 +08:00
|
|
|
|
2006-08-08 19:51:04 +08:00
|
|
|
g_object_interface_install_property (iface,
|
2006-09-22 04:16:25 +08:00
|
|
|
g_param_spec_boolean ("fixed-height",
|
2006-01-19 04:29:40 +08:00
|
|
|
NULL, NULL,
|
|
|
|
FALSE,
|
2006-08-13 23:59:18 +08:00
|
|
|
GIMP_CONFIG_PARAM_FLAGS |
|
|
|
|
GIMP_PARAM_STATIC_STRINGS));
|
2006-01-19 04:29:40 +08:00
|
|
|
|
2006-08-08 19:51:04 +08:00
|
|
|
g_object_interface_install_property (iface,
|
2006-01-19 04:29:40 +08:00
|
|
|
g_param_spec_double ("height",
|
|
|
|
NULL, NULL,
|
|
|
|
0.0, GIMP_MAX_IMAGE_SIZE,
|
|
|
|
0.0,
|
2006-08-13 23:59:18 +08:00
|
|
|
GIMP_CONFIG_PARAM_FLAGS |
|
|
|
|
GIMP_PARAM_STATIC_STRINGS));
|
2005-09-04 03:48:22 +08:00
|
|
|
|
2006-08-08 19:51:04 +08:00
|
|
|
g_object_interface_install_property (iface,
|
2006-01-19 04:29:40 +08:00
|
|
|
g_param_spec_boolean ("fixed-aspect",
|
|
|
|
NULL, NULL,
|
|
|
|
FALSE,
|
2006-08-13 23:59:18 +08:00
|
|
|
GIMP_CONFIG_PARAM_FLAGS |
|
|
|
|
GIMP_PARAM_STATIC_STRINGS));
|
2006-01-19 04:29:40 +08:00
|
|
|
|
2006-08-08 19:51:04 +08:00
|
|
|
g_object_interface_install_property (iface,
|
2006-09-15 01:11:24 +08:00
|
|
|
g_param_spec_double ("aspect-numerator",
|
2006-01-19 04:29:40 +08:00
|
|
|
NULL, NULL,
|
|
|
|
0.0, GIMP_MAX_IMAGE_SIZE,
|
2006-09-22 04:16:25 +08:00
|
|
|
1.0,
|
2006-08-13 23:59:18 +08:00
|
|
|
GIMP_CONFIG_PARAM_FLAGS |
|
|
|
|
GIMP_PARAM_STATIC_STRINGS));
|
2005-09-04 03:48:22 +08:00
|
|
|
|
2006-09-15 01:11:24 +08:00
|
|
|
g_object_interface_install_property (iface,
|
|
|
|
g_param_spec_double ("aspect-denominator",
|
|
|
|
NULL, NULL,
|
|
|
|
0.0, GIMP_MAX_IMAGE_SIZE,
|
|
|
|
1.0,
|
|
|
|
GIMP_CONFIG_PARAM_FLAGS |
|
|
|
|
GIMP_PARAM_STATIC_STRINGS));
|
|
|
|
|
2006-08-08 19:51:04 +08:00
|
|
|
g_object_interface_install_property (iface,
|
2006-01-19 04:29:40 +08:00
|
|
|
g_param_spec_boolean ("fixed-center",
|
|
|
|
NULL, NULL,
|
|
|
|
FALSE,
|
2006-08-13 23:59:18 +08:00
|
|
|
GIMP_CONFIG_PARAM_FLAGS |
|
|
|
|
GIMP_PARAM_STATIC_STRINGS));
|
2006-01-19 04:29:40 +08:00
|
|
|
|
2006-08-08 19:51:04 +08:00
|
|
|
g_object_interface_install_property (iface,
|
2006-01-19 04:29:40 +08:00
|
|
|
g_param_spec_double ("center-x",
|
|
|
|
NULL, NULL,
|
|
|
|
-GIMP_MAX_IMAGE_SIZE,
|
|
|
|
GIMP_MAX_IMAGE_SIZE,
|
|
|
|
0.0,
|
2006-08-13 23:59:18 +08:00
|
|
|
GIMP_CONFIG_PARAM_FLAGS |
|
|
|
|
GIMP_PARAM_STATIC_STRINGS));
|
2006-01-19 04:29:40 +08:00
|
|
|
|
2006-08-08 19:51:04 +08:00
|
|
|
g_object_interface_install_property (iface,
|
2006-01-19 04:29:40 +08:00
|
|
|
g_param_spec_double ("center-y",
|
|
|
|
NULL, NULL,
|
|
|
|
-GIMP_MAX_IMAGE_SIZE,
|
|
|
|
GIMP_MAX_IMAGE_SIZE,
|
|
|
|
0.0,
|
2006-08-13 23:59:18 +08:00
|
|
|
GIMP_CONFIG_PARAM_FLAGS |
|
|
|
|
GIMP_PARAM_STATIC_STRINGS));
|
2005-09-04 03:48:22 +08:00
|
|
|
|
2006-09-22 04:16:25 +08:00
|
|
|
g_object_interface_install_property (iface,
|
2006-01-19 04:29:40 +08:00
|
|
|
gimp_param_spec_unit ("unit",
|
|
|
|
NULL, NULL,
|
|
|
|
TRUE, TRUE,
|
|
|
|
GIMP_UNIT_PIXEL,
|
2006-08-13 23:59:18 +08:00
|
|
|
GIMP_CONFIG_PARAM_FLAGS |
|
|
|
|
GIMP_PARAM_STATIC_STRINGS));
|
2005-09-04 03:48:22 +08:00
|
|
|
|
2005-08-15 22:23:28 +08:00
|
|
|
initialized = TRUE;
|
|
|
|
}
|
2005-03-03 02:18:19 +08:00
|
|
|
}
|
|
|
|
|
2005-09-04 03:48:22 +08:00
|
|
|
static void
|
|
|
|
gimp_rectangle_options_private_finalize (GimpRectangleOptionsPrivate *private)
|
|
|
|
{
|
|
|
|
g_free (private);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GimpRectangleOptionsPrivate *
|
|
|
|
gimp_rectangle_options_get_private (GimpRectangleOptions *options)
|
|
|
|
{
|
|
|
|
GimpRectangleOptionsPrivate *private;
|
|
|
|
|
|
|
|
static GQuark private_key = 0;
|
|
|
|
|
|
|
|
g_return_val_if_fail (GIMP_IS_RECTANGLE_OPTIONS (options), NULL);
|
|
|
|
|
|
|
|
if (! private_key)
|
|
|
|
private_key = g_quark_from_static_string ("gimp-rectangle-options-private");
|
|
|
|
|
2006-08-08 19:51:04 +08:00
|
|
|
private = g_object_get_qdata (G_OBJECT (options), private_key);
|
2005-09-04 03:48:22 +08:00
|
|
|
|
|
|
|
if (! private)
|
|
|
|
{
|
|
|
|
private = g_new0 (GimpRectangleOptionsPrivate, 1);
|
|
|
|
|
2006-08-08 19:51:04 +08:00
|
|
|
g_object_set_qdata_full (G_OBJECT (options), private_key, private,
|
2005-09-04 03:48:22 +08:00
|
|
|
(GDestroyNotify) gimp_rectangle_options_private_finalize);
|
|
|
|
}
|
|
|
|
|
|
|
|
return private;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* gimp_rectangle_options_install_properties:
|
|
|
|
* @klass: the class structure for a type deriving from #GObject
|
|
|
|
*
|
|
|
|
* Installs the necessary properties for a class implementing
|
|
|
|
* #GimpRectangleOptions. A #GimpRectangleOptionsProp property is installed
|
|
|
|
* for each property, using the values from the #GimpRectangleOptionsProp
|
|
|
|
* enumeration. The caller must make sure itself that the enumeration
|
|
|
|
* values don't collide with some other property values they
|
|
|
|
* are using (that's what %GIMP_RECTANGLE_OPTIONS_PROP_LAST is good for).
|
|
|
|
**/
|
|
|
|
void
|
|
|
|
gimp_rectangle_options_install_properties (GObjectClass *klass)
|
|
|
|
{
|
|
|
|
g_object_class_override_property (klass,
|
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_HIGHLIGHT,
|
|
|
|
"highlight");
|
2006-06-06 02:50:13 +08:00
|
|
|
g_object_class_override_property (klass,
|
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_GUIDE,
|
|
|
|
"guide");
|
2006-09-22 04:16:25 +08:00
|
|
|
g_object_class_override_property (klass,
|
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_X0,
|
|
|
|
"x0");
|
|
|
|
g_object_class_override_property (klass,
|
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_Y0,
|
|
|
|
"y0");
|
2005-09-04 03:48:22 +08:00
|
|
|
g_object_class_override_property (klass,
|
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_FIXED_WIDTH,
|
2006-09-22 04:16:25 +08:00
|
|
|
"fixed-width");
|
2005-09-04 03:48:22 +08:00
|
|
|
g_object_class_override_property (klass,
|
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_WIDTH,
|
|
|
|
"width");
|
|
|
|
g_object_class_override_property (klass,
|
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_FIXED_HEIGHT,
|
2006-09-22 04:16:25 +08:00
|
|
|
"fixed-height");
|
2005-09-04 03:48:22 +08:00
|
|
|
g_object_class_override_property (klass,
|
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_HEIGHT,
|
|
|
|
"height");
|
|
|
|
g_object_class_override_property (klass,
|
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_FIXED_ASPECT,
|
|
|
|
"fixed-aspect");
|
|
|
|
g_object_class_override_property (klass,
|
2006-09-15 01:11:24 +08:00
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_ASPECT_NUMERATOR,
|
|
|
|
"aspect-numerator");
|
|
|
|
g_object_class_override_property (klass,
|
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_ASPECT_DENOMINATOR,
|
|
|
|
"aspect-denominator");
|
2005-09-04 03:48:22 +08:00
|
|
|
g_object_class_override_property (klass,
|
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_FIXED_CENTER,
|
|
|
|
"fixed-center");
|
|
|
|
g_object_class_override_property (klass,
|
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_CENTER_X,
|
|
|
|
"center-x");
|
|
|
|
g_object_class_override_property (klass,
|
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_CENTER_Y,
|
|
|
|
"center-y");
|
|
|
|
g_object_class_override_property (klass,
|
|
|
|
GIMP_RECTANGLE_OPTIONS_PROP_UNIT,
|
|
|
|
"unit");
|
2006-03-26 21:50:13 +08:00
|
|
|
}
|
|
|
|
|
2005-09-04 03:48:22 +08:00
|
|
|
void
|
|
|
|
gimp_rectangle_options_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2006-09-22 04:16:25 +08:00
|
|
|
GimpRectangleOptions *options = GIMP_RECTANGLE_OPTIONS (object);
|
|
|
|
GimpRectangleOptionsPrivate *private;
|
|
|
|
|
|
|
|
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
|
2005-08-15 22:23:28 +08:00
|
|
|
|
2005-09-04 03:48:22 +08:00
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case GIMP_RECTANGLE_OPTIONS_PROP_HIGHLIGHT:
|
2006-09-22 04:16:25 +08:00
|
|
|
private->highlight = g_value_get_boolean (value);
|
2005-09-04 03:48:22 +08:00
|
|
|
break;
|
2006-06-06 02:50:13 +08:00
|
|
|
case GIMP_RECTANGLE_OPTIONS_PROP_GUIDE:
|
2006-09-22 04:16:25 +08:00
|
|
|
private->guide = g_value_get_enum (value);
|
|
|
|
break;
|
|
|
|
case GIMP_RECTANGLE_OPTIONS_PROP_X0:
|
|
|
|
private->x0 = g_value_get_double (value);
|
|
|
|
break;
|
|
|
|
case GIMP_RECTANGLE_OPTIONS_PROP_Y0:
|
|
|
|
private->y0 = g_value_get_double (value);
|
2006-06-06 02:50:13 +08:00
|
|
|
break;
|
2005-09-04 03:48:22 +08:00
|
|
|
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_WIDTH:
|
2006-09-22 04:16:25 +08:00
|
|
|
private->fixed_width = g_value_get_boolean (value);
|
2005-09-04 03:48:22 +08:00
|
|
|
break;
|
|
|
|
case GIMP_RECTANGLE_OPTIONS_PROP_WIDTH:
|
2006-09-22 04:16:25 +08:00
|
|
|
private->width = g_value_get_double (value);
|
2005-09-04 03:48:22 +08:00
|
|
|
break;
|
|
|
|
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_HEIGHT:
|
2006-09-22 04:16:25 +08:00
|
|
|
private->fixed_height = g_value_get_boolean (value);
|
2005-09-04 03:48:22 +08:00
|
|
|
break;
|
|
|
|
case GIMP_RECTANGLE_OPTIONS_PROP_HEIGHT:
|
2006-09-22 04:16:25 +08:00
|
|
|
private->height = g_value_get_double (value);
|
2005-09-04 03:48:22 +08:00
|
|
|
break;
|
|
|
|
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_ASPECT:
|
2006-09-22 04:16:25 +08:00
|
|
|
private->fixed_aspect = g_value_get_boolean (value);
|
2005-09-04 03:48:22 +08:00
|
|
|
break;
|
2006-09-15 01:11:24 +08:00
|
|
|
case GIMP_RECTANGLE_OPTIONS_PROP_ASPECT_NUMERATOR:
|
2006-09-22 04:16:25 +08:00
|
|
|
private->aspect_numerator = g_value_get_double (value);
|
2006-09-15 01:11:24 +08:00
|
|
|
break;
|
|
|
|
case GIMP_RECTANGLE_OPTIONS_PROP_ASPECT_DENOMINATOR:
|
2006-09-22 04:16:25 +08:00
|
|
|
private->aspect_denominator = g_value_get_double (value);
|
2006-06-10 09:39:10 +08:00
|
|
|
break;
|
2005-09-04 03:48:22 +08:00
|
|
|
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_CENTER:
|
2006-09-22 04:16:25 +08:00
|
|
|
private->fixed_center = g_value_get_boolean (value);
|
2005-09-04 03:48:22 +08:00
|
|
|
break;
|
|
|
|
case GIMP_RECTANGLE_OPTIONS_PROP_CENTER_X:
|
2006-09-22 04:16:25 +08:00
|
|
|
private->center_x = g_value_get_double (value);
|
2005-09-04 03:48:22 +08:00
|
|
|
break;
|
|
|
|
case GIMP_RECTANGLE_OPTIONS_PROP_CENTER_Y:
|
2006-09-22 04:16:25 +08:00
|
|
|
private->center_y = g_value_get_double (value);
|
2005-09-04 03:48:22 +08:00
|
|
|
break;
|
|
|
|
case GIMP_RECTANGLE_OPTIONS_PROP_UNIT:
|
2006-09-22 04:16:25 +08:00
|
|
|
private->unit = g_value_get_int (value);
|
2006-03-26 21:50:13 +08:00
|
|
|
break;
|
2005-09-04 03:48:22 +08:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
gimp_rectangle_options_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
2006-09-22 04:16:25 +08:00
|
|
|
GimpRectangleOptions *options = GIMP_RECTANGLE_OPTIONS (object);
|
|
|
|
GimpRectangleOptionsPrivate *private;
|
|
|
|
|
|
|
|
private = GIMP_RECTANGLE_OPTIONS_GET_PRIVATE (options);
|
|
|
|
|
2005-09-04 03:48:22 +08:00
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case GIMP_RECTANGLE_OPTIONS_PROP_HIGHLIGHT:
|
2006-09-22 04:16:25 +08:00
|
|
|
g_value_set_boolean (value, private->highlight);
|
2005-09-04 03:48:22 +08:00
|
|
|
break;
|
2006-06-06 02:50:13 +08:00
|
|
|
case GIMP_RECTANGLE_OPTIONS_PROP_GUIDE:
|
2006-09-22 04:16:25 +08:00
|
|
|
g_value_set_enum (value, private->guide);
|
|
|
|
break;
|
|
|
|
case GIMP_RECTANGLE_OPTIONS_PROP_X0:
|
|
|
|
g_value_set_double (value, private->x0);
|
|
|
|
break;
|
|
|
|
case GIMP_RECTANGLE_OPTIONS_PROP_Y0:
|
|
|
|
g_value_set_double (value, private->y0);
|
2006-06-06 02:50:13 +08:00
|
|
|
break;
|
2005-09-04 03:48:22 +08:00
|
|
|
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_WIDTH:
|
2006-09-22 04:16:25 +08:00
|
|
|
g_value_set_boolean (value, private->fixed_width);
|
2005-09-04 03:48:22 +08:00
|
|
|
break;
|
|
|
|
case GIMP_RECTANGLE_OPTIONS_PROP_WIDTH:
|
2006-09-22 04:16:25 +08:00
|
|
|
g_value_set_double (value, private->width);
|
2005-09-04 03:48:22 +08:00
|
|
|
break;
|
|
|
|
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_HEIGHT:
|
2006-09-22 04:16:25 +08:00
|
|
|
g_value_set_boolean (value, private->fixed_height);
|
2005-09-04 03:48:22 +08:00
|
|
|
break;
|
|
|
|
case GIMP_RECTANGLE_OPTIONS_PROP_HEIGHT:
|
2006-09-22 04:16:25 +08:00
|
|
|
g_value_set_double (value, private->height);
|
2005-09-04 03:48:22 +08:00
|
|
|
break;
|
|
|
|
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_ASPECT:
|
2006-09-22 04:16:25 +08:00
|
|
|
g_value_set_boolean (value, private->fixed_aspect);
|
2005-09-04 03:48:22 +08:00
|
|
|
break;
|
2006-09-15 01:11:24 +08:00
|
|
|
case GIMP_RECTANGLE_OPTIONS_PROP_ASPECT_NUMERATOR:
|
2006-09-22 04:16:25 +08:00
|
|
|
g_value_set_double (value, private->aspect_numerator);
|
2006-09-15 01:11:24 +08:00
|
|
|
break;
|
|
|
|
case GIMP_RECTANGLE_OPTIONS_PROP_ASPECT_DENOMINATOR:
|
2006-09-22 04:16:25 +08:00
|
|
|
g_value_set_double (value, private->aspect_denominator);
|
2006-06-10 09:39:10 +08:00
|
|
|
break;
|
2005-09-04 03:48:22 +08:00
|
|
|
case GIMP_RECTANGLE_OPTIONS_PROP_FIXED_CENTER:
|
2006-09-22 04:16:25 +08:00
|
|
|
g_value_set_boolean (value, private->fixed_center);
|
2005-09-04 03:48:22 +08:00
|
|
|
break;
|
|
|
|
case GIMP_RECTANGLE_OPTIONS_PROP_CENTER_X:
|
2006-09-22 04:16:25 +08:00
|
|
|
g_value_set_double (value, private->center_x);
|
2005-09-04 03:48:22 +08:00
|
|
|
break;
|
|
|
|
case GIMP_RECTANGLE_OPTIONS_PROP_CENTER_Y:
|
2006-09-22 04:16:25 +08:00
|
|
|
g_value_set_double (value, private->center_y);
|
2005-09-04 03:48:22 +08:00
|
|
|
break;
|
|
|
|
case GIMP_RECTANGLE_OPTIONS_PROP_UNIT:
|
2006-09-22 04:16:25 +08:00
|
|
|
g_value_set_int (value, private->unit);
|
2006-03-26 21:50:13 +08:00
|
|
|
break;
|
2005-09-04 03:48:22 +08:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
2005-03-03 02:18:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
|
|
|
gimp_rectangle_options_gui (GimpToolOptions *tool_options)
|
|
|
|
{
|
2005-03-09 07:17:19 +08:00
|
|
|
GObject *config = G_OBJECT (tool_options);
|
2006-08-28 06:19:35 +08:00
|
|
|
GtkWidget *vbox = gimp_tool_options_gui (tool_options);
|
2005-03-09 07:17:19 +08:00
|
|
|
GtkWidget *button;
|
2006-06-06 02:50:13 +08:00
|
|
|
GtkWidget *combo;
|
2005-03-10 06:22:38 +08:00
|
|
|
GtkWidget *table;
|
|
|
|
GtkWidget *entry;
|
|
|
|
GtkWidget *hbox;
|
|
|
|
GtkWidget *label;
|
2005-03-03 02:18:19 +08:00
|
|
|
|
2006-06-10 09:39:10 +08:00
|
|
|
button = gimp_prop_check_button_new (config, "fixed-center",
|
|
|
|
_("Expand from center"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2005-03-03 02:18:19 +08:00
|
|
|
button = gimp_prop_check_button_new (config, "highlight",
|
|
|
|
_("Highlight"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
|
|
|
|
2005-03-10 06:22:38 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 0);
|
2006-09-22 04:16:25 +08:00
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
|
2005-03-10 06:22:38 +08:00
|
|
|
gtk_widget_show (hbox);
|
|
|
|
|
2005-10-21 00:53:54 +08:00
|
|
|
table = gtk_table_new (4, 3, FALSE);
|
2005-03-10 06:22:38 +08:00
|
|
|
gtk_table_set_col_spacings (GTK_TABLE (table), 5);
|
2006-09-22 04:16:25 +08:00
|
|
|
gtk_table_set_row_spacings (GTK_TABLE (table), 5);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), table, FALSE, FALSE, 5);
|
2005-03-10 06:22:38 +08:00
|
|
|
|
2006-09-22 04:16:25 +08:00
|
|
|
/* Height */
|
|
|
|
button = gimp_prop_toggle_button_new (config, "fixed-width",
|
|
|
|
_("Fix"), FALSE);
|
2005-03-10 06:22:38 +08:00
|
|
|
gtk_widget_show (button);
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), button, 0, 1, 1, 2);
|
2006-09-22 04:16:25 +08:00
|
|
|
|
2005-03-10 06:22:38 +08:00
|
|
|
entry = gimp_prop_size_entry_new (config, "width", "unit", "%a",
|
|
|
|
GIMP_SIZE_ENTRY_UPDATE_SIZE, 300);
|
2006-09-22 04:16:25 +08:00
|
|
|
label = gtk_label_new (_("Width"));
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 1, 2);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
2005-03-10 06:22:38 +08:00
|
|
|
gimp_size_entry_show_unit_menu (GIMP_SIZE_ENTRY (entry), FALSE);
|
2006-09-22 04:16:25 +08:00
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), entry, 2, 3, 1, 2);
|
2005-03-10 06:22:38 +08:00
|
|
|
gtk_widget_show (entry);
|
|
|
|
|
2006-09-22 04:16:25 +08:00
|
|
|
/* Height */
|
|
|
|
button = gimp_prop_toggle_button_new (config, "fixed-height",
|
|
|
|
_("Fix"), FALSE);
|
2005-03-10 06:22:38 +08:00
|
|
|
gtk_widget_show (button);
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), button, 0, 1, 2, 3);
|
2006-09-22 04:16:25 +08:00
|
|
|
|
|
|
|
label = gtk_label_new (_("Height"));
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 2, 3);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
2005-03-10 06:22:38 +08:00
|
|
|
entry = gimp_prop_size_entry_new (config, "height", "unit", "%a",
|
|
|
|
GIMP_SIZE_ENTRY_UPDATE_SIZE, 300);
|
|
|
|
gimp_size_entry_show_unit_menu (GIMP_SIZE_ENTRY (entry), FALSE);
|
2006-09-22 04:16:25 +08:00
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), entry, 2, 3, 2, 3);
|
2005-03-10 06:22:38 +08:00
|
|
|
gtk_widget_show (entry);
|
|
|
|
|
2006-09-22 04:16:25 +08:00
|
|
|
/* Aspect */
|
|
|
|
button = gimp_prop_toggle_button_new (config, "fixed-aspect",
|
|
|
|
_("Fix"), FALSE);
|
2005-03-10 06:22:38 +08:00
|
|
|
gtk_widget_show (button);
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), button, 0, 1, 3, 4);
|
2006-09-15 01:11:24 +08:00
|
|
|
|
2006-09-22 04:16:25 +08:00
|
|
|
label = gtk_label_new (_("Aspect"));
|
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), label, 1, 2, 3, 4);
|
|
|
|
gtk_widget_show (label);
|
|
|
|
|
2006-09-15 01:11:24 +08:00
|
|
|
hbox = gimp_prop_aspect_ratio_new (config,
|
|
|
|
"aspect-numerator",
|
|
|
|
"aspect-denominator",
|
|
|
|
3);
|
2006-09-22 04:16:25 +08:00
|
|
|
gtk_table_attach_defaults (GTK_TABLE (table), hbox, 2, 3, 3, 4);
|
2006-09-15 01:11:24 +08:00
|
|
|
gtk_widget_show (hbox);
|
2005-03-10 06:22:38 +08:00
|
|
|
|
|
|
|
gtk_widget_show (table);
|
|
|
|
|
2006-09-22 04:16:25 +08:00
|
|
|
hbox = gtk_hbox_new (FALSE, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 10);
|
|
|
|
gtk_widget_show (hbox);
|
2006-03-26 21:50:13 +08:00
|
|
|
|
2006-09-22 04:16:25 +08:00
|
|
|
combo = gimp_prop_enum_combo_box_new (config, "guide", 0, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (combo);
|
2005-03-09 07:17:19 +08:00
|
|
|
|
2005-03-03 02:18:19 +08:00
|
|
|
return vbox;
|
|
|
|
}
|