static void tool_manager_disconnect_options (GimpToolManager *tool_manager, GimpContext *user_context, GimpToolInfo *tool_info) { if (tool_info->context_props) { if (GIMP_IS_PAINT_OPTIONS (tool_info->tool_options)) { /* Storing is unconditional, because the user may turn on * brush sharing mid use */ gimp_paint_options_copy_brush_props (GIMP_PAINT_OPTIONS (tool_info->tool_options), tool_manager->shared_paint_options); gimp_paint_options_copy_dynamics_props (GIMP_PAINT_OPTIONS (tool_info->tool_options), tool_manager->shared_paint_options); gimp_paint_options_copy_gradient_props (GIMP_PAINT_OPTIONS (tool_info->tool_options), tool_manager->shared_paint_options); } gimp_context_set_parent (GIMP_CONTEXT (tool_info->tool_options), NULL); } }
static void tool_manager_connect_options (GimpToolManager *tool_manager, GimpContext *user_context, GimpToolInfo *tool_info) { if (tool_info->context_props) { GimpCoreConfig *config = user_context->gimp->config; GimpContextPropMask global_props = 0; /* FG and BG are always shared between all tools */ global_props |= GIMP_CONTEXT_PROP_MASK_FOREGROUND; global_props |= GIMP_CONTEXT_PROP_MASK_BACKGROUND; if (config->global_brush) global_props |= GIMP_CONTEXT_PROP_MASK_BRUSH; if (config->global_dynamics) global_props |= GIMP_CONTEXT_PROP_MASK_DYNAMICS; if (config->global_pattern) global_props |= GIMP_CONTEXT_PROP_MASK_PATTERN; if (config->global_palette) global_props |= GIMP_CONTEXT_PROP_MASK_PALETTE; if (config->global_gradient) global_props |= GIMP_CONTEXT_PROP_MASK_GRADIENT; if (config->global_font) global_props |= GIMP_CONTEXT_PROP_MASK_FONT; gimp_context_copy_properties (GIMP_CONTEXT (tool_info->tool_options), user_context, tool_info->context_props & ~global_props); gimp_context_set_parent (GIMP_CONTEXT (tool_info->tool_options), user_context); if (GIMP_IS_PAINT_OPTIONS (tool_info->tool_options)) { if (config->global_brush) gimp_paint_options_copy_brush_props (tool_manager->shared_paint_options, GIMP_PAINT_OPTIONS (tool_info->tool_options)); if (config->global_dynamics) gimp_paint_options_copy_dynamics_props (tool_manager->shared_paint_options, GIMP_PAINT_OPTIONS (tool_info->tool_options)); if (config->global_gradient) gimp_paint_options_copy_gradient_props (tool_manager->shared_paint_options, GIMP_PAINT_OPTIONS (tool_info->tool_options)); } } }
static void tool_manager_preset_changed (GimpContext *user_context, GimpToolPreset *preset, GimpToolManager *tool_manager) { GimpToolInfo *preset_tool; gchar *options_name; gboolean tool_change = FALSE; if (! preset || user_context->gimp->busy) return; preset_tool = gimp_context_get_tool (GIMP_CONTEXT (preset->tool_options)); if (preset_tool != gimp_context_get_tool (user_context)) tool_change = TRUE; if (! tool_change) tool_manager_disconnect_options (tool_manager, user_context, preset_tool); /* save the name, we don't want to overwrite it */ options_name = g_strdup (gimp_object_get_name (preset_tool->tool_options)); gimp_config_copy (GIMP_CONFIG (preset->tool_options), GIMP_CONFIG (preset_tool->tool_options), 0); /* restore the saved name */ gimp_object_take_name (GIMP_OBJECT (preset_tool->tool_options), options_name); if (tool_change) gimp_context_set_tool (user_context, preset_tool); else tool_manager_connect_options (tool_manager, user_context, preset_tool); gimp_context_copy_properties (GIMP_CONTEXT (preset->tool_options), user_context, gimp_tool_preset_get_prop_mask (preset)); if (GIMP_IS_PAINT_OPTIONS (preset->tool_options)) { GimpCoreConfig *config = user_context->gimp->config; GimpToolOptions *src = preset->tool_options; GimpToolOptions *dest = tool_manager->active_tool->tool_info->tool_options; /* if connect_options() did overwrite the brush options and the * preset contains a brush, use the brush options from the * preset */ if (config->global_brush && preset->use_brush) gimp_paint_options_copy_brush_props (GIMP_PAINT_OPTIONS (src), GIMP_PAINT_OPTIONS (dest)); if (config->global_dynamics && preset->use_dynamics) gimp_paint_options_copy_dynamics_props (GIMP_PAINT_OPTIONS (src), GIMP_PAINT_OPTIONS (dest)); if (config->global_gradient && preset->use_gradient) gimp_paint_options_copy_gradient_props (GIMP_PAINT_OPTIONS (src), GIMP_PAINT_OPTIONS (dest)); } }
static void tool_manager_preset_changed (GimpContext *user_context, GimpToolPreset *preset, GimpToolManager *tool_manager) { GimpToolInfo *preset_tool; gchar *options_name; gboolean tool_change = FALSE; if (! preset || user_context->gimp->busy) return; preset_tool = gimp_context_get_tool (GIMP_CONTEXT (preset->tool_options)); if (preset_tool != gimp_context_get_tool (user_context)) tool_change = TRUE; if (! tool_change) tool_manager_disconnect_options (tool_manager, user_context, preset_tool); /* save the name, we don't want to overwrite it */ options_name = g_strdup (gimp_object_get_name (preset_tool->tool_options)); gimp_config_copy (GIMP_CONFIG (preset->tool_options), GIMP_CONFIG (preset_tool->tool_options), 0); /* restore the saved name */ gimp_object_take_name (GIMP_OBJECT (preset_tool->tool_options), options_name); if (tool_change) gimp_context_set_tool (user_context, preset_tool); else tool_manager_connect_options (tool_manager, user_context, preset_tool); gimp_context_copy_properties (GIMP_CONTEXT (preset->tool_options), user_context, gimp_tool_preset_get_prop_mask (preset)); if (GIMP_IS_PAINT_OPTIONS (preset->tool_options)) { GimpToolOptions *src = preset->tool_options; GimpToolOptions *dest = tool_manager->active_tool->tool_info->tool_options; /* copy various data objects' additional tool options again * manually, they might have been overwritten by e.g. the "link * brush stuff to brush defaults" logic in * gimptooloptions-gui.c */ if (preset->use_brush) gimp_paint_options_copy_brush_props (GIMP_PAINT_OPTIONS (src), GIMP_PAINT_OPTIONS (dest)); if (preset->use_dynamics) gimp_paint_options_copy_dynamics_props (GIMP_PAINT_OPTIONS (src), GIMP_PAINT_OPTIONS (dest)); if (preset->use_gradient) gimp_paint_options_copy_gradient_props (GIMP_PAINT_OPTIONS (src), GIMP_PAINT_OPTIONS (dest)); } }