static GimpData * gimp_pattern_duplicate (GimpData *data) { GimpPattern *pattern = g_object_new (GIMP_TYPE_PATTERN, NULL); pattern->mask = gimp_temp_buf_copy (GIMP_PATTERN (data)->mask); return GIMP_DATA (pattern); }
static void gimp_drawable_tree_view_new_pattern_dropped (GtkWidget *widget, gint x, gint y, GimpViewable *viewable, gpointer data) { gimp_drawable_tree_view_new_dropped (GIMP_ITEM_TREE_VIEW (data), x, y, NULL, GIMP_PATTERN (viewable)); }
static void pattern_preview_drop_pattern (GtkWidget *widget, gint x, gint y, GimpViewable *viewable, gpointer data) { GimpContext *context = GIMP_CONTEXT (data); gimp_context_set_pattern (context, GIMP_PATTERN (viewable)); }
static gchar * gimp_pattern_get_description (GimpViewable *viewable, gchar **tooltip) { GimpPattern *pattern = GIMP_PATTERN (viewable); return g_strdup_printf ("%s (%d × %d)", gimp_object_get_name (pattern), gimp_temp_buf_get_width (pattern->mask), gimp_temp_buf_get_height (pattern->mask)); }
static gboolean gimp_pattern_get_size (GimpViewable *viewable, gint *width, gint *height) { GimpPattern *pattern = GIMP_PATTERN (viewable); *width = gimp_temp_buf_get_width (pattern->mask); *height = gimp_temp_buf_get_height (pattern->mask); return TRUE; }
static gint64 gimp_pattern_get_memsize (GimpObject *object, gint64 *gui_size) { GimpPattern *pattern = GIMP_PATTERN (object); gint64 memsize = 0; memsize += gimp_temp_buf_get_memsize (pattern->mask); return memsize + GIMP_OBJECT_CLASS (parent_class)->get_memsize (object, gui_size); }
static void gimp_pattern_finalize (GObject *object) { GimpPattern *pattern = GIMP_PATTERN (object); if (pattern->mask) { gimp_temp_buf_unref (pattern->mask); pattern->mask = NULL; } G_OBJECT_CLASS (parent_class)->finalize (object); }
static void gimp_display_shell_drop_pattern (GtkWidget *widget, gint x, gint y, GimpViewable *viewable, gpointer data) { GIMP_LOG (DND, NULL); if (GIMP_IS_PATTERN (viewable)) gimp_display_shell_dnd_bucket_fill (GIMP_DISPLAY_SHELL (data), GIMP_PATTERN_BUCKET_FILL, NULL, GIMP_PATTERN (viewable)); }
static void gimp_pattern_clipboard_constructed (GObject *object) { GimpPatternClipboard *pattern = GIMP_PATTERN_CLIPBOARD (object); G_OBJECT_CLASS (parent_class)->constructed (object); g_assert (GIMP_IS_GIMP (pattern->gimp)); g_signal_connect_object (pattern->gimp, "buffer-changed", G_CALLBACK (gimp_pattern_clipboard_buffer_changed), pattern, 0); gimp_pattern_clipboard_buffer_changed (pattern->gimp, GIMP_PATTERN (pattern)); }
static gchar * gimp_pattern_get_checksum (GimpTagged *tagged) { GimpPattern *pattern = GIMP_PATTERN (tagged); gchar *checksum_string = NULL; if (pattern->mask) { GChecksum *checksum = g_checksum_new (G_CHECKSUM_MD5); g_checksum_update (checksum, gimp_temp_buf_get_data (pattern->mask), gimp_temp_buf_get_data_size (pattern->mask)); checksum_string = g_strdup (g_checksum_get_string (checksum)); g_checksum_free (checksum); } return checksum_string; }
static void gimp_display_shell_drop_pattern (GtkWidget *widget, gint x, gint y, GimpViewable *viewable, gpointer data) { GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (data); GimpFillOptions *options = gimp_fill_options_new (shell->display->gimp, NULL, FALSE); GIMP_LOG (DND, NULL); gimp_fill_options_set_style (options, GIMP_FILL_STYLE_PATTERN); gimp_context_set_pattern (GIMP_CONTEXT (options), GIMP_PATTERN (viewable)); gimp_display_shell_dnd_fill (shell, options, C_("undo-type", "Drop pattern to layer")); g_object_unref (options); }
static void gimp_drawable_tree_view_drop_viewable (GimpContainerTreeView *view, GimpViewable *src_viewable, GimpViewable *dest_viewable, GtkTreeViewDropPosition drop_pos) { if (dest_viewable && GIMP_IS_PATTERN (src_viewable)) { gimp_edit_fill_full (gimp_item_get_image (GIMP_ITEM (dest_viewable)), GIMP_DRAWABLE (dest_viewable), NULL, GIMP_PATTERN (src_viewable), GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE, C_("undo-type", "Drop pattern to layer")); gimp_image_flush (gimp_item_get_image (GIMP_ITEM (dest_viewable))); return; } GIMP_CONTAINER_TREE_VIEW_CLASS (parent_class)->drop_viewable (view, src_viewable, dest_viewable, drop_pos); }