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

« back to all changes in this revision

Viewing changes to app/widgets/gimpbufferview.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
 
/* The GIMP -- an image manipulation program
 
1
/* GIMP - The GNU Image Manipulation Program
2
2
 * Copyright (C) 1995 Spencer Kimball and Peter Mattis
3
3
 *
4
4
 * gimpbufferview.c
36
36
#include "gimpcontainerview.h"
37
37
#include "gimpbufferview.h"
38
38
#include "gimpdnd.h"
 
39
#include "gimpdocked.h"
 
40
#include "gimpeditor.h"
39
41
#include "gimphelp-ids.h"
40
42
#include "gimpview.h"
41
43
#include "gimpviewrendererbuffer.h"
44
46
#include "gimp-intl.h"
45
47
 
46
48
 
47
 
static void   gimp_buffer_view_class_init     (GimpBufferViewClass *klass);
48
 
static void   gimp_buffer_view_init           (GimpBufferView      *view);
49
 
 
50
 
static void   gimp_buffer_view_activate_item  (GimpContainerEditor *editor,
51
 
                                               GimpViewable        *viewable);
52
 
 
53
 
static void   gimp_buffer_view_buffer_changed (Gimp                *gimp,
54
 
                                               GimpBufferView      *buffer_view);
55
 
static void   gimp_buffer_view_preview_notify (GimpContainerView   *view,
56
 
                                               GParamSpec          *pspec,
57
 
                                               GimpBufferView      *buffer_view);
58
 
 
59
 
 
60
 
static GimpContainerEditorClass *parent_class = NULL;
61
 
 
62
 
 
63
 
GType
64
 
gimp_buffer_view_get_type (void)
65
 
{
66
 
  static GType view_type = 0;
67
 
 
68
 
  if (! view_type)
69
 
    {
70
 
      static const GTypeInfo view_info =
71
 
      {
72
 
        sizeof (GimpBufferViewClass),
73
 
        NULL,           /* base_init */
74
 
        NULL,           /* base_finalize */
75
 
        (GClassInitFunc) gimp_buffer_view_class_init,
76
 
        NULL,           /* class_finalize */
77
 
        NULL,           /* class_data */
78
 
        sizeof (GimpBufferView),
79
 
        0,              /* n_preallocs */
80
 
        (GInstanceInitFunc) gimp_buffer_view_init,
81
 
      };
82
 
 
83
 
      view_type = g_type_register_static (GIMP_TYPE_CONTAINER_EDITOR,
84
 
                                          "GimpBufferView",
85
 
                                          &view_info, 0);
86
 
    }
87
 
 
88
 
  return view_type;
89
 
}
 
49
static void   gimp_buffer_view_docked_iface_init (GimpDockedInterface *iface);
 
50
 
 
51
static void   gimp_buffer_view_set_context       (GimpDocked          *docked,
 
52
                                                  GimpContext         *context);
 
53
 
 
54
static void   gimp_buffer_view_activate_item     (GimpContainerEditor *editor,
 
55
                                                  GimpViewable        *viewable);
 
56
 
 
57
static void   gimp_buffer_view_buffer_changed    (Gimp                *gimp,
 
58
                                                  GimpBufferView      *buffer_view);
 
59
static void   gimp_buffer_view_view_notify       (GimpContainerView   *view,
 
60
                                                  GParamSpec          *pspec,
 
61
                                                  GimpBufferView      *buffer_view);
 
62
 
 
63
 
 
64
G_DEFINE_TYPE_WITH_CODE (GimpBufferView, gimp_buffer_view,
 
65
                         GIMP_TYPE_CONTAINER_EDITOR,
 
66
                         G_IMPLEMENT_INTERFACE (GIMP_TYPE_DOCKED,
 
67
                                                gimp_buffer_view_docked_iface_init))
 
68
 
 
69
#define parent_class gimp_buffer_view_parent_class
 
70
 
 
71
static GimpDockedInterface *parent_docked_iface = NULL;
 
72
 
90
73
 
91
74
static void
92
75
gimp_buffer_view_class_init (GimpBufferViewClass *klass)
93
76
{
94
77
  GimpContainerEditorClass *editor_class = GIMP_CONTAINER_EDITOR_CLASS (klass);
95
78
 
96
 
  parent_class = g_type_class_peek_parent (klass);
97
 
 
98
79
  editor_class->activate_item = gimp_buffer_view_activate_item;
99
80
}
100
81
 
101
82
static void
 
83
gimp_buffer_view_docked_iface_init (GimpDockedInterface *iface)
 
84
{
 
85
  parent_docked_iface = g_type_interface_peek_parent (iface);
 
86
 
 
87
  if (! parent_docked_iface)
 
88
    parent_docked_iface = g_type_default_interface_peek (GIMP_TYPE_DOCKED);
 
89
 
 
90
  iface->set_context = gimp_buffer_view_set_context;
 
91
}
 
92
 
 
93
static void
102
94
gimp_buffer_view_init (GimpBufferView *view)
103
95
{
104
96
  view->paste_button        = NULL;
107
99
  view->delete_button       = NULL;
108
100
}
109
101
 
 
102
static void
 
103
gimp_buffer_view_set_context (GimpDocked  *docked,
 
104
                              GimpContext *context)
 
105
{
 
106
  GimpBufferView *view = GIMP_BUFFER_VIEW (docked);
 
107
 
 
108
  parent_docked_iface->set_context (docked, context);
 
109
 
 
110
  gimp_view_renderer_set_context (GIMP_VIEW (view->global_view)->renderer,
 
111
                                  context);
 
112
}
 
113
 
 
114
 
 
115
/*  public functions  */
 
116
 
110
117
GtkWidget *
111
118
gimp_buffer_view_new (GimpViewType     view_type,
112
119
                      GimpContainer   *container,
146
153
  gtk_container_add (GTK_CONTAINER (frame), hbox);
147
154
  gtk_widget_show (hbox);
148
155
 
149
 
  buffer_view->global_preview =
150
 
    gimp_view_new_full_by_types (GIMP_TYPE_VIEW,
 
156
  buffer_view->global_view =
 
157
    gimp_view_new_full_by_types (NULL,
 
158
                                 GIMP_TYPE_VIEW,
151
159
                                 GIMP_TYPE_BUFFER,
152
160
                                 view_size, view_size, view_border_width,
153
161
                                 FALSE, FALSE, TRUE);
154
 
  gtk_box_pack_start (GTK_BOX (hbox), buffer_view->global_preview,
 
162
  gtk_box_pack_start (GTK_BOX (hbox), buffer_view->global_view,
155
163
                      FALSE, FALSE, 0);
156
 
  gtk_widget_show (buffer_view->global_preview);
 
164
  gtk_widget_show (buffer_view->global_view);
157
165
 
158
 
  g_signal_connect_object (editor->view, "notify::preview-size",
159
 
                           G_CALLBACK (gimp_buffer_view_preview_notify),
 
166
  g_signal_connect_object (editor->view, "notify::view-size",
 
167
                           G_CALLBACK (gimp_buffer_view_view_notify),
160
168
                           buffer_view, 0);
161
 
  g_signal_connect_object (editor->view, "notify::preview-border-width",
162
 
                           G_CALLBACK (gimp_buffer_view_preview_notify),
 
169
  g_signal_connect_object (editor->view, "notify::view-border-width",
 
170
                           G_CALLBACK (gimp_buffer_view_view_notify),
163
171
                           buffer_view, 0);
164
172
 
165
173
  buffer_view->global_label = gtk_label_new (_("(None)"));
207
215
  return GTK_WIDGET (buffer_view);
208
216
}
209
217
 
 
218
 
 
219
/*  private functions  */
 
220
 
210
221
static void
211
222
gimp_buffer_view_activate_item (GimpContainerEditor *editor,
212
223
                                GimpViewable        *viewable)
229
240
gimp_buffer_view_buffer_changed (Gimp           *gimp,
230
241
                                 GimpBufferView *buffer_view)
231
242
{
232
 
  gimp_view_set_viewable (GIMP_VIEW (buffer_view->global_preview),
 
243
  gimp_view_set_viewable (GIMP_VIEW (buffer_view->global_view),
233
244
                          (GimpViewable *) gimp->global_buffer);
234
245
 
235
246
  if (gimp->global_buffer)
248
259
}
249
260
 
250
261
static void
251
 
gimp_buffer_view_preview_notify (GimpContainerView *container_view,
252
 
                                 GParamSpec        *pspec,
253
 
                                 GimpBufferView    *buffer_view)
 
262
gimp_buffer_view_view_notify (GimpContainerView *container_view,
 
263
                              GParamSpec        *pspec,
 
264
                              GimpBufferView    *buffer_view)
254
265
{
255
 
  GimpView *view = GIMP_VIEW (buffer_view->global_preview);
 
266
  GimpView *view = GIMP_VIEW (buffer_view->global_view);
256
267
  gint      view_size;
257
268
  gint      view_border_width;
258
269
 
259
 
  view_size = gimp_container_view_get_preview_size (container_view,
260
 
                                                    &view_border_width);
 
270
  view_size = gimp_container_view_get_view_size (container_view,
 
271
                                                 &view_border_width);
261
272
 
262
273
  gimp_view_renderer_set_size_full (view->renderer,
263
274
                                    view_size, view_size, view_border_width);