2008-10-25 01:55:30 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
|
|
|
* Copyright (C) 1995-1999 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* gimpfilleditor.c
|
|
|
|
* Copyright (C) 2008 Michael Natterer <mitch@gimp.org>
|
|
|
|
*
|
2009-01-18 06:28:01 +08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
2008-10-25 01:55:30 +08:00
|
|
|
* it under the terms of the GNU General Public License as published by
|
2009-01-18 06:28:01 +08:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2008-10-25 01:55:30 +08: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
|
2009-01-18 06:28:01 +08:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2008-10-25 01:55:30 +08:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2013-11-02 05:28:18 +08:00
|
|
|
#include <gegl.h>
|
2008-10-25 01:55:30 +08:00
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
#include "libgimpbase/gimpbase.h"
|
|
|
|
#include "libgimpwidgets/gimpwidgets.h"
|
|
|
|
|
|
|
|
#include "widgets-types.h"
|
|
|
|
|
|
|
|
#include "core/gimpfilloptions.h"
|
|
|
|
|
2008-10-25 06:34:24 +08:00
|
|
|
#include "gimpcolorpanel.h"
|
2008-10-25 01:55:30 +08:00
|
|
|
#include "gimpfilleditor.h"
|
2008-10-25 06:34:24 +08:00
|
|
|
#include "gimppropwidgets.h"
|
|
|
|
#include "gimpviewablebox.h"
|
|
|
|
#include "gimpwidgets-utils.h"
|
2008-10-25 01:55:30 +08:00
|
|
|
|
|
|
|
#include "gimp-intl.h"
|
|
|
|
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_OPTIONS,
|
2008-10-25 06:34:24 +08:00
|
|
|
PROP_EDIT_CONTEXT
|
2008-10-25 01:55:30 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-01-14 16:38:11 +08:00
|
|
|
static void gimp_fill_editor_constructed (GObject *object);
|
|
|
|
static void gimp_fill_editor_finalize (GObject *object);
|
|
|
|
static void gimp_fill_editor_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec);
|
|
|
|
static void gimp_fill_editor_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec);
|
2008-10-25 01:55:30 +08:00
|
|
|
|
|
|
|
|
2010-10-30 21:44:46 +08:00
|
|
|
G_DEFINE_TYPE (GimpFillEditor, gimp_fill_editor, GTK_TYPE_BOX)
|
2008-10-25 01:55:30 +08:00
|
|
|
|
|
|
|
#define parent_class gimp_fill_editor_parent_class
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_fill_editor_class_init (GimpFillEditorClass *klass)
|
|
|
|
{
|
|
|
|
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
|
|
|
|
2011-01-14 16:38:11 +08:00
|
|
|
object_class->constructed = gimp_fill_editor_constructed;
|
2008-10-25 01:55:30 +08:00
|
|
|
object_class->finalize = gimp_fill_editor_finalize;
|
|
|
|
object_class->set_property = gimp_fill_editor_set_property;
|
|
|
|
object_class->get_property = gimp_fill_editor_get_property;
|
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_OPTIONS,
|
2008-10-25 06:34:24 +08:00
|
|
|
g_param_spec_object ("options",
|
|
|
|
NULL, NULL,
|
2008-10-25 01:55:30 +08:00
|
|
|
GIMP_TYPE_FILL_OPTIONS,
|
|
|
|
GIMP_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
2008-10-25 06:34:24 +08:00
|
|
|
|
|
|
|
g_object_class_install_property (object_class, PROP_EDIT_CONTEXT,
|
|
|
|
g_param_spec_boolean ("edit-context",
|
|
|
|
NULL, NULL,
|
|
|
|
FALSE,
|
|
|
|
GIMP_PARAM_READWRITE |
|
|
|
|
G_PARAM_CONSTRUCT_ONLY));
|
2008-10-25 01:55:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_fill_editor_init (GimpFillEditor *editor)
|
|
|
|
{
|
2010-10-30 21:44:46 +08:00
|
|
|
gtk_orientable_set_orientation (GTK_ORIENTABLE (editor),
|
|
|
|
GTK_ORIENTATION_VERTICAL);
|
|
|
|
|
2008-10-29 21:30:47 +08:00
|
|
|
gtk_box_set_spacing (GTK_BOX (editor), 6);
|
2008-10-25 01:55:30 +08:00
|
|
|
}
|
|
|
|
|
2011-01-14 16:38:11 +08:00
|
|
|
static void
|
|
|
|
gimp_fill_editor_constructed (GObject *object)
|
2008-10-25 01:55:30 +08:00
|
|
|
{
|
2011-01-14 16:38:11 +08:00
|
|
|
GimpFillEditor *editor = GIMP_FILL_EDITOR (object);
|
2008-10-25 01:55:30 +08:00
|
|
|
GtkWidget *box;
|
2008-10-29 21:30:47 +08:00
|
|
|
GtkWidget *button;
|
2008-10-25 01:55:30 +08:00
|
|
|
|
2012-11-13 04:51:22 +08:00
|
|
|
G_OBJECT_CLASS (parent_class)->constructed (object);
|
2008-10-25 01:55:30 +08:00
|
|
|
|
2018-02-12 05:23:10 +08:00
|
|
|
gimp_assert (GIMP_IS_FILL_OPTIONS (editor->options));
|
2008-10-25 01:55:30 +08:00
|
|
|
|
|
|
|
box = gimp_prop_enum_radio_box_new (G_OBJECT (editor->options), "style",
|
|
|
|
0, 0);
|
|
|
|
gtk_box_pack_start (GTK_BOX (editor), box, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (box);
|
|
|
|
|
2008-10-25 06:34:24 +08:00
|
|
|
if (editor->edit_context)
|
|
|
|
{
|
|
|
|
GtkWidget *color_button;
|
|
|
|
GtkWidget *pattern_box;
|
|
|
|
|
|
|
|
color_button = gimp_prop_color_button_new (G_OBJECT (editor->options),
|
|
|
|
"foreground",
|
|
|
|
_("Fill Color"),
|
|
|
|
-1, 24,
|
|
|
|
GIMP_COLOR_AREA_SMALL_CHECKS);
|
|
|
|
gimp_color_panel_set_context (GIMP_COLOR_PANEL (color_button),
|
|
|
|
GIMP_CONTEXT (editor->options));
|
|
|
|
gimp_enum_radio_box_add (GTK_BOX (box), color_button,
|
2008-10-29 01:40:32 +08:00
|
|
|
GIMP_FILL_STYLE_SOLID, FALSE);
|
2008-10-25 06:34:24 +08:00
|
|
|
|
|
|
|
pattern_box = gimp_prop_pattern_box_new (NULL,
|
2010-11-02 21:05:47 +08:00
|
|
|
GIMP_CONTEXT (editor->options),
|
|
|
|
NULL, 2,
|
2008-10-25 06:34:24 +08:00
|
|
|
"pattern-view-type",
|
|
|
|
"pattern-view-size");
|
|
|
|
gimp_enum_radio_box_add (GTK_BOX (box), pattern_box,
|
2008-10-29 01:40:32 +08:00
|
|
|
GIMP_FILL_STYLE_PATTERN, FALSE);
|
2008-10-25 06:34:24 +08:00
|
|
|
}
|
|
|
|
|
2008-10-29 21:30:47 +08:00
|
|
|
button = gimp_prop_check_button_new (G_OBJECT (editor->options),
|
|
|
|
"antialias",
|
|
|
|
_("_Antialiasing"));
|
|
|
|
gtk_box_pack_start (GTK_BOX (editor), button, FALSE, FALSE, 0);
|
|
|
|
gtk_widget_show (button);
|
2008-10-25 01:55:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_fill_editor_finalize (GObject *object)
|
|
|
|
{
|
|
|
|
GimpFillEditor *editor = GIMP_FILL_EDITOR (object);
|
|
|
|
|
2017-07-16 00:38:01 +08:00
|
|
|
g_clear_object (&editor->options);
|
2008-10-25 01:55:30 +08:00
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_fill_editor_set_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
const GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpFillEditor *editor = GIMP_FILL_EDITOR (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_OPTIONS:
|
|
|
|
if (editor->options)
|
|
|
|
g_object_unref (editor->options);
|
|
|
|
editor->options = g_value_dup_object (value);
|
|
|
|
break;
|
|
|
|
|
2008-10-25 06:34:24 +08:00
|
|
|
case PROP_EDIT_CONTEXT:
|
|
|
|
editor->edit_context = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
|
2008-10-25 01:55:30 +08:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gimp_fill_editor_get_property (GObject *object,
|
|
|
|
guint property_id,
|
|
|
|
GValue *value,
|
|
|
|
GParamSpec *pspec)
|
|
|
|
{
|
|
|
|
GimpFillEditor *editor = GIMP_FILL_EDITOR (object);
|
|
|
|
|
|
|
|
switch (property_id)
|
|
|
|
{
|
|
|
|
case PROP_OPTIONS:
|
|
|
|
g_value_set_object (value, editor->options);
|
|
|
|
break;
|
|
|
|
|
2008-10-25 06:34:24 +08:00
|
|
|
case PROP_EDIT_CONTEXT:
|
|
|
|
g_value_set_boolean (value, editor->edit_context);
|
|
|
|
break;
|
|
|
|
|
2008-10-25 01:55:30 +08:00
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
GtkWidget *
|
2008-10-25 06:34:24 +08:00
|
|
|
gimp_fill_editor_new (GimpFillOptions *options,
|
|
|
|
gboolean edit_context)
|
2008-10-25 01:55:30 +08:00
|
|
|
{
|
|
|
|
g_return_val_if_fail (GIMP_IS_FILL_OPTIONS (options), NULL);
|
|
|
|
|
|
|
|
return g_object_new (GIMP_TYPE_FILL_EDITOR,
|
2008-10-25 06:34:24 +08:00
|
|
|
"options", options,
|
|
|
|
"edit-context", edit_context ? TRUE : FALSE,
|
2008-10-25 01:55:30 +08:00
|
|
|
NULL);
|
|
|
|
}
|