[gimp/gtk3-port: 452/457] app: add "source", "vendor-id" and "product-id" to GimpDeviceInfo
- From: Michael Natterer <mitch src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp/gtk3-port: 452/457] app: add "source", "vendor-id" and "product-id" to GimpDeviceInfo
- Date: Sat, 19 May 2018 18:41:39 +0000 (UTC)
commit 76a257858eaffae093323ffcbd7406da33112eb9
Author: Michael Natterer <mitch gimp org>
Date: Wed May 16 21:19:58 2018 +0200
app: add "source", "vendor-id" and "product-id" to GimpDeviceInfo
and display them in GimpDeviceInfoEditor.
app/widgets/gimpdeviceeditor.c | 1 +
app/widgets/gimpdeviceinfo.c | 105 ++++++++++++++++++++++++++++++++++++
app/widgets/gimpdeviceinfo.h | 5 ++
app/widgets/gimpdeviceinfoeditor.c | 47 +++++++++++-----
4 files changed, 143 insertions(+), 15 deletions(-)
---
diff --git a/app/widgets/gimpdeviceeditor.c b/app/widgets/gimpdeviceeditor.c
index aaca06f..9e0279c 100644
--- a/app/widgets/gimpdeviceeditor.c
+++ b/app/widgets/gimpdeviceeditor.c
@@ -199,6 +199,7 @@ gimp_device_editor_init (GimpDeviceEditor *editor)
gtk_widget_show (private->image);
private->stack = gtk_stack_new ();
+ gtk_container_set_border_width (GTK_CONTAINER (private->stack), 12);
gtk_stack_set_transition_type (GTK_STACK (private->stack),
GTK_STACK_TRANSITION_TYPE_SLIDE_UP_DOWN);
gtk_box_pack_start (GTK_BOX (vbox), private->stack, TRUE, TRUE, 0);
diff --git a/app/widgets/gimpdeviceinfo.c b/app/widgets/gimpdeviceinfo.c
index 955e0d4..cbfdd81 100644
--- a/app/widgets/gimpdeviceinfo.c
+++ b/app/widgets/gimpdeviceinfo.c
@@ -52,6 +52,9 @@ enum
PROP_DEVICE,
PROP_DISPLAY,
PROP_MODE,
+ PROP_SOURCE,
+ PROP_VENDOR_ID,
+ PROP_PRODUCT_ID,
PROP_AXES,
PROP_KEYS,
PROP_PRESSURE_CURVE
@@ -117,6 +120,28 @@ gimp_device_info_class_init (GimpDeviceInfoClass *klass)
GDK_MODE_DISABLED,
GIMP_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_SOURCE,
+ g_param_spec_enum ("source",
+ NULL, NULL,
+ GDK_TYPE_INPUT_SOURCE,
+ GDK_SOURCE_MOUSE,
+ GIMP_PARAM_STATIC_STRINGS |
+ G_PARAM_READABLE));
+
+ g_object_class_install_property (object_class, PROP_VENDOR_ID,
+ g_param_spec_string ("vendor-id",
+ NULL, NULL,
+ NULL,
+ GIMP_PARAM_STATIC_STRINGS |
+ G_PARAM_READABLE));
+
+ g_object_class_install_property (object_class, PROP_PRODUCT_ID,
+ g_param_spec_string ("product-id",
+ NULL, NULL,
+ NULL,
+ GIMP_PARAM_STATIC_STRINGS |
+ G_PARAM_READABLE));
+
param_spec = g_param_spec_enum ("axis",
NULL, NULL,
GDK_TYPE_AXIS_USE,
@@ -337,6 +362,18 @@ gimp_device_info_get_property (GObject *object,
g_value_set_enum (value, gimp_device_info_get_mode (info));
break;
+ case PROP_SOURCE:
+ g_value_set_enum (value, gimp_device_info_get_source (info));
+ break;
+
+ case PROP_VENDOR_ID:
+ g_value_set_string (value, gimp_device_info_get_vendor_id (info));
+ break;
+
+ case PROP_PRODUCT_ID:
+ g_value_set_string (value, gimp_device_info_get_product_id (info));
+ break;
+
case PROP_AXES:
{
GimpValueArray *array;
@@ -516,6 +553,8 @@ gimp_device_info_set_device (GimpDeviceInfo *info,
strcmp (gdk_device_get_name (device),
gimp_object_get_name (info)) == 0);
+ g_object_freeze_notify (G_OBJECT (info));
+
if (device)
{
info->device = device;
@@ -583,6 +622,11 @@ gimp_device_info_set_device (GimpDeviceInfo *info,
g_object_notify (G_OBJECT (info), "device");
g_object_notify (G_OBJECT (info), "display");
+ g_object_notify (G_OBJECT (info), "source");
+ g_object_notify (G_OBJECT (info), "vendor-id");
+ g_object_notify (G_OBJECT (info), "product-id");
+
+ g_object_thaw_notify (G_OBJECT (info));
}
void
@@ -721,6 +765,67 @@ gimp_device_info_has_cursor (GimpDeviceInfo *info)
return FALSE;
}
+GdkInputSource
+gimp_device_info_get_source (GimpDeviceInfo *info)
+{
+ g_return_val_if_fail (GIMP_IS_DEVICE_INFO (info), GDK_SOURCE_MOUSE);
+
+ if (info->device)
+ return gdk_device_get_source (info->device);
+
+ return GDK_SOURCE_MOUSE;
+}
+
+const gchar *
+gimp_device_info_get_vendor_id (GimpDeviceInfo *info)
+{
+ const gchar *id = _("(Device not present)");
+
+ g_return_val_if_fail (GIMP_IS_DEVICE_INFO (info), NULL);
+
+ if (info->device)
+ {
+ if (gdk_device_get_device_type (info->device) == GDK_DEVICE_TYPE_MASTER)
+ {
+ id = _("(Virtual decvice)");
+ }
+ else
+ {
+ id = gdk_device_get_vendor_id (info->device);
+
+ if (! (id && strlen (id)))
+ id = _("(none)");
+ }
+ }
+
+ return id;
+}
+
+const gchar *
+gimp_device_info_get_product_id (GimpDeviceInfo *info)
+{
+ const gchar *id = _("(Device not present)");
+
+ g_return_val_if_fail (GIMP_IS_DEVICE_INFO (info), NULL);
+
+ if (info->device)
+ {
+ if (gdk_device_get_device_type (info->device) == GDK_DEVICE_TYPE_MASTER)
+ {
+ return _("(Virtual decvice)");
+ }
+ else
+ {
+ id = gdk_device_get_product_id (info->device);
+
+ if (! (id && strlen (id)))
+ id = _("(none)");
+ }
+ }
+
+ return id;
+}
+
gint
gimp_device_info_get_n_axes (GimpDeviceInfo *info)
{
diff --git a/app/widgets/gimpdeviceinfo.h b/app/widgets/gimpdeviceinfo.h
index abc1d19..583428a 100644
--- a/app/widgets/gimpdeviceinfo.h
+++ b/app/widgets/gimpdeviceinfo.h
@@ -93,6 +93,11 @@ void gimp_device_info_set_mode (GimpDeviceInfo *info,
gboolean gimp_device_info_has_cursor (GimpDeviceInfo *info);
+GdkInputSource gimp_device_info_get_source (GimpDeviceInfo *info);
+
+const gchar * gimp_device_info_get_vendor_id (GimpDeviceInfo *info);
+const gchar * gimp_device_info_get_product_id (GimpDeviceInfo *info);
+
gint gimp_device_info_get_n_axes (GimpDeviceInfo *info);
GdkAxisUse gimp_device_info_get_axis_use (GimpDeviceInfo *info,
gint axis);
diff --git a/app/widgets/gimpdeviceinfoeditor.c b/app/widgets/gimpdeviceinfoeditor.c
index b999c0c..85e9452 100644
--- a/app/widgets/gimpdeviceinfoeditor.c
+++ b/app/widgets/gimpdeviceinfoeditor.c
@@ -195,7 +195,7 @@ gimp_device_info_editor_init (GimpDeviceInfoEditor *editor)
gtk_box_set_spacing (GTK_BOX (editor), 12);
- private->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
+ private->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
gtk_box_pack_start (GTK_BOX (editor), private->vbox, TRUE, TRUE, 0);
gtk_widget_show (private->vbox);
@@ -332,7 +332,8 @@ gimp_device_info_editor_constructed (GObject *object)
{
GimpDeviceInfoEditor *editor = GIMP_DEVICE_INFO_EDITOR (object);
GimpDeviceInfoEditorPrivate *private;
- GtkWidget *hbox;
+ GtkWidget *frame;
+ GtkWidget *grid;
GtkWidget *label;
GtkWidget *combo;
gint n_axes;
@@ -345,23 +346,39 @@ gimp_device_info_editor_constructed (GObject *object)
gimp_assert (GIMP_IS_DEVICE_INFO (private->info));
- /* the mode menu */
+ /* general device information */
- hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
- gtk_box_pack_start (GTK_BOX (private->vbox), hbox, FALSE, FALSE, 0);
- gtk_box_reorder_child (GTK_BOX (private->vbox), hbox, 0);
- gtk_widget_show (hbox);
+ frame = gimp_frame_new (_("General"));
+ gtk_box_pack_start (GTK_BOX (private->vbox), frame, FALSE, FALSE, 0);
+ gtk_box_reorder_child (GTK_BOX (private->vbox), frame, 0);
+ gtk_widget_show (frame);
- label = gtk_label_new_with_mnemonic (_("_Mode:"));
- gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
- gtk_widget_show (label);
+ grid = gtk_grid_new ();
+ gtk_grid_set_row_spacing (GTK_GRID (grid), 4);
+ gtk_grid_set_column_spacing (GTK_GRID (grid), 6);
+ gtk_container_add (GTK_CONTAINER (frame), grid);
+ gtk_widget_show (grid);
combo = gimp_prop_enum_combo_box_new (G_OBJECT (private->info), "mode",
0, 0);
- gtk_box_pack_start (GTK_BOX (hbox), combo, FALSE, FALSE, 0);
- gtk_widget_show (combo);
+ gimp_grid_attach_aligned (GTK_GRID (grid), 0, 0,
+ _("_Mode:"), 0.0, 0.5,
+ combo, 1);
+
+ label = gimp_prop_enum_label_new (G_OBJECT (private->info), "source");
+ gimp_grid_attach_aligned (GTK_GRID (grid), 0, 1,
+ _("Source:"), 0.0, 0.5,
+ label, 1);
+
+ label = gimp_prop_label_new (G_OBJECT (private->info), "vendor-id");
+ gimp_grid_attach_aligned (GTK_GRID (grid), 0, 2,
+ _("Vendor ID:"), 0.0, 0.5,
+ label, 1);
- gtk_label_set_mnemonic_widget (GTK_LABEL (label), combo);
+ label = gimp_prop_label_new (G_OBJECT (private->info), "product-id");
+ gimp_grid_attach_aligned (GTK_GRID (grid), 0, 3,
+ _("Product ID:"), 0.0, 0.5,
+ label, 1);
/* the axes */
@@ -416,7 +433,6 @@ gimp_device_info_editor_constructed (GObject *object)
for (i = GDK_AXIS_X; i < GDK_AXIS_LAST; i++)
{
- GtkWidget *frame;
GimpCurve *curve;
gchar *title;
@@ -434,6 +450,7 @@ gimp_device_info_editor_constructed (GObject *object)
if (curve)
{
GtkWidget *vbox;
+ GtkWidget *hbox;
GtkWidget *view;
GtkWidget *label;
GtkWidget *combo;
@@ -464,7 +481,7 @@ gimp_device_info_editor_constructed (GObject *object)
hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_box_set_spacing (GTK_BOX (hbox), 6);
- gtk_box_pack_start (GTK_BOX (vbox), hbox, TRUE, TRUE, 0);
+ gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
label = gtk_label_new_with_mnemonic (_("Curve _type:"));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]