1 /* GIMP - The GNU Image Manipulation Program
2  * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
16  */
17 
18 #include "config.h"
19 
20 #include <gdk-pixbuf/gdk-pixbuf.h>
21 #include <gegl.h>
22 
23 #include "libgimpconfig/gimpconfig.h"
24 
25 #include "paint-types.h"
26 
27 #include "gimperaseroptions.h"
28 
29 #include "gimp-intl.h"
30 
31 
32 #define ERASER_DEFAULT_ANTI_ERASE FALSE
33 
34 
35 enum
36 {
37   PROP_0,
38   PROP_ANTI_ERASE
39 };
40 
41 
42 static void   gimp_eraser_options_set_property (GObject         *object,
43                                                 guint            property_id,
44                                                 const GValue    *value,
45                                                 GParamSpec      *pspec);
46 static void   gimp_eraser_options_get_property (GObject         *object,
47                                                 guint            property_id,
48                                                 GValue          *value,
49                                                 GParamSpec      *pspec);
50 
51 
G_DEFINE_TYPE(GimpEraserOptions,gimp_eraser_options,GIMP_TYPE_PAINT_OPTIONS)52 G_DEFINE_TYPE (GimpEraserOptions, gimp_eraser_options,
53                GIMP_TYPE_PAINT_OPTIONS)
54 
55 
56 static void
57 gimp_eraser_options_class_init (GimpEraserOptionsClass *klass)
58 {
59   GObjectClass *object_class = G_OBJECT_CLASS (klass);
60 
61   object_class->set_property = gimp_eraser_options_set_property;
62   object_class->get_property = gimp_eraser_options_get_property;
63 
64   GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_ANTI_ERASE,
65                             "anti-erase",
66                             _("Anti erase"),
67                             NULL,
68                             ERASER_DEFAULT_ANTI_ERASE,
69                             GIMP_PARAM_STATIC_STRINGS);
70 }
71 
72 static void
gimp_eraser_options_init(GimpEraserOptions * options)73 gimp_eraser_options_init (GimpEraserOptions *options)
74 {
75 }
76 
77 static void
gimp_eraser_options_set_property(GObject * object,guint property_id,const GValue * value,GParamSpec * pspec)78 gimp_eraser_options_set_property (GObject      *object,
79                                   guint         property_id,
80                                   const GValue *value,
81                                   GParamSpec   *pspec)
82 {
83   GimpEraserOptions *options = GIMP_ERASER_OPTIONS (object);
84 
85   switch (property_id)
86     {
87     case PROP_ANTI_ERASE:
88       options->anti_erase = g_value_get_boolean (value);
89       break;
90     default:
91       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
92       break;
93     }
94 }
95 
96 static void
gimp_eraser_options_get_property(GObject * object,guint property_id,GValue * value,GParamSpec * pspec)97 gimp_eraser_options_get_property (GObject    *object,
98                                  guint       property_id,
99                                  GValue     *value,
100                                  GParamSpec *pspec)
101 {
102   GimpEraserOptions *options = GIMP_ERASER_OPTIONS (object);
103 
104   switch (property_id)
105     {
106     case PROP_ANTI_ERASE:
107       g_value_set_boolean (value, options->anti_erase);
108       break;
109     default:
110       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
111       break;
112     }
113 }
114