[mousetweaks] Initial GSettings migration
- From: Gerd Kohlberger <gerdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mousetweaks] Initial GSettings migration
- Date: Mon, 11 Oct 2010 12:46:05 +0000 (UTC)
commit 2038a9f2957c343d42b5b447f44c2e2569e16f52
Author: Gerd Kohlberger <gerdk src gnome org>
Date: Mon Oct 11 14:44:29 2010 +0200
Initial GSettings migration
- Add a new MtSettings object.
- Add a gschema file.
- Update build system.
configure.ac | 40 +++--
data/Makefile.am | 6 +-
data/org.gnome.mousetweaks.gschema.xml | 69 ++++++++
src/Makefile.am | 4 +-
src/mt-common.h | 17 ++
src/mt-settings.c | 290 ++++++++++++++++++++++++++++++++
src/mt-settings.h | 60 +++++++
7 files changed, 469 insertions(+), 17 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 6e07d14..82423b3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -33,17 +33,23 @@ AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [Gettext Package])
AM_GLIB_GNU_GETTEXT
+dnl *** gsettings ***
+
+GLIB_GSETTINGS
+
dnl *** documentation ***
GNOME_DOC_INIT
dnl *** dependencies ***
+GLIB_REQUIRED=2.25.3
GIO_REQUIRED=2.25.9
GTK_REQUIRED=2.91.0
-GCONF_REQUIRED=2.16.0
+GCONF_REQUIRED=2.31.1
PKG_CHECK_MODULES(DEPENDENCIES,
+ glib-2.0 >= $GLIB_REQUIRED
gio-2.0 >= $GIO_REQUIRED
gtk+-3.0 >= $GTK_REQUIRED
gconf-2.0 >= $GCONF_REQUIRED
@@ -94,17 +100,21 @@ AM_GCONF_SOURCE_2
dnl *** output ***
-AC_OUTPUT([Makefile
- src/Makefile
- data/Makefile
- pixmaps/Makefile
- po/Makefile.in
- help/Makefile
- man/Makefile])
-
-echo ""
-echo "Building panel applets:"
-echo "-----------------------"
-echo " pointer-capture: $build_pca"
-echo " dwell-click: $build_dca"
-echo ""
+AC_CONFIG_FILES([
+ Makefile
+ src/Makefile
+ data/Makefile
+ pixmaps/Makefile
+ po/Makefile.in
+ help/Makefile
+ man/Makefile
+])
+
+AC_OUTPUT
+
+echo "
+Building panel applets:
+-----------------------
+ pointer-capture: $build_pca
+ dwell-click: $build_dca
+"
diff --git a/data/Makefile.am b/data/Makefile.am
index 75fd616..7bc3818 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -56,11 +56,15 @@ if BUILD_PCA
endif
endif
+ GSETTINGS_RULES@
+gsettings_SCHEMAS = org.gnome.mousetweaks.gschema.xml
+
EXTRA_DIST = \
$(schemas_in_files) \
$(server_in_in_files) \
$(menu_DATA) \
- $(ui_DATA)
+ $(ui_DATA) \
+ $(gsettings_SCHEMA)
DISTCLEANFILES = \
$(server_DATA) \
diff --git a/data/org.gnome.mousetweaks.gschema.xml b/data/org.gnome.mousetweaks.gschema.xml
new file mode 100644
index 0000000..86c24ce
--- /dev/null
+++ b/data/org.gnome.mousetweaks.gschema.xml
@@ -0,0 +1,69 @@
+<schemalist>
+ <schema id="org.gnome.mousetweaks" path="/desktop/gnome/accessibility/mouse/">
+ <key name="dwell-enabled" type="b">
+ <default>false</default>
+ <summary>Enable dwell click</summary>
+ <description>Enable dwell click.</description>
+ </key>
+ <key name="dwell-time" type="d">
+ <default>1.20</default>
+ <summary>Dwell click time</summary>
+ <description>Time in seconds before a click is triggered.</description>
+ </key>
+ <key name="dwell-threshold" type="i">
+ <default>10</default>
+ <summary>Movement threshold</summary>
+ <description>Distance in pixels before movement will be recognized.</description>
+ </key>
+ <key name="dwell-gesture-single" type="i">
+ <default>0</default>
+ <summary>Gesture single click</summary>
+ <description>Direction to perform a single click. ("0" = Left, "1" = Right, "2" = Up, "3" = Down)</description>
+ </key>
+ <key name="dwell-gesture-double" type="i">
+ <default>2</default>
+ <summary>Gesture double click</summary>
+ <description>Direction to perform a double click. ("0" = Left, "1" = Right, "2" = Up, "3" = Down)</description>
+ </key>
+ <key name="dwell-gesture-drag" type="i">
+ <default>3</default>
+ <summary>Gesture drag click</summary>
+ <description>Direction to perform dragging. ("0" = Left, "1" = Right, "2" = Up, "3" = Down)</description>
+ </key>
+ <key name="dwell-gesture-secondary" type="i">
+ <default>1</default>
+ <summary>Gesture secondary click</summary>
+ <description>Direction to perform a secondary click. ("0" = Left, "1" = Right, "2" = Up, "3" = Down)</description>
+ </key>
+ <key name="dwell-mode" type="i">
+ <default>0</default>
+ <summary>Dwell click mode</summary>
+ <description>The active dwell click mode. ("0" = Window mode, "1" = Gesture mode)</description>
+ </key>
+ <key name="ctw-visible" type="b">
+ <default>true</default>
+ <summary>Show click type window</summary>
+ <description>Show click type window.</description>
+ </key>
+ <key name="ctw-style" type="i">
+ <default>2</default>
+ <summary>Click type window style</summary>
+ <description>Button style in the click type window. ("0" = Text, "1" = Icon, "2" = Both)</description>
+ </key>
+ <key name="ssc-enabled" type="b">
+ <default>false</default>
+ <summary>Enable secondary click</summary>
+ <description>Enable simulated secondary click.</description>
+ </key>
+ <key name="ssc-time" type="d">
+ <default>1.20</default>
+ <summary>Secondary click time</summary>
+ <description>Time in seconds before a simulated secondary click is triggered.</description>
+ </key>
+ <key name="animate-cursor" type="b">
+ <default>true</default>
+ <summary>Animate cursor</summary>
+ <description>Show elapsed time as a cursor overlay.</description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/src/Makefile.am b/src/Makefile.am
index a9ae75e..f0c1c38 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -33,7 +33,9 @@ mousetweaks_SOURCES = \
mt-listener.c \
mt-listener.h \
mt-sig-handler.c \
- mt-sig-handler.h
+ mt-sig-handler.h \
+ mt-settings.c \
+ mt-settings.h
mousetweaks_CFLAGS = \
$(AM_CPPFLAGS) \
diff --git a/src/mt-common.h b/src/mt-common.h
index b3b844f..86d452f 100644
--- a/src/mt-common.h
+++ b/src/mt-common.h
@@ -51,6 +51,23 @@ G_BEGIN_DECLS
#define OPT_STYLE MT_GCONF_HOME "/button_layout"
#define OPT_ANIMATE MT_GCONF_HOME "/animate_cursor"
+/* GSettings */
+#define MT_SCHEMA_ID "org.gnome.mousetweaks"
+
+#define KEY_DWELL_ENABLED "dwell-enabled"
+#define KEY_DWELL_TIME "dwell-time"
+#define KEY_DWELL_THRESHOLD "dwell-threshold"
+#define KEY_DWELL_MODE "dwell-mode"
+#define KEY_DWELL_GESTURE_SINGLE "dwell-gesture-single"
+#define KEY_DWELL_GESTURE_DOUBLE "dwell-gesture-double"
+#define KEY_DWELL_GESTURE_DRAG "dwell-gesture-drag"
+#define KEY_DWELL_GESTURE_SECONDARY "dwell-gesture-secondary"
+#define KEY_SSC_ENABLED "ssc-enabled"
+#define KEY_SSC_TIME "ssc-time"
+#define KEY_CTW_VISIBLE "ctw-visible"
+#define KEY_CTW_STYLE "ctw-style"
+#define KEY_ANIMATE_CURSOR "animate-cursor"
+
enum
{
DWELL_MODE_CTW = 0,
diff --git a/src/mt-settings.c b/src/mt-settings.c
new file mode 100644
index 0000000..9e5937e
--- /dev/null
+++ b/src/mt-settings.c
@@ -0,0 +1,290 @@
+/*
+ * Copyright © 2010 Gerd Kohlberger <gerdko gmail com>
+ *
+ * This file is part of Mousetweaks.
+ *
+ * Mousetweaks is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Mousetweaks 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "mt-settings.h"
+#include "mt-common.h"
+
+#define PFLAGS (G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)
+
+#define BIND_PROP(p,k) (g_settings_bind (ms->settings, (k), ms, (p), \
+ G_SETTINGS_BIND_DEFAULT | G_SETTINGS_BIND_NO_SENSITIVITY))
+
+enum
+{
+ PROP_0,
+ PROP_DWELL_ENABLED,
+ PROP_DWELL_TIME,
+ PROP_DWELL_THRESHOLD,
+ PROP_DWELL_MODE,
+ PROP_DWELL_GESTURE_SINGLE,
+ PROP_DWELL_GESTURE_DOUBLE,
+ PROP_DWELL_GESTURE_DRAG,
+ PROP_DWELL_GESTURE_SECONDARY,
+ PROP_SSC_ENABLED,
+ PROP_SSC_TIME,
+ PROP_CTW_VISIBLE,
+ PROP_CTW_STYLE,
+ PROP_ANIMATE_CURSOR,
+};
+
+G_DEFINE_TYPE (MtSettings, mt_settings, G_TYPE_OBJECT)
+
+static void
+mt_settings_init (MtSettings *ms)
+{
+ ms->settings = g_settings_new (MT_SCHEMA_ID);
+
+ BIND_PROP ("dwell-enabled", KEY_DWELL_ENABLED);
+ BIND_PROP ("dwell-time", KEY_DWELL_TIME);
+ BIND_PROP ("dwell-threshold", KEY_DWELL_THRESHOLD);
+ BIND_PROP ("dwell-mode", KEY_DWELL_MODE);
+ BIND_PROP ("dwell-gesture-single", KEY_DWELL_GESTURE_SINGLE);
+ BIND_PROP ("dwell-gesture-double", KEY_DWELL_GESTURE_DOUBLE);
+ BIND_PROP ("dwell-gesture-drag", KEY_DWELL_GESTURE_DRAG);
+ BIND_PROP ("dwell-gesture-secondary", KEY_DWELL_GESTURE_SECONDARY);
+ BIND_PROP ("ssc-enabled", KEY_SSC_ENABLED);
+ BIND_PROP ("ssc-time", KEY_SSC_TIME);
+ BIND_PROP ("ctw-visible", KEY_CTW_VISIBLE);
+ BIND_PROP ("ctw-style", KEY_CTW_STYLE);
+ BIND_PROP ("animate-cursor", KEY_ANIMATE_CURSOR);
+}
+
+static void
+mt_settings_dispose (GObject *object)
+{
+ MtSettings *ms = MT_SETTINGS (object);
+
+ if (ms->settings)
+ {
+ g_object_unref (ms->settings);
+ ms->settings = NULL;
+ }
+
+ G_OBJECT_CLASS (mt_settings_parent_class)->dispose (object);
+}
+
+static void
+mt_settings_set_property (GObject *object,
+ guint prop_id,
+ const GValue *value,
+ GParamSpec *pspec)
+{
+ MtSettings *ms = MT_SETTINGS (object);
+
+ switch (prop_id)
+ {
+ case PROP_DWELL_ENABLED:
+ ms->dwell_enabled = g_value_get_boolean (value);
+ break;
+ case PROP_DWELL_TIME:
+ ms->dwell_time = g_value_get_double (value);
+ break;
+ case PROP_DWELL_THRESHOLD:
+ ms->dwell_threshold = g_value_get_int (value);
+ break;
+ case PROP_DWELL_MODE:
+ ms->dwell_mode = g_value_get_int (value);
+ break;
+ case PROP_DWELL_GESTURE_SINGLE:
+ ms->dwell_gesture_single = g_value_get_int (value);
+ break;
+ case PROP_DWELL_GESTURE_DOUBLE:
+ ms->dwell_gesture_double = g_value_get_int (value);
+ break;
+ case PROP_DWELL_GESTURE_DRAG:
+ ms->dwell_gesture_drag = g_value_get_int (value);
+ break;
+ case PROP_DWELL_GESTURE_SECONDARY:
+ ms->dwell_gesture_secondary = g_value_get_int (value);
+ break;
+ case PROP_SSC_ENABLED:
+ ms->ssc_enabled = g_value_get_boolean (value);
+ break;
+ case PROP_SSC_TIME:
+ ms->ssc_time = g_value_get_double (value);
+ break;
+ case PROP_CTW_VISIBLE:
+ ms->ctw_visible = g_value_get_boolean (value);
+ break;
+ case PROP_CTW_STYLE:
+ ms->ctw_style = g_value_get_int (value);
+ break;
+ case PROP_ANIMATE_CURSOR:
+ ms->animate_cursor = g_value_get_boolean (value);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+mt_settings_get_property (GObject *object,
+ guint prop_id,
+ GValue *value,
+ GParamSpec *pspec)
+{
+ MtSettings *ms = MT_SETTINGS (object);
+
+ switch (prop_id)
+ {
+ case PROP_DWELL_ENABLED:
+ g_value_set_boolean (value, ms->dwell_enabled);
+ break;
+ case PROP_DWELL_TIME:
+ g_value_set_double (value, ms->dwell_time);
+ break;
+ case PROP_DWELL_THRESHOLD:
+ g_value_set_int (value, ms->dwell_threshold);
+ break;
+ case PROP_DWELL_MODE:
+ g_value_set_int (value, ms->dwell_mode);
+ break;
+ case PROP_DWELL_GESTURE_SINGLE:
+ g_value_set_int (value, ms->dwell_gesture_single);
+ break;
+ case PROP_DWELL_GESTURE_DOUBLE:
+ g_value_set_int (value, ms->dwell_gesture_double);
+ break;
+ case PROP_DWELL_GESTURE_DRAG:
+ g_value_set_int (value, ms->dwell_gesture_drag);
+ break;
+ case PROP_DWELL_GESTURE_SECONDARY:
+ g_value_set_int (value, ms->dwell_gesture_secondary);
+ break;
+ case PROP_SSC_ENABLED:
+ g_value_set_boolean (value, ms->ssc_enabled);
+ break;
+ case PROP_SSC_TIME:
+ g_value_set_double (value, ms->ssc_time);
+ break;
+ case PROP_CTW_VISIBLE:
+ g_value_set_boolean (value, ms->ctw_visible);
+ break;
+ case PROP_CTW_STYLE:
+ g_value_set_int (value, ms->ctw_style);
+ break;
+ case PROP_ANIMATE_CURSOR:
+ g_value_set_boolean (value, ms->animate_cursor);
+ break;
+ default:
+ G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+ }
+}
+
+static void
+mt_settings_class_init (MtSettingsClass *klass)
+{
+ GObjectClass *object_class;
+
+ object_class = G_OBJECT_CLASS (klass);
+ object_class->set_property = mt_settings_set_property;
+ object_class->get_property = mt_settings_get_property;
+ object_class->dispose = mt_settings_dispose;
+
+ g_object_class_install_property (object_class,
+ PROP_DWELL_ENABLED,
+ g_param_spec_boolean ("dwell-enabled",
+ "Dwell enabled",
+ "Enable dwell clicks",
+ FALSE, PFLAGS));
+ g_object_class_install_property (object_class,
+ PROP_DWELL_TIME,
+ g_param_spec_double ("dwell-time",
+ "Dwell time",
+ "Dwell click time",
+ 0.1, 3.0, 1.2, PFLAGS));
+ g_object_class_install_property (object_class,
+ PROP_DWELL_THRESHOLD,
+ g_param_spec_int ("dwell-threshold",
+ "Dwell threshold",
+ "Ignore small mouse movements below threshold",
+ 0, 30, 0, PFLAGS));
+ g_object_class_install_property (object_class,
+ PROP_DWELL_MODE,
+ g_param_spec_int ("dwell-mode",
+ "Dwell mode",
+ "Dwell click mode",
+ 0, 1, 0, PFLAGS));
+ g_object_class_install_property (object_class,
+ PROP_DWELL_GESTURE_SINGLE,
+ g_param_spec_int ("dwell-gesture-single",
+ "Dwell gesture single",
+ "Gesture for single click",
+ 0, 3, 0, PFLAGS));
+ g_object_class_install_property (object_class,
+ PROP_DWELL_GESTURE_DOUBLE,
+ g_param_spec_int ("dwell-gesture-double",
+ "Dwell gesture double",
+ "Gesture for double click",
+ 0, 3, 0, PFLAGS));
+ g_object_class_install_property (object_class,
+ PROP_DWELL_GESTURE_DRAG,
+ g_param_spec_int ("dwell-gesture-drag",
+ "Dwell gesture drag",
+ "Gesture for drag action",
+ 0, 3, 0, PFLAGS));
+ g_object_class_install_property (object_class,
+ PROP_DWELL_GESTURE_SECONDARY,
+ g_param_spec_int ("dwell-gesture-secondary",
+ "Dwell gesture secondary",
+ "Gesture for secondary click",
+ 0, 3, 0, PFLAGS));
+ g_object_class_install_property (object_class,
+ PROP_SSC_ENABLED,
+ g_param_spec_boolean ("ssc-enabled",
+ "SSC enabled",
+ "Enable simulated secondary clicks",
+ FALSE, PFLAGS));
+ g_object_class_install_property (object_class,
+ PROP_SSC_TIME,
+ g_param_spec_double ("ssc-time", "SSC time",
+ "Simulated secondary click time",
+ 0.1, 3.0, 1.2, PFLAGS));
+ g_object_class_install_property (object_class,
+ PROP_CTW_VISIBLE,
+ g_param_spec_boolean ("ctw-visible",
+ "CTW visible",
+ "Show click-type window",
+ FALSE, PFLAGS));
+ g_object_class_install_property (object_class,
+ PROP_CTW_STYLE,
+ g_param_spec_int ("ctw-style",
+ "CTW style",
+ "Button style in click-type window",
+ 0, 2, 0, PFLAGS));
+ g_object_class_install_property (object_class,
+ PROP_ANIMATE_CURSOR,
+ g_param_spec_boolean ("animate-cursor",
+ "Animate cursor",
+ "Draw cursor animation",
+ TRUE, PFLAGS));
+}
+
+MtSettings *
+mt_settings_get_default (void)
+{
+ static MtSettings *ms = NULL;
+
+ if (!ms)
+ {
+ ms = g_object_new (MT_TYPE_SETTINGS, NULL);
+ g_object_add_weak_pointer (G_OBJECT (ms), (gpointer *) &ms);
+ }
+ return ms;
+}
diff --git a/src/mt-settings.h b/src/mt-settings.h
new file mode 100644
index 0000000..328e800
--- /dev/null
+++ b/src/mt-settings.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright © 2010 Gerd Kohlberger <gerdko gmail com>
+ *
+ * This file is part of Mousetweaks.
+ *
+ * Mousetweaks is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Mousetweaks 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __MT_SETTINGS_H__
+#define __MT_SETTINGS_H__
+
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
+#define MT_TYPE_SETTINGS (mt_settings_get_type ())
+#define MT_SETTINGS(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), MT_TYPE_SETTINGS, MtSettings))
+#define MT_IS_SETTINGS(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), MT_TYPE_SETTINGS))
+
+typedef GObjectClass MtSettingsClass;
+typedef struct _MtSettings MtSettings;
+
+struct _MtSettings
+{
+ GObject parent;
+
+ GSettings *settings;
+
+ gdouble dwell_time;
+ gdouble ssc_time;
+ gint dwell_threshold;
+ gint dwell_mode;
+ gint dwell_gesture_single;
+ gint dwell_gesture_double;
+ gint dwell_gesture_drag;
+ gint dwell_gesture_secondary;
+ gint ctw_style;
+ guint dwell_enabled : 1;
+ guint ssc_enabled : 1;
+ guint ctw_visible : 1;
+ guint animate_cursor : 1;
+};
+
+GType mt_settings_get_type (void) G_GNUC_CONST;
+MtSettings * mt_settings_get_default (void);
+
+G_END_DECLS
+
+#endif /* __MT_SETTINGS_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]