Commit d85157c3 authored by Michael Natterer's avatar Michael Natterer 😴
Browse files

app: rename gimp->global_buffer to gimp->clipboard_buffer

Also rename the "buffer-changed" signal and the setter, and add a
getter.
parent 9bb33914
......@@ -81,10 +81,10 @@ gimp_edit_cut (GimpImage *image,
if (buffer)
{
gimp_set_global_buffer (image->gimp, buffer);
gimp_set_clipboard_buffer (image->gimp, buffer);
g_object_unref (buffer);
return image->gimp->global_buffer;
return gimp_get_clipboard_buffer (image->gimp);
}
return NULL;
......@@ -109,10 +109,10 @@ gimp_edit_copy (GimpImage *image,
if (buffer)
{
gimp_set_global_buffer (image->gimp, buffer);
gimp_set_clipboard_buffer (image->gimp, buffer);
g_object_unref (buffer);
return image->gimp->global_buffer;
return gimp_get_clipboard_buffer (image->gimp);
}
return NULL;
......@@ -134,10 +134,10 @@ gimp_edit_copy_visible (GimpImage *image,
if (buffer)
{
gimp_set_global_buffer (image->gimp, buffer);
gimp_set_clipboard_buffer (image->gimp, buffer);
g_object_unref (buffer);
return image->gimp->global_buffer;
return gimp_get_clipboard_buffer (image->gimp);
}
return NULL;
......
......@@ -78,7 +78,7 @@ enum
INITIALIZE,
RESTORE,
EXIT,
BUFFER_CHANGED,
CLIPBOARD_CHANGED,
FILTER_HISTORY_CHANGED,
IMAGE_OPENED,
LAST_SIGNAL
......@@ -164,11 +164,11 @@ gimp_class_init (GimpClass *klass)
G_TYPE_BOOLEAN, 1,
G_TYPE_BOOLEAN);
gimp_signals[BUFFER_CHANGED] =
g_signal_new ("buffer-changed",
gimp_signals[CLIPBOARD_CHANGED] =
g_signal_new ("clipboard-changed",
G_TYPE_FROM_CLASS (klass),
G_SIGNAL_RUN_LAST,
G_STRUCT_OFFSET (GimpClass, buffer_changed),
G_STRUCT_OFFSET (GimpClass, clipboard_changed),
NULL, NULL,
gimp_marshal_VOID__VOID,
G_TYPE_NONE, 0);
......@@ -203,7 +203,7 @@ gimp_class_init (GimpClass *klass)
klass->initialize = gimp_real_initialize;
klass->restore = gimp_real_restore;
klass->exit = gimp_real_exit;
klass->buffer_changed = NULL;
klass->clipboard_changed = NULL;
g_object_class_install_property (object_class, PROP_VERBOSE,
g_param_spec_boolean ("verbose", NULL, NULL,
......@@ -426,10 +426,10 @@ gimp_finalize (GObject *object)
gimp->named_buffers = NULL;
}
if (gimp->global_buffer)
if (gimp->clipboard_buffer)
{
g_object_unref (gimp->global_buffer);
gimp->global_buffer = NULL;
g_object_unref (gimp->clipboard_buffer);
gimp->clipboard_buffer = NULL;
}
if (gimp->displays)
......@@ -536,7 +536,7 @@ gimp_get_memsize (GimpObject *object,
memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->displays), gui_size);
memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->global_buffer),
memsize += gimp_object_get_memsize (GIMP_OBJECT (gimp->clipboard_buffer),
gui_size);
memsize += gimp_data_factories_get_memsize (gimp, gui_size);
......@@ -966,24 +966,32 @@ gimp_get_tool_info_iter (Gimp *gimp)
}
void
gimp_set_global_buffer (Gimp *gimp,
GimpBuffer *buffer)
gimp_set_clipboard_buffer (Gimp *gimp,
GimpBuffer *buffer)
{
g_return_if_fail (GIMP_IS_GIMP (gimp));
g_return_if_fail (buffer == NULL || GIMP_IS_BUFFER (buffer));
if (buffer == gimp->global_buffer)
if (buffer == gimp->clipboard_buffer)
return;
if (gimp->global_buffer)
g_object_unref (gimp->global_buffer);
if (gimp->clipboard_buffer)
g_object_unref (gimp->clipboard_buffer);
gimp->global_buffer = buffer;
gimp->clipboard_buffer = buffer;
if (gimp->global_buffer)
g_object_ref (gimp->global_buffer);
if (gimp->clipboard_buffer)
g_object_ref (gimp->clipboard_buffer);
g_signal_emit (gimp, gimp_signals[BUFFER_CHANGED], 0);
g_signal_emit (gimp, gimp_signals[CLIPBOARD_CHANGED], 0);
}
GimpBuffer *
gimp_get_clipboard_buffer (Gimp *gimp)
{
g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL);
return gimp->clipboard_buffer;
}
GimpImage *
......
......@@ -89,7 +89,7 @@ struct _Gimp
GList *image_windows;
GimpBuffer *global_buffer;
GimpBuffer *clipboard_buffer;
GimpContainer *named_buffers;
GimpContainer *fonts;
......@@ -137,7 +137,7 @@ struct _GimpClass
gboolean (* exit) (Gimp *gimp,
gboolean force);
void (* buffer_changed) (Gimp *gimp);
void (* clipboard_changed) (Gimp *gimp);
void (* filter_history_changed) (Gimp *gimp);
......@@ -184,8 +184,9 @@ GList * gimp_get_image_windows (Gimp *gimp);
GList * gimp_get_paint_info_iter (Gimp *gimp);
GList * gimp_get_tool_info_iter (Gimp *gimp);
void gimp_set_global_buffer (Gimp *gimp,
void gimp_set_clipboard_buffer (Gimp *gimp,
GimpBuffer *buffer);
GimpBuffer * gimp_get_clipboard_buffer (Gimp *gimp);
GimpImage * gimp_create_image (Gimp *gimp,
gint width,
......
......@@ -57,7 +57,7 @@ static void gimp_brush_clipboard_get_property (GObject *object,
static GimpData * gimp_brush_clipboard_duplicate (GimpData *data);
#endif
static void gimp_brush_clipboard_buffer_changed (Gimp *gimp,
static void gimp_brush_clipboard_changed (Gimp *gimp,
GimpBrush *brush);
......@@ -104,11 +104,11 @@ gimp_brush_clipboard_constructed (GObject *object)
g_assert (GIMP_IS_GIMP (brush->gimp));
g_signal_connect_object (brush->gimp, "buffer-changed",
G_CALLBACK (gimp_brush_clipboard_buffer_changed),
g_signal_connect_object (brush->gimp, "clipboard-changed",
G_CALLBACK (gimp_brush_clipboard_changed),
brush, 0);
gimp_brush_clipboard_buffer_changed (brush->gimp, GIMP_BRUSH (brush));
gimp_brush_clipboard_changed (brush->gimp, GIMP_BRUSH (brush));
}
static void
......@@ -174,11 +174,12 @@ gimp_brush_clipboard_new (Gimp *gimp)
/* private functions */
static void
gimp_brush_clipboard_buffer_changed (Gimp *gimp,
GimpBrush *brush)
gimp_brush_clipboard_changed (Gimp *gimp,
GimpBrush *brush)
{
gint width;
gint height;
GimpBuffer *gimp_buffer;
gint width;
gint height;
if (brush->priv->mask)
{
......@@ -192,14 +193,16 @@ gimp_brush_clipboard_buffer_changed (Gimp *gimp,
brush->priv->pixmap = NULL;
}
if (gimp->global_buffer)
gimp_buffer = gimp_get_clipboard_buffer (gimp);
if (gimp_buffer)
{
GeglBuffer *buffer = gimp_buffer_get_buffer (gimp->global_buffer);
GeglBuffer *buffer = gimp_buffer_get_buffer (gimp_buffer);
const Babl *format = gegl_buffer_get_format (buffer);
GeglBuffer *dest_buffer;
width = MIN (gimp_buffer_get_width (gimp->global_buffer), 1024);
height = MIN (gimp_buffer_get_height (gimp->global_buffer), 1024);
width = MIN (gimp_buffer_get_width (gimp_buffer), 1024);
height = MIN (gimp_buffer_get_height (gimp_buffer), 1024);
brush->priv->mask = gimp_temp_buf_new (width, height,
babl_format ("Y u8"));
......
......@@ -57,7 +57,7 @@ static void gimp_pattern_clipboard_get_property (GObject *object,
static GimpData * gimp_pattern_clipboard_duplicate (GimpData *data);
#endif
static void gimp_pattern_clipboard_buffer_changed (Gimp *gimp,
static void gimp_pattern_clipboard_changed (Gimp *gimp,
GimpPattern *pattern);
......@@ -104,11 +104,11 @@ gimp_pattern_clipboard_constructed (GObject *object)
g_assert (GIMP_IS_GIMP (pattern->gimp));
g_signal_connect_object (pattern->gimp, "buffer-changed",
G_CALLBACK (gimp_pattern_clipboard_buffer_changed),
g_signal_connect_object (pattern->gimp, "clipboard-changed",
G_CALLBACK (gimp_pattern_clipboard_changed),
pattern, 0);
gimp_pattern_clipboard_buffer_changed (pattern->gimp, GIMP_PATTERN (pattern));
gimp_pattern_clipboard_changed (pattern->gimp, GIMP_PATTERN (pattern));
}
static void
......@@ -174,28 +174,31 @@ gimp_pattern_clipboard_new (Gimp *gimp)
/* private functions */
static void
gimp_pattern_clipboard_buffer_changed (Gimp *gimp,
GimpPattern *pattern)
gimp_pattern_clipboard_changed (Gimp *gimp,
GimpPattern *pattern)
{
GimpBuffer *gimp_buffer;
if (pattern->mask)
{
gimp_temp_buf_unref (pattern->mask);
pattern->mask = NULL;
}
if (gimp->global_buffer)
gimp_buffer = gimp_get_clipboard_buffer (gimp);
if (gimp_buffer)
{
GimpBuffer *buffer = gimp->global_buffer;
gint width;
gint height;
gint width;
gint height;
width = MIN (gimp_buffer_get_width (buffer), 1024);
height = MIN (gimp_buffer_get_height (buffer), 1024);
width = MIN (gimp_buffer_get_width (gimp_buffer), 1024);
height = MIN (gimp_buffer_get_height (gimp_buffer), 1024);
pattern->mask = gimp_temp_buf_new (width, height,
gimp_buffer_get_format (buffer));
gimp_buffer_get_format (gimp_buffer));
gegl_buffer_get (gimp_buffer_get_buffer (buffer),
gegl_buffer_get (gimp_buffer_get_buffer (gimp_buffer),
GEGL_RECTANGLE (0, 0, width, height), 1.0,
NULL,
gimp_temp_buf_get_data (pattern->mask),
......
......@@ -123,7 +123,7 @@ static void gui_tearoff_menus_notify (GimpGuiConfig *gui_config,
GParamSpec *pspec,
GtkUIManager *manager);
static void gui_global_buffer_changed (Gimp *gimp);
static void gui_clipboard_changed (Gimp *gimp);
static void gui_menu_show_tooltip (GimpUIManager *manager,
const gchar *tooltip,
......@@ -444,10 +444,10 @@ gui_restore_callback (Gimp *gimp,
dialogs_init (gimp, global_menu_factory);
gimp_clipboard_init (gimp);
gimp_clipboard_set_buffer (gimp, gimp->global_buffer);
gimp_clipboard_set_buffer (gimp, gimp_get_clipboard_buffer (gimp));
g_signal_connect (gimp, "buffer-changed",
G_CALLBACK (gui_global_buffer_changed),
g_signal_connect (gimp, "clipboard-changed",
G_CALLBACK (gui_clipboard_changed),
NULL);
gimp_devices_init (gimp);
......@@ -715,7 +715,7 @@ gui_exit_after_callback (Gimp *gimp,
* a whole lot of code paths. See bug #731389.
*/
g_signal_handlers_disconnect_by_func (gimp,
G_CALLBACK (gui_global_buffer_changed),
G_CALLBACK (gui_clipboard_changed),
NULL);
gimp_clipboard_exit (gimp);
......@@ -779,9 +779,9 @@ gui_tearoff_menus_notify (GimpGuiConfig *gui_config,
}
static void
gui_global_buffer_changed (Gimp *gimp)
gui_clipboard_changed (Gimp *gimp)
{
gimp_clipboard_set_buffer (gimp, gimp->global_buffer);
gimp_clipboard_set_buffer (gimp, gimp_get_clipboard_buffer (gimp));
}
static void
......
......@@ -203,13 +203,15 @@ edit_paste_invoker (GimpProcedure *procedure,
if (success)
{
if (gimp->global_buffer &&
GimpBuffer *buffer = gimp_get_clipboard_buffer (gimp);
if (buffer &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
floating_sel = gimp_edit_paste (gimp_item_get_image (GIMP_ITEM (drawable)),
drawable, gimp->global_buffer,
drawable, buffer,
paste_into, -1, -1, -1, -1);
if (! floating_sel)
......@@ -240,9 +242,11 @@ edit_paste_as_new_invoker (GimpProcedure *procedure,
GimpValueArray *return_vals;
GimpImage *image = NULL;
if (gimp->global_buffer)
GimpBuffer *buffer = gimp_get_clipboard_buffer (gimp);
if (buffer)
{
image = gimp_image_new_from_buffer (gimp, NULL, gimp->global_buffer);
image = gimp_image_new_from_buffer (gimp, NULL, buffer);
if (! image)
success = FALSE;
......
......@@ -54,7 +54,7 @@ static void gimp_buffer_view_set_context (GimpDocked *docked,
static void gimp_buffer_view_activate_item (GimpContainerEditor *editor,
GimpViewable *viewable);
static void gimp_buffer_view_buffer_changed (Gimp *gimp,
static void gimp_buffer_view_clipboard_changed (Gimp *gimp,
GimpBufferView *buffer_view);
static void gimp_buffer_view_view_notify (GimpContainerView *view,
GParamSpec *pspec,
......@@ -107,7 +107,7 @@ gimp_buffer_view_set_context (GimpDocked *docked,
parent_docked_iface->set_context (docked, context);
gimp_view_renderer_set_context (GIMP_VIEW (view->global_view)->renderer,
gimp_view_renderer_set_context (GIMP_VIEW (view->clipboard_view)->renderer,
context);
}
......@@ -159,15 +159,15 @@ gimp_buffer_view_new (GimpViewType view_type,
gtk_container_add (GTK_CONTAINER (frame), hbox);
gtk_widget_show (hbox);
buffer_view->global_view =
buffer_view->clipboard_view =
gimp_view_new_full_by_types (NULL,
GIMP_TYPE_VIEW,
GIMP_TYPE_BUFFER,
view_size, view_size, view_border_width,
FALSE, FALSE, TRUE);
gtk_box_pack_start (GTK_BOX (hbox), buffer_view->global_view,
gtk_box_pack_start (GTK_BOX (hbox), buffer_view->clipboard_view,
FALSE, FALSE, 0);
gtk_widget_show (buffer_view->global_view);
gtk_widget_show (buffer_view->clipboard_view);
g_signal_connect_object (editor->view, "notify::view-size",
G_CALLBACK (gimp_buffer_view_view_notify),
......@@ -176,16 +176,16 @@ gimp_buffer_view_new (GimpViewType view_type,
G_CALLBACK (gimp_buffer_view_view_notify),
buffer_view, 0);
buffer_view->global_label = gtk_label_new (_("(None)"));
gtk_box_pack_start (GTK_BOX (hbox), buffer_view->global_label,
buffer_view->clipboard_label = gtk_label_new (_("(None)"));
gtk_box_pack_start (GTK_BOX (hbox), buffer_view->clipboard_label,
FALSE, FALSE, 0);
gtk_widget_show (buffer_view->global_label);
gtk_widget_show (buffer_view->clipboard_label);
g_signal_connect_object (context->gimp, "buffer-changed",
G_CALLBACK (gimp_buffer_view_buffer_changed),
g_signal_connect_object (context->gimp, "clipboard-changed",
G_CALLBACK (gimp_buffer_view_clipboard_changed),
G_OBJECT (buffer_view), 0);
gimp_buffer_view_buffer_changed (context->gimp, buffer_view);
gimp_buffer_view_clipboard_changed (context->gimp, buffer_view);
buffer_view->paste_button =
gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "buffers",
......@@ -244,24 +244,24 @@ gimp_buffer_view_activate_item (GimpContainerEditor *editor,
}
static void
gimp_buffer_view_buffer_changed (Gimp *gimp,
GimpBufferView *buffer_view)
gimp_buffer_view_clipboard_changed (Gimp *gimp,
GimpBufferView *buffer_view)
{
gimp_view_set_viewable (GIMP_VIEW (buffer_view->global_view),
(GimpViewable *) gimp->global_buffer);
GimpBuffer *buffer = gimp_get_clipboard_buffer (gimp);
if (gimp->global_buffer)
{
gchar *desc;
gimp_view_set_viewable (GIMP_VIEW (buffer_view->clipboard_view),
GIMP_VIEWABLE (buffer));
desc = gimp_viewable_get_description (GIMP_VIEWABLE (gimp->global_buffer),
NULL);
gtk_label_set_text (GTK_LABEL (buffer_view->global_label), desc);
if (buffer)
{
gchar *desc = gimp_viewable_get_description (GIMP_VIEWABLE (buffer),
NULL);
gtk_label_set_text (GTK_LABEL (buffer_view->clipboard_label), desc);
g_free (desc);
}
else
{
gtk_label_set_text (GTK_LABEL (buffer_view->global_label), _("(None)"));
gtk_label_set_text (GTK_LABEL (buffer_view->clipboard_label), _("(None)"));
}
}
......@@ -270,7 +270,7 @@ gimp_buffer_view_view_notify (GimpContainerView *container_view,
GParamSpec *pspec,
GimpBufferView *buffer_view)
{
GimpView *view = GIMP_VIEW (buffer_view->global_view);
GimpView *view = GIMP_VIEW (buffer_view->clipboard_view);
gint view_size;
gint view_border_width;
......
......@@ -39,8 +39,8 @@ struct _GimpBufferView
{
GimpContainerEditor parent_instance;
GtkWidget *global_view;
GtkWidget *global_label;
GtkWidget *clipboard_view;
GtkWidget *clipboard_label;
GtkWidget *paste_button;
GtkWidget *paste_into_button;
......
......@@ -658,7 +658,7 @@ gimp_selection_data_get_buffer (GtkSelectionData *selection,
return (GimpBuffer *)
gimp_selection_data_get_object (selection,
gimp->named_buffers,
GIMP_OBJECT (gimp->global_buffer));
GIMP_OBJECT (gimp_get_clipboard_buffer (gimp)));
}
GimpImagefile *
......
......@@ -201,13 +201,15 @@ HELP
%invoke = (
code => <<CODE
{
if (gimp->global_buffer &&
GimpBuffer *buffer = gimp_get_clipboard_buffer (gimp);
if (buffer &&
gimp_pdb_item_is_attached (GIMP_ITEM (drawable), NULL,
GIMP_PDB_ITEM_CONTENT, error) &&
gimp_pdb_item_is_not_group (GIMP_ITEM (drawable), error))
{
floating_sel = gimp_edit_paste (gimp_item_get_image (GIMP_ITEM (drawable)),
drawable, gimp->global_buffer,
drawable, buffer,
paste_into, -1, -1, -1, -1);
if (! floating_sel)
......@@ -239,9 +241,11 @@ HELP
%invoke = (
code => <<CODE
{
if (gimp->global_buffer)
GimpBuffer *buffer = gimp_get_clipboard_buffer (gimp);
if (buffer)
{
image = gimp_image_new_from_buffer (gimp, NULL, gimp->global_buffer);
image = gimp_image_new_from_buffer (gimp, NULL, buffer);
if (! image)
success = FALSE;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment