void edit_copy_visible_cmd_callback (GtkAction *action, gpointer data) { GimpImage *image; GError *error = NULL; return_if_no_image (image, data); if (gimp_edit_copy_visible (image, action_data_get_context (data), &error)) { GimpDisplay *display = action_data_get_display (data); if (display) gimp_message_literal (image->gimp, G_OBJECT (display), GIMP_MESSAGE_INFO, _("Copied pixels to the clipboard")); gimp_image_flush (image); } else { gimp_message_literal (image->gimp, G_OBJECT (action_data_get_display (data)), GIMP_MESSAGE_WARNING, error->message); g_clear_error (&error); } }
static void gimp_display_shell_drop_buffer (GtkWidget *widget, gint drop_x, gint drop_y, GimpViewable *viewable, gpointer data) { GimpDisplayShell *shell = GIMP_DISPLAY_SHELL (data); GimpImage *image = gimp_display_get_image (shell->display); GimpDrawable *drawable; GimpBuffer *buffer; gint x, y, width, height; GIMP_LOG (DND, NULL); if (shell->display->gimp->busy) return; if (! image) { image = gimp_image_new_from_buffer (shell->display->gimp, NULL, GIMP_BUFFER (viewable)); gimp_create_display (image->gimp, image, GIMP_UNIT_PIXEL, 1.0); g_object_unref (image); return; } drawable = gimp_image_get_active_drawable (image); if (drawable) { if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable))) { gimp_message_literal (shell->display->gimp, G_OBJECT (shell->display), GIMP_MESSAGE_ERROR, _("Cannot modify the pixels of layer groups.")); return; } if (gimp_item_is_content_locked (GIMP_ITEM (drawable))) { gimp_message_literal (shell->display->gimp, G_OBJECT (shell->display), GIMP_MESSAGE_ERROR, _("The active layer's pixels are locked.")); return; } } buffer = GIMP_BUFFER (viewable); gimp_display_shell_untransform_viewport (shell, &x, &y, &width, &height); /* FIXME: popup a menu for selecting "Paste Into" */ gimp_edit_paste (image, drawable, buffer, FALSE, x, y, width, height); gimp_display_shell_dnd_flush (shell, image); }
static void gimp_action_view_accel_cleared (GtkCellRendererAccel *accel, const char *path_string, GimpActionView *view) { GtkAction *action; guint action_accel_key; GdkModifierType action_accel_mask; const gchar *accel_path; accel_path = gimp_action_view_get_accel_action (view, path_string, &action, &action_accel_key, &action_accel_mask); if (! accel_path) return; if (action_accel_key == GDK_KEY_F1) { gimp_message_literal (view->manager->gimp, G_OBJECT (view), GIMP_MESSAGE_ERROR, _("F1 cannot be remapped.")); return; } if (! gtk_accel_map_change_entry (accel_path, 0, 0, FALSE)) { gimp_message_literal (view->manager->gimp, G_OBJECT (view), GIMP_MESSAGE_ERROR, _("Removing shortcut failed.")); } }
static void copy_named_buffer_callback (GtkWidget *widget, const gchar *name, gpointer data) { GimpImage *image = GIMP_IMAGE (data); GimpDrawable *drawable = gimp_image_get_active_drawable (image); GError *error = NULL; if (! drawable) { gimp_message_literal (image->gimp, NULL, GIMP_MESSAGE_WARNING, _("There is no active layer or channel to copy from.")); return; } if (! (name && strlen (name))) name = _("(Unnamed Buffer)"); if (gimp_edit_named_copy (image, name, drawable, gimp_get_user_context (image->gimp), &error)) { gimp_image_flush (image); } else { gimp_message_literal (image->gimp, NULL, GIMP_MESSAGE_WARNING, error->message); g_clear_error (&error); } }
static void gimp_display_shell_dnd_bucket_fill (GimpDisplayShell *shell, GimpBucketFillMode fill_mode, const GimpRGB *color, GimpPattern *pattern) { GimpImage *image = gimp_display_get_image (shell->display); GimpDrawable *drawable; if (shell->display->gimp->busy) return; if (! image) return; drawable = gimp_image_get_active_drawable (image); if (! drawable) return; if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable))) { gimp_message_literal (shell->display->gimp, G_OBJECT (shell->display), GIMP_MESSAGE_ERROR, _("Cannot modify the pixels of layer groups.")); return; } if (gimp_item_is_content_locked (GIMP_ITEM (drawable))) { gimp_message_literal (shell->display->gimp, G_OBJECT (shell->display), GIMP_MESSAGE_ERROR, _("The active layer's pixels are locked.")); return; } /* FIXME: there should be a virtual method for this that the * GimpTextLayer can override. */ if (color && gimp_item_is_text_layer (GIMP_ITEM (drawable))) { gimp_text_layer_set (GIMP_TEXT_LAYER (drawable), NULL, "color", color, NULL); } else { gimp_edit_fill_full (image, drawable, color, pattern, GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE, pattern ? C_("undo-type", "Drop pattern to layer") : C_("undo-type", "Drop color to layer")); } gimp_display_shell_dnd_flush (shell, image); }
static void gimp_display_shell_dnd_fill (GimpDisplayShell *shell, GimpFillOptions *options, const gchar *undo_desc) { GimpImage *image = gimp_display_get_image (shell->display); GimpDrawable *drawable; if (shell->display->gimp->busy) return; if (! image) return; drawable = gimp_image_get_active_drawable (image); if (! drawable) return; if (gimp_viewable_get_children (GIMP_VIEWABLE (drawable))) { gimp_message_literal (shell->display->gimp, G_OBJECT (shell->display), GIMP_MESSAGE_ERROR, _("Cannot modify the pixels of layer groups.")); return; } if (gimp_item_is_content_locked (GIMP_ITEM (drawable))) { gimp_message_literal (shell->display->gimp, G_OBJECT (shell->display), GIMP_MESSAGE_ERROR, _("The active layer's pixels are locked.")); return; } /* FIXME: there should be a virtual method for this that the * GimpTextLayer can override. */ if (gimp_fill_options_get_style (options) == GIMP_FILL_STYLE_SOLID && gimp_item_is_text_layer (GIMP_ITEM (drawable))) { GimpRGB color; gimp_context_get_foreground (GIMP_CONTEXT (options), &color); gimp_text_layer_set (GIMP_TEXT_LAYER (drawable), NULL, "color", &color, NULL); } else { gimp_edit_fill (image, drawable, options, undo_desc); } gimp_display_shell_dnd_flush (shell, image); }
void vectors_selection_to_vectors_cmd_callback (GtkAction *action, gint value, gpointer data) { GimpImage *image; GtkWidget *widget; GimpProcedure *procedure; GimpValueArray *args; GimpDisplay *display; GError *error = NULL; return_if_no_image (image, data); return_if_no_widget (widget, data); if (value) procedure = gimp_pdb_lookup_procedure (image->gimp->pdb, "plug-in-sel2path-advanced"); else procedure = gimp_pdb_lookup_procedure (image->gimp->pdb, "plug-in-sel2path"); if (! procedure) { gimp_message_literal (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_ERROR, "Selection to path procedure lookup failed."); return; } display = gimp_context_get_display (action_data_get_context (data)); args = gimp_procedure_get_arguments (procedure); gimp_value_array_truncate (args, 2); g_value_set_int (gimp_value_array_index (args, 0), GIMP_RUN_INTERACTIVE); gimp_value_set_image (gimp_value_array_index (args, 1), image); gimp_procedure_execute_async (procedure, image->gimp, action_data_get_context (data), GIMP_PROGRESS (display), args, GIMP_OBJECT (display), &error); gimp_value_array_unref (args); if (error) { gimp_message_literal (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_ERROR, error->message); g_error_free (error); } }
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); }
void select_float_cmd_callback (GtkAction *action, gpointer data) { GimpImage *image; GtkWidget *widget; GError *error = NULL; return_if_no_image (image, data); return_if_no_widget (widget, data); if (gimp_selection_float (GIMP_SELECTION (gimp_image_get_mask (image)), gimp_image_get_active_drawable (image), action_data_get_context (data), TRUE, 0, 0, &error)) { gimp_image_flush (image); } else { gimp_message_literal (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_WARNING, error->message); g_clear_error (&error); } }
static void plug_in_procedure_execute (GimpPlugInProcedure *procedure, Gimp *gimp, GimpDisplay *display, GimpValueArray *args, gint n_args) { GError *error = NULL; gimp_value_array_truncate (args, n_args); /* run the plug-in procedure */ gimp_procedure_execute_async (GIMP_PROCEDURE (procedure), gimp, gimp_get_user_context (gimp), GIMP_PROGRESS (display), args, GIMP_OBJECT (display), &error); if (error) { gimp_message_literal (gimp, G_OBJECT (display), GIMP_MESSAGE_ERROR, error->message); g_error_free (error); } else { /* remember only image plug-ins */ if (GIMP_PROCEDURE (procedure)->num_args >= 2 && GIMP_IS_PARAM_SPEC_IMAGE_ID (GIMP_PROCEDURE (procedure)->args[1])) { gimp_plug_in_manager_history_add (gimp->plug_in_manager, procedure); } } }
void edit_paste_as_new_layer_cmd_callback (GtkAction *action, gpointer data) { Gimp *gimp; GimpImage *image; GimpBuffer *buffer; return_if_no_gimp (gimp, data); return_if_no_image (image, data); buffer = gimp_clipboard_get_buffer (gimp); if (buffer) { GimpLayer *layer; layer = gimp_layer_new_from_buffer (gimp_buffer_get_buffer (buffer), image, gimp_image_get_layer_format (image, TRUE), _("Clipboard"), GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE); g_object_unref (buffer); gimp_image_add_layer (image, layer, GIMP_IMAGE_ACTIVE_PARENT, -1, TRUE); gimp_image_flush (image); } else { gimp_message_literal (gimp, NULL, GIMP_MESSAGE_WARNING, _("There is no image data in the clipboard to paste.")); } }
void edit_paste_as_new_cmd_callback (GtkAction *action, gpointer data) { Gimp *gimp; GimpBuffer *buffer; return_if_no_gimp (gimp, data); buffer = gimp_clipboard_get_buffer (gimp); if (buffer) { GimpImage *image; image = gimp_image_new_from_buffer (gimp, action_data_get_image (data), buffer); g_object_unref (buffer); gimp_create_display (image->gimp, image, GIMP_UNIT_PIXEL, 1.0); g_object_unref (image); } else { gimp_message_literal (gimp, NULL, GIMP_MESSAGE_WARNING, _("There is no image data in the clipboard to paste.")); } }
void edit_fill_cmd_callback (GtkAction *action, gint value, gpointer data) { GimpImage *image; GimpDrawable *drawable; GimpFillType fill_type; GimpFillOptions *options; GError *error = NULL; return_if_no_drawable (image, drawable, data); fill_type = (GimpFillType) value; options = gimp_fill_options_new (action_data_get_gimp (data), NULL, FALSE); if (gimp_fill_options_set_by_fill_type (options, action_data_get_context (data), fill_type, &error)) { gimp_edit_fill (image, drawable, options, NULL); gimp_image_flush (image); } else { gimp_message_literal (image->gimp, NULL, GIMP_MESSAGE_WARNING, error->message); g_clear_error (&error); } g_object_unref (options); }
void edit_fill_cmd_callback (GtkAction *action, gint value, gpointer data) { GimpImage *image; GimpDrawable *drawable; GimpFillType fill_type; GError *error = NULL; return_if_no_drawable (image, drawable, data); fill_type = (GimpFillType) value; if (gimp_edit_fill (image, drawable, action_data_get_context (data), fill_type, GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE, &error)) { gimp_image_flush (image); } else { gimp_message_literal (image->gimp, NULL, GIMP_MESSAGE_WARNING, error->message); g_clear_error (&error); } }
void dialogs_save_recent_docks (Gimp *gimp) { gchar *filename; GError *error = NULL; g_return_if_fail (GIMP_IS_GIMP (gimp)); filename = dialogs_get_dockrc_filename (); if (gimp->be_verbose) g_print ("Writing '%s'\n", gimp_filename_to_utf8 (filename)); if (! gimp_config_serialize_to_file (GIMP_CONFIG (global_recent_docks), filename, "recently closed docks", "end of recently closed docks", NULL, &error)) { gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message); g_clear_error (&error); } g_free (filename); }
void dialogs_load_recent_docks (Gimp *gimp) { gchar *filename; GError *error = NULL; g_return_if_fail (GIMP_IS_GIMP (gimp)); filename = dialogs_get_dockrc_filename (); if (gimp->be_verbose) g_print ("Parsing '%s'\n", gimp_filename_to_utf8 (filename)); if (! gimp_config_deserialize_file (GIMP_CONFIG (global_recent_docks), filename, NULL, &error)) { if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT) gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message); g_clear_error (&error); } /* In GIMP 2.6 dockrc did not contain the factory entries for the * session infos, so set that up manually if needed */ gimp_container_foreach (global_recent_docks, (GFunc) dialogs_ensure_factory_entry_on_recent_dock, NULL); gimp_list_reverse (GIMP_LIST (global_recent_docks)); g_free (filename); }
void documents_recreate_preview_cmd_callback (GtkAction *action, gpointer data) { GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data); GimpContext *context; GimpContainer *container; GimpImagefile *imagefile; context = gimp_container_view_get_context (editor->view); container = gimp_container_view_get_container (editor->view); imagefile = gimp_context_get_imagefile (context); if (imagefile && gimp_container_have (container, GIMP_OBJECT (imagefile))) { GError *error = NULL; if (! gimp_imagefile_create_thumbnail (imagefile, context, NULL, context->gimp->config->thumbnail_size, FALSE, &error)) { gimp_message_literal (context->gimp, NULL , GIMP_MESSAGE_ERROR, error->message); g_clear_error (&error); } } }
void select_stroke_cmd_callback (GtkAction *action, gpointer data) { GimpImage *image; GimpDrawable *drawable; GtkWidget *widget; GtkWidget *dialog; return_if_no_image (image, data); return_if_no_widget (widget, data); drawable = gimp_image_get_active_drawable (image); if (! drawable) { gimp_message_literal (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_WARNING, _("There is no active layer or channel to stroke to.")); return; } dialog = stroke_dialog_new (GIMP_ITEM (gimp_image_get_mask (image)), action_data_get_context (data), _("Stroke Selection"), GIMP_STOCK_SELECTION_STROKE, GIMP_HELP_SELECTION_STROKE, widget); gtk_widget_show (dialog); }
static void gimp_vectors_tree_view_drop_svg (GimpContainerTreeView *tree_view, const gchar *svg_data, gsize svg_data_len, GimpViewable *dest_viewable, GtkTreeViewDropPosition drop_pos) { GimpItemTreeView *item_view = GIMP_ITEM_TREE_VIEW (tree_view); GimpImage *image = gimp_item_tree_view_get_image (item_view); GimpVectors *parent; gint index; GError *error = NULL; if (image->gimp->be_verbose) g_print ("%s: SVG dropped (len = %d)\n", G_STRFUNC, (gint) svg_data_len); index = gimp_item_tree_view_get_drop_index (item_view, dest_viewable, drop_pos, (GimpViewable **) &parent); if (! gimp_vectors_import_buffer (image, svg_data, svg_data_len, TRUE, FALSE, parent, index, NULL, &error)) { gimp_message_literal (image->gimp, G_OBJECT (tree_view), GIMP_MESSAGE_ERROR, error->message); g_clear_error (&error); } else { gimp_image_flush (image); } }
void gimp_templates_save (Gimp *gimp) { const gchar *header = "GIMP templaterc\n" "\n" "This file will be entirely rewritten each time you exit."; const gchar *footer = "end of templaterc"; GFile *file; GError *error = NULL; g_return_if_fail (GIMP_IS_GIMP (gimp)); g_return_if_fail (GIMP_IS_LIST (gimp->templates)); file = gimp_directory_file ("templaterc", NULL); if (gimp->be_verbose) g_print ("Writing '%s'\n", gimp_file_get_utf8_name (file)); if (! gimp_config_serialize_to_gfile (GIMP_CONFIG (gimp->templates), file, header, footer, NULL, &error)) { gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message); g_error_free (error); } g_object_unref (file); }
gboolean procedure_commands_run_procedure (GimpProcedure *procedure, Gimp *gimp, GimpProgress *progress, GimpRunMode run_mode, GimpValueArray *args, GimpDisplay *display) { GError *error = NULL; g_return_val_if_fail (GIMP_IS_PROCEDURE (procedure), FALSE); g_return_val_if_fail (GIMP_IS_GIMP (gimp), FALSE); g_return_val_if_fail (progress == NULL || GIMP_IS_PROGRESS (progress), FALSE); g_return_val_if_fail (display == NULL || GIMP_IS_DISPLAY (display), FALSE); g_return_val_if_fail (args != NULL, FALSE); g_value_set_int (gimp_value_array_index (args, 0), run_mode); gimp_procedure_execute_async (procedure, gimp, gimp_get_user_context (gimp), progress, args, GIMP_OBJECT (display), &error); if (error) { gimp_message_literal (gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR, error->message); g_clear_error (&error); return FALSE; } return TRUE; }
static void gimp_procedure_real_execute_async (GimpProcedure *procedure, Gimp *gimp, GimpContext *context, GimpProgress *progress, GValueArray *args, GimpObject *display) { GValueArray *return_vals; GError *error = NULL; g_return_if_fail (args->n_values >= procedure->num_args); return_vals = GIMP_PROCEDURE_GET_CLASS (procedure)->execute (procedure, gimp, context, progress, args, &error); g_value_array_free (return_vals); if (error) { gimp_message_literal (gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR, error->message); g_error_free (error); } }
/* read the pluginrc file for cached data */ static void gimp_plug_in_manager_read_pluginrc (GimpPlugInManager *manager, const gchar *pluginrc, GimpInitStatusFunc status_callback) { GSList *rc_defs; GError *error = NULL; status_callback (_("Resource configuration"), gimp_filename_to_utf8 (pluginrc), 0.0); if (manager->gimp->be_verbose) g_print ("Parsing '%s'\n", gimp_filename_to_utf8 (pluginrc)); rc_defs = plug_in_rc_parse (manager->gimp, pluginrc, &error); if (rc_defs) { GSList *list; for (list = rc_defs; list; list = g_slist_next (list)) gimp_plug_in_manager_add_from_rc (manager, list->data); /* consumes list->data */ g_slist_free (rc_defs); } else if (error) { if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT) gimp_message_literal (manager->gimp, NULL, GIMP_MESSAGE_ERROR, error->message); g_clear_error (&error); } }
static void gradients_save_as_pov_ray_response (GtkWidget *dialog, gint response_id, GimpGradient *gradient) { if (response_id == GTK_RESPONSE_OK) { GFile *file = gtk_file_chooser_get_file (GTK_FILE_CHOOSER (dialog)); GError *error = NULL; if (! gimp_gradient_save_pov (gradient, file, &error)) { gimp_message_literal (g_object_get_data (G_OBJECT (dialog), "gimp"), G_OBJECT (dialog), GIMP_MESSAGE_ERROR, error->message); g_clear_error (&error); g_object_unref (file); return; } g_object_unref (file); } gtk_widget_destroy (dialog); }
void select_stroke_last_vals_cmd_callback (GtkAction *action, gpointer data) { GimpImage *image; GimpDrawable *drawable; GimpContext *context; GtkWidget *widget; GimpStrokeOptions *options; GError *error = NULL; return_if_no_image (image, data); return_if_no_context (context, data); return_if_no_widget (widget, data); drawable = gimp_image_get_active_drawable (image); if (! drawable) { gimp_message_literal (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_WARNING, _("There is no active layer or channel to stroke to.")); return; } options = g_object_get_data (G_OBJECT (image->gimp), "saved-stroke-options"); if (options) g_object_ref (options); else options = gimp_stroke_options_new (image->gimp, context, TRUE); if (! gimp_item_stroke (GIMP_ITEM (gimp_image_get_mask (image)), drawable, context, options, NULL, TRUE, NULL, &error)) { gimp_message_literal (image->gimp, G_OBJECT (widget), GIMP_MESSAGE_WARNING, error->message); g_clear_error (&error); } else { gimp_image_flush (image); } g_object_unref (options); }
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 }
void gimp_templates_load (Gimp *gimp) { gchar *filename; GError *error = NULL; g_return_if_fail (GIMP_IS_GIMP (gimp)); g_return_if_fail (GIMP_IS_LIST (gimp->templates)); filename = gimp_personal_rc_file ("templaterc"); if (gimp->be_verbose) g_print ("Parsing '%s'\n", gimp_filename_to_utf8 (filename)); if (! gimp_config_deserialize_file (GIMP_CONFIG (gimp->templates), filename, NULL, &error)) { if (error->code == GIMP_CONFIG_ERROR_OPEN_ENOENT) { g_clear_error (&error); g_free (filename); filename = g_build_filename (gimp_sysconf_directory (), "templaterc", NULL); if (! gimp_config_deserialize_file (GIMP_CONFIG (gimp->templates), filename, NULL, &error)) { gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message); } } else { gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message); } g_clear_error (&error); } gimp_list_reverse (GIMP_LIST (gimp->templates)); g_free (filename); }
void gimp_templates_load (Gimp *gimp) { GFile *file; GError *error = NULL; g_return_if_fail (GIMP_IS_GIMP (gimp)); g_return_if_fail (GIMP_IS_LIST (gimp->templates)); file = gimp_directory_file ("templaterc", NULL); if (gimp->be_verbose) g_print ("Parsing '%s'\n", gimp_file_get_utf8_name (file)); if (! gimp_config_deserialize_gfile (GIMP_CONFIG (gimp->templates), file, NULL, &error)) { if (error->code == GIMP_CONFIG_ERROR_OPEN_ENOENT) { g_clear_error (&error); g_object_unref (file); file = gimp_sysconf_directory_file ("templaterc", NULL); if (! gimp_config_deserialize_gfile (GIMP_CONFIG (gimp->templates), file, NULL, &error)) { gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message); } } else { gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message); } g_clear_error (&error); } gimp_list_reverse (GIMP_LIST (gimp->templates)); g_object_unref (file); }
void gimp_devices_restore (Gimp *gimp) { GimpDeviceManager *manager; GimpContext *user_context; GimpDeviceInfo *current_device; GList *list; gchar *filename; GError *error = NULL; g_return_if_fail (GIMP_IS_GIMP (gimp)); manager = gimp_devices_get_manager (gimp); g_return_if_fail (GIMP_IS_DEVICE_MANAGER (manager)); user_context = gimp_get_user_context (gimp); for (list = GIMP_LIST (manager)->list; list; list = g_list_next (list)) { GimpDeviceInfo *device_info = list->data; gimp_context_copy_properties (user_context, GIMP_CONTEXT (device_info), GIMP_DEVICE_INFO_CONTEXT_MASK); gimp_device_info_set_default_tool (device_info); } filename = gimp_personal_rc_file ("devicerc"); if (gimp->be_verbose) g_print ("Parsing '%s'\n", gimp_filename_to_utf8 (filename)); if (! gimp_config_deserialize_file (GIMP_CONFIG (manager), filename, gimp, &error)) { if (error->code != GIMP_CONFIG_ERROR_OPEN_ENOENT) gimp_message_literal (gimp, NULL, GIMP_MESSAGE_ERROR, error->message); g_error_free (error); /* don't bail out here */ } g_free (filename); current_device = gimp_device_manager_get_current_device (manager); gimp_context_copy_properties (GIMP_CONTEXT (current_device), user_context, GIMP_DEVICE_INFO_CONTEXT_MASK); gimp_context_set_parent (GIMP_CONTEXT (current_device), user_context); }
static void file_open_profile_apply_rgb (GimpImage *image, GimpContext *context, GimpProgress *progress, GimpRunMode run_mode) { GimpColorConfig *config = image->gimp->config->color_management; GError *error = NULL; if (gimp_image_get_base_type (image) == GIMP_GRAY) return; if (config->mode == GIMP_COLOR_MANAGEMENT_OFF) return; if (! plug_in_icc_profile_apply_rgb (image, context, progress, run_mode, &error)) { if (error->domain == GIMP_PLUG_IN_ERROR && error->code == GIMP_PLUG_IN_NOT_FOUND) { gchar *msg = g_strdup_printf ("%s\n\n%s", error->message, _("Color management has been disabled. " "It can be enabled again in the " "Preferences dialog.")); g_object_set (config, "mode", GIMP_COLOR_MANAGEMENT_OFF, NULL); gimp_message_literal (image->gimp, G_OBJECT (progress), GIMP_MESSAGE_WARNING, msg); g_free (msg); } else { gimp_message_literal (image->gimp, G_OBJECT (progress), GIMP_MESSAGE_ERROR, error->message); } g_error_free (error); } }