gpointing-device-settings r7 - in trunk: . data modules src test
- From: hiikezoe svn gnome org
- To: svn-commits-list gnome org
- Subject: gpointing-device-settings r7 - in trunk: . data modules src test
- Date: Wed, 25 Feb 2009 06:51:46 +0000 (UTC)
Author: hiikezoe
Date: Wed Feb 25 06:51:46 2009
New Revision: 7
URL: http://svn.gnome.org/viewvc/gpointing-device-settings?rev=7&view=rev
Log:
modularized.
Added:
trunk/data/trackpoint.ui
- copied, changed from r6, /trunk/data/gtrackpoint.ui
trunk/modules/
trunk/modules/Makefile.am
trunk/modules/gpds-trackpoint-ui.c
trunk/src/gpds-module-impl.h
trunk/src/gpds-module.c
trunk/src/gpds-module.h
trunk/src/gpds-trackpoint-ui.c
- copied, changed from r6, /trunk/src/gtrackpoint-ui.c
trunk/src/gpds-trackpoint-ui.h
- copied, changed from r6, /trunk/src/gtrackpoint-ui.h
trunk/src/gpds-ui.c
trunk/src/gpds-ui.h
trunk/src/gpds-xinput.c
- copied, changed from r6, /trunk/src/gxinput.c
trunk/src/gpds-xinput.h
trunk/test/gpds-test-suite.c
- copied, changed from r6, /trunk/test/gpointing-device-settings-test-suite.c
trunk/test/test-module.c
trunk/test/test-ui.c
Removed:
trunk/data/gtrackpoint.ui
trunk/src/gtrackpoint-ui.c
trunk/src/gtrackpoint-ui.h
trunk/src/gxinput.c
trunk/src/gxinput.h
trunk/test/gpointing-device-settings-test-suite.c
Modified:
trunk/Makefile.am
trunk/configure.ac
trunk/data/Makefile.am
trunk/src/Makefile.am
trunk/src/gpointing-device-settings.c
trunk/test/Makefile.am
trunk/test/run-test.sh
trunk/test/test-xinput.c
Modified: trunk/Makefile.am
==============================================================================
--- trunk/Makefile.am (original)
+++ trunk/Makefile.am Wed Feb 25 06:51:46 2009
@@ -1,6 +1,6 @@
# -*- Mode: Makefile; tab-width: 8; indent-tabs-mode: t; -*-
-SUBDIRS = src data test po
+SUBDIRS = src modules data test po
ACLOCAL_AMFLAGS = -I m4
Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac (original)
+++ trunk/configure.ac Wed Feb 25 06:51:46 2009
@@ -70,11 +70,35 @@
AC_SUBST(XINPUT_CFLAGS)
AC_SUBST(XINPUT_LIBS)
+LT_CURRENT=1
+LT_REVISION=0
+LT_AGE=1
+LT_VERSION_INFO="$LT_CURRENT:$LT_REVISION:$LT_AGE"
+AC_SUBST(LT_CURRENT)
+AC_SUBST(LT_REVISION)
+AC_SUBST(LT_AGE)
+AC_SUBST(LT_VERSION_INFO)
+
+LT_CURRENT_MINUS_AGE=`expr $LT_CURRENT - $LT_AGE`
+AC_SUBST(LT_CURRENT_MINUS_AGE)
+
+LIBTOOL_EXPORT_OPTIONS='-export-symbols-regex "^[[^_]].*"'
+AC_SUBST(LIBTOOL_EXPORT_OPTIONS)
+
dnl **************************************************************
dnl Checks for typedefs, structures, and compiler characteristics.
dnl **************************************************************
AC_C_CONST
+gpds_moduledir="\${libdir}/\$(PACKAGE)/module"
+AC_SUBST(gpds_moduledir)
+gpds_datadir="\${datadir}/\$(PACKAGE)"
+AC_SUBST(gpds_datadir)
+gpds_ui_filedir="\${datadir}/\$(PACKAGE)/ui"
+AC_SUBST(gpds_ui_filedir)
+gpds_help_datadir="\${datadir}"
+AC_SUBST(gpds_help_datadir)
+
dnl **************************************************************
dnl Check for Cutter
dnl **************************************************************
@@ -91,6 +115,16 @@
m4_ifdef([AC_CHECK_COVERAGE], [AC_CHECK_COVERAGE])
GENHTML_OPTIONS="--title 'GPointingDeviceSettings Code Coverage'"
+GPDS_CFLAGS="$XINPUT_CFLAGS $GTK_CFLAGS"
+GPDS_CFLAGS="$GPDS_CFLAGS -DGTK_DISABLE_DEPRECATED"
+GPDS_CFLAGS="$GPDS_CFLAGS -DGDK_DISABLE_DEPRECATED"
+GPDS_CFLAGS="$GPDS_CFLAGS -DG_DISABLE_DEPRECATED"
+GPDS_CFLAGS="$GPDS_CFLAGS -DGPDS_MODULEDIR=\\\"\"\$(gpds_moduledir)\"\\\""
+GPDS_CFLAGS="$GPDS_CFLAGS -DGPDS_DATADIR=\\\"\"\$(gpds_datadir)\"\\\""
+GPDS_CFLAGS="$GPDS_CFLAGS -DGPDS_UI_FILEDIR=\\\"\"\$(gpds_ui_filedir)\"\\\""
+GPDS_CFLAGS="$GPDS_CFLAGS -DGPDS_HELP_DATADIR=\\\"\"\$(gpds_help_datadir)\"\\\""
+AC_SUBST(GPDS_CFLAGS)
+
AC_SUBST([AM_CPPFLAGS])
AC_SUBST([AM_CFLAGS])
AC_SUBST([AM_LDFLAGS])
@@ -98,6 +132,7 @@
AC_CONFIG_FILES([
Makefile
src/Makefile
+modules/Makefile
data/Makefile
test/Makefile
po/Makefile.in
Modified: trunk/data/Makefile.am
==============================================================================
--- trunk/data/Makefile.am (original)
+++ trunk/data/Makefile.am Wed Feb 25 06:51:46 2009
@@ -1,4 +1,4 @@
-uidir = $(datadir)/$(PACKAGE)
-ui_DATA = gtrackpoint.ui
+uidir = $(datadir)/$(PACKAGE)/ui
+ui_DATA = trackpoint.ui
EXTRA_DIST = $(ui_DATA)
Copied: trunk/data/trackpoint.ui (from r6, /trunk/data/gtrackpoint.ui)
==============================================================================
Added: trunk/modules/Makefile.am
==============================================================================
--- (empty file)
+++ trunk/modules/Makefile.am Wed Feb 25 06:51:46 2009
@@ -0,0 +1,21 @@
+INCLUDES = \
+ -I$(top_builddir) \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/src
+
+AM_CFLAGS = \
+ $(GPDS_CFLAGS) \
+ $(COVERAGE_CFLAGS)
+
+AM_LDFLAGS = \
+ -avoid-version -module \
+ -no-undefined -export-dynamic $(LIBTOOL_EXPORT_OPTIONS)
+
+gpds_module_LTLIBRARIES = \
+ trackpoint.la
+
+LIBS = \
+ $(top_builddir)/src/libgpds.la \
+ $(GTK_LIBS)
+
+trackpoint_la_SOURCES = gpds-trackpoint-ui.c
Added: trunk/modules/gpds-trackpoint-ui.c
==============================================================================
--- (empty file)
+++ trunk/modules/gpds-trackpoint-ui.c Wed Feb 25 06:51:46 2009
@@ -0,0 +1,503 @@
+/* -*- 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-ui.h"
+
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+#include "gpds-xinput.h"
+#include "gpds-module-impl.h"
+
+#define DEVICE_NAME "TPPS/2 IBM TrackPoint"
+#define MIDDLE_BUTTON_EMULATION "Middle Button Emulation"
+#define MIDDLE_BUTTON_TIMEOUT "Middle Button Timeout"
+#define WHEEL_EMULATION "Wheel Emulation"
+#define WHEEL_EMULATION_INERTIA "Wheel Emulation Inertia"
+#define WHEEL_EMULATION_X_AXIS "Wheel Emulation X Axis"
+#define WHEEL_EMULATION_Y_AXIS "Wheel Emulation Y Axis"
+#define WHEEL_EMULATION_TIMEOUT "Wheel Emulation Timeout"
+#define WHEEL_EMULATION_BUTTON "Wheel Emulation Button"
+#define DRAG_LOCK_BUTTONS "Drag Lock Buttons"
+
+#define GPDS_TYPE_TRACK_POINT_UI gpds_type_track_point_ui
+#define GPDS_TRACK_POINT_UI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GPDS_TYPE_TRACK_POINT_UI, GpdsTrackPointUI))
+#define GPDS_TRACK_POINT_UI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GPDS_TYPE_TRACK_POINT_UI, GpdsTrackPointUIClass))
+#define G_IS_TRACK_POINT_UI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GPDS_TYPE_TRACK_POINT_UI))
+#define G_IS_TRACK_POINT_UI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GPDS_TYPE_TRACK_POINT_UI))
+#define GPDS_TRACK_POINT_UI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GPDS_TYPE_TRACK_POINT_UI, GpdsTrackPointUIClass))
+
+typedef struct _GpdsTrackPointUI GpdsTrackPointUI;
+typedef struct _GpdsTrackPointUIClass GpdsTrackPointUIClass;
+
+struct _GpdsTrackPointUI
+{
+ GpdsUI parent;
+ GpdsXInput *xinput;
+};
+
+struct _GpdsTrackPointUIClass
+{
+ GpdsUIClass parent_class;
+};
+
+static GType gpds_type_track_point_ui = 0;
+static GpdsUIClass *parent_class;
+
+static void dispose (GObject *object);
+static gboolean is_available (GpdsUI *ui, GError **error);
+static gboolean build (GpdsUI *ui, GError **error);
+static GtkWidget *get_content_widget (GpdsUI *ui, GError **error);
+static GtkWidget *get_label_widget (GpdsUI *ui, GError **error);
+
+static void
+class_init (GpdsTrackPointUIClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
+ GpdsUIClass *ui_class = GPDS_UI_CLASS(klass);
+
+ parent_class = g_type_class_peek_parent(klass);
+ gobject_class->dispose = dispose;
+
+ ui_class->is_available = is_available;
+ ui_class->build = build;
+ ui_class->get_content_widget = get_content_widget;
+ ui_class->get_label_widget = get_label_widget;
+}
+
+static void
+init (GpdsTrackPointUI *ui)
+{
+ ui->xinput = NULL;
+}
+
+static void
+register_type (GTypeModule *type_module)
+{
+ static const GTypeInfo info =
+ {
+ sizeof (GpdsTrackPointUIClass),
+ (GBaseInitFunc) NULL,
+ (GBaseFinalizeFunc) NULL,
+ (GClassInitFunc) class_init,
+ NULL, /* class_finalize */
+ NULL, /* class_data */
+ sizeof(GpdsTrackPointUI),
+ 0,
+ (GInstanceInitFunc) init,
+ };
+
+ gpds_type_track_point_ui =
+ g_type_module_register_type(type_module,
+ GPDS_TYPE_UI,
+ "GpdsTrackPointUI",
+ &info, 0);
+}
+
+G_MODULE_EXPORT GList *
+GPDS_MODULE_IMPL_INIT (GTypeModule *type_module)
+{
+ GList *registered_types = NULL;
+
+ register_type(type_module);
+ if (gpds_type_track_point_ui)
+ registered_types =
+ g_list_prepend(registered_types,
+ (gchar *)g_type_name(gpds_type_track_point_ui));
+
+ return registered_types;
+}
+
+G_MODULE_EXPORT void
+GPDS_MODULE_IMPL_EXIT (void)
+{
+}
+
+G_MODULE_EXPORT GObject *
+GPDS_MODULE_IMPL_INSTANTIATE (void)
+{
+ return g_object_new(GPDS_TYPE_TRACK_POINT_UI, NULL);
+}
+
+static void
+dispose (GObject *object)
+{
+ GpdsTrackPointUI *ui = GPDS_TRACK_POINT_UI(object);
+
+ if (ui->xinput) {
+ g_object_unref(ui->xinput);
+ ui->xinput = NULL;
+ }
+ if (G_OBJECT_CLASS(parent_class)->dispose)
+ G_OBJECT_CLASS(parent_class)->dispose(object);
+}
+
+static void
+show_error (GError *error)
+{
+ if (!error)
+ return;
+
+ g_print("%s\n", error->message);
+}
+
+static void
+set_toggle_property (GpdsXInput *xinput, GtkToggleButton *button, const gchar *property_name)
+{
+ GError *error = NULL;
+ gboolean active;
+
+ active = gtk_toggle_button_get_active(button);
+ gpds_xinput_set_property(xinput,
+ property_name,
+ &error,
+ active ? 1 : 0,
+ NULL);
+ if (error) {
+ show_error(error);
+ g_error_free(error);
+ }
+}
+
+static void
+set_spin_property (GpdsXInput *xinput, GtkSpinButton *button, const gchar *property_name)
+{
+ GError *error = NULL;
+ gdouble value;
+
+ value = gtk_spin_button_get_value(button);
+ gpds_xinput_set_property(xinput,
+ property_name,
+ &error,
+ (gint)value,
+ NULL);
+ if (error) {
+ show_error(error);
+ g_error_free(error);
+ }
+}
+
+static void
+set_widget_sensitivity (GtkBuilder *builder,
+ const gchar *widget_id,
+ GtkToggleButton *button)
+{
+ GObject *object;
+
+ object = gtk_builder_get_object(builder, widget_id);
+ gtk_widget_set_sensitive(GTK_WIDGET(object),
+ gtk_toggle_button_get_active(button));
+}
+
+static void
+cb_middle_button_emulation_toggled (GtkToggleButton *button, gpointer user_data)
+{
+ GpdsTrackPointUI *ui = GPDS_TRACK_POINT_UI(user_data);
+ GtkBuilder *builder;
+
+ builder = gpds_ui_get_builder(GPDS_UI(user_data));
+
+ set_toggle_property(ui->xinput, button, MIDDLE_BUTTON_EMULATION);
+ set_widget_sensitivity(builder, "middle_button_emulation_box", button);
+}
+
+static void
+cb_wheel_emulation_toggled (GtkToggleButton *button, gpointer user_data)
+{
+ GpdsTrackPointUI *ui = GPDS_TRACK_POINT_UI(user_data);
+ GtkBuilder *builder;
+
+ builder = gpds_ui_get_builder(GPDS_UI(user_data));
+
+ set_toggle_property(ui->xinput, button, WHEEL_EMULATION);
+ set_widget_sensitivity(builder, "wheel_emulation_box", button);
+}
+
+static void
+set_toggle_scroll_property (GpdsXInput *xinput, GtkToggleButton *button,
+ const gchar *property_name,
+ gint first_value, gint second_value)
+{
+ GError *error = NULL;
+ gboolean active;
+
+ active = gtk_toggle_button_get_active(button);
+ if (active) {
+ gpds_xinput_set_property(xinput,
+ property_name,
+ &error,
+ first_value, second_value,
+ NULL);
+ } else {
+ gpds_xinput_set_property(xinput,
+ property_name,
+ &error,
+ -1, -1,
+ NULL);
+ }
+
+ if (error) {
+ show_error(error);
+ g_error_free(error);
+ }
+}
+
+static void
+cb_wheel_emulation_vertical_toggled (GtkToggleButton *button, gpointer user_data)
+{
+ GpdsTrackPointUI *ui = GPDS_TRACK_POINT_UI(user_data);
+ set_toggle_scroll_property(ui->xinput, button, WHEEL_EMULATION_Y_AXIS, 6, 7);
+}
+
+static void
+cb_wheel_emulation_horizontal_toggled (GtkToggleButton *button, gpointer user_data)
+{
+ GpdsTrackPointUI *ui = GPDS_TRACK_POINT_UI(user_data);
+ set_toggle_scroll_property(ui->xinput, button, WHEEL_EMULATION_X_AXIS, 4, 5);
+}
+
+static void
+cb_wheel_emulation_timeout_value_changed (GtkSpinButton *button, gpointer user_data)
+{
+ GpdsTrackPointUI *ui = GPDS_TRACK_POINT_UI(user_data);
+ set_spin_property(ui->xinput, button, WHEEL_EMULATION_TIMEOUT);
+}
+
+static void
+cb_middle_button_timeout_value_changed (GtkSpinButton *button, gpointer user_data)
+{
+ GpdsTrackPointUI *ui = GPDS_TRACK_POINT_UI(user_data);
+ set_spin_property(ui->xinput, button, MIDDLE_BUTTON_TIMEOUT);
+}
+
+static void
+setup_signals (GpdsUI *ui, GtkBuilder *builder)
+{
+ GObject *object;
+
+#define CONNECT(object_name, signal_name) \
+ object = gtk_builder_get_object(builder, #object_name); \
+ g_signal_connect(object, #signal_name, \
+ G_CALLBACK(cb_ ## object_name ## _ ## signal_name),\
+ ui)
+
+ CONNECT(middle_button_emulation, toggled);
+ CONNECT(middle_button_timeout, value_changed);
+ CONNECT(wheel_emulation, toggled);
+ CONNECT(wheel_emulation_timeout, value_changed);
+ CONNECT(wheel_emulation_vertical, toggled);
+ CONNECT(wheel_emulation_horizontal, toggled);
+
+#undef CONNECT
+}
+
+static gboolean
+get_integer_property (GpdsXInput *xinput, const gchar *property_name,
+ gint **values, gulong *n_values)
+{
+ GError *error = NULL;
+
+ gpds_xinput_get_property(xinput,
+ property_name,
+ &error,
+ values, n_values);
+ if (error) {
+ show_error(error);
+ g_error_free(error);
+ return FALSE;
+ }
+
+ return TRUE;
+
+}
+
+static void
+set_integer_property (GpdsXInput *xinput, const gchar *property_name,
+ GtkBuilder *builder, const gchar *object_name)
+{
+ GObject *object;
+ gint *values;
+ gulong n_values;
+
+ if (!get_integer_property(xinput, property_name,
+ &values, &n_values)) {
+ return;
+ }
+
+ object = gtk_builder_get_object(builder, object_name);
+ gtk_spin_button_set_value(GTK_SPIN_BUTTON(object),
+ values[0]);
+ g_free(values);
+}
+
+static void
+set_boolean_property (GpdsXInput *xinput, const gchar *property_name,
+ GtkBuilder *builder, const gchar *object_name)
+{
+ GObject *object;
+ gint *values;
+ gulong n_values;
+
+ if (!get_integer_property(xinput, property_name,
+ &values, &n_values)) {
+ return;
+ }
+
+ object = gtk_builder_get_object(builder, object_name);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(object),
+ values[0] == 1 ? TRUE : FALSE);
+ g_free(values);
+}
+
+static void
+set_scroll_property (GpdsXInput *xinput, const gchar *property_name,
+ GtkBuilder *builder, const gchar *object_name)
+{
+ GObject *object;
+ gint *values;
+ gulong n_values;
+
+ if (!get_integer_property(xinput, property_name,
+ &values, &n_values)) {
+ return;
+ }
+
+ object = gtk_builder_get_object(builder, object_name);
+ gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(object),
+ n_values == 2 ? TRUE : FALSE);
+ g_free(values);
+}
+
+static void
+setup_current_values (GpdsUI *ui, GtkBuilder *builder)
+{
+ GpdsTrackPointUI *track_point_ui = GPDS_TRACK_POINT_UI(ui);
+
+ set_boolean_property(track_point_ui->xinput, MIDDLE_BUTTON_EMULATION,
+ builder, "middle_button_emulation");
+ set_boolean_property(track_point_ui->xinput, WHEEL_EMULATION,
+ builder, "wheel_emulation");
+
+ set_integer_property(track_point_ui->xinput, MIDDLE_BUTTON_TIMEOUT,
+ builder, "middle_button_timeout");
+ set_integer_property(track_point_ui->xinput, WHEEL_EMULATION_TIMEOUT,
+ builder, "wheel_emulation_timeout");
+
+ set_scroll_property(track_point_ui->xinput, WHEEL_EMULATION_Y_AXIS,
+ builder, "wheel_emulation_vertical");
+ set_scroll_property(track_point_ui->xinput, WHEEL_EMULATION_X_AXIS,
+ builder, "wheel_emulation_horizontal");
+}
+
+static const gchar *
+get_build_file_path (void)
+{
+ const gchar *path;
+
+ path = g_getenv("GPDS_TRACK_POINT_UI_FILE_PATH");
+ return path ? path : GPDS_UI_FILEDIR "/trackpoint.ui";
+}
+
+static gboolean
+is_available (GpdsUI *ui, GError **error)
+{
+ if (!gpds_xinput_exist_device(DEVICE_NAME)) {
+ g_set_error(error,
+ GPDS_XINPUT_ERROR,
+ GPDS_XINPUT_ERROR_NO_DEVICE,
+ _("No device found."));
+ return FALSE;
+ }
+
+ if (!g_file_test(get_build_file_path(), G_FILE_TEST_EXISTS)) {
+ g_set_error(error,
+ GPDS_UI_ERROR,
+ GPDS_UI_ERROR_NO_UI_FILE,
+ _("%s does not found."),
+ get_build_file_path());
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+static gboolean
+build (GpdsUI *ui, GError **error)
+{
+ GtkBuilder *builder;
+
+ builder = gpds_ui_get_builder(ui);
+
+ if (!gtk_builder_add_from_file(builder, get_build_file_path(), error))
+ return FALSE;
+
+ GPDS_TRACK_POINT_UI(ui)->xinput = gpds_xinput_new(DEVICE_NAME);
+
+ setup_current_values(ui, builder);
+ setup_signals(ui, builder);
+
+ return TRUE;
+}
+
+static GtkWidget *
+get_content_widget (GpdsUI *ui, GError **error)
+{
+ GtkBuilder *builder;
+ GObject *widget;
+
+ builder = gpds_ui_get_builder(ui);
+
+ widget = gtk_builder_get_object(builder, "main-widget");
+ if (!widget) {
+ g_set_error(error,
+ GPDS_UI_ERROR,
+ GPDS_UI_ERROR_NO_WIDGET,
+ _("There is no widget(%s)."),
+ "main-widget");
+ }
+
+ return GTK_WIDGET(widget);
+}
+
+static GtkWidget *
+get_label_widget (GpdsUI *ui, GError **error)
+{
+ GtkBuilder *builder;
+ GObject *widget;
+
+ builder = gpds_ui_get_builder(ui);
+
+ widget = gtk_builder_get_object(builder, "main-widget-label");
+ if (!widget) {
+ g_set_error(error,
+ GPDS_UI_ERROR,
+ GPDS_UI_ERROR_NO_WIDGET,
+ _("There is no widget(%s)."),
+ "main-widget-label");
+ }
+
+ return GTK_WIDGET(widget);
+}
+
+/*
+vi:ts=4:nowrap:ai:expandtab:sw=4
+*/
Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Wed Feb 25 06:51:46 2009
@@ -1,18 +1,38 @@
+lib_LTLIBRARIES = libgpds.la
+
+libgpds_public_headers = \
+ gpds-module-impl.h \
+ gpds-ui.h \
+ gpds-xinput.h
+
+libgpds_la_SOURCES = \
+ $(libgpds_public_headers) \
+ gpds-module.c \
+ gpds-module.h \
+ gpds-ui.c \
+ gpds-xinput.c
+libgpds_la_CFLAGS = \
+ $(GPDS_CFLAGS) \
+ $(COVERAGE_CFLAGS)
+
+libgpds_la_LDFLAGS = \
+ -version-info $(LT_VERSION_INFO) \
+ -no-undefined
+
+libgpds_la_LIBADD = \
+ $(GTK_LIBS) \
+ $(XINPUT_LIBS)
+
bin_PROGRAMS = gpointing-device-settings
-gpointing_device_settings_CFLAGS = \
- -DDATADIR=\""$(datadir)/$(PACKAGE)"\" \
- -DHELPDATADIR=\""$(datadir)"\" \
- $(XINPUT_CFLAGS) \
- $(GTK_CFLAGS)
+gpointing_device_settings_CFLAGS = \
+ $(GPDS_CFLAGS) \
+ $(COVERAGE_CFLAGS)
gpointing_device_settings_SOURCES = \
- gpointing-device-settings.c \
- gtrackpoint-ui.c \
- gtrackpoint-ui.h \
- gxinput.c \
- gxinput.h
+ gpointing-device-settings.c
gpointing_device_settings_LDADD = \
- $(GTK_LIBS) \
+ $(top_builddir)/src/libgpds.la \
+ $(GTK_LIBS) \
$(XINPUT_LIBS)
Added: trunk/src/gpds-module-impl.h
==============================================================================
--- (empty file)
+++ trunk/src/gpds-module-impl.h Wed Feb 25 06:51:46 2009
@@ -0,0 +1,47 @@
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2006 Kouhei Sutou <kou cozmixng org>
+ *
+ * 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/>.
+ *
+ */
+
+#ifndef __GPDS_MODULE_IMPL_H__
+#define __GPDS_MODULE_IMPL_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#include "gpds-module.h"
+
+typedef GList *(*GpdsModuleInitFunc) (GTypeModule *module);
+typedef void (*GpdsModuleExitFunc) (void);
+typedef GObject *(*GpdsModuleInstantiateFunc) (void);
+
+#define GPDS_MODULE_IMPL_INIT gpds_module_impl_init
+#define GPDS_MODULE_IMPL_EXIT gpds_module_impl_exit
+#define GPDS_MODULE_IMPL_INSTANTIATE gpds_module_impl_instantiate
+
+GList *GPDS_MODULE_IMPL_INIT (GTypeModule *module);
+void GPDS_MODULE_IMPL_EXIT (void);
+GObject *GPDS_MODULE_IMPL_INSTANTIATE (void);
+
+G_END_DECLS
+
+#endif /* __GPDS_MODULE_IMPL_H__ */
+
+/*
+vi:nowrap:ai:expandtab:sw=4
+*/
Added: trunk/src/gpds-module.c
==============================================================================
--- (empty file)
+++ trunk/src/gpds-module.c Wed Feb 25 06:51:46 2009
@@ -0,0 +1,404 @@
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2006 Kouhei Sutou <kou cozmixng org>
+ *
+ * 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/>.
+ *
+ * $Id: cut-module.c 1206 2007-04-20 10:29:28Z ktou $
+ */
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <gmodule.h>
+
+#include "gpds-module.h"
+#include "gpds-module-impl.h"
+
+#define GPDS_MODULE_GET_PRIVATE(obj) \
+ (G_TYPE_INSTANCE_GET_PRIVATE((obj), GPDS_TYPE_MODULE, GpdsModulePrivate))
+
+typedef struct _GpdsModulePrivate GpdsModulePrivate;
+struct _GpdsModulePrivate
+{
+ GModule *library;
+ gchar *mod_path;
+ GList *registered_types;
+
+ GpdsModuleInitFunc init;
+ GpdsModuleExitFunc exit;
+ GpdsModuleInstantiateFunc instantiate;
+};
+
+G_DEFINE_TYPE(GpdsModule, gpds_module, G_TYPE_TYPE_MODULE)
+
+static void finalize (GObject *object);
+static gboolean load (GTypeModule *module);
+static void unload (GTypeModule *module);
+
+static void _gpds_module_show_error (GModule *module);
+static GModule *_gpds_module_open (const gchar *mod_path);
+static void _gpds_module_close (GModule *module);
+static gboolean _gpds_module_load_func (GModule *module,
+ const gchar *func_name,
+ gpointer *symbol);
+static gboolean _gpds_module_match_name (const gchar *mod_path,
+ const gchar *name);
+
+static void
+gpds_module_class_init (GpdsModuleClass *klass)
+{
+ GObjectClass *gobject_class;
+ GTypeModuleClass *type_module_class;
+
+ gobject_class = G_OBJECT_CLASS(klass);
+ gobject_class->finalize = finalize;
+
+ type_module_class = G_TYPE_MODULE_CLASS(klass);
+ type_module_class->load = load;
+ type_module_class->unload = unload;
+
+ g_type_class_add_private(gobject_class, sizeof(GpdsModulePrivate));
+}
+
+static void
+gpds_module_init (GpdsModule *module)
+{
+ GpdsModulePrivate *priv = GPDS_MODULE_GET_PRIVATE(module);
+
+ priv->library = NULL;
+ priv->mod_path = NULL;
+ priv->registered_types = NULL;
+}
+
+static void
+finalize (GObject *object)
+{
+ GpdsModulePrivate *priv = GPDS_MODULE_GET_PRIVATE(object);
+
+ g_free(priv->mod_path);
+ priv->mod_path = NULL;
+ g_list_free(priv->registered_types);
+ priv->registered_types = NULL;
+
+ G_OBJECT_CLASS(gpds_module_parent_class)->finalize(object);
+}
+
+static gboolean
+load (GTypeModule *module)
+{
+ GpdsModulePrivate *priv = GPDS_MODULE_GET_PRIVATE(module);
+
+ priv->library = _gpds_module_open(priv->mod_path);
+ if (!priv->library)
+ return FALSE;
+
+ if (!_gpds_module_load_func(priv->library,
+ G_STRINGIFY(GPDS_MODULE_IMPL_INIT),
+ (gpointer)&priv->init) ||
+ !_gpds_module_load_func(priv->library,
+ G_STRINGIFY(GPDS_MODULE_IMPL_EXIT),
+ (gpointer)&priv->exit) ||
+ !_gpds_module_load_func(priv->library,
+ G_STRINGIFY(GPDS_MODULE_IMPL_INSTANTIATE),
+ (gpointer)&priv->instantiate)) {
+ _gpds_module_close(priv->library);
+ priv->library = NULL;
+ return FALSE;
+ }
+
+ g_list_free(priv->registered_types);
+ priv->registered_types = priv->init(module);
+
+ return TRUE;
+}
+
+static void
+unload (GTypeModule *module)
+{
+ GpdsModulePrivate *priv = GPDS_MODULE_GET_PRIVATE(module);
+
+ priv->exit();
+
+ _gpds_module_close(priv->library);
+ priv->library = NULL;
+
+ priv->init = NULL;
+ priv->exit = NULL;
+ priv->instantiate = NULL;
+
+ g_list_free(priv->registered_types);
+ priv->registered_types = NULL;
+}
+
+GList *
+gpds_module_collect_registered_types (GList *modules)
+{
+ GList *results = NULL;
+ GList *node;
+
+ for (node = modules; node; node = g_list_next(node)) {
+ GpdsModule *module = node->data;
+ GTypeModule *g_type_module;
+
+ g_type_module = G_TYPE_MODULE(module);
+ if (g_type_module_use(g_type_module)) {
+ GpdsModulePrivate *priv;
+ GList *node;
+
+ priv = GPDS_MODULE_GET_PRIVATE(module);
+ for (node = priv->registered_types;
+ node;
+ node = g_list_next(node)) {
+ results = g_list_prepend(results, node->data);
+ }
+
+ g_type_module_unuse(g_type_module);
+ }
+ }
+
+ return results;
+}
+
+GList *
+gpds_module_collect_names (GList *modules)
+{
+ GList *results = NULL;
+ GList *node;
+
+ for (node = modules; node; node = g_list_next(node)) {
+ GpdsModule *module;
+
+ module = node->data;
+ results = g_list_prepend(results, G_TYPE_MODULE(module)->name);
+ }
+
+ return results;
+}
+
+static void
+_gpds_module_show_error (GModule *module)
+{
+ const gchar *module_error_message;
+
+ module_error_message = g_module_error();
+ if (!module_error_message)
+ return;
+
+ if (module) {
+ g_warning("%s: %s", g_module_name(module), module_error_message);
+ } else {
+ g_warning("%s", module_error_message);
+ }
+}
+
+GpdsModule *
+gpds_module_find (GList *modules, const gchar *name)
+{
+ GList *node;
+
+ for (node = modules; node; node = g_list_next(node)) {
+ GpdsModule *module = node->data;
+ GpdsModulePrivate *priv;
+
+ priv = GPDS_MODULE_GET_PRIVATE(module);
+ if (_gpds_module_match_name(priv->mod_path, name))
+ return module;
+ }
+
+ return NULL;
+}
+
+GObject *
+gpds_module_instantiate (GpdsModule *module)
+{
+ GObject *object = NULL;
+ GpdsModulePrivate *priv;
+
+ priv = GPDS_MODULE_GET_PRIVATE(module);
+ if (g_type_module_use(G_TYPE_MODULE(module))) {
+ object = priv->instantiate();
+ g_type_module_unuse(G_TYPE_MODULE(module));
+ }
+
+ return object;
+}
+
+
+static GModule *
+_gpds_module_open (const gchar *mod_path)
+{
+ GModule *module;
+
+ module = g_module_open(mod_path, G_MODULE_BIND_LAZY | G_MODULE_BIND_LOCAL);
+ if (!module) {
+ _gpds_module_show_error(NULL);
+ }
+
+ return module;
+}
+
+static void
+_gpds_module_close (GModule *module)
+{
+ if (module && g_module_close(module)) {
+ _gpds_module_show_error(NULL);
+ }
+}
+
+static gchar *
+_gpds_module_module_file_name (const gchar *name)
+{
+ return g_strconcat(name, "." G_MODULE_SUFFIX, NULL);
+}
+
+static gboolean
+_gpds_module_load_func (GModule *module, const gchar *func_name,
+ gpointer *symbol)
+{
+ g_return_val_if_fail(module, FALSE);
+
+ if (g_module_symbol(module, func_name, symbol)) {
+ return TRUE;
+ } else {
+ _gpds_module_show_error(module);
+ return FALSE;
+ }
+}
+
+GpdsModule *
+gpds_module_load_module (const gchar *base_dir, const gchar *name)
+{
+ gchar *mod_base_name, *mod_path;
+ GpdsModule *module = NULL;
+
+ mod_base_name = g_build_filename(base_dir, name, NULL);
+ if (g_str_has_suffix(mod_base_name, G_MODULE_SUFFIX)) {
+ mod_path = mod_base_name;
+ } else {
+ mod_path = _gpds_module_module_file_name(mod_base_name);
+ g_free(mod_base_name);
+ }
+
+ if (g_file_test(mod_path, G_FILE_TEST_EXISTS)) {
+ GpdsModulePrivate *priv;
+ gchar *mod_name;
+
+ module = g_object_new(GPDS_TYPE_MODULE, NULL);
+ priv = GPDS_MODULE_GET_PRIVATE(module);
+ priv->mod_path = g_strdup(mod_path);
+
+ mod_name = g_strdup(name);
+ if (g_str_has_suffix(mod_name, "."G_MODULE_SUFFIX)) {
+ guint last_index;
+ last_index = strlen(mod_name) - strlen("."G_MODULE_SUFFIX);
+ mod_name[last_index] = '\0';
+ }
+ g_type_module_set_name(G_TYPE_MODULE(module), mod_name);
+ g_free(mod_name);
+ }
+ g_free(mod_path);
+
+ return module;
+}
+
+const gchar *
+gpds_module_directory (void)
+{
+ const gchar *dir;
+
+ dir = g_getenv("GPDS_MODULE_DIR");
+ return dir ? dir : GPDS_MODULEDIR;
+}
+
+GList *
+gpds_module_load_modules (void)
+{
+ return gpds_module_load_modules_unique(gpds_module_directory(), NULL);
+}
+
+GList *
+gpds_module_load_modules_unique (const gchar *base_dir, GList *exist_modules)
+{
+ GDir *dir;
+ GSList *sorted_entries = NULL;
+ GSList *node = NULL;
+ GList *modules = NULL;
+ const gchar *entry;
+
+ dir = g_dir_open(base_dir, 0, NULL);
+ if (!dir)
+ return exist_modules;
+
+ while ((entry = g_dir_read_name(dir))) {
+ sorted_entries = g_slist_prepend(sorted_entries, g_strdup(entry));
+ }
+ sorted_entries = g_slist_sort(sorted_entries, (GCompareFunc)strcmp);
+ for (node = sorted_entries; node; node = g_slist_next(node)) {
+ GpdsModule *module;
+ GTypeModule *g_module;
+
+ entry = node->data;
+ module = gpds_module_load_module(base_dir, entry);
+ if (!module)
+ continue;
+
+ g_module = G_TYPE_MODULE(module);
+ if (gpds_module_find(exist_modules, g_module->name))
+ gpds_module_unload(module);
+ else
+ modules = g_list_prepend(modules, module);
+ }
+ g_slist_foreach(sorted_entries, (GFunc)g_free, NULL);
+ g_slist_free(sorted_entries);
+ g_dir_close(dir);
+
+ return g_list_concat(modules, exist_modules);
+}
+
+static gboolean
+_gpds_module_match_name (const gchar *mod_path, const gchar *name)
+{
+ gboolean matched;
+ gchar *module_base_name, *normalized_matched_name;
+
+ module_base_name = g_path_get_basename(mod_path);
+ normalized_matched_name = g_strconcat(name, "." G_MODULE_SUFFIX, NULL);
+
+ matched = (0 == strcmp(module_base_name, normalized_matched_name));
+
+ g_free(module_base_name);
+ g_free(normalized_matched_name);
+
+ return matched;
+}
+
+void
+gpds_module_unload (GpdsModule *module)
+{
+ GTypeModule *type_module;
+
+ g_return_if_fail(GPDS_IS_MODULE(module));
+
+ type_module = G_TYPE_MODULE(module);
+
+ if (type_module->type_infos || type_module->interface_infos)
+ return;
+
+ g_object_unref(module);
+}
+
+/*
+vi:ts=4:nowrap:ai:expandtab:sw=4
+*/
Added: trunk/src/gpds-module.h
==============================================================================
--- (empty file)
+++ trunk/src/gpds-module.h Wed Feb 25 06:51:46 2009
@@ -0,0 +1,71 @@
+/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Copyright (C) 2006 Kouhei Sutou <kou cozmixng org>
+ *
+ * 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/>.
+ *
+ */
+
+#ifndef __GPDS_MODULE_H__
+#define __GPDS_MODULE_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GPDS_TYPE_MODULE (gpds_module_get_type ())
+#define GPDS_MODULE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GPDS_TYPE_MODULE, GpdsModule))
+#define GPDS_MODULE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GPDS_TYPE_MODULE, GpdsModuleClass))
+#define GPDS_IS_MODULE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GPDS_TYPE_MODULE))
+#define GPDS_IS_MODULE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GPDS_TYPE_MODULE))
+#define GPDS_MODULE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GPDS_TYPE_MODULE, GpdsModuleClass))
+
+typedef struct _GpdsModule GpdsModule;
+typedef struct _GpdsModuleClass GpdsModuleClass;
+
+struct _GpdsModule
+{
+ GTypeModule object;
+};
+
+struct _GpdsModuleClass
+{
+ GTypeModuleClass parent_class;
+};
+
+GType gpds_module_get_type (void) G_GNUC_CONST;
+
+GpdsModule *gpds_module_load_module (const gchar *base_dir,
+ const gchar *name);
+GList *gpds_module_load_modules (void);
+GList *gpds_module_load_modules_unique (const gchar *base_dir,
+ GList *modules);
+GpdsModule *gpds_module_find (GList *modules,
+ const gchar *name);
+const gchar *gpds_module_directory (void);
+
+GList *gpds_module_collect_registered_types (GList *modules);
+GList *gpds_module_collect_names (GList *modules);
+
+GObject *gpds_module_instantiate (GpdsModule *module);
+void gpds_module_unload (GpdsModule *module);
+
+
+G_END_DECLS
+
+#endif /* __GPDS_MODULE_H__ */
+
+/*
+vi:ts=4:nowrap:ai:expandtab:sw=4
+*/
Copied: trunk/src/gpds-trackpoint-ui.c (from r6, /trunk/src/gtrackpoint-ui.c)
==============================================================================
--- /trunk/src/gtrackpoint-ui.c (original)
+++ trunk/src/gpds-trackpoint-ui.c Wed Feb 25 06:51:46 2009
@@ -21,11 +21,11 @@
#include "config.h"
#endif /* HAVE_CONFIG_H */
-#include "gtrackpoint-ui.h"
+#include "gpds-trackpoint-ui.h"
#include <gtk/gtk.h>
#include <glib/gi18n.h>
-#include "gxinput.h"
+#include "gpds-xinput.h"
#define DEVICE_NAME "TPPS/2 IBM TrackPoint"
#define MIDDLE_BUTTON_EMULATION "Middle Button Emulation"
@@ -38,42 +38,42 @@
#define WHEEL_EMULATION_BUTTON "Wheel Emulation Button"
#define DRAG_LOCK_BUTTONS "Drag Lock Buttons"
-typedef struct _GTrackPointUIPriv GTrackPointUIPriv;
-struct _GTrackPointUIPriv
+typedef struct _GpdsTrackPointUIPriv GpdsTrackPointUIPriv;
+struct _GpdsTrackPointUIPriv
{
GtkBuilder *builder;
GError *error;
- GXInput *xinput;
+ GpdsXInput *xinput;
};
-#define G_TRACK_POINT_UI_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), G_TYPE_TRACK_POINT_UI, GTrackPointUIPriv))
+#define GPDS_TRACK_POINT_UI_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), GPDS_TYPE_TRACK_POINT_UI, GpdsTrackPointUIPriv))
-G_DEFINE_TYPE (GTrackPointUI, g_track_point_ui, G_TYPE_OBJECT)
+G_DEFINE_TYPE (GpdsTrackPointUI, gpds_track_point_ui, G_TYPE_OBJECT)
static void dispose (GObject *object);
static void
-g_track_point_ui_class_init (GTrackPointUIClass *klass)
+gpds_track_point_ui_class_init (GpdsTrackPointUIClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
gobject_class->dispose = dispose;
- g_type_class_add_private(gobject_class, sizeof(GTrackPointUIPriv));
+ g_type_class_add_private(gobject_class, sizeof(GpdsTrackPointUIPriv));
}
static void
-g_track_point_ui_init (GTrackPointUI *ui)
+gpds_track_point_ui_init (GpdsTrackPointUI *ui)
{
- GTrackPointUIPriv *priv = G_TRACK_POINT_UI_GET_PRIVATE(ui);
+ GpdsTrackPointUIPriv *priv = GPDS_TRACK_POINT_UI_GET_PRIVATE(ui);
priv->xinput = NULL;
priv->error = NULL;
priv->builder = gtk_builder_new();
gtk_builder_add_from_file(priv->builder,
- DATADIR "/gtrackpoint.ui", &priv->error);
+ GPDS_DATADIR "/gtrackpoint.ui", &priv->error);
if (priv->error) {
g_print("%s\n", priv->error->message);
}
@@ -82,7 +82,7 @@
static void
dispose (GObject *object)
{
- GTrackPointUIPriv *priv = G_TRACK_POINT_UI_GET_PRIVATE(object);
+ GpdsTrackPointUIPriv *priv = GPDS_TRACK_POINT_UI_GET_PRIVATE(object);
if (priv->builder) {
g_object_unref(priv->builder);
@@ -99,8 +99,8 @@
priv->error = NULL;
}
- if (G_OBJECT_CLASS(g_track_point_ui_parent_class)->dispose)
- G_OBJECT_CLASS(g_track_point_ui_parent_class)->dispose(object);
+ if (G_OBJECT_CLASS(gpds_track_point_ui_parent_class)->dispose)
+ G_OBJECT_CLASS(gpds_track_point_ui_parent_class)->dispose(object);
}
static void
@@ -113,13 +113,13 @@
}
static void
-set_toggle_property (GXInput *xinput, GtkToggleButton *button, const gchar *property_name)
+set_toggle_property (GpdsXInput *xinput, GtkToggleButton *button, const gchar *property_name)
{
GError *error = NULL;
gboolean active;
active = gtk_toggle_button_get_active(button);
- g_xinput_set_property(xinput,
+ gpds_xinput_set_property(xinput,
property_name,
&error,
active ? 1 : 0,
@@ -131,13 +131,13 @@
}
static void
-set_spin_property (GXInput *xinput, GtkSpinButton *button, const gchar *property_name)
+set_spin_property (GpdsXInput *xinput, GtkSpinButton *button, const gchar *property_name)
{
GError *error = NULL;
gdouble value;
value = gtk_spin_button_get_value(button);
- g_xinput_set_property(xinput,
+ gpds_xinput_set_property(xinput,
property_name,
&error,
(gint)value,
@@ -163,7 +163,7 @@
static void
cb_middle_button_emulation_toggled (GtkToggleButton *button, gpointer user_data)
{
- GTrackPointUIPriv *priv = G_TRACK_POINT_UI_GET_PRIVATE(user_data);
+ GpdsTrackPointUIPriv *priv = GPDS_TRACK_POINT_UI_GET_PRIVATE(user_data);
set_toggle_property(priv->xinput, button, MIDDLE_BUTTON_EMULATION);
set_widget_sensitivity(priv->builder, "middle_button_emulation_box", button);
@@ -172,14 +172,14 @@
static void
cb_wheel_emulation_toggled (GtkToggleButton *button, gpointer user_data)
{
- GTrackPointUIPriv *priv = G_TRACK_POINT_UI_GET_PRIVATE(user_data);
+ GpdsTrackPointUIPriv *priv = GPDS_TRACK_POINT_UI_GET_PRIVATE(user_data);
set_toggle_property(priv->xinput, button, WHEEL_EMULATION);
set_widget_sensitivity(priv->builder, "wheel_emulation_box", button);
}
static void
-set_toggle_scroll_property (GXInput *xinput, GtkToggleButton *button,
+set_toggle_scroll_property (GpdsXInput *xinput, GtkToggleButton *button,
const gchar *property_name,
gint first_value, gint second_value)
{
@@ -188,13 +188,13 @@
active = gtk_toggle_button_get_active(button);
if (active) {
- g_xinput_set_property(xinput,
+ gpds_xinput_set_property(xinput,
property_name,
&error,
first_value, second_value,
NULL);
} else {
- g_xinput_set_property(xinput,
+ gpds_xinput_set_property(xinput,
property_name,
&error,
-1, -1,
@@ -210,7 +210,7 @@
static void
cb_wheel_emulation_vertical_toggled (GtkToggleButton *button, gpointer user_data)
{
- GTrackPointUIPriv *priv = G_TRACK_POINT_UI_GET_PRIVATE(user_data);
+ GpdsTrackPointUIPriv *priv = GPDS_TRACK_POINT_UI_GET_PRIVATE(user_data);
set_toggle_scroll_property(priv->xinput, button, WHEEL_EMULATION_Y_AXIS, 6, 7);
}
@@ -218,7 +218,7 @@
static void
cb_wheel_emulation_horizontal_toggled (GtkToggleButton *button, gpointer user_data)
{
- GTrackPointUIPriv *priv = G_TRACK_POINT_UI_GET_PRIVATE(user_data);
+ GpdsTrackPointUIPriv *priv = GPDS_TRACK_POINT_UI_GET_PRIVATE(user_data);
set_toggle_scroll_property(priv->xinput, button, WHEEL_EMULATION_X_AXIS, 4, 5);
}
@@ -226,7 +226,7 @@
static void
cb_wheel_emulation_timeout_value_changed (GtkSpinButton *button, gpointer user_data)
{
- GTrackPointUIPriv *priv = G_TRACK_POINT_UI_GET_PRIVATE(user_data);
+ GpdsTrackPointUIPriv *priv = GPDS_TRACK_POINT_UI_GET_PRIVATE(user_data);
set_spin_property(priv->xinput, button, WHEEL_EMULATION_TIMEOUT);
}
@@ -234,15 +234,15 @@
static void
cb_middle_button_timeout_value_changed (GtkSpinButton *button, gpointer user_data)
{
- GTrackPointUIPriv *priv = G_TRACK_POINT_UI_GET_PRIVATE(user_data);
+ GpdsTrackPointUIPriv *priv = GPDS_TRACK_POINT_UI_GET_PRIVATE(user_data);
set_spin_property(priv->xinput, button, MIDDLE_BUTTON_TIMEOUT);
}
static void
-setup_signals (GTrackPointUI *ui)
+setup_signals (GpdsTrackPointUI *ui)
{
- GTrackPointUIPriv *priv = G_TRACK_POINT_UI_GET_PRIVATE(ui);
+ GpdsTrackPointUIPriv *priv = GPDS_TRACK_POINT_UI_GET_PRIVATE(ui);
GObject *object;
#define CONNECT(object_name, signal_name) \
@@ -262,12 +262,12 @@
}
static gboolean
-get_integer_property (GXInput *xinput, const gchar *property_name,
+get_integer_property (GpdsXInput *xinput, const gchar *property_name,
gint **values, gulong *n_values)
{
GError *error = NULL;
- g_xinput_get_property(xinput,
+ gpds_xinput_get_property(xinput,
property_name,
&error,
values, n_values);
@@ -282,7 +282,7 @@
}
static void
-set_integer_property (GXInput *xinput, const gchar *property_name,
+set_integer_property (GpdsXInput *xinput, const gchar *property_name,
GtkBuilder *builder, const gchar *object_name)
{
GObject *object;
@@ -301,7 +301,7 @@
}
static void
-set_boolean_property (GXInput *xinput, const gchar *property_name,
+set_boolean_property (GpdsXInput *xinput, const gchar *property_name,
GtkBuilder *builder, const gchar *object_name)
{
GObject *object;
@@ -320,7 +320,7 @@
}
static void
-set_scroll_property (GXInput *xinput, const gchar *property_name,
+set_scroll_property (GpdsXInput *xinput, const gchar *property_name,
GtkBuilder *builder, const gchar *object_name)
{
GObject *object;
@@ -339,9 +339,9 @@
}
static void
-setup_current_values (GTrackPointUI *ui)
+setup_current_values (GpdsTrackPointUI *ui)
{
- GTrackPointUIPriv *priv = G_TRACK_POINT_UI_GET_PRIVATE(ui);
+ GpdsTrackPointUIPriv *priv = GPDS_TRACK_POINT_UI_GET_PRIVATE(ui);
set_boolean_property(priv->xinput, MIDDLE_BUTTON_EMULATION,
priv->builder, "middle_button_emulation");
@@ -360,41 +360,41 @@
}
static void
-setup (GTrackPointUI *ui)
+setup (GpdsTrackPointUI *ui)
{
setup_current_values(ui);
setup_signals(ui);
}
-GTrackPointUI *
-g_track_point_ui_new (void)
+GpdsTrackPointUI *
+gpds_track_point_ui_new (void)
{
- return g_object_new(G_TYPE_TRACK_POINT_UI, NULL);
+ return g_object_new(GPDS_TYPE_TRACK_POINT_UI, NULL);
}
GtkWidget *
-g_track_point_ui_get_widget (GTrackPointUI *ui)
+gpds_track_point_ui_get_widget (GpdsTrackPointUI *ui)
{
- GTrackPointUIPriv *priv = G_TRACK_POINT_UI_GET_PRIVATE(ui);
+ GpdsTrackPointUIPriv *priv = GPDS_TRACK_POINT_UI_GET_PRIVATE(ui);
if (!priv->builder)
return NULL;
- if (!g_xinput_exist_device(DEVICE_NAME)) {
+ if (!gpds_xinput_exist_device(DEVICE_NAME)) {
g_print("No %s found\n", DEVICE_NAME);
return NULL;
}
- priv->xinput = g_xinput_new(DEVICE_NAME);
+ priv->xinput = gpds_xinput_new(DEVICE_NAME);
setup(ui);
return GTK_WIDGET(gtk_builder_get_object(priv->builder, "main-widget"));
}
GtkWidget *
-g_track_point_ui_get_label_widget (GTrackPointUI *ui)
+gpds_track_point_ui_get_label_widget (GpdsTrackPointUI *ui)
{
- GTrackPointUIPriv *priv = G_TRACK_POINT_UI_GET_PRIVATE(ui);
+ GpdsTrackPointUIPriv *priv = GPDS_TRACK_POINT_UI_GET_PRIVATE(ui);
if (!priv->builder)
return NULL;
Copied: trunk/src/gpds-trackpoint-ui.h (from r6, /trunk/src/gtrackpoint-ui.h)
==============================================================================
--- /trunk/src/gtrackpoint-ui.h (original)
+++ trunk/src/gpds-trackpoint-ui.h Wed Feb 25 06:51:46 2009
@@ -20,38 +20,35 @@
#ifndef __GTRACKPOINT_UI_H__
#define __GTRACKPOINT_UI_H__
-#include <glib-object.h>
-#include <gtk/gtk.h>
+#include "gpds-ui.h"
G_BEGIN_DECLS
-#define G_TYPE_TRACK_POINT_UI (g_track_point_ui_get_type ())
-#define G_TRACK_POINT_UI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), G_TYPE_TRACK_POINT_UI, GTrackPointUI))
-#define G_TRACK_POINT_UI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), G_TYPE_TRACK_POINT_UI, GTrackPointUIClass))
-#define G_IS_TRACK_POINT_UI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), G_TYPE_TRACK_POINT_UI))
-#define G_IS_TRACK_POINT_UI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), G_TYPE_TRACK_POINT_UI))
-#define G_TRACK_POINT_UI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), G_TYPE_TRACK_POINT_UI, GTrackPointUIClass))
+#define GPDS_TYPE_TRACK_POINT_UI (gpds_track_point_ui_get_type ())
+#define GPDS_TRACK_POINT_UI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GPDS_TYPE_TRACK_POINT_UI, GpdsTrackPointUI))
+#define GPDS_TRACK_POINT_UI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GPDS_TYPE_TRACK_POINT_UI, GpdsTrackPointUIClass))
+#define G_IS_TRACK_POINT_UI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GPDS_TYPE_TRACK_POINT_UI))
+#define G_IS_TRACK_POINT_UI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GPDS_TYPE_TRACK_POINT_UI))
+#define GPDS_TRACK_POINT_UI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GPDS_TYPE_TRACK_POINT_UI, GpdsTrackPointUIClass))
-typedef struct _GTrackPointUI GTrackPointUI;
-typedef struct _GTrackPointUIClass GTrackPointUIClass;
+typedef struct _GpdsTrackPointUI GpdsTrackPointUI;
+typedef struct _GpdsTrackPointUIClass GpdsTrackPointUIClass;
-struct _GTrackPointUI
+struct _GpdsTrackPointUI
{
- GObject parent;
+ GpdsUI parent;
};
-struct _GTrackPointUIClass
+struct _GpdsTrackPointUIClass
{
- GObjectClass parent_class;
+ GpdsUIClass parent_class;
};
-void g_track_point_create_window (void);
-
-GType g_track_point_ui_get_type (void) G_GNUC_CONST;
-GTrackPointUI *g_track_point_ui_new (void);
-GtkWidget *g_track_point_ui_get_widget (GTrackPointUI *ui);
-GtkWidget *g_track_point_ui_get_label_widget
- (GTrackPointUI *ui);
+GType gpds_track_point_ui_get_type (void) G_GNUC_CONST;
+GpdsTrackPointUI *gpds_track_point_ui_new (void);
+GtkWidget *gpds_track_point_ui_get_widget (GpdsTrackPointUI *ui);
+GtkWidget *gpds_track_point_ui_get_label_widget
+ (GpdsTrackPointUI *ui);
G_END_DECLS
Added: trunk/src/gpds-ui.c
==============================================================================
--- (empty file)
+++ trunk/src/gpds-ui.c Wed Feb 25 06:51:46 2009
@@ -0,0 +1,156 @@
+/* -*- 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-ui.h"
+
+#include <gtk/gtk.h>
+#include <glib/gi18n.h>
+#include "gpds-module.h"
+#include "gpds-xinput.h"
+
+typedef struct _GpdsUIPriv GpdsUIPriv;
+struct _GpdsUIPriv
+{
+ GtkBuilder *builder;
+ GpdsXInput *xinput;
+};
+
+
+#define GPDS_UI_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), GPDS_TYPE_UI, GpdsUIPriv))
+
+G_DEFINE_ABSTRACT_TYPE(GpdsUI, gpds_ui, G_TYPE_OBJECT)
+
+static void dispose (GObject *object);
+
+static void
+gpds_ui_class_init (GpdsUIClass *klass)
+{
+ GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
+
+ gobject_class->dispose = dispose;
+
+ g_type_class_add_private(gobject_class, sizeof(GpdsUIPriv));
+}
+
+static void
+gpds_ui_init (GpdsUI *ui)
+{
+ GpdsUIPriv *priv = GPDS_UI_GET_PRIVATE(ui);
+
+ priv->xinput = NULL;
+ priv->builder = gtk_builder_new();
+}
+
+static void
+dispose (GObject *object)
+{
+ GpdsUIPriv *priv = GPDS_UI_GET_PRIVATE(object);
+
+ if (priv->builder) {
+ g_object_unref(priv->builder);
+ priv->builder = NULL;
+ }
+
+ if (priv->xinput) {
+ g_object_unref(priv->xinput);
+ priv->xinput = NULL;
+ }
+
+ if (G_OBJECT_CLASS(gpds_ui_parent_class)->dispose)
+ G_OBJECT_CLASS(gpds_ui_parent_class)->dispose(object);
+}
+
+GQuark
+gpds_ui_error_quark (void)
+{
+ return g_quark_from_static_string("gpds-ui-error-quark");
+}
+
+GpdsUI *
+gpds_ui_new (const gchar *name)
+{
+ GpdsModule *module;
+ GObject *ui;
+
+ module = gpds_module_load_module(gpds_module_directory(), name);
+ g_return_val_if_fail(module != NULL, NULL);
+
+ ui = gpds_module_instantiate(module);
+
+ return GPDS_UI(ui);
+}
+
+gboolean
+gpds_ui_is_available (GpdsUI *ui, GError **error)
+{
+ GpdsUIClass *klass;
+
+ g_return_val_if_fail(GPDS_IS_UI(ui), FALSE);
+
+ klass = GPDS_UI_GET_CLASS(ui);
+ return (klass->is_available) ? klass->is_available(ui, error) : FALSE;
+}
+
+gboolean
+gpds_ui_build (GpdsUI *ui, GError **error)
+{
+ GpdsUIClass *klass;
+
+ g_return_val_if_fail(GPDS_IS_UI(ui), FALSE);
+
+ klass = GPDS_UI_GET_CLASS(ui);
+ return (klass->build) ? klass->build(ui, error) : FALSE;
+}
+
+GtkWidget *
+gpds_ui_get_content_widget (GpdsUI *ui, GError **error)
+{
+ GpdsUIClass *klass;
+
+ g_return_val_if_fail(GPDS_IS_UI(ui), FALSE);
+
+ klass = GPDS_UI_GET_CLASS(ui);
+ return (klass->get_content_widget) ? klass->get_content_widget(ui, error) : FALSE;
+}
+
+GtkWidget *
+gpds_ui_get_label_widget (GpdsUI *ui, GError **error)
+{
+ GpdsUIClass *klass;
+
+ g_return_val_if_fail(GPDS_IS_UI(ui), FALSE);
+
+ klass = GPDS_UI_GET_CLASS(ui);
+ return (klass->get_label_widget) ? klass->get_label_widget(ui, error) : FALSE;
+}
+
+
+GtkBuilder *
+gpds_ui_get_builder (GpdsUI *ui)
+{
+ return GPDS_UI_GET_PRIVATE(ui)->builder;
+}
+
+/*
+vi:ts=4:nowrap:ai:expandtab:sw=4
+*/
Added: trunk/src/gpds-ui.h
==============================================================================
--- (empty file)
+++ trunk/src/gpds-ui.h Wed Feb 25 06:51:46 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/>.
+ *
+ */
+
+#ifndef __GPDS_UI_H__
+#define __GPDS_UI_H__
+
+#include <glib-object.h>
+#include <gtk/gtk.h>
+
+G_BEGIN_DECLS
+
+#define GPDS_UI_ERROR (gpds_ui_error_quark())
+
+#define GPDS_TYPE_UI (gpds_ui_get_type ())
+#define GPDS_UI(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GPDS_TYPE_UI, GpdsUI))
+#define GPDS_UI_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GPDS_TYPE_UI, GpdsUIClass))
+#define GPDS_IS_UI(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GPDS_TYPE_UI))
+#define GPDS_IS_UI_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GPDS_TYPE_UI))
+#define GPDS_UI_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GPDS_TYPE_UI, GpdsUIClass))
+
+typedef enum
+{
+ GPDS_UI_ERROR_NO_UI_FILE,
+ GPDS_UI_ERROR_NO_WIDGET
+} GpdsUIError;
+
+typedef struct _GpdsUI GpdsUI;
+typedef struct _GpdsUIClass GpdsUIClass;
+
+struct _GpdsUI
+{
+ GObject parent;
+};
+
+struct _GpdsUIClass
+{
+ GObjectClass parent_class;
+
+ gboolean (*is_available) (GpdsUI *ui, GError **error);
+ gboolean (*build) (GpdsUI *ui, GError **error);
+ GtkWidget *(*get_content_widget) (GpdsUI *ui, GError **error);
+ GtkWidget *(*get_label_widget) (GpdsUI *ui, GError **error);
+};
+
+GQuark gpds_ui_error_quark (void);
+GType gpds_ui_get_type (void) G_GNUC_CONST;
+GpdsUI *gpds_ui_new (const gchar *name);
+gboolean gpds_ui_is_available (GpdsUI *ui, GError **error);
+gboolean gpds_ui_build (GpdsUI *ui, GError **error);
+GtkWidget *gpds_ui_get_content_widget (GpdsUI *ui, GError **error);
+GtkWidget *gpds_ui_get_label_widget (GpdsUI *ui, GError **error);
+
+GtkBuilder *gpds_ui_get_builder (GpdsUI *ui);
+
+G_END_DECLS
+
+#endif /* __GPDS_UI_H__ */
+/*
+vi:ts=4:nowrap:ai:expandtab:sw=4
+*/
Copied: trunk/src/gpds-xinput.c (from r6, /trunk/src/gxinput.c)
==============================================================================
--- /trunk/src/gxinput.c (original)
+++ trunk/src/gpds-xinput.c Wed Feb 25 06:51:46 2009
@@ -21,7 +21,7 @@
#include "config.h"
#endif /* HAVE_CONFIG_H */
-#include "gxinput.h"
+#include "gpds-xinput.h"
#include <gtk/gtk.h>
#include <gdk/gdkx.h>
@@ -30,8 +30,8 @@
#include <X11/Xatom.h>
#include <string.h>
-typedef struct _GXInputPriv GXInputPriv;
-struct _GXInputPriv
+typedef struct _GpdsXInputPriv GpdsXInputPriv;
+struct _GpdsXInputPriv
{
gchar *device_name;
XDeviceInfo *device_info_list;
@@ -44,9 +44,9 @@
PROP_DEVICE_NAME
};
-#define G_XINPUT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), G_TYPE_XINPUT, GXInputPriv))
+#define GPDS_XINPUT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), GPDS_TYPE_XINPUT, GpdsXInputPriv))
-G_DEFINE_TYPE (GXInput, g_xinput, G_TYPE_OBJECT)
+G_DEFINE_TYPE (GpdsXInput, gpds_xinput, G_TYPE_OBJECT)
static void dispose (GObject *object);
static void set_property (GObject *object,
@@ -59,7 +59,7 @@
GParamSpec *pspec);
static void
-g_xinput_class_init (GXInputClass *klass)
+gpds_xinput_class_init (GpdsXInputClass *klass)
{
GObjectClass *gobject_class = G_OBJECT_CLASS(klass);
@@ -76,13 +76,13 @@
NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
- g_type_class_add_private(gobject_class, sizeof(GXInputPriv));
+ g_type_class_add_private(gobject_class, sizeof(GpdsXInputPriv));
}
static void
-g_xinput_init (GXInput *xinput)
+gpds_xinput_init (GpdsXInput *xinput)
{
- GXInputPriv *priv = G_XINPUT_GET_PRIVATE(xinput);
+ GpdsXInputPriv *priv = GPDS_XINPUT_GET_PRIVATE(xinput);
priv->device_name = NULL;
priv->device_info_list = NULL;
@@ -92,7 +92,7 @@
static void
dispose (GObject *object)
{
- GXInputPriv *priv = G_XINPUT_GET_PRIVATE(object);
+ GpdsXInputPriv *priv = GPDS_XINPUT_GET_PRIVATE(object);
g_free(priv->device_name);
@@ -106,8 +106,8 @@
priv->device = NULL;
}
- if (G_OBJECT_CLASS(g_xinput_parent_class)->dispose)
- G_OBJECT_CLASS(g_xinput_parent_class)->dispose(object);
+ if (G_OBJECT_CLASS(gpds_xinput_parent_class)->dispose)
+ G_OBJECT_CLASS(gpds_xinput_parent_class)->dispose(object);
}
static void
@@ -116,7 +116,7 @@
const GValue *value,
GParamSpec *pspec)
{
- GXInputPriv *priv = G_XINPUT_GET_PRIVATE(object);
+ GpdsXInputPriv *priv = GPDS_XINPUT_GET_PRIVATE(object);
switch (prop_id) {
case PROP_DEVICE_NAME:
@@ -135,7 +135,7 @@
GValue *value,
GParamSpec *pspec)
{
- GXInputPriv *priv = G_XINPUT_GET_PRIVATE(object);
+ GpdsXInputPriv *priv = GPDS_XINPUT_GET_PRIVATE(object);
switch (prop_id) {
case PROP_DEVICE_NAME:
@@ -148,15 +148,15 @@
}
GQuark
-g_xinput_error_quark (void)
+gpds_xinput_error_quark (void)
{
- return g_quark_from_static_string("g-xinput-error-quark");
+ return g_quark_from_static_string("gpds-xinput-error-quark");
}
-GXInput *
-g_xinput_new (const gchar *device_name)
+GpdsXInput *
+gpds_xinput_new (const gchar *device_name)
{
- return g_object_new(G_TYPE_XINPUT,
+ return g_object_new(GPDS_TYPE_XINPUT,
"device-name", device_name,
NULL);
}
@@ -188,8 +188,8 @@
device_info = get_device_info(device_name);
if (!device_info) {
g_set_error(error,
- G_XINPUT_ERROR,
- G_XINPUT_ERROR_NO_DEVICE,
+ GPDS_XINPUT_ERROR,
+ GPDS_XINPUT_ERROR_NO_DEVICE,
_("No device found."));
return NULL;
}
@@ -197,8 +197,8 @@
device = XOpenDevice(GDK_DISPLAY(), device_info->id);
if (!device) {
g_set_error(error,
- G_XINPUT_ERROR,
- G_XINPUT_ERROR_NO_DEVICE,
+ GPDS_XINPUT_ERROR,
+ GPDS_XINPUT_ERROR_NO_DEVICE,
_("Could not open %s device."), device_name);
return NULL;
}
@@ -207,9 +207,9 @@
}
static XDevice *
-get_device (GXInput *xinput, GError **error)
+get_device (GpdsXInput *xinput, GError **error)
{
- GXInputPriv *priv = G_XINPUT_GET_PRIVATE(xinput);
+ GpdsXInputPriv *priv = GPDS_XINPUT_GET_PRIVATE(xinput);
if (priv->device)
return priv->device;
@@ -219,7 +219,7 @@
}
static gboolean
-set_property_va_list (GXInput *xinput,
+set_property_va_list (GpdsXInput *xinput,
const gchar *property_name,
GError **error,
gint first_value, va_list var_args)
@@ -291,7 +291,7 @@
}
gboolean
-g_xinput_set_property (GXInput *xinput,
+gpds_xinput_set_property (GpdsXInput *xinput,
const gchar *property_name,
GError **error,
gint first_value, ...)
@@ -307,7 +307,7 @@
}
static Atom
-get_atom (GXInput *xinput, const gchar *property_name, GError **error)
+get_atom (GpdsXInput *xinput, const gchar *property_name, GError **error)
{
gint i, n_properties;
XDevice *device;
@@ -334,7 +334,7 @@
}
static gboolean
-get_int_property (GXInput *xinput,
+get_int_property (GpdsXInput *xinput,
const gchar *property_name,
GError **error,
gint **values, gulong *n_values)
@@ -393,7 +393,7 @@
}
gboolean
-g_xinput_get_property (GXInput *xinput,
+gpds_xinput_get_property (GpdsXInput *xinput,
const gchar *property_name,
GError **error,
gint **values,
@@ -409,7 +409,7 @@
}
gboolean
-g_xinput_exist_device (const gchar *device_name)
+gpds_xinput_exist_device (const gchar *device_name)
{
return get_device_info(device_name) ? TRUE : FALSE;
}
Added: trunk/src/gpds-xinput.h
==============================================================================
--- (empty file)
+++ trunk/src/gpds-xinput.h Wed Feb 25 06:51:46 2009
@@ -0,0 +1,81 @@
+/* -*- 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/>.
+ *
+ */
+
+#ifndef __GPDS_XINPUT_H__
+#define __GPDS_XINPUT_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define GPDS_XINPUT_ERROR (gpds_xinput_error_quark())
+
+#define GPDS_TYPE_XINPUT (gpds_xinput_get_type ())
+#define GPDS_XINPUT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GPDS_TYPE_XINPUT, GpdsXInput))
+#define GPDS_XINPUT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GPDS_TYPE_XINPUT, GpdsXInputClass))
+#define GPDS_IS_XINPUT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GPDS_TYPE_XINPUT))
+#define GPDS_IS_XINPUT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GPDS_TYPE_XINPUT))
+#define GPDS_XINPUT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS((obj), GPDS_TYPE_XINPUT, GpdsXInputClass))
+
+typedef enum
+{
+ GPDS_XINPUT_ERROR_NO_DEVICE,
+ GPDS_XINPUT_ERROR_UNABLE_TO_OPEN_DEVICE
+} GpdsXInputError;
+
+typedef struct _GpdsXInput GpdsXInput;
+typedef struct _GpdsXInputClass GpdsXInputClass;
+
+struct _GpdsXInput
+{
+ GObject parent;
+};
+
+struct _GpdsXInputClass
+{
+ GObjectClass parent_class;
+};
+
+GQuark gpds_xinput_error_quark (void);
+
+GType gpds_xinput_get_type (void) G_GNUC_CONST;
+
+gboolean gpds_xinput_exist_device (const gchar *device_name);
+
+GpdsXInput *gpds_xinput_new (const gchar *device_name);
+
+gboolean gpds_xinput_set_property (GpdsXInput *xinput,
+ const gchar *property_name,
+ GError **error,
+ gint first_property_value,
+ ...) G_GNUC_NULL_TERMINATED;
+gboolean gpds_xinput_get_property (GpdsXInput *xinput,
+ const gchar *property_name,
+ GError **error,
+ gint **values,
+ gulong *n_values);
+
+G_END_DECLS
+
+#endif /* __GPDS_XINPUT_H__ */
+
+/*
+vi:ts=4:nowrap:ai:expandtab:sw=4
+*/
+
Modified: trunk/src/gpointing-device-settings.c
==============================================================================
--- trunk/src/gpointing-device-settings.c (original)
+++ trunk/src/gpointing-device-settings.c Wed Feb 25 06:51:46 2009
@@ -21,12 +21,31 @@
#include "config.h"
#endif /* HAVE_CONFIG_H */
-#include "gpointing-device-settings.h"
-
#include <gtk/gtk.h>
#include <glib/gi18n.h>
-#include "gtrackpoint-ui.h"
-#include "gxinput.h"
+#include "gpds-xinput.h"
+#include "gpds-module.h"
+#include "gpds-ui.h"
+
+static GList *modules = NULL;
+static GList *uis = NULL;
+
+static gboolean
+gpds_init (void)
+{
+ modules = gpds_module_load_modules();
+ return TRUE;
+}
+
+static gboolean
+gpds_quit (void)
+{
+ g_list_foreach(uis, (GFunc)g_object_unref, NULL);
+ g_list_free(uis);
+ g_list_free(modules);
+
+ return TRUE;
+}
static void
cb_response (GtkDialog *dialog, gint response_id, gpointer user_data)
@@ -34,15 +53,49 @@
gtk_main_quit();
}
+static void
+append_uis (GtkNotebook *notebook)
+{
+ GError *error = NULL;
+ GList *ui_names, *name;
+
+ ui_names = gpds_module_collect_names(modules);
+
+ for (name = ui_names; name; name = g_list_next(name)) {
+ GpdsUI *ui;
+ GtkWidget *widget = NULL;
+ GtkWidget *label = NULL;
+
+ ui = gpds_ui_new(name->data);
+ uis = g_list_prepend(uis, ui);
+
+ if (!gpds_ui_is_available(ui, NULL))
+ continue;
+
+ gpds_ui_build(ui, &error);
+ widget = gpds_ui_get_content_widget(ui, NULL);
+ label = gpds_ui_get_label_widget(ui, NULL);
+
+ if (!widget)
+ widget = gtk_label_new(error->message);
+
+ gtk_notebook_append_page(notebook,
+ widget, label);
+
+ }
+
+ g_list_free(ui_names);
+}
+
int
main (int argc, char *argv[])
{
- GTrackPointUI *ui;
GtkWidget *dialog, *notebook, *content_area;
- GtkWidget *widget;
gtk_init(&argc, &argv);
+ gpds_init();
+
dialog = gtk_dialog_new_with_buttons(_("TrackPoint Settings"),
NULL,
0,
@@ -55,19 +108,11 @@
content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
gtk_container_add(GTK_CONTAINER(content_area),
notebook);
-
- ui = g_track_point_ui_new();
- widget = g_track_point_ui_get_widget(ui);
- if (!widget)
- widget = gtk_label_new(_("No device availlable"));
-
- gtk_notebook_append_page(GTK_NOTEBOOK(notebook),
- widget, NULL);
-
+ append_uis(GTK_NOTEBOOK(notebook));
gtk_widget_show_all(dialog);
gtk_main();
- g_object_unref(ui);
+ gpds_quit();
return 0;
}
Modified: trunk/test/Makefile.am
==============================================================================
--- trunk/test/Makefile.am (original)
+++ trunk/test/Makefile.am Wed Feb 25 06:51:46 2009
@@ -2,9 +2,11 @@
TESTS = run-test.sh
TESTS_ENVIRONMENT = NO_MAKE=yes CUTTER="$(CUTTER)"
-noinst_LTLIBRARIES = \
- suite_gpointing-device-settings_test.la \
- test_xinput.la
+noinst_LTLIBRARIES = \
+ suite_gpds_test.la \
+ test-xinput.la \
+ test-module.la \
+ test-ui.la
endif
EXTRA_DIST = \
@@ -25,14 +27,16 @@
-avoid-version \
-no-undefined
-LIBS = \
- $(GTK_LIBS) \
+LIBS = \
+ $(top_builddir)/src/libgpds.la \
+ $(GTK_LIBS) \
$(GCUTTER_LIBS)
-suite_gpointing_device_settings_test_la_SOURCES = gpointing-device-settings-test-suite.c
+suite_gpds_test_la_SOURCES = gpds-test-suite.c
test_xinput_la_SOURCES = test-xinput.c
-test_xinput_la_LIBADD = $(top_builddir)/src/gpointing_device_settings-gxinput.o
+test_module_la_SOURCES = test-module.c
+test_ui_la_SOURCES = test-ui.c
echo-cutter:
@echo $(CUTTER)
Copied: trunk/test/gpds-test-suite.c (from r6, /trunk/test/gpointing-device-settings-test-suite.c)
==============================================================================
--- /trunk/test/gpointing-device-settings-test-suite.c (original)
+++ trunk/test/gpds-test-suite.c Wed Feb 25 06:51:46 2009
@@ -1,14 +1,19 @@
#include <gcutter.h>
#include <gtk/gtk.h>
-void gpointing_device_settings_test_warmup (void);
+void gpds_test_warmup (void);
void
-gpointing_device_settings_test_warmup (void)
+gpds_test_warmup (void)
{
gtk_init(0, NULL);
}
+void
+gpds_test_cooldown (void)
+{
+}
+
/*
vi:ts=4:nowrap:ai:expandtab:sw=4
*/
Modified: trunk/test/run-test.sh
==============================================================================
--- trunk/test/run-test.sh (original)
+++ trunk/test/run-test.sh Wed Feb 25 06:51:46 2009
@@ -20,7 +20,8 @@
export BASE_DIR="`dirname $0`"
top_dir="$BASE_DIR/.."
top_dir="`cd $top_dir; pwd`"
-export KZ_EMBED_MODULE_DIR="$top_dir/module/embed/gecko/.libs"
+export GPDS_MODULE_DIR="$top_dir/modules/.libs"
+export GPDS_TRACK_POINT_UI_FILE_PATH="$top_dir/data/trackpoint.ui"
if test x"$NO_MAKE" != x"yes"; then
if which gmake > /dev/null; then
Added: trunk/test/test-module.c
==============================================================================
--- (empty file)
+++ trunk/test/test-module.c Wed Feb 25 06:51:46 2009
@@ -0,0 +1,77 @@
+#include "gpds-module.h"
+
+#include <gcutter.h>
+
+void test_load_modules (void);
+void test_collect_names (void);
+void test_instantiate (void);
+
+static GList *modules;
+static GpdsModule *module;
+static GError *error;
+static GList *names;
+static GList *expected_names;
+static GObject *object;
+
+void
+setup (void)
+{
+ module = NULL;
+ modules = NULL;
+ names = NULL;
+ expected_names = NULL;
+ object = NULL;
+ error = NULL;
+}
+
+void
+teardown (void)
+{
+ if (object)
+ g_object_unref(object);
+ g_list_free(modules);
+ g_list_free(names);
+ g_list_free(expected_names);
+}
+
+void
+test_load_modules (void)
+{
+ modules = gpds_module_load_modules();
+ cut_assert(modules);
+}
+
+void
+test_collect_names (void)
+{
+ expected_names = g_list_append(expected_names, "trackpoint");
+
+ cut_trace(test_load_modules());
+
+ names = gpds_module_collect_names(modules);
+
+ gcut_assert_equal_list_string(expected_names, names);
+}
+
+void
+test_instantiate (void)
+{
+ GList *name;
+
+ cut_trace(test_collect_names());
+
+ for (name = names; name; name = g_list_next(name)) {
+ module = gpds_module_find(modules, name->data);
+ cut_assert(module);
+
+ object = gpds_module_instantiate(module);
+ cut_assert(object);
+ g_object_unref(object);
+ object = NULL;
+ }
+}
+
+
+/*
+vi:ts=4:nowrap:ai:expandtab:sw=4
+*/
Added: trunk/test/test-ui.c
==============================================================================
--- (empty file)
+++ trunk/test/test-ui.c Wed Feb 25 06:51:46 2009
@@ -0,0 +1,53 @@
+#include "gpds-ui.h"
+
+#include <gcutter.h>
+
+void test_new (void);
+void test_is_available (void);
+void test_build (void);
+
+static GError *error;
+static GpdsUI *ui;
+
+void
+setup (void)
+{
+ ui = NULL;
+ error = NULL;
+}
+
+void
+teardown (void)
+{
+ if (ui)
+ g_object_unref(ui);
+}
+
+void
+test_new (void)
+{
+ ui = gpds_ui_new("trackpoint");
+ cut_assert(ui);
+}
+
+void
+test_is_available (void)
+{
+ cut_trace(test_new());
+
+ gpds_ui_is_available(ui, &error);
+ gcut_assert_error(error);
+}
+
+void
+test_build (void)
+{
+ cut_trace(test_new());
+
+ cut_assert_true(gpds_ui_build(ui, &error));
+ gcut_assert_error(error);
+}
+
+/*
+vi:ts=4:nowrap:ai:expandtab:sw=4
+*/
Modified: trunk/test/test-xinput.c
==============================================================================
--- trunk/test/test-xinput.c (original)
+++ trunk/test/test-xinput.c Wed Feb 25 06:51:46 2009
@@ -1,11 +1,11 @@
-#include "gxinput.h"
+#include "gpds-xinput.h"
#include <gcutter.h>
void test_new (void);
void test_property (void);
-static GXInput *xinput;
+static GpdsXInput *xinput;
static gint *values;
static gulong n_values;
static GError *error;
@@ -31,7 +31,7 @@
void
test_new (void)
{
- xinput = g_xinput_new("TPPS/2 IBM TrackPoint");
+ xinput = gpds_xinput_new("TPPS/2 IBM TrackPoint");
cut_assert(xinput);
}
@@ -41,7 +41,7 @@
gint original_value;
cut_trace(test_new());
- cut_assert_true(g_xinput_get_property(xinput,
+ cut_assert_true(gpds_xinput_get_property(xinput,
"Middle Button Emulation",
&error,
&values, &n_values));
@@ -49,13 +49,13 @@
cut_assert_equal_int(1, n_values);
original_value = values[0];
- cut_assert_true(g_xinput_set_property(xinput,
+ cut_assert_true(gpds_xinput_set_property(xinput,
"Middle Button Emulation",
&error,
1, NULL));
gcut_assert_error(error);
g_free(values);
- cut_assert_true(g_xinput_get_property(xinput,
+ cut_assert_true(gpds_xinput_get_property(xinput,
"Middle Button Emulation",
&error,
&values, &n_values));
@@ -63,14 +63,14 @@
cut_assert_equal_int(1, n_values);
cut_assert_equal_int(1, values[0]);
- cut_assert_true(g_xinput_set_property(xinput,
+ cut_assert_true(gpds_xinput_set_property(xinput,
"Middle Button Emulation",
&error,
original_value, NULL));
gcut_assert_error(error);
g_free(values);
- cut_assert_true(g_xinput_get_property(xinput,
+ cut_assert_true(gpds_xinput_get_property(xinput,
"Middle Button Emulation",
&error,
&values, &n_values));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]