~ubuntu-branches/ubuntu/jaunty/gimp/jaunty-security

« back to all changes in this revision

Viewing changes to app/tools/gimprectangleselectoptions.c

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Holbach
  • Date: 2007-05-02 16:33:03 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20070502163303-bvzhjzbpw8qglc4y
Tags: 2.3.16-1ubuntu1
* Resynchronized with Debian, remaining Ubuntu changes:
  - debian/rules: i18n magic.
* debian/control.in:
  - Maintainer: Ubuntu Core Developers <ubuntu-devel@lists.ubuntu.com>
* debian/patches/02_help-message.patch,
  debian/patches/03_gimp.desktop.in.in.patch,
  debian/patches/10_dont_show_wizard.patch: updated.
* debian/patches/04_composite-signedness.patch,
  debian/patches/05_add-letter-spacing.patch: dropped, used upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 2 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, write to the Free Software
 
16
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
17
 */
 
18
 
 
19
#include "config.h"
 
20
 
 
21
#include <gtk/gtk.h>
 
22
 
 
23
#include "libgimpconfig/gimpconfig.h"
 
24
#include "libgimpwidgets/gimpwidgets.h"
 
25
 
 
26
#include "tools-types.h"
 
27
 
 
28
#include "core/gimptoolinfo.h"
 
29
 
 
30
#include "widgets/gimppropwidgets.h"
 
31
 
 
32
#include "gimprectangleoptions.h"
 
33
#include "gimprectangleselectoptions.h"
 
34
#include "gimprectangleselecttool.h"
 
35
#include "gimptooloptions-gui.h"
 
36
 
 
37
#include "gimp-intl.h"
 
38
 
 
39
 
 
40
enum
 
41
{
 
42
  PROP_ROUND_CORNERS = GIMP_RECTANGLE_OPTIONS_PROP_LAST + 1,
 
43
  PROP_CORNER_RADIUS
 
44
};
 
45
 
 
46
 
 
47
static void   gimp_rect_select_options_set_property (GObject      *object,
 
48
                                                     guint         property_id,
 
49
                                                     const GValue *value,
 
50
                                                     GParamSpec   *pspec);
 
51
static void   gimp_rect_select_options_get_property (GObject      *object,
 
52
                                                     guint         property_id,
 
53
                                                     GValue       *value,
 
54
                                                     GParamSpec   *pspec);
 
55
 
 
56
 
 
57
G_DEFINE_TYPE_WITH_CODE (GimpRectSelectOptions, gimp_rect_select_options,
 
58
                         GIMP_TYPE_SELECTION_OPTIONS,
 
59
                         G_IMPLEMENT_INTERFACE (GIMP_TYPE_RECTANGLE_OPTIONS,
 
60
                                                NULL))
 
61
 
 
62
 
 
63
static void
 
64
gimp_rect_select_options_class_init (GimpRectSelectOptionsClass *klass)
 
65
{
 
66
  GObjectClass *object_class = G_OBJECT_CLASS (klass);
 
67
 
 
68
  object_class->set_property = gimp_rect_select_options_set_property;
 
69
  object_class->get_property = gimp_rect_select_options_get_property;
 
70
 
 
71
  GIMP_CONFIG_INSTALL_PROP_BOOLEAN (object_class, PROP_ROUND_CORNERS,
 
72
                                    "round-corners", NULL,
 
73
                                    FALSE,
 
74
                                    GIMP_PARAM_STATIC_STRINGS);
 
75
 
 
76
  GIMP_CONFIG_INSTALL_PROP_DOUBLE (object_class, PROP_CORNER_RADIUS,
 
77
                                   "corner-radius", NULL,
 
78
                                   0.0, 100.0, 5.0,
 
79
                                   GIMP_PARAM_STATIC_STRINGS);
 
80
 
 
81
  gimp_rectangle_options_install_properties (object_class);
 
82
}
 
83
 
 
84
static void
 
85
gimp_rect_select_options_init (GimpRectSelectOptions *options)
 
86
{
 
87
}
 
88
 
 
89
static void
 
90
gimp_rect_select_options_set_property (GObject      *object,
 
91
                                       guint         property_id,
 
92
                                       const GValue *value,
 
93
                                       GParamSpec   *pspec)
 
94
{
 
95
  GimpRectSelectOptions *options = GIMP_RECT_SELECT_OPTIONS (object);
 
96
 
 
97
  switch (property_id)
 
98
    {
 
99
    case PROP_ROUND_CORNERS:
 
100
      options->round_corners = g_value_get_boolean (value);
 
101
      break;
 
102
 
 
103
    case PROP_CORNER_RADIUS:
 
104
      options->corner_radius = g_value_get_double (value);
 
105
      break;
 
106
 
 
107
    default:
 
108
      gimp_rectangle_options_set_property (object, property_id, value, pspec);
 
109
      break;
 
110
    }
 
111
}
 
112
 
 
113
static void
 
114
gimp_rect_select_options_get_property (GObject      *object,
 
115
                                       guint         property_id,
 
116
                                       GValue       *value,
 
117
                                       GParamSpec   *pspec)
 
118
{
 
119
  GimpRectSelectOptions *options = GIMP_RECT_SELECT_OPTIONS (object);
 
120
 
 
121
  switch (property_id)
 
122
    {
 
123
    case PROP_ROUND_CORNERS:
 
124
      g_value_set_boolean (value, options->round_corners);
 
125
      break;
 
126
 
 
127
    case PROP_CORNER_RADIUS:
 
128
      g_value_set_double (value, options->corner_radius);
 
129
      break;
 
130
 
 
131
    default:
 
132
      gimp_rectangle_options_get_property (object, property_id, value, pspec);
 
133
      break;
 
134
    }
 
135
}
 
136
 
 
137
GtkWidget *
 
138
gimp_rect_select_options_gui (GimpToolOptions *tool_options)
 
139
{
 
140
  GObject   *config = G_OBJECT (tool_options);
 
141
  GtkWidget *vbox   = gimp_selection_options_gui (tool_options);
 
142
 
 
143
  /*  the round corners frame  */
 
144
  if (tool_options->tool_info->tool_type == GIMP_TYPE_RECT_SELECT_TOOL)
 
145
    {
 
146
      GtkWidget *frame;
 
147
      GtkWidget *button;
 
148
      GtkWidget *table;
 
149
 
 
150
      table = gtk_table_new (1, 3, FALSE);
 
151
      gtk_table_set_col_spacings (GTK_TABLE (table), 2);
 
152
 
 
153
      frame = gimp_prop_expanding_frame_new (config, "round-corners",
 
154
                                             _("Rounded corners"),
 
155
                                             table, &button);
 
156
      gtk_box_pack_start (GTK_BOX (vbox), frame, FALSE, FALSE, 0);
 
157
      gtk_widget_show (frame);
 
158
 
 
159
      g_object_set_data (G_OBJECT (button), "set_sensitive",
 
160
                         GIMP_SELECTION_OPTIONS (tool_options)->antialias_toggle);
 
161
      gtk_widget_set_sensitive (GIMP_SELECTION_OPTIONS (tool_options)->antialias_toggle,
 
162
                                GIMP_RECT_SELECT_OPTIONS (tool_options)->round_corners);
 
163
 
 
164
      gimp_prop_scale_entry_new (config, "corner-radius",
 
165
                                 GTK_TABLE (table), 0, 0,
 
166
                                 _("Radius:"),
 
167
                                 0.0, 100.0, 1,
 
168
                                 FALSE, 0.0, 0.0);
 
169
  }
 
170
 
 
171
  /*  the rectangle options  */
 
172
  {
 
173
    GtkWidget *vbox_rectangle;
 
174
 
 
175
    vbox_rectangle = gimp_rectangle_options_gui (tool_options);
 
176
    gtk_box_pack_start (GTK_BOX (vbox), vbox_rectangle, FALSE, FALSE, 0);
 
177
    gtk_widget_show (vbox_rectangle);
 
178
 
 
179
    g_object_set (GIMP_RECTANGLE_OPTIONS (tool_options),
 
180
                  "highlight", FALSE,
 
181
                  NULL);
 
182
  }
 
183
 
 
184
  return vbox;
 
185
}