[gimp/gimp-2-10] app: add gimp_tool_widget_{set,get}_focus(); "focus-changed" signal
- From: Ell <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gimp-2-10] app: add gimp_tool_widget_{set,get}_focus(); "focus-changed" signal
- Date: Tue, 5 Jun 2018 08:34:36 +0000 (UTC)
commit f4f1ecf54a580655658b92d628394684be74bad1
Author: Ell <ell_se yahoo com>
Date: Sat Jun 2 01:38:38 2018 -0400
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 eeed9c413b2abbde03c18ddf4bb9a05dda97e659)
app/display/gimptoolwidget.c | 34 ++++++++++++++++++++++++++++++++++
app/display/gimptoolwidget.h | 5 +++++
2 files changed, 39 insertions(+)
---
diff --git a/app/display/gimptoolwidget.c b/app/display/gimptoolwidget.c
index eb442ca55b..871215a62a 100644
--- a/app/display/gimptoolwidget.c
+++ b/app/display/gimptoolwidget.c
@@ -56,6 +56,7 @@ enum
SNAP_OFFSETS,
STATUS,
STATUS_COORDS,
+ FOCUS_CHANGED,
LAST_SIGNAL
};
@@ -69,6 +70,8 @@ struct _GimpToolWidgetPrivate
gint snap_offset_y;
gint snap_width;
gint snap_height;
+
+ gboolean focus;
};
@@ -168,6 +171,15 @@ gimp_tool_widget_class_init (GimpToolWidgetClass *klass)
G_TYPE_DOUBLE,
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_param_spec_object ("shell",
NULL, NULL,
@@ -320,6 +332,28 @@ gimp_tool_widget_get_item (GimpToolWidget *widget)
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
gimp_tool_widget_response (GimpToolWidget *widget,
gint response_id)
diff --git a/app/display/gimptoolwidget.h b/app/display/gimptoolwidget.h
index 7f2cac1708..0c1e9b876c 100644
--- a/app/display/gimptoolwidget.h
+++ b/app/display/gimptoolwidget.h
@@ -69,6 +69,7 @@ struct _GimpToolWidgetClass
const gchar *separator,
gdouble y,
const gchar *help);
+ void (* focus_changed) (GimpToolWidget *widget);
/* virtual functions */
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);
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
*/
void gimp_tool_widget_response (GimpToolWidget *widget,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]