app: respond to "focus-changed" signal in various tool widgets

... by disabling persistent item highlights when unfocused.
This commit is contained in:
Ell 2018-06-02 01:43:53 -04:00
parent eeed9c413b
commit 49089fc427
2 changed files with 17 additions and 2 deletions

View File

@ -139,6 +139,7 @@ static void gimp_tool_line_get_property (GObject *object,
GParamSpec *pspec);
static void gimp_tool_line_changed (GimpToolWidget *widget);
static void gimp_tool_line_focus_changed (GimpToolWidget *widget);
static gint gimp_tool_line_button_press (GimpToolWidget *widget,
const GimpCoords *coords,
guint32 time,
@ -218,6 +219,7 @@ gimp_tool_line_class_init (GimpToolLineClass *klass)
object_class->get_property = gimp_tool_line_get_property;
widget_class->changed = gimp_tool_line_changed;
widget_class->focus_changed = gimp_tool_line_focus_changed;
widget_class->button_press = gimp_tool_line_button_press;
widget_class->button_release = gimp_tool_line_button_release;
widget_class->motion = gimp_tool_line_motion;
@ -615,6 +617,14 @@ gimp_tool_line_changed (GimpToolWidget *widget)
gimp_tool_line_update_hilight (line);
}
static void
gimp_tool_line_focus_changed (GimpToolWidget *widget)
{
GimpToolLine *line = GIMP_TOOL_LINE (widget);
gimp_tool_line_update_hilight (line);
}
gboolean
gimp_tool_line_button_press (GimpToolWidget *widget,
const GimpCoords *coords,
@ -1440,8 +1450,11 @@ static void
gimp_tool_line_update_hilight (GimpToolLine *line)
{
GimpToolLinePrivate *private = line->private;
gboolean focus;
gint i;
focus = gimp_tool_widget_get_focus (GIMP_TOOL_WIDGET (line));
for (i = GIMP_TOOL_LINE_HANDLE_NONE + 1;
i < (gint) private->sliders->len;
i++)
@ -1450,7 +1463,7 @@ gimp_tool_line_update_hilight (GimpToolLine *line)
handle = gimp_tool_line_get_handle (line, i);
gimp_canvas_item_set_highlight (handle, i == private->selection);
gimp_canvas_item_set_highlight (handle, focus && i == private->selection);
}
}

View File

@ -208,6 +208,7 @@ gimp_tool_path_class_init (GimpToolPathClass *klass)
object_class->get_property = gimp_tool_path_get_property;
widget_class->changed = gimp_tool_path_changed;
widget_class->focus_changed = gimp_tool_path_changed;
widget_class->button_press = gimp_tool_path_button_press;
widget_class->button_release = gimp_tool_path_button_release;
widget_class->motion = gimp_tool_path_motion;
@ -442,7 +443,8 @@ gimp_tool_path_changed (GimpToolWidget *widget)
g_array_index (coords, GimpCoords, i + 1).x,
g_array_index (coords, GimpCoords, i + 1).y);
gimp_canvas_item_set_highlight (item, TRUE);
if (gimp_tool_widget_get_focus (widget))
gimp_canvas_item_set_highlight (item, TRUE);
private->items = g_list_prepend (private->items, item);
}