[gimp] app: finally apply tool presets when one is seleced
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] app: finally apply tool presets when one is seleced
- Date: Wed, 21 Apr 2010 18:58:57 +0000 (UTC)
commit 56e4585f700b59c8349093dcbeb1abd0ab787a23
Author: Michael Natterer <mitch gimp org>
Date: Wed Apr 21 20:56:49 2010 +0200
app: finally apply tool presets when one is seleced
currently respects the fact that FG/BG are always global and the
global brush,pattern,... settings from gimprc. This should probably
not change, but rather be overridable on a per-preset basis as
suggested.
app/tools/tool_manager.c | 132 +++++++++++++++++++++++++++-------------------
1 files changed, 78 insertions(+), 54 deletions(-)
---
diff --git a/app/tools/tool_manager.c b/app/tools/tool_manager.c
index 45c2ba8..35160ae 100644
--- a/app/tools/tool_manager.c
+++ b/app/tools/tool_manager.c
@@ -56,18 +56,23 @@ struct _GimpToolManager
/* local function prototypes */
-static GimpToolManager * tool_manager_get (Gimp *gimp);
-static void tool_manager_set (Gimp *gimp,
- GimpToolManager *tool_manager);
-static void tool_manager_tool_changed (GimpContext *user_context,
- GimpToolInfo *tool_info,
- GimpToolManager *tool_manager);
-static void tool_manager_preset_changed (GimpContext *user_context,
- GimpToolPreset *preset,
- GimpToolManager *tool_manager);
-static void tool_manager_image_clean_dirty (GimpImage *image,
- GimpDirtyMask dirty_mask,
- GimpToolManager *tool_manager);
+static GimpToolManager * tool_manager_get (Gimp *gimp);
+static void tool_manager_set (Gimp *gimp,
+ GimpToolManager *tool_manager);
+static void tool_manager_tool_changed (GimpContext *user_context,
+ GimpToolInfo *tool_info,
+ GimpToolManager *tool_manager);
+static void tool_manager_preset_changed (GimpContext *user_context,
+ GimpToolPreset *preset,
+ GimpToolManager *tool_manager);
+static void tool_manager_image_clean_dirty (GimpImage *image,
+ GimpDirtyMask dirty_mask,
+ GimpToolManager *tool_manager);
+
+static void tool_manager_connect_options (GimpContext *user_context,
+ GimpToolInfo *tool_info);
+static void tool_manager_disconnect_options (GimpContext *user_context,
+ GimpToolInfo *tool_info);
/* public functions */
@@ -592,45 +597,15 @@ tool_manager_tool_changed (GimpContext *user_context,
}
/* disconnect the old tool's context */
- if (tool_manager->active_tool &&
- tool_manager->active_tool->tool_info &&
- tool_manager->active_tool->tool_info->context_props)
+ if (tool_manager->active_tool &&
+ tool_manager->active_tool->tool_info)
{
- GimpToolInfo *old_tool_info = tool_manager->active_tool->tool_info;
-
- gimp_context_set_parent (GIMP_CONTEXT (old_tool_info->tool_options),
- NULL);
+ tool_manager_disconnect_options (user_context,
+ tool_manager->active_tool->tool_info);
}
/* connect the new tool's context */
- 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_FOREGROUND_MASK;
- global_props |= GIMP_CONTEXT_BACKGROUND_MASK;
-
- if (config->global_brush)
- global_props |= GIMP_CONTEXT_BRUSH_MASK;
- if (config->global_dynamics)
- global_props |= GIMP_CONTEXT_DYNAMICS_MASK;
- if (config->global_pattern)
- global_props |= GIMP_CONTEXT_PATTERN_MASK;
- if (config->global_palette)
- global_props |= GIMP_CONTEXT_PALETTE_MASK;
- if (config->global_gradient)
- global_props |= GIMP_CONTEXT_GRADIENT_MASK;
- if (config->global_font)
- global_props |= GIMP_CONTEXT_FONT_MASK;
-
- 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);
- }
+ tool_manager_connect_options (user_context, tool_info);
tool_manager_select_tool (user_context->gimp, new_tool);
@@ -643,6 +618,7 @@ tool_manager_preset_changed (GimpContext *user_context,
GimpToolManager *tool_manager)
{
GimpToolInfo *preset_tool;
+ gboolean tool_change = FALSE;
if (! preset || user_context->gimp->busy)
return;
@@ -650,14 +626,18 @@ tool_manager_preset_changed (GimpContext *user_context,
preset_tool = gimp_context_get_tool (GIMP_CONTEXT (preset->tool_options));
if (preset_tool != gimp_context_get_tool (user_context))
- {
- gimp_context_set_tool (user_context, preset_tool);
+ tool_change = TRUE;
-#if 0
- gimp_config_copy (GIMP_CONFIG (preset->tool_options),
- GIMP_CONFIG (preset_tool->tool_options), 0);
-#endif
- }
+ 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);
}
static void
@@ -678,3 +658,47 @@ tool_manager_image_clean_dirty (GimpImage *image,
display);
}
}
+
+static void
+tool_manager_connect_options (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_FOREGROUND_MASK;
+ global_props |= GIMP_CONTEXT_BACKGROUND_MASK;
+
+ if (config->global_brush)
+ global_props |= GIMP_CONTEXT_BRUSH_MASK;
+ if (config->global_dynamics)
+ global_props |= GIMP_CONTEXT_DYNAMICS_MASK;
+ if (config->global_pattern)
+ global_props |= GIMP_CONTEXT_PATTERN_MASK;
+ if (config->global_palette)
+ global_props |= GIMP_CONTEXT_PALETTE_MASK;
+ if (config->global_gradient)
+ global_props |= GIMP_CONTEXT_GRADIENT_MASK;
+ if (config->global_font)
+ global_props |= GIMP_CONTEXT_FONT_MASK;
+
+ 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);
+ }
+}
+
+static void
+tool_manager_disconnect_options (GimpContext *user_context,
+ GimpToolInfo *tool_info)
+{
+ if (tool_info->context_props)
+ {
+ gimp_context_set_parent (GIMP_CONTEXT (tool_info->tool_options), NULL);
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]