gpointing-device-settings r130 - in trunk: src test
- From: hiikezoe svn gnome org
- To: svn-commits-list gnome org
- Subject: gpointing-device-settings r130 - in trunk: src test
- Date: Fri, 6 Mar 2009 07:35:13 +0000 (UTC)
Author: hiikezoe
Date: Fri Mar 6 07:35:13 2009
New Revision: 130
URL: http://svn.gnome.org/viewvc/gpointing-device-settings?rev=130&view=rev
Log:
Move GpdsXInputPointerInfo functions into new file.
Added:
trunk/src/gpds-xinput-pointer-info.c
trunk/src/gpds-xinput-pointer-info.h
- copied, changed from r129, /trunk/src/gpds-xinput-utils.h
trunk/test/test-xinput-pointer-info.c
Modified:
trunk/src/Makefile.am
trunk/src/gpds-xinput-utils.c
trunk/src/gpds-xinput-utils.h
trunk/test/Makefile.am
trunk/test/test-xinput-utils.c
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Fri Mar 6 07:35:13 2009
@@ -5,6 +5,7 @@
gpds-module-impl.h \
gpds-ui.h \
gpds-xinput.h \
+ gpds-xinput-pointer-info.h \
gpds-xinput-utils.h
libgpds_la_SOURCES = \
@@ -13,6 +14,7 @@
gpds-module.h \
gpds-ui.c \
gpds-xinput.c \
+ gpds-xinput-pointer-info.c \
gpds-xinput-utils.c
AM_CFLAGS = -DG_LOG_DOMAIN=\"GPointingDeviceSettings\"
Added: trunk/src/gpds-xinput-pointer-info.c
==============================================================================
--- (empty file)
+++ trunk/src/gpds-xinput-pointer-info.c Fri Mar 6 07:35:13 2009
@@ -0,0 +1,76 @@
+/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2009 Hiroyuki Ikezoe <poincare ikezoe net>
+ *
+ * This library is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif /* HAVE_CONFIG_H */
+
+#include "gpds-xinput-pointer-info.h"
+
+#include <gdk/gdkx.h>
+#include "gpds-xinput-utils.h"
+
+GpdsXInputPointerInfo *
+gpds_xinput_pointer_info_new (const gchar *name, const gchar *type_name)
+{
+ GpdsXInputPointerInfo *info;
+
+ info = g_new0(GpdsXInputPointerInfo, 1);
+ info->name = g_strdup(name);
+ info->type_name = g_strdup(type_name);
+
+ return info;
+}
+
+void
+gpds_xinput_pointer_info_free (GpdsXInputPointerInfo *info)
+{
+ g_free(info->name);
+ g_free(info->type_name);
+ g_free(info);
+}
+
+GList *
+gpds_xinput_utils_collect_pointer_infos (void)
+{
+ GList *device_names = NULL;
+ XDeviceInfo *device_infos;
+ gint i, n_device_infos;
+
+ device_infos = XListInputDevices(GDK_DISPLAY(), &n_device_infos);
+
+ for (i = 0; i < n_device_infos; i++) {
+ GpdsXInputPointerInfo *info;
+
+ if (device_infos[i].use != IsXExtensionPointer)
+ continue;
+ info = gpds_xinput_pointer_info_new(device_infos[i].name,
+ XGetAtomName(GDK_DISPLAY(), device_infos[i].type));
+
+ device_names = g_list_prepend(device_names, info);
+ }
+
+ XFreeDeviceList(device_infos);
+
+ return device_names;
+}
+
+/*
+vi:ts=4:nowrap:ai:expandtab:sw=4
+*/
Copied: trunk/src/gpds-xinput-pointer-info.h (from r129, /trunk/src/gpds-xinput-utils.h)
==============================================================================
--- /trunk/src/gpds-xinput-utils.h (original)
+++ trunk/src/gpds-xinput-pointer-info.h Fri Mar 6 07:35:13 2009
@@ -17,24 +17,13 @@
*
*/
-#ifndef __GPDS_XINPUT_UTILS_H__
-#define __GPDS_XINPUT_UTILS_H__
+#ifndef __GPDS_XINPUT_POINTER_INFO_H__
+#define __GPDS_XINPUT_POINTER_INFO_H__
#include <glib.h>
-#include <X11/extensions/XInput.h>
-#include <X11/Xatom.h>
G_BEGIN_DECLS
-#define GPDS_XINPUT_UTILS_ERROR (gpds_xinput_utils_error_quark())
-
-typedef enum
-{
- GPDS_XINPUT_UTILS_ERROR_NO_DEVICE,
- GPDS_XINPUT_UTILS_ERROR_UNABLE_TO_OPEN_DEVICE,
- GPDS_XINPUT_UTILS_ERROR_NO_FLOAT_ATOM
-} GpdsXInputUtilsError;
-
typedef struct _GpdsXInputPointerInfo GpdsXInputPointerInfo;
struct _GpdsXInputPointerInfo
{
@@ -45,17 +34,12 @@
GpdsXInputPointerInfo *gpds_xinput_pointer_info_new (const gchar *name,
const gchar *type_name);
void gpds_xinput_pointer_info_free (GpdsXInputPointerInfo *info);
-
-GQuark gpds_xinput_utils_error_quark (void);
-XDeviceInfo *gpds_xinput_utils_get_device_info (const gchar *device_name);
-XDevice *gpds_xinput_utils_open_device (const gchar *device_name, GError **error);
-Atom gpds_xinput_utils_get_float_atom (GError **error);
-gboolean gpds_xinput_utils_exist_device (const gchar *device_name);
-GList *gpds_xinput_utils_collect_pointer_infos (void);
+GList *gpds_xinput_utils_collect_pointer_infos
+ (void);
G_END_DECLS
-#endif /* __GPDS_XINPUT_UTILS_H__ */
+#endif /* __GPDS_XINPUT_POINTER_INFO_H__ */
/*
vi:ts=4:nowrap:ai:expandtab:sw=4
Modified: trunk/src/gpds-xinput-utils.c
==============================================================================
--- trunk/src/gpds-xinput-utils.c (original)
+++ trunk/src/gpds-xinput-utils.c Fri Mar 6 07:35:13 2009
@@ -27,6 +27,7 @@
#include <gdk/gdkx.h>
#include <glib/gi18n.h>
#include <string.h>
+#include "gpds-xinput-pointer-info.h"
GQuark
gpds_xinput_utils_error_quark (void)
@@ -105,51 +106,6 @@
return gpds_xinput_utils_get_device_info(device_name) ? TRUE : FALSE;
}
-GpdsXInputPointerInfo *
-gpds_xinput_pointer_info_new (const gchar *name, const gchar *type_name)
-{
- GpdsXInputPointerInfo *info;
-
- info = g_new0(GpdsXInputPointerInfo, 1);
- info->name = g_strdup(name);
- info->type_name = g_strdup(type_name);
-
- return info;
-}
-
-void
-gpds_xinput_pointer_info_free (GpdsXInputPointerInfo *info)
-{
- g_free(info->name);
- g_free(info->type_name);
- g_free(info);
-}
-
-GList *
-gpds_xinput_utils_collect_pointer_infos (void)
-{
- GList *device_names = NULL;
- XDeviceInfo *device_infos;
- gint i, n_device_infos;
-
- device_infos = XListInputDevices(GDK_DISPLAY(), &n_device_infos);
-
- for (i = 0; i < n_device_infos; i++) {
- GpdsXInputPointerInfo *info;
-
- if (device_infos[i].use != IsXExtensionPointer)
- continue;
- info = gpds_xinput_pointer_info_new(device_infos[i].name,
- XGetAtomName(GDK_DISPLAY(), device_infos[i].type));
-
- device_names = g_list_prepend(device_names, info);
- }
-
- XFreeDeviceList(device_infos);
-
- return device_names;
-}
-
/*
vi:ts=4:nowrap:ai:expandtab:sw=4
*/
Modified: trunk/src/gpds-xinput-utils.h
==============================================================================
--- trunk/src/gpds-xinput-utils.h (original)
+++ trunk/src/gpds-xinput-utils.h Fri Mar 6 07:35:13 2009
@@ -35,23 +35,11 @@
GPDS_XINPUT_UTILS_ERROR_NO_FLOAT_ATOM
} GpdsXInputUtilsError;
-typedef struct _GpdsXInputPointerInfo GpdsXInputPointerInfo;
-struct _GpdsXInputPointerInfo
-{
- gchar *name;
- gchar *type_name; /* MOUSE, TOUCHPAD, ... */
-};
-
-GpdsXInputPointerInfo *gpds_xinput_pointer_info_new (const gchar *name,
- const gchar *type_name);
-void gpds_xinput_pointer_info_free (GpdsXInputPointerInfo *info);
-
GQuark gpds_xinput_utils_error_quark (void);
XDeviceInfo *gpds_xinput_utils_get_device_info (const gchar *device_name);
XDevice *gpds_xinput_utils_open_device (const gchar *device_name, GError **error);
Atom gpds_xinput_utils_get_float_atom (GError **error);
gboolean gpds_xinput_utils_exist_device (const gchar *device_name);
-GList *gpds_xinput_utils_collect_pointer_infos (void);
G_END_DECLS
Modified: trunk/test/Makefile.am
==============================================================================
--- trunk/test/Makefile.am (original)
+++ trunk/test/Makefile.am Fri Mar 6 07:35:13 2009
@@ -2,11 +2,12 @@
TESTS = run-test.sh
TESTS_ENVIRONMENT = NO_MAKE=yes CUTTER="$(CUTTER)"
-noinst_LTLIBRARIES = \
- suite_gpds_test.la \
- test-xinput.la \
- test-xinput-utils.la \
- test-module.la \
+noinst_LTLIBRARIES = \
+ suite_gpds_test.la \
+ test-xinput.la \
+ test-xinput-pointer-info.la \
+ test-xinput-utils.la \
+ test-module.la \
test-ui.la
endif
@@ -36,6 +37,7 @@
suite_gpds_test_la_SOURCES = gpds-test-suite.c
test_xinput_la_SOURCES = test-xinput.c
+test_xinput_pointer_info_la_SOURCES = test-xinput-pointer-info.c
test_xinput_utils_la_SOURCES = test-xinput-utils.c
test_module_la_SOURCES = test-module.c
test_ui_la_SOURCES = test-ui.c
Added: trunk/test/test-xinput-pointer-info.c
==============================================================================
--- (empty file)
+++ trunk/test/test-xinput-pointer-info.c Fri Mar 6 07:35:13 2009
@@ -0,0 +1,64 @@
+#include "gpds-xinput-pointer-info.h"
+
+#include <gcutter.h>
+#include <gdk/gdkx.h>
+
+void test_collect (void);
+
+static GList *pointer_infos;
+static GList *expected_pointer_infos;
+
+void
+setup (void)
+{
+ pointer_infos = NULL;
+ expected_pointer_infos = NULL;
+}
+
+void
+teardown (void)
+{
+ if (pointer_infos) {
+ g_list_foreach(pointer_infos, (GFunc)gpds_xinput_pointer_info_free, NULL);
+ g_list_free(pointer_infos);
+ }
+}
+
+static void
+gpds_xinput_pointer_info_inspect (GString *string,
+ gconstpointer data,
+ gpointer user_data)
+{
+ GpdsXInputPointerInfo *info = (GpdsXInputPointerInfo*)data;
+
+ g_string_append_printf(string, "%s (%s)", info->name, info->type_name);
+}
+
+static gboolean
+gpds_xinput_pointer_info_equal (gconstpointer a, gconstpointer b)
+{
+ GpdsXInputPointerInfo *a_info = (GpdsXInputPointerInfo*)a;
+ GpdsXInputPointerInfo *b_info = (GpdsXInputPointerInfo*)b;
+
+ if (!a || !b)
+ return FALSE;
+
+ if (g_strcmp0(a_info->name, b_info->name))
+ return FALSE;
+ return (!g_strcmp0(a_info->type_name, b_info->type_name));
+}
+
+void
+test_collect (void)
+{
+ pointer_infos = gpds_xinput_utils_collect_pointer_infos();
+
+ gcut_assert_equal_list(expected_pointer_infos, pointer_infos,
+ gpds_xinput_pointer_info_equal,
+ gpds_xinput_pointer_info_inspect,
+ NULL);
+}
+
+/*
+vi:ts=4:nowrap:ai:expandtab:sw=4
+*/
Modified: trunk/test/test-xinput-utils.c
==============================================================================
--- trunk/test/test-xinput-utils.c (original)
+++ trunk/test/test-xinput-utils.c Fri Mar 6 07:35:13 2009
@@ -10,16 +10,12 @@
static GError *error;
static XDevice *device;
-static GList *pointer_infos;
-static GList *expected_pointer_infos;
void
setup (void)
{
error = NULL;
device = NULL;
- pointer_infos = NULL;
- expected_pointer_infos = NULL;
}
void
@@ -28,11 +24,6 @@
if (device)
XCloseDevice(GDK_DISPLAY(), device);
g_clear_error(&error);
-
- if (pointer_infos) {
- g_list_foreach(pointer_infos, (GFunc)gpds_xinput_pointer_info_free, NULL);
- g_list_free(pointer_infos);
- }
}
void
@@ -63,41 +54,6 @@
cut_assert(device);
}
-static void
-gpds_xinput_pointer_info_inspect (GString *string,
- gconstpointer data,
- gpointer user_data)
-{
- GpdsXInputPointerInfo *info = (GpdsXInputPointerInfo*)data;
-
- g_string_append_printf(string, "%s (%s)", info->name, info->type_name);
-}
-
-static gboolean
-gpds_xinput_pointer_info_equal (gconstpointer a, gconstpointer b)
-{
- GpdsXInputPointerInfo *a_info = (GpdsXInputPointerInfo*)a;
- GpdsXInputPointerInfo *b_info = (GpdsXInputPointerInfo*)b;
-
- if (!a || !b)
- return FALSE;
-
- if (g_strcmp0(a_info->name, b_info->name))
- return FALSE;
- return (!g_strcmp0(a_info->type_name, b_info->type_name));
-}
-
-void
-test_collect_pointer_infos (void)
-{
- pointer_infos = gpds_xinput_utils_collect_pointer_infos();
-
- gcut_assert_equal_list(expected_pointer_infos, pointer_infos,
- gpds_xinput_pointer_info_equal,
- gpds_xinput_pointer_info_inspect,
- NULL);
-}
-
/*
vi:ts=4:nowrap:ai:expandtab:sw=4
*/
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]