~ubuntu-branches/ubuntu/vivid/gimp/vivid

« back to all changes in this revision

Viewing changes to app/widgets/gimpbrushfactoryview.c

  • Committer: Package Import Robot
  • Author(s): Jordi Mallach
  • Date: 2012-05-08 18:50:03 UTC
  • mto: (1.1.26) (0.5.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 71.
  • Revision ID: package-import@ubuntu.com-20120508185003-tltkvbaysf8d2426
ImportĀ upstreamĀ versionĀ 2.8.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
 * gimpbrushfactoryview.c
5
5
 * Copyright (C) 2001 Michael Natterer <mitch@gimp.org>
6
6
 *
7
 
 * This program is free software; you can redistribute it and/or modify
 
7
 * This program is free software: you can redistribute it and/or modify
8
8
 * it under the terms of the GNU General Public License as published by
9
 
 * the Free Software Foundation; either version 2 of the License, or
 
9
 * the Free Software Foundation; either version 3 of the License, or
10
10
 * (at your option) any later version.
11
11
 *
12
12
 * This program is distributed in the hope that it will be useful,
15
15
 * GNU General Public License for more details.
16
16
 *
17
17
 * You should have received a copy of the GNU General Public License
18
 
 * along with this program; if not, write to the Free Software
19
 
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
19
 */
21
20
 
22
21
#include "config.h"
33
32
#include "core/gimpbrushgenerated.h"
34
33
#include "core/gimpdatafactory.h"
35
34
 
 
35
#include "gimpbrushfactoryview.h"
36
36
#include "gimpcontainerview.h"
37
 
#include "gimpbrushfactoryview.h"
 
37
#include "gimpmenufactory.h"
 
38
#include "gimpspinscale.h"
38
39
#include "gimpviewrenderer.h"
39
40
 
40
41
#include "gimp-intl.h"
41
42
 
42
43
 
43
 
static void   gimp_brush_factory_view_destroy         (GtkObject            *object);
 
44
static void   gimp_brush_factory_view_dispose         (GObject              *object);
44
45
 
45
46
static void   gimp_brush_factory_view_select_item     (GimpContainerEditor  *editor,
46
47
                                                       GimpViewable         *viewable);
60
61
static void
61
62
gimp_brush_factory_view_class_init (GimpBrushFactoryViewClass *klass)
62
63
{
63
 
  GtkObjectClass           *object_class = GTK_OBJECT_CLASS (klass);
 
64
  GObjectClass             *object_class = G_OBJECT_CLASS (klass);
64
65
  GimpContainerEditorClass *editor_class = GIMP_CONTAINER_EDITOR_CLASS (klass);
65
66
 
66
 
  object_class->destroy     = gimp_brush_factory_view_destroy;
 
67
  object_class->dispose     = gimp_brush_factory_view_dispose;
67
68
 
68
69
  editor_class->select_item = gimp_brush_factory_view_select_item;
69
70
}
71
72
static void
72
73
gimp_brush_factory_view_init (GimpBrushFactoryView *view)
73
74
{
74
 
  GtkWidget *table;
75
 
 
76
 
  table = gtk_table_new (1, 3, FALSE);
77
 
  gtk_table_set_col_spacings (GTK_TABLE (table), 2);
78
 
  gtk_widget_show (table);
79
 
 
80
75
  view->spacing_adjustment =
81
 
    GTK_ADJUSTMENT (gimp_scale_entry_new (GTK_TABLE (table), 0, 0,
82
 
                                          _("Spacing:"), -1, -1,
83
 
                                          0.0, 1.0, 200.0, 1.0, 10.0, 1,
84
 
                                          FALSE, 1.0, 5000.0,
85
 
                                          _("Percentage of width of brush"),
86
 
                                          NULL));
 
76
    GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 1.0, 5000.0,
 
77
                                        1.0, 10.0, 0.0));
87
78
 
88
 
  view->spacing_scale = GIMP_SCALE_ENTRY_SCALE (view->spacing_adjustment);
 
79
  view->spacing_scale = gimp_spin_scale_new (view->spacing_adjustment,
 
80
                                             _("Spacing"), 1);
 
81
  gimp_spin_scale_set_scale_limits (GIMP_SPIN_SCALE (view->spacing_scale),
 
82
                                   1.0, 200.0);
 
83
  gimp_help_set_help_data (view->spacing_scale,
 
84
                           _("Percentage of width of brush"),
 
85
                           NULL);
89
86
 
90
87
  g_signal_connect (view->spacing_adjustment, "value-changed",
91
88
                    G_CALLBACK (gimp_brush_factory_view_spacing_update),
92
89
                    view);
93
 
 
94
 
  view->spacing_changed_handler_id = 0;
95
90
}
96
91
 
97
92
static void
98
 
gimp_brush_factory_view_destroy (GtkObject *object)
 
93
gimp_brush_factory_view_dispose (GObject *object)
99
94
{
100
95
  GimpBrushFactoryView *view   = GIMP_BRUSH_FACTORY_VIEW (object);
101
96
  GimpContainerEditor  *editor = GIMP_CONTAINER_EDITOR (object);
102
97
 
103
98
  if (view->spacing_changed_handler_id)
104
99
    {
105
 
      GimpContainer *container;
 
100
      GimpDataFactory *factory;
 
101
      GimpContainer   *container;
106
102
 
107
 
      container = gimp_container_view_get_container (editor->view);
 
103
      factory   = gimp_data_factory_view_get_data_factory (GIMP_DATA_FACTORY_VIEW (editor));
 
104
      container = gimp_data_factory_get_container (factory);
108
105
 
109
106
      gimp_container_remove_handler (container,
110
107
                                     view->spacing_changed_handler_id);
112
109
      view->spacing_changed_handler_id = 0;
113
110
    }
114
111
 
115
 
  GTK_OBJECT_CLASS (parent_class)->destroy (object);
 
112
  G_OBJECT_CLASS (parent_class)->dispose (object);
116
113
}
117
114
 
118
115
GtkWidget *
128
125
  GimpContainerEditor  *editor;
129
126
 
130
127
  g_return_val_if_fail (GIMP_IS_DATA_FACTORY (factory), NULL);
 
128
  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);
131
129
  g_return_val_if_fail (view_size > 0 &&
132
130
                        view_size <= GIMP_VIEWABLE_MAX_PREVIEW_SIZE, NULL);
133
131
  g_return_val_if_fail (view_border_width >= 0 &&
134
132
                        view_border_width <= GIMP_VIEW_MAX_BORDER_WIDTH,
135
133
                        NULL);
 
134
  g_return_val_if_fail (menu_factory == NULL ||
 
135
                        GIMP_IS_MENU_FACTORY (menu_factory), NULL);
136
136
 
137
 
  factory_view = g_object_new (GIMP_TYPE_BRUSH_FACTORY_VIEW, NULL);
 
137
  factory_view = g_object_new (GIMP_TYPE_BRUSH_FACTORY_VIEW,
 
138
                               "view-type",         view_type,
 
139
                               "data-factory",      factory,
 
140
                               "context",           context,
 
141
                               "view-size",         view_size,
 
142
                               "view-border-width", view_border_width,
 
143
                               "menu-factory",      menu_factory,
 
144
                               "menu-identifier",   "<Brushes>",
 
145
                               "ui-path",           "/brushes-popup",
 
146
                               "action-group",      "brushes",
 
147
                               NULL);
138
148
 
139
149
  factory_view->change_brush_spacing = change_brush_spacing;
140
150
 
141
 
  if (! gimp_data_factory_view_construct (GIMP_DATA_FACTORY_VIEW (factory_view),
142
 
                                          view_type,
143
 
                                          factory,
144
 
                                          context,
145
 
                                          view_size, view_border_width,
146
 
                                          menu_factory, "<Brushes>",
147
 
                                          "/brushes-popup",
148
 
                                          "brushes"))
149
 
    {
150
 
      g_object_unref (factory_view);
151
 
      return NULL;
152
 
    }
153
 
 
154
151
  editor = GIMP_CONTAINER_EDITOR (factory_view);
155
152
 
156
 
  /*  eek  */
157
 
  gtk_box_pack_end (GTK_BOX (editor->view),
158
 
                    gtk_widget_get_parent (factory_view->spacing_scale),
 
153
  gtk_box_pack_end (GTK_BOX (editor->view), factory_view->spacing_scale,
159
154
                    FALSE, FALSE, 0);
 
155
  gtk_widget_show (factory_view->spacing_scale);
160
156
 
161
157
  factory_view->spacing_changed_handler_id =
162
 
    gimp_container_add_handler (factory->container, "spacing-changed",
 
158
    gimp_container_add_handler (gimp_data_factory_get_container (factory), "spacing-changed",
163
159
                                G_CALLBACK (gimp_brush_factory_view_spacing_changed),
164
160
                                factory_view);
165
161