static void tool_manager_preset_changed (GimpContext *user_context, GimpToolPreset *preset, GimpToolManager *tool_manager) { GimpToolInfo *preset_tool; 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 (user_context, preset_tool); gimp_config_copy (GIMP_CONFIG (preset->tool_options), GIMP_CONFIG (preset_tool->tool_options), 0); if (tool_change) gimp_context_set_tool (user_context, preset_tool); else tool_manager_connect_options (user_context, preset_tool); gimp_context_copy_properties (GIMP_CONTEXT (preset->tool_options), user_context, gimp_tool_preset_get_prop_mask (preset)); }
static void tool_manager_tool_changed (GimpContext *user_context, GimpToolInfo *tool_info, GimpToolManager *tool_manager) { GimpTool *new_tool = NULL; if (! tool_info) return; /* FIXME: gimp_busy HACK */ if (user_context->gimp->busy) { /* there may be contexts waiting for the user_context's "tool-changed" * signal, so stop emitting it. */ g_signal_stop_emission_by_name (user_context, "tool-changed"); if (G_TYPE_FROM_INSTANCE (tool_manager->active_tool) != tool_info->tool_type) { g_signal_handlers_block_by_func (user_context, tool_manager_tool_changed, tool_manager); /* explicitly set the current tool */ gimp_context_set_tool (user_context, tool_manager->active_tool->tool_info); g_signal_handlers_unblock_by_func (user_context, tool_manager_tool_changed, tool_manager); } return; } if (g_type_is_a (tool_info->tool_type, GIMP_TYPE_TOOL)) { new_tool = g_object_new (tool_info->tool_type, "tool-info", tool_info, NULL); } else { g_warning ("%s: tool_info->tool_type is no GimpTool subclass", G_STRFUNC); return; } /* disconnect the old tool's context */ if (tool_manager->active_tool && tool_manager->active_tool->tool_info) { tool_manager_disconnect_options (user_context, tool_manager->active_tool->tool_info); } /* connect the new tool's context */ tool_manager_connect_options (user_context, tool_info); tool_manager_select_tool (user_context->gimp, new_tool); g_object_unref (new_tool); }
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)); } }
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_tool_changed (GimpContext *user_context, GimpToolInfo *tool_info, GimpToolManager *tool_manager) { GimpTool *new_tool = NULL; if (! tool_info) return; if (! g_type_is_a (tool_info->tool_type, GIMP_TYPE_TOOL)) { g_warning ("%s: tool_info->tool_type is no GimpTool subclass", G_STRFUNC); return; } /* FIXME: gimp_busy HACK */ if (user_context->gimp->busy) { /* there may be contexts waiting for the user_context's "tool-changed" * signal, so stop emitting it. */ g_signal_stop_emission_by_name (user_context, "tool-changed"); if (G_TYPE_FROM_INSTANCE (tool_manager->active_tool) != tool_info->tool_type) { g_signal_handlers_block_by_func (user_context, tool_manager_tool_changed, tool_manager); /* explicitly set the current tool */ gimp_context_set_tool (user_context, tool_manager->active_tool->tool_info); g_signal_handlers_unblock_by_func (user_context, tool_manager_tool_changed, tool_manager); } return; } if (tool_manager->active_tool) { GimpTool *active_tool = tool_manager->active_tool; GimpDisplay *display; /* NULL image returns any display (if there is any) */ display = gimp_tool_has_image (active_tool, NULL); /* commit the old tool's operation before creating the new tool * because creating a tool might mess with the old tool's * options (old and new tool might be the same) */ if (display) tool_manager_control_active (user_context->gimp, GIMP_TOOL_ACTION_COMMIT, display); /* disconnect the old tool's context */ if (active_tool->tool_info) tool_manager_disconnect_options (tool_manager, user_context, active_tool->tool_info); } new_tool = g_object_new (tool_info->tool_type, "tool-info", tool_info, NULL); /* connect the new tool's context */ tool_manager_connect_options (tool_manager, user_context, tool_info); tool_manager_select_tool (user_context->gimp, new_tool); g_object_unref (new_tool); }