app: add gimp_tool_widget_{set,get}_focus(); "focus-changed" signal
The next few commits are going to add support for using multiple
tool widgets simultaneously. As a first step, add a notion of a
focused tool widget, by adding gimp_tool_widget_{set,get}_focus(),
which tools/subclasses can use to control focus, and a
corresponding "focus-changed" signal, which tools/subclasses can
use to respond to focus changes.
(cherry picked from commit eeed9c413b
)
This commit is contained in:
@ -56,6 +56,7 @@ enum
|
|||||||
SNAP_OFFSETS,
|
SNAP_OFFSETS,
|
||||||
STATUS,
|
STATUS,
|
||||||
STATUS_COORDS,
|
STATUS_COORDS,
|
||||||
|
FOCUS_CHANGED,
|
||||||
LAST_SIGNAL
|
LAST_SIGNAL
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -69,6 +70,8 @@ struct _GimpToolWidgetPrivate
|
|||||||
gint snap_offset_y;
|
gint snap_offset_y;
|
||||||
gint snap_width;
|
gint snap_width;
|
||||||
gint snap_height;
|
gint snap_height;
|
||||||
|
|
||||||
|
gboolean focus;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -168,6 +171,15 @@ gimp_tool_widget_class_init (GimpToolWidgetClass *klass)
|
|||||||
G_TYPE_DOUBLE,
|
G_TYPE_DOUBLE,
|
||||||
G_TYPE_STRING);
|
G_TYPE_STRING);
|
||||||
|
|
||||||
|
widget_signals[FOCUS_CHANGED] =
|
||||||
|
g_signal_new ("focus-changed",
|
||||||
|
G_TYPE_FROM_CLASS (klass),
|
||||||
|
G_SIGNAL_RUN_FIRST,
|
||||||
|
G_STRUCT_OFFSET (GimpToolWidgetClass, focus_changed),
|
||||||
|
NULL, NULL,
|
||||||
|
g_cclosure_marshal_VOID__VOID,
|
||||||
|
G_TYPE_NONE, 0);
|
||||||
|
|
||||||
g_object_class_install_property (object_class, PROP_SHELL,
|
g_object_class_install_property (object_class, PROP_SHELL,
|
||||||
g_param_spec_object ("shell",
|
g_param_spec_object ("shell",
|
||||||
NULL, NULL,
|
NULL, NULL,
|
||||||
@ -320,6 +332,28 @@ gimp_tool_widget_get_item (GimpToolWidget *widget)
|
|||||||
return widget->private->item;
|
return widget->private->item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
gimp_tool_widget_set_focus (GimpToolWidget *widget,
|
||||||
|
gboolean focus)
|
||||||
|
{
|
||||||
|
g_return_if_fail (GIMP_IS_TOOL_WIDGET (widget));
|
||||||
|
|
||||||
|
if (focus != widget->private->focus)
|
||||||
|
{
|
||||||
|
widget->private->focus = focus;
|
||||||
|
|
||||||
|
g_signal_emit (widget, widget_signals[FOCUS_CHANGED], 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
gboolean
|
||||||
|
gimp_tool_widget_get_focus (GimpToolWidget *widget)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail (GIMP_IS_TOOL_WIDGET (widget), FALSE);
|
||||||
|
|
||||||
|
return widget->private->focus;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
gimp_tool_widget_response (GimpToolWidget *widget,
|
gimp_tool_widget_response (GimpToolWidget *widget,
|
||||||
gint response_id)
|
gint response_id)
|
||||||
|
@ -69,6 +69,7 @@ struct _GimpToolWidgetClass
|
|||||||
const gchar *separator,
|
const gchar *separator,
|
||||||
gdouble y,
|
gdouble y,
|
||||||
const gchar *help);
|
const gchar *help);
|
||||||
|
void (* focus_changed) (GimpToolWidget *widget);
|
||||||
|
|
||||||
/* virtual functions */
|
/* virtual functions */
|
||||||
gint (* button_press) (GimpToolWidget *widget,
|
gint (* button_press) (GimpToolWidget *widget,
|
||||||
@ -119,6 +120,10 @@ GType gimp_tool_widget_get_type (void) G_GNUC_CONST;
|
|||||||
GimpDisplayShell * gimp_tool_widget_get_shell (GimpToolWidget *widget);
|
GimpDisplayShell * gimp_tool_widget_get_shell (GimpToolWidget *widget);
|
||||||
GimpCanvasItem * gimp_tool_widget_get_item (GimpToolWidget *widget);
|
GimpCanvasItem * gimp_tool_widget_get_item (GimpToolWidget *widget);
|
||||||
|
|
||||||
|
void gimp_tool_widget_set_focus (GimpToolWidget *widget,
|
||||||
|
gboolean focus);
|
||||||
|
gboolean gimp_tool_widget_get_focus (GimpToolWidget *widget);
|
||||||
|
|
||||||
/* for subclasses, to notify the handling tool
|
/* for subclasses, to notify the handling tool
|
||||||
*/
|
*/
|
||||||
void gimp_tool_widget_response (GimpToolWidget *widget,
|
void gimp_tool_widget_response (GimpToolWidget *widget,
|
||||||
|
Reference in New Issue
Block a user