GimpContext * gimp_pdb_context_new (Gimp *gimp, GimpContext *parent, gboolean set_parent) { GimpPDBContext *context; GList *list; g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); g_return_val_if_fail (GIMP_IS_CONTEXT (parent), NULL); context = g_object_new (GIMP_TYPE_PDB_CONTEXT, "gimp", gimp, "name", "PDB Context", NULL); gimp_config_sync (G_OBJECT (parent), G_OBJECT (context), 0); if (set_parent) { gimp_context_define_properties (GIMP_CONTEXT (context), GIMP_CONTEXT_ALL_PROPS_MASK, FALSE); gimp_context_set_parent (GIMP_CONTEXT (context), parent); for (list = gimp_get_paint_info_iter (gimp); list; list = g_list_next (list)) { GimpPaintInfo *info = list->data; gimp_container_add (context->paint_options_list, GIMP_OBJECT (info->paint_options)); } } else { for (list = GIMP_LIST (GIMP_PDB_CONTEXT (parent)->paint_options_list)->list; list; list = g_list_next (list)) { GimpPaintOptions *options = gimp_config_duplicate (list->data); gimp_container_add (context->paint_options_list, GIMP_OBJECT (options)); g_object_unref (options); } } return GIMP_CONTEXT (context); }
static void palette_import_response (GtkWidget *widget, gint response_id, ImportDialog *dialog) { Gimp *gimp = dialog->context->gimp; palette_import_image_changed (dialog->context, NULL, dialog); if (dialog->palette) { if (response_id == GTK_RESPONSE_OK) { const gchar *name = gtk_entry_get_text (GTK_ENTRY (dialog->entry)); if (name && *name) gimp_object_set_name (GIMP_OBJECT (dialog->palette), name); gimp_container_add (gimp_data_factory_get_container (gimp->palette_factory), GIMP_OBJECT (dialog->palette)); } } gtk_widget_destroy (dialog->dialog); }
static void gimp_tagged_container_src_add (GimpFilteredContainer *filtered_container, GimpObject *object) { GimpTaggedContainer *tagged_container = GIMP_TAGGED_CONTAINER (filtered_container); GList *list; for (list = gimp_tagged_get_tags (GIMP_TAGGED (object)); list; list = g_list_next (list)) { gimp_tagged_container_ref_tag (tagged_container, list->data); } g_signal_connect (object, "tag-added", G_CALLBACK (gimp_tagged_container_tag_added), tagged_container); g_signal_connect (object, "tag-removed", G_CALLBACK (gimp_tagged_container_tag_removed), tagged_container); if (gimp_tagged_container_object_matches (tagged_container, object)) { gimp_container_add (GIMP_CONTAINER (tagged_container), object); } }
static void gimp_paint_register (Gimp *gimp, GType paint_type, GType paint_options_type, const gchar *identifier, const gchar *blurb, const gchar *stock_id) { GimpPaintInfo *paint_info; g_return_if_fail (GIMP_IS_GIMP (gimp)); g_return_if_fail (g_type_is_a (paint_type, GIMP_TYPE_PAINT_CORE)); g_return_if_fail (g_type_is_a (paint_options_type, GIMP_TYPE_PAINT_OPTIONS)); g_return_if_fail (identifier != NULL); g_return_if_fail (blurb != NULL); paint_info = gimp_paint_info_new (gimp, paint_type, paint_options_type, identifier, blurb, stock_id); gimp_container_add (gimp->paint_info_list, GIMP_OBJECT (paint_info)); g_object_unref (paint_info); if (paint_type == GIMP_TYPE_PAINTBRUSH) gimp_paint_info_set_standard (gimp, paint_info); }
static void gimp_font_list_add_font (GimpFontList *list, PangoContext *context, PangoFontDescription *desc) { gchar *name; if (! desc) return; name = pango_font_description_to_string (desc); if (g_utf8_validate (name, -1, NULL)) { GimpFont *font; font = g_object_new (GIMP_TYPE_FONT, "name", name, "pango-context", context, NULL); gimp_container_add (GIMP_CONTAINER (list), GIMP_OBJECT (font)); g_object_unref (font); } g_free (name); }
const gchar * gimp_edit_named_cut (GimpImage *image, const gchar *name, GimpDrawable *drawable, GimpContext *context, GError **error) { GimpBuffer *buffer; g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL); g_return_val_if_fail (name != NULL, NULL); g_return_val_if_fail (GIMP_IS_DRAWABLE (drawable), NULL); g_return_val_if_fail (gimp_item_is_attached (GIMP_ITEM (drawable)), NULL); g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); buffer = gimp_edit_extract (image, GIMP_PICKABLE (drawable), context, TRUE, error); if (buffer) { gimp_object_set_name (GIMP_OBJECT (buffer), name); gimp_container_add (image->gimp->named_buffers, GIMP_OBJECT (buffer)); g_object_unref (buffer); return gimp_object_get_name (buffer); } return NULL; }
const gchar * gimp_edit_named_copy_visible (GimpImage *image, const gchar *name, GimpContext *context, GError **error) { GimpBuffer *buffer; g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL); g_return_val_if_fail (name != NULL, NULL); g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL); g_return_val_if_fail (error == NULL || *error == NULL, NULL); buffer = gimp_edit_extract (image, GIMP_PICKABLE (image), context, FALSE, error); if (buffer) { gimp_object_set_name (GIMP_OBJECT (buffer), name); gimp_container_add (image->gimp->named_buffers, GIMP_OBJECT (buffer)); g_object_unref (buffer); return gimp_object_get_name (buffer); } return NULL; }
static void palettes_merge_callback (GtkWidget *widget, const gchar *palette_name, gpointer data) { /* FIXME: reimplement palettes_merge_callback() */ #if 0 GimpContainerEditor *editor; GimpPalette *palette; GimpPalette *new_palette; GList *sel_list; editor = (GimpContainerEditor *) data; sel_list = GTK_LIST (GIMP_CONTAINER_LIST_VIEW (editor->view)->gtk_list)->selection; if (! sel_list) { gimp_message_literal (gimp, G_OBJECT (widget), GIMP_MESSAGE_WARNING, "Can't merge palettes because " "there are no palettes selected."); return; } new_palette = GIMP_PALETTE (gimp_palette_new (palette_name, FALSE)); while (sel_list) { GimpListItem *list_item; list_item = GIMP_LIST_ITEM (sel_list->data); palette = (GimpPalette *) GIMP_VIEW (list_item->preview)->viewable; if (palette) { GList *cols; for (cols = gimp_palette_get_colors (palette); cols; cols = g_list_next (cols)) { GimpPaletteEntry *entry = cols->data; gimp_palette_add_entry (new_palette, entry->name, &entry->color); } } sel_list = sel_list->next; } gimp_container_add (editor->view->container, GIMP_OBJECT (new_palette)); #endif }
static void gimp_displays_image_dirty_callback (GimpImage *image, GimpDirtyMask dirty_mask, GimpContainer *container) { if (image->dirty && image->disp_count > 0 && ! gimp_container_have (container, GIMP_OBJECT (image))) gimp_container_add (container, GIMP_OBJECT (image)); }
void gimp_undo_stack_push_undo (GimpUndoStack *stack, GimpUndo *undo) { g_return_if_fail (GIMP_IS_UNDO_STACK (stack)); g_return_if_fail (GIMP_IS_UNDO (undo)); gimp_container_add (GIMP_CONTAINER (stack->undos), GIMP_OBJECT (undo)); }
GimpContainer * gimp_displays_get_dirty_images (Gimp *gimp) { g_return_val_if_fail (GIMP_IS_GIMP (gimp), NULL); if (gimp_displays_dirty (gimp)) { GimpContainer *container = gimp_list_new_weak (GIMP_TYPE_IMAGE, FALSE); GList *list; GQuark handler; handler = gimp_container_add_handler (gimp->images, "clean", G_CALLBACK (gimp_displays_image_dirty_callback), container); g_object_set_data (G_OBJECT (container), "clean-handler", GINT_TO_POINTER (handler)); handler = gimp_container_add_handler (gimp->images, "dirty", G_CALLBACK (gimp_displays_image_dirty_callback), container); g_object_set_data (G_OBJECT (container), "dirty-handler", GINT_TO_POINTER (handler)); g_signal_connect_object (container, "disconnect", G_CALLBACK (gimp_displays_dirty_images_disconnect), G_OBJECT (gimp->images), 0); gimp_container_add_handler (container, "clean", G_CALLBACK (gimp_displays_image_clean_callback), container); gimp_container_add_handler (container, "dirty", G_CALLBACK (gimp_displays_image_clean_callback), container); for (list = GIMP_LIST (gimp->images)->list; list; list = g_list_next (list)) { GimpImage *image = list->data; if (image->dirty && image->disp_count > 0) gimp_container_add (container, GIMP_OBJECT (image)); } return container; } return NULL; }
static void gimp_controller_list_add_clicked (GtkWidget *button, GimpControllerList *list) { GimpControllerInfo *info; GimpContainer *container; if (list->src_gtype == GIMP_TYPE_CONTROLLER_KEYBOARD && gimp_controllers_get_keyboard (list->gimp) != NULL) { gimp_message_literal (list->gimp, G_OBJECT (button), GIMP_MESSAGE_WARNING, _("There can only be one active keyboard " "controller.\n\n" "You already have a keyboard controller in " "your list of active controllers.")); return; } else if (list->src_gtype == GIMP_TYPE_CONTROLLER_WHEEL && gimp_controllers_get_wheel (list->gimp) != NULL) { gimp_message_literal (list->gimp, G_OBJECT (button), GIMP_MESSAGE_WARNING, _("There can only be one active wheel " "controller.\n\n" "You already have a wheel controller in " "your list of active controllers.")); return; } else if (list->src_gtype == GIMP_TYPE_CONTROLLER_MOUSE && gimp_controllers_get_mouse (list->gimp) != NULL) { gimp_message_literal (list->gimp, G_OBJECT (button), GIMP_MESSAGE_WARNING, _("There can only be one active mouse " "controller.\n\n" "You already have a mouse controller in " "your list of active controllers.")); return; } info = gimp_controller_info_new (list->src_gtype); container = gimp_controllers_get_list (list->gimp); gimp_container_add (container, GIMP_OBJECT (info)); g_object_unref (info); gimp_container_view_select_item (GIMP_CONTAINER_VIEW (list->dest), GIMP_VIEWABLE (info)); gimp_controller_list_edit_clicked (NULL, list); }
static void gimp_tagged_container_tag_added (GimpTagged *tagged, GimpTag *tag, GimpTaggedContainer *tagged_container) { gimp_tagged_container_ref_tag (tagged_container, tag); if (gimp_tagged_container_object_matches (tagged_container, GIMP_OBJECT (tagged)) && ! gimp_container_have (GIMP_CONTAINER (tagged_container), GIMP_OBJECT (tagged))) { gimp_container_add (GIMP_CONTAINER (tagged_container), GIMP_OBJECT (tagged)); } }
GimpDisplay * gimp_display_new (GimpImage *image, GimpUnit unit, gdouble scale, GimpMenuFactory *menu_factory, GimpUIManager *popup_manager) { GimpDisplay *display; gint ID; g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL); /* If there isn't an interface, never create a display */ if (image->gimp->no_interface) return NULL; do { ID = image->gimp->next_display_ID++; if (image->gimp->next_display_ID == G_MAXINT) image->gimp->next_display_ID = 1; } while (gimp_display_get_by_ID (image->gimp, ID)); display = g_object_new (GIMP_TYPE_DISPLAY, "id", ID, NULL); /* refs the image */ gimp_display_connect (display, image); /* create the shell for the image */ display->shell = gimp_display_shell_new (display, unit, scale, menu_factory, popup_manager); gtk_widget_show (display->shell); g_signal_connect (GIMP_DISPLAY_SHELL (display->shell)->statusbar, "cancel", G_CALLBACK (gimp_display_progress_canceled), display); /* add the display to the list */ gimp_container_add (image->gimp->displays, GIMP_OBJECT (display)); return display; }
static GimpGradient * gimp_gradients_add_gradient (Gimp *gimp, const gchar *name, const gchar *id) { GimpGradient *gradient; gradient = GIMP_GRADIENT (gimp_gradient_new (gimp_get_user_context (gimp), name)); gimp_data_make_internal (GIMP_DATA (gradient), id); gimp_container_add (gimp_data_factory_get_container (gimp->gradient_factory), GIMP_OBJECT (gradient)); g_object_unref (gradient); g_object_set_data (G_OBJECT (gimp), id, gradient); return gradient; }
static void gimp_font_list_add_font (GimpFontList *list, PangoContext *context, PangoFontDescription *desc) { GimpFont *font; gchar *name; gsize len; if (! desc) return; name = font_desc_to_string (desc); len = strlen (name); if (! g_utf8_validate (name, len, NULL)) { g_free (name); return; } #ifdef __GNUC__ #warning remove this as soon as we depend on Pango 1.16.5 #endif if (g_str_has_suffix (name, " Not-Rotated")) name[len - strlen (" Not-Rotated")] = '\0'; font = g_object_new (GIMP_TYPE_FONT, "name", name, "pango-context", context, NULL); g_free (name); gimp_container_add (GIMP_CONTAINER (list), GIMP_OBJECT (font)); g_object_unref (font); }
static void gimp_tools_register (GType tool_type, GType tool_options_type, GimpToolOptionsGUIFunc options_gui_func, 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_data, const gchar *icon_name, gpointer data) { Gimp *gimp = (Gimp *) data; GimpToolInfo *tool_info; const gchar *paint_core_name; gboolean visible; g_return_if_fail (GIMP_IS_GIMP (gimp)); g_return_if_fail (g_type_is_a (tool_type, GIMP_TYPE_TOOL)); g_return_if_fail (tool_options_type == G_TYPE_NONE || g_type_is_a (tool_options_type, GIMP_TYPE_TOOL_OPTIONS)); if (tool_options_type == G_TYPE_NONE) tool_options_type = GIMP_TYPE_TOOL_OPTIONS; if (tool_type == GIMP_TYPE_PENCIL_TOOL) { paint_core_name = "gimp-pencil"; } else if (tool_type == GIMP_TYPE_PAINTBRUSH_TOOL) { paint_core_name = "gimp-paintbrush"; } else if (tool_type == GIMP_TYPE_ERASER_TOOL) { paint_core_name = "gimp-eraser"; } else if (tool_type == GIMP_TYPE_AIRBRUSH_TOOL) { paint_core_name = "gimp-airbrush"; } else if (tool_type == GIMP_TYPE_CLONE_TOOL) { paint_core_name = "gimp-clone"; } else if (tool_type == GIMP_TYPE_HEAL_TOOL) { paint_core_name = "gimp-heal"; } else if (tool_type == GIMP_TYPE_PERSPECTIVE_CLONE_TOOL) { paint_core_name = "gimp-perspective-clone"; } else if (tool_type == GIMP_TYPE_CONVOLVE_TOOL) { paint_core_name = "gimp-convolve"; } else if (tool_type == GIMP_TYPE_SMUDGE_TOOL) { paint_core_name = "gimp-smudge"; } else if (tool_type == GIMP_TYPE_DODGE_BURN_TOOL) { paint_core_name = "gimp-dodge-burn"; } else if (tool_type == GIMP_TYPE_INK_TOOL) { paint_core_name = "gimp-ink"; } else if (tool_type == GIMP_TYPE_MYBRUSH_TOOL) { paint_core_name = "gimp-mybrush"; } else { paint_core_name = "gimp-paintbrush"; } tool_info = gimp_tool_info_new (gimp, tool_type, tool_options_type, context_props, identifier, blurb, help, menu_label, menu_accel, help_domain, help_data, paint_core_name, icon_name); visible = (! g_type_is_a (tool_type, GIMP_TYPE_IMAGE_MAP_TOOL)); g_object_set (tool_info, "visible", visible, NULL); g_object_set_data (G_OBJECT (tool_info), "gimp-tool-default-visible", GINT_TO_POINTER (visible)); g_object_set_data (G_OBJECT (tool_info), "gimp-tool-options-gui-func", options_gui_func); gimp_container_add (gimp->tool_info_list, GIMP_OBJECT (tool_info)); g_object_unref (tool_info); if (tool_type == GIMP_TYPE_PAINTBRUSH_TOOL) gimp_tool_info_set_standard (gimp, tool_info); }
static void gimp_real_initialize (Gimp *gimp, GimpInitStatusFunc status_callback) { static const GimpDataFactoryLoaderEntry brush_loader_entries[] = { { gimp_brush_load, GIMP_BRUSH_FILE_EXTENSION, FALSE }, { gimp_brush_load, GIMP_BRUSH_PIXMAP_FILE_EXTENSION, FALSE }, { gimp_brush_load_abr, GIMP_BRUSH_PS_FILE_EXTENSION, FALSE }, { gimp_brush_load_abr, GIMP_BRUSH_PSP_FILE_EXTENSION, FALSE }, { gimp_brush_generated_load, GIMP_BRUSH_GENERATED_FILE_EXTENSION, TRUE }, { gimp_brush_pipe_load, GIMP_BRUSH_PIPE_FILE_EXTENSION, FALSE } }; static const GimpDataFactoryLoaderEntry dynamics_loader_entries[] = { { gimp_dynamics_load, GIMP_DYNAMICS_FILE_EXTENSION, TRUE } }; static const GimpDataFactoryLoaderEntry mybrush_loader_entries[] = { { gimp_mybrush_load, GIMP_MYBRUSH_FILE_EXTENSION, FALSE } }; static const GimpDataFactoryLoaderEntry pattern_loader_entries[] = { { gimp_pattern_load, GIMP_PATTERN_FILE_EXTENSION, FALSE }, { gimp_pattern_load_pixbuf, NULL /* fallback loader */, FALSE } }; static const GimpDataFactoryLoaderEntry gradient_loader_entries[] = { { gimp_gradient_load, GIMP_GRADIENT_FILE_EXTENSION, TRUE }, { gimp_gradient_load_svg, GIMP_GRADIENT_SVG_FILE_EXTENSION, FALSE } }; static const GimpDataFactoryLoaderEntry palette_loader_entries[] = { { gimp_palette_load, GIMP_PALETTE_FILE_EXTENSION, TRUE } }; static const GimpDataFactoryLoaderEntry tool_preset_loader_entries[] = { { gimp_tool_preset_load, GIMP_TOOL_PRESET_FILE_EXTENSION, TRUE } }; GimpData *clipboard_brush; GimpData *clipboard_pattern; if (gimp->be_verbose) g_print ("INIT: %s\n", G_STRFUNC); status_callback (_("Initialization"), NULL, 0.0); gimp_fonts_init (gimp); gimp->brush_factory = gimp_data_factory_new (gimp, GIMP_TYPE_BRUSH, "brush-path", "brush-path-writable", brush_loader_entries, G_N_ELEMENTS (brush_loader_entries), gimp_brush_new, gimp_brush_get_standard); gimp_object_set_static_name (GIMP_OBJECT (gimp->brush_factory), "brush factory"); gimp->dynamics_factory = gimp_data_factory_new (gimp, GIMP_TYPE_DYNAMICS, "dynamics-path", "dynamics-path-writable", dynamics_loader_entries, G_N_ELEMENTS (dynamics_loader_entries), gimp_dynamics_new, gimp_dynamics_get_standard); gimp_object_set_static_name (GIMP_OBJECT (gimp->dynamics_factory), "dynamics factory"); gimp->mybrush_factory = gimp_data_factory_new (gimp, GIMP_TYPE_MYBRUSH, "mypaint-brush-path", "mypaint-brush-path-writable", mybrush_loader_entries, G_N_ELEMENTS (mybrush_loader_entries), NULL, NULL); gimp_object_set_static_name (GIMP_OBJECT (gimp->mybrush_factory), "mypaint brush factory"); gimp->pattern_factory = gimp_data_factory_new (gimp, GIMP_TYPE_PATTERN, "pattern-path", "pattern-path-writable", pattern_loader_entries, G_N_ELEMENTS (pattern_loader_entries), NULL, gimp_pattern_get_standard); gimp_object_set_static_name (GIMP_OBJECT (gimp->pattern_factory), "pattern factory"); gimp->gradient_factory = gimp_data_factory_new (gimp, GIMP_TYPE_GRADIENT, "gradient-path", "gradient-path-writable", gradient_loader_entries, G_N_ELEMENTS (gradient_loader_entries), gimp_gradient_new, gimp_gradient_get_standard); gimp_object_set_static_name (GIMP_OBJECT (gimp->gradient_factory), "gradient factory"); gimp->palette_factory = gimp_data_factory_new (gimp, GIMP_TYPE_PALETTE, "palette-path", "palette-path-writable", palette_loader_entries, G_N_ELEMENTS (palette_loader_entries), gimp_palette_new, gimp_palette_get_standard); gimp_object_set_static_name (GIMP_OBJECT (gimp->palette_factory), "palette factory"); gimp->tool_preset_factory = gimp_data_factory_new (gimp, GIMP_TYPE_TOOL_PRESET, "tool-preset-path", "tool-preset-path-writable", tool_preset_loader_entries, G_N_ELEMENTS (tool_preset_loader_entries), gimp_tool_preset_new, NULL); gimp_object_set_static_name (GIMP_OBJECT (gimp->tool_preset_factory), "tool preset factory"); gimp->tag_cache = gimp_tag_cache_new (); gimp_paint_init (gimp); /* Set the last values used to default values. */ gimp->image_new_last_template = gimp_config_duplicate (GIMP_CONFIG (gimp->config->default_image)); /* create user and default context */ gimp_contexts_init (gimp); /* add the builtin FG -> BG etc. gradients */ gimp_gradients_init (gimp); /* add the color history palette */ gimp_palettes_init (gimp); /* add the clipboard brush */ clipboard_brush = gimp_brush_clipboard_new (gimp); gimp_data_make_internal (GIMP_DATA (clipboard_brush), "gimp-brush-clipboard"); gimp_container_add (gimp_data_factory_get_container (gimp->brush_factory), GIMP_OBJECT (clipboard_brush)); g_object_unref (clipboard_brush); /* add the clipboard pattern */ clipboard_pattern = gimp_pattern_clipboard_new (gimp); gimp_data_make_internal (GIMP_DATA (clipboard_pattern), "gimp-pattern-clipboard"); gimp_container_add (gimp_data_factory_get_container (gimp->pattern_factory), GIMP_OBJECT (clipboard_pattern)); g_object_unref (clipboard_pattern); /* register all internal procedures */ status_callback (NULL, _("Internal Procedures"), 0.2); internal_procs_init (gimp->pdb); gimp_pdb_compat_procs_register (gimp->pdb, gimp->pdb_compat_mode); gimp_plug_in_manager_initialize (gimp->plug_in_manager, status_callback); status_callback (NULL, "", 1.0); }