44
46
#include "gimp-intl.h"
47
static void gimp_buffer_view_class_init (GimpBufferViewClass *klass);
48
static void gimp_buffer_view_init (GimpBufferView *view);
50
static void gimp_buffer_view_activate_item (GimpContainerEditor *editor,
51
GimpViewable *viewable);
53
static void gimp_buffer_view_buffer_changed (Gimp *gimp,
54
GimpBufferView *buffer_view);
55
static void gimp_buffer_view_preview_notify (GimpContainerView *view,
57
GimpBufferView *buffer_view);
60
static GimpContainerEditorClass *parent_class = NULL;
64
gimp_buffer_view_get_type (void)
66
static GType view_type = 0;
70
static const GTypeInfo view_info =
72
sizeof (GimpBufferViewClass),
74
NULL, /* base_finalize */
75
(GClassInitFunc) gimp_buffer_view_class_init,
76
NULL, /* class_finalize */
77
NULL, /* class_data */
78
sizeof (GimpBufferView),
80
(GInstanceInitFunc) gimp_buffer_view_init,
83
view_type = g_type_register_static (GIMP_TYPE_CONTAINER_EDITOR,
49
static void gimp_buffer_view_docked_iface_init (GimpDockedInterface *iface);
51
static void gimp_buffer_view_set_context (GimpDocked *docked,
52
GimpContext *context);
54
static void gimp_buffer_view_activate_item (GimpContainerEditor *editor,
55
GimpViewable *viewable);
57
static void gimp_buffer_view_buffer_changed (Gimp *gimp,
58
GimpBufferView *buffer_view);
59
static void gimp_buffer_view_view_notify (GimpContainerView *view,
61
GimpBufferView *buffer_view);
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))
69
#define parent_class gimp_buffer_view_parent_class
71
static GimpDockedInterface *parent_docked_iface = NULL;
92
75
gimp_buffer_view_class_init (GimpBufferViewClass *klass)
94
77
GimpContainerEditorClass *editor_class = GIMP_CONTAINER_EDITOR_CLASS (klass);
96
parent_class = g_type_class_peek_parent (klass);
98
79
editor_class->activate_item = gimp_buffer_view_activate_item;
83
gimp_buffer_view_docked_iface_init (GimpDockedInterface *iface)
85
parent_docked_iface = g_type_interface_peek_parent (iface);
87
if (! parent_docked_iface)
88
parent_docked_iface = g_type_default_interface_peek (GIMP_TYPE_DOCKED);
90
iface->set_context = gimp_buffer_view_set_context;
102
94
gimp_buffer_view_init (GimpBufferView *view)
104
96
view->paste_button = NULL;
107
99
view->delete_button = NULL;
103
gimp_buffer_view_set_context (GimpDocked *docked,
104
GimpContext *context)
106
GimpBufferView *view = GIMP_BUFFER_VIEW (docked);
108
parent_docked_iface->set_context (docked, context);
110
gimp_view_renderer_set_context (GIMP_VIEW (view->global_view)->renderer,
115
/* public functions */
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);
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,
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);
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),
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),
165
173
buffer_view->global_label = gtk_label_new (_("(None)"));
251
gimp_buffer_view_preview_notify (GimpContainerView *container_view,
253
GimpBufferView *buffer_view)
262
gimp_buffer_view_view_notify (GimpContainerView *container_view,
264
GimpBufferView *buffer_view)
255
GimpView *view = GIMP_VIEW (buffer_view->global_preview);
266
GimpView *view = GIMP_VIEW (buffer_view->global_view);
257
268
gint view_border_width;
259
view_size = gimp_container_view_get_preview_size (container_view,
270
view_size = gimp_container_view_get_view_size (container_view,
262
273
gimp_view_renderer_set_size_full (view->renderer,
263
274
view_size, view_size, view_border_width);