gimpairbrushoptions.c 4.79 KB
Newer Older
1
/* GIMP - The GNU Image Manipulation Program
2 3
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
 *
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 8 9 10 11 12 13 14
 * (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
15
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 17 18 19
 */

#include "config.h"

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 28
#include "gimpairbrushoptions.h"

29 30
#include "gimp-intl.h"

31

32 33
#define AIRBRUSH_DEFAULT_RATE        80.0
#define AIRBRUSH_DEFAULT_FLOW        10.0
34
#define AIRBRUSH_DEFAULT_MOTION_ONLY FALSE
35

36 37 38 39
enum
{
  PROP_0,
  PROP_RATE,
40
  PROP_MOTION_ONLY,
41 42
  PROP_FLOW,
  PROP_PRESSURE /*for backwards copatibility of tool options*/
43 44 45 46 47 48 49 50 51 52 53 54 55
};


static void   gimp_airbrush_options_set_property (GObject      *object,
                                                  guint         property_id,
                                                  const GValue *value,
                                                  GParamSpec   *pspec);
static void   gimp_airbrush_options_get_property (GObject      *object,
                                                  guint         property_id,
                                                  GValue       *value,
                                                  GParamSpec   *pspec);


Michael Natterer's avatar
Michael Natterer committed
56
G_DEFINE_TYPE (GimpAirbrushOptions, gimp_airbrush_options,
57
               GIMP_TYPE_PAINT_OPTIONS)
58

59

60
static void
61 62
gimp_airbrush_options_class_init (GimpAirbrushOptionsClass *klass)
{
63
  GObjectClass *object_class = G_OBJECT_CLASS (klass);
64 65 66 67

  object_class->set_property = gimp_airbrush_options_set_property;
  object_class->get_property = gimp_airbrush_options_get_property;

68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
  GIMP_CONFIG_PROP_DOUBLE (object_class, PROP_RATE,
                           "rate",
                           C_("airbrush-tool", "Rate"),
                           NULL,
                           0.0, 150.0, AIRBRUSH_DEFAULT_RATE,
                           GIMP_PARAM_STATIC_STRINGS);


  GIMP_CONFIG_PROP_BOOLEAN (object_class, PROP_MOTION_ONLY,
                            "motion-only",
                            _("Motion only"),
                            NULL,
                            AIRBRUSH_DEFAULT_MOTION_ONLY,
                            GIMP_PARAM_STATIC_STRINGS);

  GIMP_CONFIG_PROP_DOUBLE (object_class, PROP_FLOW,
                           "flow",
                           _("Flow"),
                           NULL,
                           0.0, 100.0, AIRBRUSH_DEFAULT_FLOW,
                           GIMP_PARAM_STATIC_STRINGS);

  /* backwads-compadibility prop for flow fomerly known as pressure */
  GIMP_CONFIG_PROP_DOUBLE (object_class, PROP_PRESSURE,
                           "pressure",
                           NULL, NULL,
                           0.0, 100.0, AIRBRUSH_DEFAULT_FLOW,
                           GIMP_CONFIG_PARAM_IGNORE);
96 97
}

Michael Natterer's avatar
Michael Natterer committed
98 99 100 101 102
static void
gimp_airbrush_options_init (GimpAirbrushOptions *options)
{
}

103 104 105 106 107 108
static void
gimp_airbrush_options_set_property (GObject      *object,
                                    guint         property_id,
                                    const GValue *value,
                                    GParamSpec   *pspec)
{
109
  GimpAirbrushOptions *options = GIMP_AIRBRUSH_OPTIONS (object);
110 111 112 113 114 115

  switch (property_id)
    {
    case PROP_RATE:
      options->rate = g_value_get_double (value);
      break;
116 117 118
    case PROP_MOTION_ONLY:
      options->motion_only = g_value_get_boolean (value);
      break;
119
    case PROP_PRESSURE:
120 121
    case PROP_FLOW:
      options->flow = g_value_get_double (value);
122
      break;
123

124 125 126 127 128 129 130 131 132 133 134 135
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
      break;
    }
}

static void
gimp_airbrush_options_get_property (GObject    *object,
                                    guint       property_id,
                                    GValue     *value,
                                    GParamSpec *pspec)
{
136
  GimpAirbrushOptions *options = GIMP_AIRBRUSH_OPTIONS (object);
137 138 139 140 141 142

  switch (property_id)
    {
    case PROP_RATE:
      g_value_set_double (value, options->rate);
      break;
143 144 145
    case PROP_MOTION_ONLY:
      g_value_set_boolean (value, options->motion_only);
      break;
146
    case PROP_PRESSURE:
147 148
    case PROP_FLOW:
      g_value_set_double (value, options->flow);
149
      break;
150

151 152 153 154
    default:
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
      break;
    }
155
}