static GimpObject * gimp_pdb_get_data_factory_item (GimpDataFactory *data_factory, const gchar *name) { GimpObject *gimp_object; gimp_object = gimp_container_get_child_by_name (gimp_data_factory_get_container (data_factory), name); if (! gimp_object) gimp_object = gimp_container_get_child_by_name (gimp_data_factory_get_container_obsolete (data_factory), name); return gimp_object; }
GimpFont * gimp_pdb_get_font (Gimp *gimp, const gchar *name, GError **error) { GimpFont *font; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); if (! name || ! strlen (name)) { g_set_error_literal (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT, _("Invalid empty font name")); return NULL; } font = (GimpFont *) gimp_container_get_child_by_name (gimp->fonts, name); if (! font) { g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT, _("Font '%s' not found"), name); } return font; }
GimpBuffer * gimp_pdb_get_buffer (Gimp *gimp, const gchar *name, GError **error) { GimpBuffer *buffer; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); if (! name || ! strlen (name)) { g_set_error_literal (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT, _("Invalid empty buffer name")); return NULL; } buffer = (GimpBuffer *) gimp_container_get_child_by_name (gimp->named_buffers, name); if (! buffer) { g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT, _("Named buffer '%s' not found"), name); } return buffer; }
static void gimp_container_entry_changed (GtkEntry *entry, GimpContainerView *view) { GimpContainer *container = gimp_container_view_get_container (view); GimpObject *object; const gchar *text; if (! container) return; text = gtk_entry_get_text (entry); object = gimp_container_get_child_by_name (container, text); if (object) { gtk_widget_modify_text (GTK_WIDGET (entry), GTK_STATE_NORMAL, NULL); gimp_container_view_item_selected (view, GIMP_VIEWABLE (object)); } else { /* While editing the entry, contents shows in red for non-existent item. */ GdkColor gdk_red; gdk_red.red = 65535; gdk_red.green = 0; gdk_red.blue = 0; gtk_widget_modify_text (GTK_WIDGET (entry), GTK_STATE_NORMAL, &gdk_red); } }
void tools_reset_cmd_callback (GtkAction *action, gpointer data) { GimpContext *context; GimpContainer *container; GList *list; gint i = 0; return_if_no_context (context, data); container = context->gimp->tool_info_list; for (list = gimp_tools_get_default_order (context->gimp); list; list = g_list_next (list)) { GimpObject *object = gimp_container_get_child_by_name (container, list->data); if (object) { gboolean visible; gimp_container_reorder (container, object, i); visible = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (object), "gimp-tool-default-visible")); g_object_set (object, "visible", visible, NULL); i++; } } }
GimpPaintInfo * gimp_pdb_get_paint_info (Gimp *gimp, const gchar *name, GError **error) { GimpPaintInfo *paint_info; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); if (! name || ! strlen (name)) { g_set_error_literal (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT, _("Invalid empty paint method name")); return NULL; } paint_info = (GimpPaintInfo *) gimp_container_get_child_by_name (gimp->paint_info_list, name); if (! paint_info) { g_set_error (error, GIMP_PDB_ERROR, GIMP_PDB_ERROR_INVALID_ARGUMENT, _("Paint method '%s' does not exist"), name); } return paint_info; }
static GValueArray * buffer_get_image_type_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GValueArray *args) { gboolean success = TRUE; GValueArray *return_vals; const gchar *buffer_name; gint32 image_type = 0; buffer_name = g_value_get_string (&args->values[0]); if (success) { GimpBuffer *buffer = (GimpBuffer *) gimp_container_get_child_by_name (gimp->named_buffers, buffer_name); if (buffer) image_type = gimp_buffer_get_image_type (buffer); else success = FALSE; } return_vals = gimp_procedure_get_return_values (procedure, success); if (success) g_value_set_enum (&return_vals->values[1], image_type); return return_vals; }
static GValueArray * buffer_delete_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GValueArray *args) { gboolean success = TRUE; const gchar *buffer_name; buffer_name = g_value_get_string (&args->values[0]); if (success) { GimpBuffer *buffer = (GimpBuffer *) gimp_container_get_child_by_name (gimp->named_buffers, buffer_name); if (buffer) success = gimp_container_remove (gimp->named_buffers, GIMP_OBJECT (buffer)); else success = FALSE; } return gimp_procedure_get_return_values (procedure, success); }
void gimp_image_map_tool_edit_as (GimpImageMapTool *im_tool, const gchar *new_tool_id, GimpConfig *config) { GimpDisplay *display; GimpContext *user_context; GimpToolInfo *tool_info; GimpTool *new_tool; g_return_if_fail (GIMP_IS_IMAGE_MAP_TOOL (im_tool)); g_return_if_fail (new_tool_id); g_return_if_fail (GIMP_IS_CONFIG (config)); display = GIMP_TOOL (im_tool)->display; user_context = gimp_get_user_context (display->gimp); tool_info = (GimpToolInfo *) gimp_container_get_child_by_name (display->gimp->tool_info_list, new_tool_id); gimp_context_set_tool (user_context, tool_info); tool_manager_initialize_active (display->gimp, display); new_tool = tool_manager_get_active (display->gimp); GIMP_IMAGE_MAP_TOOL (new_tool)->default_config = g_object_ref (config); gimp_image_map_tool_reset (GIMP_IMAGE_MAP_TOOL (new_tool)); }
static GValueArray * palette_set_columns_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GValueArray *args) { gboolean success = TRUE; const gchar *name; gint32 columns; name = g_value_get_string (&args->values[0]); columns = g_value_get_int (&args->values[1]); if (success) { GimpPalette *palette = (GimpPalette *) gimp_container_get_child_by_name (gimp->palette_factory->container, name); if (palette && GIMP_DATA (palette)->writable) gimp_palette_set_columns (palette, columns); else success = FALSE; } return gimp_procedure_get_return_values (procedure, success); }
static GValueArray * palette_get_columns_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GValueArray *args) { gboolean success = TRUE; GValueArray *return_vals; const gchar *name; gint32 num_columns = 0; name = g_value_get_string (&args->values[0]); if (success) { GimpPalette *palette = (GimpPalette *) gimp_container_get_child_by_name (gimp->palette_factory->container, name); if (palette) num_columns = palette->n_columns; else success = FALSE; } return_vals = gimp_procedure_get_return_values (procedure, success); if (success) g_value_set_int (&return_vals->values[1], num_columns); return return_vals; }
static GValueArray * palette_is_editable_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GValueArray *args) { gboolean success = TRUE; GValueArray *return_vals; const gchar *name; gboolean editable = FALSE; name = g_value_get_string (&args->values[0]); if (success) { GimpPalette *palette = (GimpPalette *) gimp_container_get_child_by_name (gimp->palette_factory->container, name); if (palette) editable = GIMP_DATA (palette)->writable; else success = FALSE; } return_vals = gimp_procedure_get_return_values (procedure, success); if (success) g_value_set_boolean (&return_vals->values[1], editable); return return_vals; }
GimpPaintOptions * gimp_pdb_context_get_paint_options (GimpPDBContext *context, const gchar *name) { g_return_val_if_fail (GIMP_IS_PDB_CONTEXT (context), NULL); g_return_val_if_fail (name != NULL, NULL); return (GimpPaintOptions *) gimp_container_get_child_by_name (context->paint_options_list, name); }
GimpToolInfo * gimp_get_tool_info (Gimp *gimp, const gchar *tool_id) { gpointer info; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); g_return_val_if_fail (tool_id != NULL, NULL); info = gimp_container_get_child_by_name (gimp->tool_info_list, tool_id); return (GimpToolInfo *) info; }
static gboolean gui_pdb_dialog_set (Gimp *gimp, GimpContainer *container, const gchar *callback_name, const gchar *object_name, va_list args) { GimpPdbDialogClass *klass = NULL; if (gimp_container_get_children_type (container) == GIMP_TYPE_BRUSH) klass = g_type_class_peek (GIMP_TYPE_BRUSH_SELECT); else if (gimp_container_get_children_type (container) == GIMP_TYPE_FONT) klass = g_type_class_peek (GIMP_TYPE_FONT_SELECT); else if (gimp_container_get_children_type (container) == GIMP_TYPE_GRADIENT) klass = g_type_class_peek (GIMP_TYPE_GRADIENT_SELECT); else if (gimp_container_get_children_type (container) == GIMP_TYPE_PALETTE) klass = g_type_class_peek (GIMP_TYPE_PALETTE_SELECT); else if (gimp_container_get_children_type (container) == GIMP_TYPE_PATTERN) klass = g_type_class_peek (GIMP_TYPE_PATTERN_SELECT); if (klass) { GimpPdbDialog *dialog; dialog = gimp_pdb_dialog_get_by_callback (klass, callback_name); if (dialog && dialog->select_type == gimp_container_get_children_type (container)) { GimpObject *object; object = gimp_container_get_child_by_name (container, object_name); if (object) { const gchar *prop_name = va_arg (args, const gchar *); gimp_context_set_by_type (dialog->context, dialog->select_type, object); if (prop_name) g_object_set_valist (G_OBJECT (dialog), prop_name, args); gtk_window_present (GTK_WINDOW (dialog)); return TRUE; } } }
static void gimp_container_entry_changed (GtkEntry *entry, GimpContainerView *view) { GimpContainer *container = gimp_container_view_get_container (view); GimpObject *object; const gchar *text; if (! container) return; text = gtk_entry_get_text (entry); object = gimp_container_get_child_by_name (container, text); if (object) gimp_container_view_item_selected (view, GIMP_VIEWABLE (object)); }
static GValueArray * palette_entry_get_name_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GValueArray *args) { gboolean success = TRUE; GValueArray *return_vals; const gchar *name; gint32 entry_num; gchar *entry_name = NULL; name = g_value_get_string (&args->values[0]); entry_num = g_value_get_int (&args->values[1]); if (success) { GimpPalette *palette = (GimpPalette *) gimp_container_get_child_by_name (gimp->palette_factory->container, name); if (palette) { if (entry_num >= 0 && entry_num < palette->n_colors) { GimpPaletteEntry *entry = g_list_nth_data (palette->colors, entry_num); entry_name = g_strdup (entry->name); } else success = FALSE; } else success = FALSE; } return_vals = gimp_procedure_get_return_values (procedure, success); if (success) g_value_take_string (&return_vals->values[1], entry_name); return return_vals; }
void gimp_device_info_set_default_tool (GimpDeviceInfo *info) { g_return_if_fail (GIMP_IS_DEVICE_INFO (info)); if (info->device && gdk_device_get_source (info->device) == GDK_SOURCE_ERASER) { GimpContainer *tools = GIMP_CONTEXT (info)->gimp->tool_info_list; GimpToolInfo *eraser; eraser = GIMP_TOOL_INFO (gimp_container_get_child_by_name (tools, "gimp-eraser-tool")); if (eraser) gimp_context_set_tool (GIMP_CONTEXT (info), eraser); } }
static GValueArray * palette_add_entry_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GValueArray *args) { gboolean success = TRUE; GValueArray *return_vals; const gchar *name; const gchar *entry_name; GimpRGB color; gint32 entry_num = 0; name = g_value_get_string (&args->values[0]); entry_name = g_value_get_string (&args->values[1]); gimp_value_get_rgb (&args->values[2], &color); if (success) { GimpPalette *palette = (GimpPalette *) gimp_container_get_child_by_name (gimp->palette_factory->container, name); if (palette && GIMP_DATA (palette)->writable) { GimpPaletteEntry *entry = gimp_palette_add_entry (palette, -1, entry_name, &color); entry_num = entry->position; } else success = FALSE; } return_vals = gimp_procedure_get_return_values (procedure, success); if (success) g_value_set_int (&return_vals->values[1], entry_num); return return_vals; }
static GValueArray * palette_entry_set_name_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GValueArray *args) { gboolean success = TRUE; const gchar *name; gint32 entry_num; const gchar *entry_name; name = g_value_get_string (&args->values[0]); entry_num = g_value_get_int (&args->values[1]); entry_name = g_value_get_string (&args->values[2]); if (success) { GimpPalette *palette = (GimpPalette *) gimp_container_get_child_by_name (gimp->palette_factory->container, name); if (palette && GIMP_DATA (palette)->writable) { if (entry_num >= 0 && entry_num < palette->n_colors) { GimpPaletteEntry *entry = g_list_nth_data (palette->colors, entry_num); g_free (entry->name); entry->name = g_strdup (entry_name); gimp_data_dirty (GIMP_DATA (palette)); } else success = FALSE; } else success = FALSE; } return gimp_procedure_get_return_values (procedure, success); }
static GValueArray * palette_duplicate_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GValueArray *args) { gboolean success = TRUE; GValueArray *return_vals; const gchar *name; gchar *copy_name = NULL; name = g_value_get_string (&args->values[0]); if (success) { GimpPalette *palette = (GimpPalette *) gimp_container_get_child_by_name (gimp->palette_factory->container, name); if (palette) { GimpPalette *palette_copy = (GimpPalette *) gimp_data_factory_data_duplicate (gimp->palette_factory, GIMP_DATA (palette)); if (palette_copy) copy_name = g_strdup (gimp_object_get_name (GIMP_OBJECT (palette_copy))); else success = FALSE; } else success = FALSE; } return_vals = gimp_procedure_get_return_values (procedure, success); if (success) g_value_take_string (&return_vals->values[1], copy_name); return return_vals; }
static GValueArray * palette_delete_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GValueArray *args) { gboolean success = TRUE; const gchar *name; name = g_value_get_string (&args->values[0]); if (success) { GimpPalette *palette = (GimpPalette *) gimp_container_get_child_by_name (gimp->palette_factory->container, name); if (palette && GIMP_DATA (palette)->deletable) { GError *error = NULL; success = gimp_data_factory_data_delete (gimp->palette_factory, GIMP_DATA (palette), TRUE, &error); if (! success) { gimp_message (gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR, "%s", error->message); g_clear_error (&error); } } else success = FALSE; } return gimp_procedure_get_return_values (procedure, success); }
static GValueArray * buffer_rename_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GValueArray *args) { gboolean success = TRUE; GValueArray *return_vals; const gchar *buffer_name; const gchar *new_name; gchar *real_name = NULL; buffer_name = g_value_get_string (&args->values[0]); new_name = g_value_get_string (&args->values[1]); if (success) { GimpBuffer *buffer = (GimpBuffer *) gimp_container_get_child_by_name (gimp->named_buffers, buffer_name); if (buffer) { gimp_object_set_name (GIMP_OBJECT (buffer), new_name); real_name = g_strdup (gimp_object_get_name (GIMP_OBJECT (buffer))); } else success = FALSE; } return_vals = gimp_procedure_get_return_values (procedure, success); if (success) g_value_take_string (&return_vals->values[1], real_name); return return_vals; }
static void gimp_data_editor_set_aux_info (GimpDocked *docked, GList *aux_info) { GimpDataEditor *editor = GIMP_DATA_EDITOR (docked); GList *list; parent_docked_iface->set_aux_info (docked, aux_info); for (list = aux_info; list; list = g_list_next (list)) { GimpSessionInfoAux *aux = list->data; if (! strcmp (aux->name, AUX_INFO_EDIT_ACTIVE)) { gboolean edit_active; edit_active = ! g_ascii_strcasecmp (aux->value, "true"); gimp_data_editor_set_edit_active (editor, edit_active); } else if (! strcmp (aux->name, AUX_INFO_CURRENT_DATA)) { if (! editor->edit_active) { GimpData *data; data = (GimpData *) gimp_container_get_child_by_name (gimp_data_factory_get_container (editor->data_factory), aux->value); if (data) gimp_data_editor_set_data (editor, data); } } } }
void gimp_tools_restore (Gimp *gimp) { GimpContainer *gimp_list; GimpObject *object; GFile *file; GList *list; GError *error = NULL; g_return_if_fail (GIMP_IS_GIMP (gimp)); gimp_list = gimp_list_new (GIMP_TYPE_TOOL_INFO, FALSE); file = gimp_directory_file ("toolrc", NULL); if (gimp->be_verbose) g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file)); if (gimp_config_deserialize_gfile (GIMP_CONFIG (gimp_list), file, NULL, NULL)) { gint n = gimp_container_get_n_children (gimp->tool_info_list); gint i; gimp_list_reverse (GIMP_LIST (gimp_list)); for (list = GIMP_LIST (gimp_list)->list, i = 0; list; list = g_list_next (list), i++) { const gchar *name; name = gimp_object_get_name (list->data); object = gimp_container_get_child_by_name (gimp->tool_info_list, name); if (object) { g_object_set (object, "visible", GIMP_TOOL_INFO (list->data)->visible, NULL); gimp_container_reorder (gimp->tool_info_list, object, MIN (i, n - 1)); } } } g_object_unref (file); g_object_unref (gimp_list); /* make the generic operation tool invisible by default */ object = gimp_container_get_child_by_name (gimp->tool_info_list, "gimp-operation-tool"); if (object) g_object_set (object, "visible", FALSE, NULL); for (list = gimp_get_tool_info_iter (gimp); list; list = g_list_next (list)) { GimpToolInfo *tool_info = GIMP_TOOL_INFO (list->data); /* get default values from prefs (see bug #120832) */ gimp_config_reset (GIMP_CONFIG (tool_info->tool_options)); } if (! gimp_contexts_load (gimp, &error)) { gimp_message_literal (gimp, NULL, GIMP_MESSAGE_WARNING, error->message); g_clear_error (&error); } /* make sure there is always a tool active, so broken config files * can't leave us with no initial tool */ if (! gimp_context_get_tool (gimp_get_user_context (gimp))) { gimp_context_set_tool (gimp_get_user_context (gimp), gimp_get_tool_info_iter (gimp)->data); } for (list = gimp_get_tool_info_iter (gimp); list; list = g_list_next (list)) { GimpToolInfo *tool_info = GIMP_TOOL_INFO (list->data); GimpToolOptionsGUIFunc options_gui_func; GtkWidget *options_gui; /* copy all context properties except those the tool actually * uses, because the subsequent deserialize() on the tool * options will only set the properties that were set to * non-default values at the time of saving, and we want to * keep these default values as if they have been saved. * (see bug #541586). */ gimp_context_copy_properties (gimp_get_user_context (gimp), GIMP_CONTEXT (tool_info->tool_options), GIMP_CONTEXT_PROP_MASK_ALL &~ (tool_info->context_props | GIMP_CONTEXT_PROP_MASK_TOOL | GIMP_CONTEXT_PROP_MASK_PAINT_INFO)); gimp_tool_options_deserialize (tool_info->tool_options, NULL); options_gui_func = g_object_get_data (G_OBJECT (tool_info), "gimp-tool-options-gui-func"); if (options_gui_func) { options_gui = (* options_gui_func) (tool_info->tool_options); } else { GtkWidget *label; options_gui = gimp_tool_options_gui (tool_info->tool_options); label = gtk_label_new (_("This tool has\nno options.")); gtk_label_set_justify (GTK_LABEL (label), GTK_JUSTIFY_CENTER); gimp_label_set_attributes (GTK_LABEL (label), PANGO_ATTR_STYLE, PANGO_STYLE_ITALIC, -1); gtk_box_pack_start (GTK_BOX (options_gui), label, FALSE, FALSE, 6); gtk_widget_show (label); } gimp_tools_set_tool_options_gui (tool_info->tool_options, g_object_ref_sink (options_gui)); } }
GimpToolInfo * gimp_tool_info_new (Gimp *gimp, GType tool_type, GType tool_options_type, GimpContextPropMask context_props, const gchar *identifier, const gchar *blurb, const gchar *help, const gchar *menu_label, const gchar *menu_accel, const gchar *help_domain, const gchar *help_id, const gchar *paint_core_name, const gchar *icon_name) { GimpPaintInfo *paint_info; GimpToolInfo *tool_info; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); g_return_val_if_fail (identifier != NULL, NULL); g_return_val_if_fail (blurb != NULL, NULL); g_return_val_if_fail (help != NULL, NULL); g_return_val_if_fail (menu_label != NULL, NULL); g_return_val_if_fail (help_id != NULL, NULL); g_return_val_if_fail (paint_core_name != NULL, NULL); g_return_val_if_fail (icon_name != NULL, NULL); paint_info = (GimpPaintInfo *) gimp_container_get_child_by_name (gimp->paint_info_list, paint_core_name); g_return_val_if_fail (GIMP_IS_PAINT_INFO (paint_info), NULL); tool_info = g_object_new (GIMP_TYPE_TOOL_INFO, "name", identifier, "icon-name", icon_name, NULL); tool_info->gimp = gimp; tool_info->tool_type = tool_type; tool_info->tool_options_type = tool_options_type; tool_info->context_props = context_props; tool_info->blurb = g_strdup (blurb); tool_info->help = g_strdup (help); tool_info->menu_label = g_strdup (menu_label); tool_info->menu_accel = g_strdup (menu_accel); tool_info->help_domain = g_strdup (help_domain); tool_info->help_id = g_strdup (help_id); tool_info->paint_info = paint_info; if (tool_info->tool_options_type == paint_info->paint_options_type) { tool_info->tool_options = g_object_ref (paint_info->paint_options); } else { tool_info->tool_options = g_object_new (tool_info->tool_options_type, "gimp", gimp, "name", identifier, NULL); } g_object_set (tool_info->tool_options, "tool", tool_info, "tool-info", tool_info, NULL); if (tool_info->tool_options_type != GIMP_TYPE_TOOL_OPTIONS) { GimpContainer *presets; presets = gimp_data_factory_get_container (gimp->tool_preset_factory); tool_info->presets = gimp_filtered_container_new (presets, gimp_tool_info_filter_preset, tool_info); } return tool_info; }
static GValueArray * brushes_get_brush_data_invoker (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, const GValueArray *args) { gboolean success = TRUE; GValueArray *return_vals; const gchar *name; gchar *actual_name = NULL; gdouble opacity = 0.0; gint32 spacing = 0; gint32 paint_mode = 0; gint32 width = 0; gint32 height = 0; gint32 length = 0; guint8 *mask_data = NULL; name = g_value_get_string (&args->values[0]); if (success) { GimpBrush *brush; if (name && strlen (name)) { brush = (GimpBrush *) gimp_container_get_child_by_name (gimp->brush_factory->container, name); } else { brush = gimp_context_get_brush (context); } if (brush) { actual_name = g_strdup (gimp_object_get_name (GIMP_OBJECT (brush))); opacity = 1.0; spacing = gimp_brush_get_spacing (brush); paint_mode = 0; width = brush->mask->width; height = brush->mask->height; length = brush->mask->height * brush->mask->width; mask_data = g_memdup (temp_buf_data (brush->mask), length); } else success = FALSE; } return_vals = gimp_procedure_get_return_values (procedure, success); if (success) { g_value_take_string (&return_vals->values[1], actual_name); g_value_set_double (&return_vals->values[2], opacity); g_value_set_int (&return_vals->values[3], spacing); g_value_set_enum (&return_vals->values[4], paint_mode); g_value_set_int (&return_vals->values[5], width); g_value_set_int (&return_vals->values[6], height); g_value_set_int (&return_vals->values[7], length); gimp_value_take_int8array (&return_vals->values[8], mask_data, length); } return return_vals; }
static gboolean gui_pdb_dialog_new (Gimp *gimp, GimpContext *context, GimpProgress *progress, GimpContainer *container, const gchar *title, const gchar *callback_name, const gchar *object_name, va_list args) { GType dialog_type = G_TYPE_NONE; const gchar *dialog_role = NULL; const gchar *help_id = NULL; if (gimp_container_get_children_type (container) == GIMP_TYPE_BRUSH) { dialog_type = GIMP_TYPE_BRUSH_SELECT; dialog_role = "gimp-brush-selection"; help_id = GIMP_HELP_BRUSH_DIALOG; } else if (gimp_container_get_children_type (container) == GIMP_TYPE_FONT) { dialog_type = GIMP_TYPE_FONT_SELECT; dialog_role = "gimp-font-selection"; help_id = GIMP_HELP_FONT_DIALOG; } else if (gimp_container_get_children_type (container) == GIMP_TYPE_GRADIENT) { dialog_type = GIMP_TYPE_GRADIENT_SELECT; dialog_role = "gimp-gradient-selection"; help_id = GIMP_HELP_GRADIENT_DIALOG; } else if (gimp_container_get_children_type (container) == GIMP_TYPE_PALETTE) { dialog_type = GIMP_TYPE_PALETTE_SELECT; dialog_role = "gimp-palette-selection"; help_id = GIMP_HELP_PALETTE_DIALOG; } else if (gimp_container_get_children_type (container) == GIMP_TYPE_PATTERN) { dialog_type = GIMP_TYPE_PATTERN_SELECT; dialog_role = "gimp-pattern-selection"; help_id = GIMP_HELP_PATTERN_DIALOG; } if (dialog_type != G_TYPE_NONE) { GimpObject *object = NULL; if (object_name && strlen (object_name)) object = gimp_container_get_child_by_name (container, object_name); if (! object) object = gimp_context_get_by_type (context, gimp_container_get_children_type (container)); if (object) { GParameter *params = NULL; gint n_params = 0; GtkWidget *dialog; GtkWidget *view; params = gimp_parameters_append (dialog_type, params, &n_params, "title", title, "role", dialog_role, "help-func", gimp_standard_help_func, "help-id", help_id, "pdb", gimp->pdb, "context", context, "select-type", gimp_container_get_children_type (container), "initial-object", object, "callback-name", callback_name, "menu-factory", global_menu_factory, NULL); params = gimp_parameters_append_valist (dialog_type, params, &n_params, args); dialog = g_object_newv (dialog_type, n_params, params); gimp_parameters_free (params, n_params); view = GIMP_PDB_DIALOG (dialog)->view; if (view) gimp_docked_set_show_button_bar (GIMP_DOCKED (view), FALSE); if (progress) { guint32 window_id = gimp_progress_get_window_id (progress); if (window_id) gimp_window_set_transient_for (GTK_WINDOW (dialog), window_id); } gtk_widget_show (dialog); /* workaround for bug #360106 */ { GSource *source = g_timeout_source_new (100); GClosure *closure; closure = g_cclosure_new_object (G_CALLBACK (gui_pdb_dialog_present), G_OBJECT (dialog)); g_source_set_closure (source, closure); g_source_attach (source, NULL); g_source_unref (source); } return TRUE; } } return FALSE; }