[gtk/wip/otte/dnd: 26/30] device: gdk_device_list_axes() => gdk_device_get_axis_names()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk/wip/otte/dnd: 26/30] device: gdk_device_list_axes() => gdk_device_get_axis_names()
- Date: Sun, 23 Feb 2020 01:01:14 +0000 (UTC)
commit 4280ca2263ae519df0662c150269bb4cbec4c5b0
Author: Benjamin Otte <otte redhat com>
Date: Sat Feb 22 23:31:24 2020 +0100
device: gdk_device_list_axes() => gdk_device_get_axis_names()
Turn a GList of GdkAtom into a char ** - and rename the function to not
cause problems.
docs/reference/gdk/gdk4-sections.txt | 2 +-
gdk/gdkdevice.c | 30 +++++++++++++++++++-----------
gdk/gdkdevice.h | 2 +-
3 files changed, 21 insertions(+), 13 deletions(-)
---
diff --git a/docs/reference/gdk/gdk4-sections.txt b/docs/reference/gdk/gdk4-sections.txt
index c6814e2c7c..bff1aea44c 100644
--- a/docs/reference/gdk/gdk4-sections.txt
+++ b/docs/reference/gdk/gdk4-sections.txt
@@ -471,7 +471,7 @@ gdk_device_get_history
gdk_device_free_history
GdkTimeCoord
gdk_device_get_axis
-gdk_device_list_axes
+gdk_device_get_axis_names
gdk_device_get_axis_value
gdk_device_get_last_event_surface
diff --git a/gdk/gdkdevice.c b/gdk/gdkdevice.c
index 186738cf04..b9d0e47bfe 100644
--- a/gdk/gdkdevice.c
+++ b/gdk/gdkdevice.c
@@ -1081,33 +1081,41 @@ gdk_device_get_n_axes (GdkDevice *device)
}
/**
- * gdk_device_list_axes:
- * @device: a pointer #GdkDevice
+ * gdk_device_get_axis_names:
+ * @device: a #GdkDevice
*
- * Returns a #GList of #GdkAtoms, containing the labels for
+ * Returns a null-terminated array of strings, containing the labels for
* the axes that @device currently has.
+ * If the device has no axes, %NULL is returned.
*
- * Returns: (transfer container) (element-type GdkAtom):
- * A #GList of strings, free with g_list_free().
+ * Returns: (nullable) (transfer full): A null-terminated string array,
+ * free with g_strfreev().
**/
-GList *
-gdk_device_list_axes (GdkDevice *device)
+char **
+gdk_device_get_axis_names (GdkDevice *device)
{
- GList *axes = NULL;
+ GPtrArray *axes;
gint i;
g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
g_return_val_if_fail (gdk_device_get_source (device) != GDK_SOURCE_KEYBOARD, NULL);
+ if (device->axes->len == 0)
+ return NULL;
+
+ axes = g_ptr_array_new ();
+
for (i = 0; i < device->axes->len; i++)
{
GdkAxisInfo axis_info;
axis_info = g_array_index (device->axes, GdkAxisInfo, i);
- axes = g_list_prepend (axes, axis_info.label);
+ g_ptr_array_add (axes, g_strdup (axis_info.label));
}
- return g_list_reverse (axes);
+ g_ptr_array_add (axes, NULL);
+
+ return (char **) g_ptr_array_free (axes, FALSE);
}
/**
@@ -1119,7 +1127,7 @@ gdk_device_list_axes (GdkDevice *device)
*
* Interprets an array of double as axis values for a given device,
* and locates the value in the array for a given axis label, as returned
- * by gdk_device_list_axes()
+ * by gdk_device_get_axes()
*
* Returns: %TRUE if the given axis use was found, otherwise %FALSE.
**/
diff --git a/gdk/gdkdevice.h b/gdk/gdkdevice.h
index 5520e73dfb..9a2cc758bf 100644
--- a/gdk/gdkdevice.h
+++ b/gdk/gdkdevice.h
@@ -184,7 +184,7 @@ void gdk_device_free_history (GdkTimeCoord **events,
GDK_AVAILABLE_IN_ALL
gint gdk_device_get_n_axes (GdkDevice *device);
GDK_AVAILABLE_IN_ALL
-GList * gdk_device_list_axes (GdkDevice *device);
+char ** gdk_device_get_axis_names (GdkDevice *device);
GDK_AVAILABLE_IN_ALL
gboolean gdk_device_get_axis_value (GdkDevice *device,
gdouble *axes,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]