[mousetweaks] Add new "orientation" option to the click-type window
- From: Gerd Kohlberger <gerdk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mousetweaks] Add new "orientation" option to the click-type window
- Date: Wed, 27 Oct 2010 21:35:21 +0000 (UTC)
commit b8633ea5169ae0d97ca27217bd96731627a4f5f5
Author: Gerd Kohlberger <gerdk src gnome org>
Date: Wed Oct 27 23:31:15 2010 +0200
Add new "orientation" option to the click-type window
This commit also adds GType generation for all our enums. Some of
the enums have been renamed to be more consistent. All of the object
properties now use enums instead of ints and all GSettings keys now
use enums too.
configure.ac | 17 ++-
data/Makefile.am | 4 +
data/mousetweaks.ui | 46 ++++++--
data/org.gnome.mousetweaks.gschema.xml.in | 13 ++-
src/Makefile.am | 29 +++++
src/dwell-click-applet.c | 52 ++++----
src/mt-common.c | 75 ++-----------
src/mt-common.h | 39 ++++---
src/mt-ctw.c | 180 ++++++++++++++++++++++-------
src/mt-cursor-manager.c | 25 +++--
src/mt-enum-types.c.template | 96 +++++++++++++++
src/mt-enum-types.h.template | 53 +++++++++
src/mt-main.c | 28 +++---
src/mt-service.c | 26 +++--
src/mt-service.h | 6 +-
src/mt-settings.c | 36 +++++--
src/mt-settings.h | 33 +++---
17 files changed, 527 insertions(+), 231 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index df65f60..113b6d2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_PREREQ(2.57)
+AC_PREREQ(2.63)
AC_INIT([mousetweaks],
[2.91.2],
[http://bugzilla.gnome.org/enter_bug.cgi?product=mousetweaks])
@@ -8,9 +8,9 @@ AC_CONFIG_HEADER([config.h])
AC_CONFIG_MACRO_DIR([m4])
AC_PREFIX_DEFAULT([/usr])
-AM_INIT_AUTOMAKE([1.9])
-AM_MAINTAINER_MODE
-m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
+AM_INIT_AUTOMAKE([1.11 -Wno-portability])
+AM_SILENT_RULES([yes])
+AM_MAINTAINER_MODE([enable])
AC_PROG_CC
AC_PROG_INSTALL
@@ -84,6 +84,11 @@ if test "$build_dca" = yes -o "$build_pca" = yes; then
PKG_CHECK_MODULES(PANELAPPLET, libpanelapplet-2.0)
fi
+dnl *** GLib tools ***
+
+GLIB_MKENUMS="$($PKG_CONFIG --variable=glib_mkenums glib-2.0)"
+AC_SUBST([GLIB_MKENUMS])
+
dnl *** output ***
AC_CONFIG_FILES([
@@ -98,9 +103,9 @@ AC_CONFIG_FILES([
AC_OUTPUT
-echo "
+AC_MSG_RESULT([
Building panel applets:
-----------------------
pointer-capture: $build_pca
dwell-click: $build_dca
-"
+])
diff --git a/data/Makefile.am b/data/Makefile.am
index 7993ae7..663d28c 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -36,6 +36,9 @@ menu_DATA = $(pca_menu) $(dca_menu)
convertdir = $(datadir)/GConf/gsettings
convert_DATA = mousetweaks.convert
+gsettings_ENUM_NAMESPACE = org.gnome.mousetweaks
+gsettings_ENUM_FILES = $(top_srcdir)/src/mt-common.h
+
gsettings_in_files = org.gnome.mousetweaks.gschema.xml.in $(pca_schema)
gsettings_SCHEMAS = $(gsettings_in_files:.xml.in=.xml)
@INTLTOOL_XML_NOMERGE_RULE@
@@ -46,6 +49,7 @@ EXTRA_DIST = \
$(menu_DATA) \
$(ui_DATA) \
$(gsettings_in_files) \
+ $(gsettings_ENUM_FILES) \
$(convert_DATA)
DISTCLEANFILES = \
diff --git a/data/mousetweaks.ui b/data/mousetweaks.ui
index b48abf3..793e853 100644
--- a/data/mousetweaks.ui
+++ b/data/mousetweaks.ui
@@ -1,4 +1,4 @@
-<?xml version="1.0"?>
+<?xml version="1.0" encoding="UTF-8"?>
<interface>
<requires lib="gtk+" version="2.16"/>
<!-- interface-naming-policy project-wide -->
@@ -200,28 +200,56 @@
<object class="GtkMenu" id="popup">
<property name="visible">True</property>
<child>
- <object class="GtkRadioMenuItem" id="icon">
+ <object class="GtkMenuItem" id="menu_button_style">
<property name="visible">True</property>
- <property name="label" translatable="yes">Show Icons only</property>
+ <property name="label" translatable="yes">Button Style</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkRadioMenuItem" id="menu_text">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Text only</property>
<property name="draw_as_radio">True</property>
- <property name="group">both</property>
+ <property name="group">menu_both</property>
</object>
</child>
<child>
- <object class="GtkRadioMenuItem" id="text">
+ <object class="GtkRadioMenuItem" id="menu_icon">
<property name="visible">True</property>
- <property name="label" translatable="yes">Show Text only</property>
+ <property name="label" translatable="yes">Icons only</property>
<property name="draw_as_radio">True</property>
- <property name="group">both</property>
+ <property name="group">menu_both</property>
</object>
</child>
<child>
- <object class="GtkRadioMenuItem" id="both">
+ <object class="GtkRadioMenuItem" id="menu_both">
<property name="visible">True</property>
- <property name="label" translatable="yes">Show Icons and Text</property>
+ <property name="label" translatable="yes">Text and Icons</property>
<property name="active">True</property>
<property name="draw_as_radio">True</property>
</object>
</child>
+ <child>
+ <object class="GtkMenuItem" id="menu_orientation">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Orientation</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkRadioMenuItem" id="menu_horizontal">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Horizontal</property>
+ <property name="active">True</property>
+ <property name="draw_as_radio">True</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkRadioMenuItem" id="menu_vertical">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes">Vertical</property>
+ <property name="draw_as_radio">True</property>
+ <property name="group">menu_horizontal</property>
+ </object>
+ </child>
</object>
</interface>
diff --git a/data/org.gnome.mousetweaks.gschema.xml.in b/data/org.gnome.mousetweaks.gschema.xml.in
index ff93020..36c0e74 100644
--- a/data/org.gnome.mousetweaks.gschema.xml.in
+++ b/data/org.gnome.mousetweaks.gschema.xml.in
@@ -1,9 +1,14 @@
<schemalist>
<schema id="org.gnome.mousetweaks" path="/desktop/gnome/a11y/mouse/" gettext-domain="mousetweaks">
- <key name="click-type-window-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 name="click-type-window-style" enum="org.gnome.mousetweaks.MtClickTypeWindowStyle">
+ <default>'both'</default>
+ <_summary>Click-type window style</_summary>
+ <_description>Button style of the click-type window.</_description>
+ </key>
+ <key name="click-type-window-orientation" enum="org.gnome.mousetweaks.MtClickTypeWindowOrientation">
+ <default>'horizontal'</default>
+ <_summary>Click-type window orientation</_summary>
+ <_description>Orientation of the click-type window.</_description>
</key>
</schema>
</schemalist>
diff --git a/src/Makefile.am b/src/Makefile.am
index e0a1590..0565bdd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -14,6 +14,7 @@ endif
bin_PROGRAMS = mousetweaks $(pca_bin) $(dca_bin)
mousetweaks_SOURCES = \
+ $(BUILT_SOURCES) \
mt-main.c \
mt-common.c \
mt-common.h \
@@ -44,6 +45,7 @@ mousetweaks_LDADD = \
$(DEPENDENCIES_LIBS)
dwell_click_applet_SOURCES = \
+ $(BUILT_SOURCES) \
dwell-click-applet.c \
mt-common.c \
mt-common.h
@@ -67,4 +69,31 @@ pointer_capture_applet_CFLAGS = \
pointer_capture_applet_LDADD = \
$(PANELAPPLET_LIBS)
+BUILT_SOURCES = \
+ mt-enum-types.c \
+ mt-enum-types.h
+
+EXTRA_DIST = \
+ mt-enum-types.c.template \
+ mt-enum-types.h.template
+
+CLEANFILES = \
+ stamp-mt-enum-types.h \
+ $(BUILT_SOURCES)
+
+# GLib mkenum
+mt-enum-types.h: stamp-mt-enum-types.h
+ @true
+
+stamp-mt-enum-types.h: mt-enum-types.h.template mt-common.h
+ $(AM_V_GEN) $(GLIB_MKENUMS) --template $< $(filter-out $<,$^) > xgen-gtbh \
+ && (cmp -s xgen-gtbh mt-enum-types.h || cp xgen-gtbh mt-enum-types.h) \
+ && rm -f xgen-gtbh \
+ && echo timestamp > $(@F)
+
+mt-enum-types.c: mt-enum-types.c.template mt-common.h
+ $(AM_V_GEN) $(GLIB_MKENUMS) --template $< $(filter-out $<,$^) > xgen-gtbc \
+ && (cmp -s xgen-gtbc mt-enum-types.c || cp xgen-gtbc mt-enum-types.c) \
+ && rm -f xgen-gtbc
+
-include $(top_srcdir)/git.mk
diff --git a/src/dwell-click-applet.c b/src/dwell-click-applet.c
index 8be6070..51c9ffc 100644
--- a/src/dwell-click-applet.c
+++ b/src/dwell-click-applet.c
@@ -28,22 +28,22 @@
typedef struct _DwellData DwellData;
struct _DwellData
{
- GSettings *settings;
- GDBusProxy *proxy;
- GtkBuilder *ui;
- GtkWidget *box;
- GtkWidget *ct_box;
- GtkWidget *enable;
- GtkWidget *button;
- GdkPixbuf *click[4];
- gint button_width;
- gint button_height;
- MtClickType cct;
- gboolean active;
- GTimer *timer;
- guint tid;
- gdouble delay;
- gdouble elapsed;
+ GSettings *settings;
+ GDBusProxy *proxy;
+ GtkBuilder *ui;
+ GtkWidget *box;
+ GtkWidget *ct_box;
+ GtkWidget *enable;
+ GtkWidget *button;
+ GdkPixbuf *click[4];
+ gint button_width;
+ gint button_height;
+ MtDwellClickType cct;
+ gboolean active;
+ GTimer *timer;
+ guint tid;
+ gdouble delay;
+ gdouble elapsed;
};
static const gchar *img_widgets[] =
@@ -118,8 +118,8 @@ mt_proxy_owner_notify (GObject *object,
}
static void
-handle_click_type_changed (DwellData *dd,
- MtClickType click_type)
+handle_click_type_changed (DwellData *dd,
+ MtDwellClickType click_type)
{
GtkToggleButton *button;
GSList *group;
@@ -186,8 +186,8 @@ mt_proxy_init (DwellData *dd)
}
static void
-mt_proxy_set_click_type (GDBusProxy *proxy,
- MtClickType click_type)
+mt_proxy_set_click_type (GDBusProxy *proxy,
+ MtDwellClickType click_type)
{
GVariant *ct;
@@ -448,7 +448,7 @@ preferences_dialog (BonoboUIComponent *component,
{
mt_common_show_dialog (_("Failed to Open the Univeral Access Panel"),
error->message,
- MT_MESSAGE_WARNING);
+ MT_MESSAGE_TYPE_WARNING);
g_error_free (error);
}
}
@@ -605,7 +605,7 @@ fill_applet (PanelApplet *applet)
/* dbus */
mt_proxy_init (dd);
- dd->cct = DWELL_CLICK_TYPE_SINGLE;
+ dd->cct = MT_DWELL_CLICK_TYPE_SINGLE;
dd->timer = g_timer_new ();
/* about dialog */
@@ -626,13 +626,13 @@ fill_applet (PanelApplet *applet)
G_CALLBACK (dwell_time_changed), dd);
/* icons */
- dd->click[DWELL_CLICK_TYPE_SINGLE] =
+ dd->click[MT_DWELL_CLICK_TYPE_SINGLE] =
gdk_pixbuf_new_from_file (DATADIR "/single-click.png", NULL);
- dd->click[DWELL_CLICK_TYPE_DOUBLE] =
+ dd->click[MT_DWELL_CLICK_TYPE_DOUBLE] =
gdk_pixbuf_new_from_file (DATADIR "/double-click.png", NULL);
- dd->click[DWELL_CLICK_TYPE_DRAG] =
+ dd->click[MT_DWELL_CLICK_TYPE_DRAG] =
gdk_pixbuf_new_from_file (DATADIR "/drag-click.png", NULL);
- dd->click[DWELL_CLICK_TYPE_RIGHT] =
+ dd->click[MT_DWELL_CLICK_TYPE_RIGHT] =
gdk_pixbuf_new_from_file (DATADIR "/right-click.png", NULL);
/* applet initialization */
diff --git a/src/mt-common.c b/src/mt-common.c
index 0d785ff..7b496bc 100644
--- a/src/mt-common.c
+++ b/src/mt-common.c
@@ -19,46 +19,6 @@
#include "mt-common.h"
-GType
-g_desktop_mouse_dwell_mode_get_type (void)
-{
- static volatile gsize type_id__volatile = 0;
-
- if (g_once_init_enter (&type_id__volatile))
- {
- static const GEnumValue values[] =
- {
- { G_DESKTOP_MOUSE_DWELL_MODE_WINDOW, "G_DESKTOP_MOUSE_DWELL_MODE_WINDOW", "window" },
- { G_DESKTOP_MOUSE_DWELL_MODE_GESTURE, "G_DESKTOP_MOUSE_DWELL_MODE_GESTURE", "gesture" },
- { 0, NULL, NULL }
- };
- GType type_id = g_enum_register_static (g_intern_static_string ("GDesktopMouseDwellMode"), values);
- g_once_init_leave (&type_id__volatile, type_id);
- }
- return type_id__volatile;
-}
-
-GType
-g_desktop_mouse_dwell_direction_get_type (void)
-{
- static volatile gsize type_id__volatile = 0;
-
- if (g_once_init_enter (&type_id__volatile))
- {
- static const GEnumValue values[] =
- {
- { G_DESKTOP_MOUSE_DWELL_DIRECTION_LEFT, "G_DESKTOP_MOUSE_DWELL_DIRECTION_LEFT", "left" },
- { G_DESKTOP_MOUSE_DWELL_DIRECTION_RIGHT, "G_DESKTOP_MOUSE_DWELL_DIRECTION_RIGHT", "right" },
- { G_DESKTOP_MOUSE_DWELL_DIRECTION_UP, "G_DESKTOP_MOUSE_DWELL_DIRECTION_UP", "up" },
- { G_DESKTOP_MOUSE_DWELL_DIRECTION_DOWN, "G_DESKTOP_MOUSE_DWELL_DIRECTION_DOWN", "down" },
- { 0, NULL, NULL }
- };
- GType type_id = g_enum_register_static (g_intern_static_string ("GDesktopMouseDwellDirection"), values);
- g_once_init_leave (&type_id__volatile, type_id);
- }
- return type_id__volatile;
-}
-
Display *
mt_common_get_xdisplay (void)
{
@@ -112,21 +72,23 @@ mt_common_show_help (GdkScreen *screen, guint32 timestamp)
if (!gtk_show_uri (screen, "ghelp:mousetweaks", timestamp, &error))
{
mt_common_show_dialog (_("Failed to Display Help"),
- error->message, MT_MESSAGE_WARNING);
+ error->message,
+ MT_MESSAGE_TYPE_WARNING);
g_error_free (error);
}
}
-gint
+void
mt_common_show_dialog (const gchar *primary,
const gchar *secondary,
MtMessageType type)
{
GtkWidget *dialog;
- gint ret;
- dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_ERROR,
- GTK_BUTTONS_NONE, "%s", primary);
+ dialog = gtk_message_dialog_new (NULL, 0,
+ GTK_MESSAGE_ERROR,
+ GTK_BUTTONS_NONE,
+ "%s", primary);
gtk_window_set_title (GTK_WINDOW (dialog), g_get_application_name ());
gtk_window_set_icon_name (GTK_WINDOW (dialog), MT_ICON_NAME);
@@ -136,34 +98,17 @@ mt_common_show_dialog (const gchar *primary,
switch (type)
{
- case MT_MESSAGE_QUESTION:
- g_object_set (dialog, "message-type", GTK_MESSAGE_QUESTION, NULL);
- gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- GTK_STOCK_YES, GTK_RESPONSE_YES,
- GTK_STOCK_NO, GTK_RESPONSE_NO,
- NULL);
- break;
- case MT_MESSAGE_WARNING:
+ case MT_MESSAGE_TYPE_WARNING:
g_object_set (dialog, "message-type", GTK_MESSAGE_WARNING, NULL);
gtk_dialog_add_button (GTK_DIALOG (dialog),
GTK_STOCK_OK, GTK_RESPONSE_OK);
break;
- case MT_MESSAGE_LOGOUT:
- gtk_dialog_add_buttons (GTK_DIALOG (dialog),
- _("Enable and Log Out"), GTK_RESPONSE_ACCEPT,
- GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
- NULL);
- gtk_dialog_set_default_response (GTK_DIALOG (dialog),
- GTK_RESPONSE_ACCEPT);
- break;
- case MT_MESSAGE_ERROR:
+ case MT_MESSAGE_TYPE_ERROR:
default:
gtk_dialog_add_button (GTK_DIALOG (dialog),
GTK_STOCK_OK, GTK_RESPONSE_OK);
}
- ret = gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_dialog_run (GTK_DIALOG (dialog));
gtk_widget_destroy (dialog);
-
- return ret;
}
diff --git a/src/mt-common.h b/src/mt-common.h
index 8175606..c6e4663 100644
--- a/src/mt-common.h
+++ b/src/mt-common.h
@@ -29,6 +29,8 @@
#include <gdk/gdkx.h>
#include <gsettings-desktop-schemas/gdesktop-enums.h>
+#include "mt-enum-types.h"
+
G_BEGIN_DECLS
#define MT_ICON_NAME "input-mouse"
@@ -40,6 +42,7 @@ G_BEGIN_DECLS
/* GSettings */
#define MOUSETWEAKS_SCHEMA_ID "org.gnome.mousetweaks"
#define KEY_CTW_STYLE "click-type-window-style"
+#define KEY_CTW_ORIENTATION "click-type-window-orientation"
#define A11Y_MOUSE_SCHEMA_ID "org.gnome.desktop.a11y.mouse"
#define KEY_DWELL_ENABLED "dwell-click-enabled"
@@ -54,27 +57,33 @@ G_BEGIN_DECLS
#define KEY_SSC_TIME "secondary-click-time"
#define KEY_CTW_VISIBLE "click-type-window-visible"
-#define G_DESKTOP_TYPE_MOUSE_DWELL_MODE (g_desktop_mouse_dwell_mode_get_type())
-#define G_DESKTOP_TYPE_MOUSE_DWELL_DIRECTION (g_desktop_mouse_dwell_direction_get_type())
+#define N_CLICK_TYPES 4
-GType g_desktop_mouse_dwell_mode_get_type (void) G_GNUC_CONST;
-GType g_desktop_mouse_dwell_direction_get_type (void) G_GNUC_CONST;
+typedef enum
+{
+ MT_DWELL_CLICK_TYPE_RIGHT,
+ MT_DWELL_CLICK_TYPE_DRAG,
+ MT_DWELL_CLICK_TYPE_DOUBLE,
+ MT_DWELL_CLICK_TYPE_SINGLE
+} MtDwellClickType;
typedef enum
{
- DWELL_CLICK_TYPE_RIGHT = 0,
- DWELL_CLICK_TYPE_DRAG,
- DWELL_CLICK_TYPE_DOUBLE,
- DWELL_CLICK_TYPE_SINGLE,
- N_CLICK_TYPES
-} MtClickType;
+ MT_CLICK_TYPE_WINDOW_STYLE_TEXT,
+ MT_CLICK_TYPE_WINDOW_STYLE_ICON,
+ MT_CLICK_TYPE_WINDOW_STYLE_BOTH
+} MtClickTypeWindowStyle;
typedef enum
{
- MT_MESSAGE_ERROR = 0,
- MT_MESSAGE_WARNING,
- MT_MESSAGE_QUESTION,
- MT_MESSAGE_LOGOUT
+ MT_CLICK_TYPE_WINDOW_ORIENTATION_HORIZONTAL,
+ MT_CLICK_TYPE_WINDOW_ORIENTATION_VERTICAL
+} MtClickTypeWindowOrientation;
+
+typedef enum /*< skip >*/
+{
+ MT_MESSAGE_TYPE_ERROR,
+ MT_MESSAGE_TYPE_WARNING,
} MtMessageType;
Display * mt_common_get_xdisplay (void);
@@ -87,7 +96,7 @@ GdkScreen * mt_common_get_screen (void);
void mt_common_show_help (GdkScreen *screen,
guint32 timestamp);
-gint mt_common_show_dialog (const gchar *primary,
+void mt_common_show_dialog (const gchar *primary,
const gchar *secondary,
MtMessageType type);
diff --git a/src/mt-ctw.c b/src/mt-ctw.c
index fe1fbb9..1cd75ee 100644
--- a/src/mt-ctw.c
+++ b/src/mt-ctw.c
@@ -29,13 +29,6 @@
static GtkBuilder *builder;
-enum
-{
- BUTTON_STYLE_TEXT = 0,
- BUTTON_STYLE_ICON,
- BUTTON_STYLE_BOTH
-};
-
static void
service_click_type_changed (MtService *service, GParamSpec *pspec)
{
@@ -77,31 +70,45 @@ ctw_style_changed (MtSettings *ms, GParamSpec *pspec)
switch (ms->ctw_style)
{
- case BUTTON_STYLE_BOTH:
+ case MT_CLICK_TYPE_WINDOW_STYLE_BOTH:
g_object_set (icon, "yalign", 1.0, NULL);
gtk_widget_show (icon);
g_object_set (label, "yalign", 0.0, NULL);
gtk_widget_show (label);
break;
- case BUTTON_STYLE_TEXT:
+ case MT_CLICK_TYPE_WINDOW_STYLE_TEXT:
gtk_widget_hide (icon);
g_object_set (icon, "yalign", 0.5, NULL);
gtk_widget_show (label);
g_object_set (label, "yalign", 0.5, NULL);
break;
- case BUTTON_STYLE_ICON:
+ case MT_CLICK_TYPE_WINDOW_STYLE_ICON:
gtk_widget_show (icon);
g_object_set (icon, "yalign", 0.5, NULL);
gtk_widget_hide (label);
g_object_set (label, "yalign", 0.5, NULL);
- default:
break;
}
}
}
static void
-ctw_button_cb (GtkToggleButton *button, gpointer data)
+ctw_orientation_changed (MtSettings *ms, GParamSpec *pspec)
+{
+ if (ms->ctw_orientation == MT_CLICK_TYPE_WINDOW_ORIENTATION_HORIZONTAL)
+ {
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (O ("box")),
+ GTK_ORIENTATION_HORIZONTAL);
+ }
+ else
+ {
+ gtk_orientable_set_orientation (GTK_ORIENTABLE (O ("box")),
+ GTK_ORIENTATION_VERTICAL);
+ }
+}
+
+static void
+ctw_button_toggled (GtkToggleButton *button, gpointer data)
{
GSList *group;
@@ -118,28 +125,82 @@ ctw_context_menu (GtkWidget *widget, GdkEventButton *bev, gpointer data)
{
if (bev->button == 3)
{
- gtk_menu_popup (GTK_MENU (O ("popup")), 0, 0, 0, 0, bev->button, bev->time);
+ gtk_menu_popup (GTK_MENU (O ("popup")),
+ 0, 0, 0, 0,
+ bev->button, bev->time);
return TRUE;
}
return FALSE;
}
static void
-ctw_menu_toggled (GtkCheckMenuItem *item, gpointer data)
+ctw_button_style_icon_toggled (GtkCheckMenuItem *item, gpointer data)
{
- GSList *group;
+ if (gtk_check_menu_item_get_active (item))
+ {
+ g_object_set (mt_settings_get_default (), "ctw-style",
+ MT_CLICK_TYPE_WINDOW_STYLE_ICON, NULL);
+ }
+}
+static void
+ctw_button_style_text_toggled (GtkCheckMenuItem *item, gpointer data)
+{
if (gtk_check_menu_item_get_active (item))
{
- group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (item));
- g_object_set (mt_settings_get_default (),
- "ctw-style", g_slist_index (group, item),
- NULL);
+ g_object_set (mt_settings_get_default (), "ctw-style",
+ MT_CLICK_TYPE_WINDOW_STYLE_TEXT, NULL);
+ }
+}
+
+static void
+ctw_button_style_both_toggled (GtkCheckMenuItem *item, gpointer data)
+{
+ if (gtk_check_menu_item_get_active (item))
+ {
+ g_object_set (mt_settings_get_default (), "ctw-style",
+ MT_CLICK_TYPE_WINDOW_STYLE_BOTH, NULL);
}
}
+static void
+ctw_orientation_horizontal_toggled (GtkCheckMenuItem *item, gpointer data)
+{
+ if (gtk_check_menu_item_get_active (item))
+ {
+ g_object_set (mt_settings_get_default (), "ctw-orientation",
+ MT_CLICK_TYPE_WINDOW_ORIENTATION_HORIZONTAL, NULL);
+ }
+}
+
+static void
+ctw_orientation_vertical_toggled (GtkCheckMenuItem *item, gpointer data)
+{
+ if (gtk_check_menu_item_get_active (item))
+ {
+ g_object_set (mt_settings_get_default (), "ctw-orientation",
+ MT_CLICK_TYPE_WINDOW_ORIENTATION_VERTICAL, NULL);
+ }
+}
+
+static void
+ctw_menu_label_set_bold (GtkWidget *item)
+{
+ GtkWidget *label;
+ PangoAttrList *list;
+ PangoAttribute *attr;
+
+ list = pango_attr_list_new ();
+ attr = pango_attr_weight_new (PANGO_WEIGHT_BOLD);
+ pango_attr_list_insert (list, attr);
+
+ label = gtk_bin_get_child (GTK_BIN (item));
+ gtk_label_set_attributes (GTK_LABEL (label), list);
+ pango_attr_list_unref (list);
+}
+
static gboolean
-ctw_delete_cb (GtkWidget *win, GdkEvent *ev, gpointer data)
+ctw_window_delete (GtkWidget *widget, GdkEvent *event, gpointer data)
{
g_object_set (mt_settings_get_default (), "ctw-visible", FALSE, NULL);
return TRUE;
@@ -153,9 +214,7 @@ mt_ctw_init (gint x, gint y)
GtkWidget *ctw;
GObject *obj;
GError *error = NULL;
- const gchar *b[] = { "single", "double", "drag", "right" };
- GSList *group;
- gpointer data;
+ const gchar *button_names[] = { "single", "double", "drag", "right" };
gint i;
/* load UI */
@@ -173,15 +232,18 @@ mt_ctw_init (gint x, gint y)
ctw = mt_ctw_get_window ();
gtk_window_stick (GTK_WINDOW (ctw));
gtk_window_set_keep_above (GTK_WINDOW (ctw), TRUE);
- g_signal_connect (ctw, "delete-event", G_CALLBACK (ctw_delete_cb), NULL);
+ g_signal_connect (ctw, "delete-event",
+ G_CALLBACK (ctw_window_delete), NULL);
/* init buttons */
for (i = 0; i < N_CLICK_TYPES; i++)
{
- obj = O (b[i]);
+ obj = O (button_names[i]);
gtk_toggle_button_set_mode (GTK_TOGGLE_BUTTON (obj), FALSE);
- g_signal_connect (obj, "toggled", G_CALLBACK (ctw_button_cb), NULL);
- g_signal_connect (obj, "button-press-event", G_CALLBACK (ctw_context_menu), NULL);
+ g_object_connect (obj,
+ "signal::toggled", G_CALLBACK (ctw_button_toggled), NULL,
+ "signal::button-press-event", G_CALLBACK (ctw_context_menu), NULL,
+ NULL);
}
/* service */
@@ -193,27 +255,59 @@ mt_ctw_init (gint x, gint y)
/* settings */
ms = mt_settings_get_default ();
- g_signal_connect (ms, "notify::ctw-visible",
- G_CALLBACK (ctw_visibility_changed), NULL);
- g_signal_connect (ms, "notify::dwell-enabled",
- G_CALLBACK (ctw_visibility_changed), NULL);
- g_signal_connect (ms, "notify::dwell-mode",
- G_CALLBACK (ctw_sensitivity_changed), NULL);
- g_signal_connect (ms, "notify::ctw-mode",
- G_CALLBACK (ctw_style_changed), NULL);
+ g_object_connect (ms,
+ "signal::notify::ctw-visible", G_CALLBACK (ctw_visibility_changed), NULL,
+ "signal::notify::ctw-style", G_CALLBACK (ctw_style_changed), NULL,
+ "signal::notify::ctw-orientation", G_CALLBACK (ctw_orientation_changed), NULL,
+ "signal::notify::dwell-enabled", G_CALLBACK (ctw_visibility_changed), NULL,
+ "signal::notify::dwell-mode", G_CALLBACK (ctw_sensitivity_changed), NULL,
+ NULL);
ctw_visibility_changed (ms, NULL);
ctw_sensitivity_changed (ms, NULL);
- /* init context menu */
- obj = O ("both");
- g_signal_connect (obj, "toggled", G_CALLBACK (ctw_menu_toggled), NULL);
- g_signal_connect (O ("text"), "toggled", G_CALLBACK (ctw_menu_toggled), NULL);
- g_signal_connect (O ("icon"), "toggled", G_CALLBACK (ctw_menu_toggled), NULL);
+ /* context menu: button style */
+ switch (ms->ctw_style)
+ {
+ case MT_CLICK_TYPE_WINDOW_STYLE_BOTH:
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (O ("menu_both")), TRUE);
+ break;
+ case MT_CLICK_TYPE_WINDOW_STYLE_TEXT:
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (O ("menu_text")), TRUE);
+ break;
+ case MT_CLICK_TYPE_WINDOW_STYLE_ICON:
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (O ("menu_icon")), TRUE);
+ break;
+ }
+
+ g_signal_connect (O ("menu_both"), "toggled",
+ G_CALLBACK (ctw_button_style_both_toggled), NULL);
+ g_signal_connect (O ("menu_text"), "toggled",
+ G_CALLBACK (ctw_button_style_text_toggled), NULL);
+ g_signal_connect (O ("menu_icon"), "toggled",
+ G_CALLBACK (ctw_button_style_icon_toggled), NULL);
+
+ ctw_style_changed (ms, NULL);
+ ctw_menu_label_set_bold (W ("menu_orientation"));
+
+ /* context menu: orientation */
+ switch (ms->ctw_orientation)
+ {
+ case MT_CLICK_TYPE_WINDOW_ORIENTATION_HORIZONTAL:
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (O ("menu_horizontal")), TRUE);
+ break;
+ case MT_CLICK_TYPE_WINDOW_ORIENTATION_VERTICAL:
+ gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (O ("menu_vertical")), TRUE);
+ break;
+ }
+
+ g_signal_connect (O ("menu_horizontal"), "toggled",
+ G_CALLBACK (ctw_orientation_horizontal_toggled), NULL);
+ g_signal_connect (O ("menu_vertical"), "toggled",
+ G_CALLBACK (ctw_orientation_vertical_toggled), NULL);
- group = gtk_radio_menu_item_get_group (GTK_RADIO_MENU_ITEM (obj));
- data = g_slist_nth_data (group, ms->ctw_style);
- gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (data), TRUE);
+ ctw_orientation_changed (ms, NULL);
+ ctw_menu_label_set_bold (W ("menu_button_style"));
/* XXX: remember window position */
if (x != -1 && y != -1)
diff --git a/src/mt-cursor-manager.c b/src/mt-cursor-manager.c
index a2fe8c4..50936b4 100644
--- a/src/mt-cursor-manager.c
+++ b/src/mt-cursor-manager.c
@@ -46,7 +46,7 @@ static void mt_cursor_manager_clear_cache (GObject *settings
MtCursorManager *manager);
static GdkFilterReturn mt_cursor_manager_event_filter (GdkXEvent *gdk_xevent,
GdkEvent *gdk_event,
- gpointer data);
+ MtCursorManager *manager);
G_DEFINE_TYPE (MtCursorManager, mt_cursor_manager, G_TYPE_OBJECT)
@@ -74,7 +74,7 @@ mt_cursor_manager_init (MtCursorManager *manager)
XFixesDisplayCursorNotifyMask);
}
- gdk_window_add_filter (NULL, mt_cursor_manager_event_filter, manager);
+ gdk_window_add_filter (NULL, (GdkFilterFunc) mt_cursor_manager_event_filter, manager);
/* listen for cursor theme changes */
gs = gtk_settings_get_default ();
@@ -89,7 +89,7 @@ mt_cursor_manager_finalize (GObject *object)
{
MtCursorManagerPrivate *priv = MT_CURSOR_MANAGER (object)->priv;
- gdk_window_remove_filter (NULL, mt_cursor_manager_event_filter, object);
+ gdk_window_remove_filter (NULL, (GdkFilterFunc) mt_cursor_manager_event_filter, object);
g_hash_table_destroy (priv->cache);
G_OBJECT_CLASS (mt_cursor_manager_parent_class)->finalize (object);
@@ -206,9 +206,9 @@ mt_cursor_manager_add_cursor (MtCursorManager *manager,
}
static GdkFilterReturn
-mt_cursor_manager_event_filter (GdkXEvent *gdk_xevent,
- GdkEvent *gdk_event,
- gpointer data)
+mt_cursor_manager_event_filter (GdkXEvent *gdk_xevent,
+ GdkEvent *gdk_event,
+ MtCursorManager *manager)
{
XEvent *xev = gdk_xevent;
@@ -218,15 +218,18 @@ mt_cursor_manager_event_filter (GdkXEvent *gdk_xevent,
if (cn->cursor_name != None)
{
- MtCursorManager *manager = data;
XFixesCursorImage *image;
image = XFixesGetCursorImage (cn->display);
- if (!mt_cursor_manager_lookup_cursor (manager, image->name))
- mt_cursor_manager_add_cursor (manager, image);
+ if (image)
+ {
+ if (!mt_cursor_manager_lookup_cursor (manager, image->name))
+ mt_cursor_manager_add_cursor (manager, image);
+
+ g_signal_emit (manager, signals[CURSOR_CHANGED], 0, image->name);
- g_signal_emit (manager, signals[CURSOR_CHANGED], 0, image->name);
- XFree (image);
+ XFree (image);
+ }
}
}
return GDK_FILTER_CONTINUE;
diff --git a/src/mt-enum-types.c.template b/src/mt-enum-types.c.template
new file mode 100644
index 0000000..c61e341
--- /dev/null
+++ b/src/mt-enum-types.c.template
@@ -0,0 +1,96 @@
+/*** BEGIN file-header ***/
+/*
+ * 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 <gsettings-desktop-schemas/gdesktop-enums.h>
+
+#include "mt-enum-types.h"
+
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+#include "@filename@"
+
+GType
+g_desktop_mouse_dwell_mode_get_type (void)
+{
+ static volatile gsize g_define_type_id__volatile = 0;
+ if (g_once_init_enter (&g_define_type_id__volatile))
+ {
+ static const GEnumValue values[] =
+ {
+ { G_DESKTOP_MOUSE_DWELL_MODE_WINDOW, "G_DESKTOP_MOUSE_DWELL_MODE_WINDOW", "window" },
+ { G_DESKTOP_MOUSE_DWELL_MODE_GESTURE, "G_DESKTOP_MOUSE_DWELL_MODE_GESTURE", "gesture" },
+ { 0, NULL, NULL }
+ };
+ GType g_define_type_id = g_enum_register_static (g_intern_static_string ("GDesktopMouseDwellMode"), values);
+ g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
+ }
+ return g_define_type_id__volatile;
+}
+
+GType
+g_desktop_mouse_dwell_direction_get_type (void)
+{
+ static volatile gsize g_define_type_id__volatile = 0;
+ if (g_once_init_enter (&g_define_type_id__volatile))
+ {
+ static const GEnumValue values[] =
+ {
+ { G_DESKTOP_MOUSE_DWELL_DIRECTION_LEFT, "G_DESKTOP_MOUSE_DWELL_DIRECTION_LEFT", "left" },
+ { G_DESKTOP_MOUSE_DWELL_DIRECTION_RIGHT, "G_DESKTOP_MOUSE_DWELL_DIRECTION_RIGHT", "right" },
+ { G_DESKTOP_MOUSE_DWELL_DIRECTION_UP, "G_DESKTOP_MOUSE_DWELL_DIRECTION_UP", "up" },
+ { G_DESKTOP_MOUSE_DWELL_DIRECTION_DOWN, "G_DESKTOP_MOUSE_DWELL_DIRECTION_DOWN", "down" },
+ { 0, NULL, NULL }
+ };
+ GType g_define_type_id = g_enum_register_static (g_intern_static_string ("GDesktopMouseDwellDirection"), values);
+ g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
+ }
+ return g_define_type_id__volatile;
+}
+
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+GType
+ enum_name@_get_type (void)
+{
+ static volatile gsize g_define_type_id__volatile = 0;
+ if (g_once_init_enter (&g_define_type_id__volatile))
+ {
+ static const G Type@Value values[] =
+ {
+/*** END value-header ***/
+
+/*** BEGIN value-production ***/
+ { @VALUENAME@, "@VALUENAME@", "@valuenick@" },
+/*** END value-production ***/
+
+/*** BEGIN value-tail ***/
+ { 0, NULL, NULL }
+ };
+ GType g_define_type_id = g_ type@_register_static (g_intern_static_string ("@EnumName@"), values);
+ g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
+ }
+ return g_define_type_id__volatile;
+}
+
+/*** END value-tail ***/
+/*** BEGIN file-tail ***/
+/*** END file-tail ***/
diff --git a/src/mt-enum-types.h.template b/src/mt-enum-types.h.template
new file mode 100644
index 0000000..5d559c3
--- /dev/null
+++ b/src/mt-enum-types.h.template
@@ -0,0 +1,53 @@
+/*** BEGIN file-header ***/
+/*
+ * 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_ENUM_TYPES_H__
+#define __MT_ENUM_TYPES_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+/*** END file-header ***/
+
+/*** BEGIN file-production ***/
+
+/* enumerations from <gsettings-desktop-schemas/gdesktop-enums.h> */
+
+#define G_DESKTOP_TYPE_MOUSE_DWELL_MODE (g_desktop_mouse_dwell_mode_get_type ())
+GType g_desktop_mouse_dwell_mode_get_type (void) G_GNUC_CONST;
+
+#define G_DESKTOP_TYPE_MOUSE_DWELL_DIRECTION (g_desktop_mouse_dwell_direction_get_type ())
+GType g_desktop_mouse_dwell_direction_get_type (void) G_GNUC_CONST;
+
+/* enumerations from "@filename@" */
+
+/*** END file-production ***/
+
+/*** BEGIN value-header ***/
+#define MT_TYPE_ ENUMSHORT@ (@enum_name _get_type ())
+GType @enum_name _get_type (void) G_GNUC_CONST;
+
+/*** END value-header ***/
+
+/*** BEGIN file-tail ***/
+G_END_DECLS
+
+#endif /* __MT_ENUM_TYPES_H__ */
+/*** END file-tail ***/
diff --git a/src/mt-main.c b/src/mt-main.c
index 044de83..3fbf6a0 100644
--- a/src/mt-main.c
+++ b/src/mt-main.c
@@ -141,7 +141,7 @@ mt_main_set_cursor (MtData *mt, GdkCursorType type)
static void
mt_main_do_dwell_click (MtData *mt)
{
- MtClickType click_type;
+ MtDwellClickType click_type;
MtSettings *ms;
ms = mt_settings_get_default ();
@@ -157,14 +157,14 @@ mt_main_do_dwell_click (MtData *mt)
switch (click_type)
{
- case DWELL_CLICK_TYPE_SINGLE:
+ case MT_DWELL_CLICK_TYPE_SINGLE:
mt_main_generate_button_event (mt, 1, CLICK, 60);
break;
- case DWELL_CLICK_TYPE_DOUBLE:
+ case MT_DWELL_CLICK_TYPE_DOUBLE:
mt_main_generate_button_event (mt, 1, DOUBLE_CLICK, 10);
- mt_service_set_click_type (mt->service, DWELL_CLICK_TYPE_SINGLE);
+ mt_service_set_click_type (mt->service, MT_DWELL_CLICK_TYPE_SINGLE);
break;
- case DWELL_CLICK_TYPE_DRAG:
+ case MT_DWELL_CLICK_TYPE_DRAG:
if (!mt->dwell_drag_started)
{
mt_main_generate_button_event (mt, 1, PRESS, CurrentTime);
@@ -177,12 +177,12 @@ mt_main_do_dwell_click (MtData *mt)
mt_main_set_cursor (mt, GDK_LEFT_PTR);
mt->dwell_drag_started = FALSE;
- mt_service_set_click_type (mt->service, DWELL_CLICK_TYPE_SINGLE);
+ mt_service_set_click_type (mt->service, MT_DWELL_CLICK_TYPE_SINGLE);
}
break;
- case DWELL_CLICK_TYPE_RIGHT:
+ case MT_DWELL_CLICK_TYPE_RIGHT:
mt_main_generate_button_event (mt, 3, CLICK, 10);
- mt_service_set_click_type (mt->service, DWELL_CLICK_TYPE_SINGLE);
+ mt_service_set_click_type (mt->service, MT_DWELL_CLICK_TYPE_SINGLE);
break;
default:
g_warning ("Unknown click-type.");
@@ -233,7 +233,7 @@ mt_main_analyze_gesture (MtData *mt)
GDesktopMouseDwellDirection direction;
gint x, y;
- if (mt_service_get_click_type (mt->service) == DWELL_CLICK_TYPE_DRAG)
+ if (mt_service_get_click_type (mt->service) == MT_DWELL_CLICK_TYPE_DRAG)
return TRUE;
gdk_display_get_pointer (gdk_display_get_default (), NULL, &x, &y, NULL);
@@ -246,19 +246,19 @@ mt_main_analyze_gesture (MtData *mt)
if (direction == ms->dwell_gesture_single)
{
- mt_service_set_click_type (mt->service, DWELL_CLICK_TYPE_SINGLE);
+ mt_service_set_click_type (mt->service, MT_DWELL_CLICK_TYPE_SINGLE);
}
else if (direction == ms->dwell_gesture_double)
{
- mt_service_set_click_type (mt->service, DWELL_CLICK_TYPE_DOUBLE);
+ mt_service_set_click_type (mt->service, MT_DWELL_CLICK_TYPE_DOUBLE);
}
else if (direction == ms->dwell_gesture_drag)
{
- mt_service_set_click_type (mt->service, DWELL_CLICK_TYPE_DRAG);
+ mt_service_set_click_type (mt->service, MT_DWELL_CLICK_TYPE_DRAG);
}
else if (direction == ms->dwell_gesture_secondary)
{
- mt_service_set_click_type (mt->service, DWELL_CLICK_TYPE_RIGHT);
+ mt_service_set_click_type (mt->service, MT_DWELL_CLICK_TYPE_RIGHT);
}
else
{
@@ -369,7 +369,7 @@ mt_dwell_click_cancel (MtData *mt)
mt->dwell_drag_started = FALSE;
}
- mt_service_set_click_type (mt->service, DWELL_CLICK_TYPE_SINGLE);
+ mt_service_set_click_type (mt->service, MT_DWELL_CLICK_TYPE_SINGLE);
}
static void
diff --git a/src/mt-service.c b/src/mt-service.c
index 4d92e8b..509d914 100644
--- a/src/mt-service.c
+++ b/src/mt-service.c
@@ -58,7 +58,7 @@ mt_service_init (MtService *service)
MT_TYPE_SERVICE,
MtServicePrivate);
- priv->click_type = DWELL_CLICK_TYPE_SINGLE;
+ priv->click_type = MT_DWELL_CLICK_TYPE_SINGLE;
priv->owner_id = g_bus_own_name (G_BUS_TYPE_SESSION,
MOUSETWEAKS_DBUS_NAME,
G_BUS_NAME_OWNER_FLAGS_NONE,
@@ -84,7 +84,7 @@ mt_service_set_property (GObject *object,
switch (prop_id)
{
case PROP_CLICK_TYPE:
- service->priv->click_type = g_value_get_int (value);
+ service->priv->click_type = g_value_get_enum (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -102,7 +102,7 @@ mt_service_get_property (GObject *object,
switch (prop_id)
{
case PROP_CLICK_TYPE:
- g_value_set_int (value, service->priv->click_type);
+ g_value_set_enum (value, service->priv->click_type);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -138,11 +138,15 @@ mt_service_class_init (MtServiceClass *klass)
object_class->set_property = mt_service_set_property;
object_class->dispose = mt_service_dispose;
- g_object_class_install_property (object_class, PROP_CLICK_TYPE,
- g_param_spec_int ("click-type", "Click type",
- "The currently active click type",
- 0, 3, DWELL_CLICK_TYPE_SINGLE,
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
+ g_object_class_install_property (object_class,
+ PROP_CLICK_TYPE,
+ g_param_spec_enum ("click-type",
+ "Click type",
+ "The currently active click type",
+ MT_TYPE_DWELL_CLICK_TYPE,
+ MT_DWELL_CLICK_TYPE_SINGLE,
+ G_PARAM_READWRITE |
+ G_PARAM_STATIC_STRINGS));
g_type_class_add_private (klass, sizeof (MtServicePrivate));
}
@@ -264,8 +268,8 @@ mt_service_get_default (void)
}
void
-mt_service_set_click_type (MtService *service,
- MtClickType type)
+mt_service_set_click_type (MtService *service,
+ MtDwellClickType type)
{
g_return_if_fail (MT_IS_SERVICE (service));
@@ -276,7 +280,7 @@ mt_service_set_click_type (MtService *service,
}
}
-MtClickType
+MtDwellClickType
mt_service_get_click_type (MtService *service)
{
g_return_val_if_fail (MT_IS_SERVICE (service), -1);
diff --git a/src/mt-service.h b/src/mt-service.h
index 40c4188..1852250 100644
--- a/src/mt-service.h
+++ b/src/mt-service.h
@@ -44,9 +44,9 @@ GType mt_service_get_type (void) G_GNUC_CONST;
MtService * mt_service_get_default (void);
-MtClickType mt_service_get_click_type (MtService *service);
-void mt_service_set_click_type (MtService *service,
- MtClickType type);
+MtDwellClickType mt_service_get_click_type (MtService *service);
+void mt_service_set_click_type (MtService *service,
+ MtDwellClickType type);
G_END_DECLS
diff --git a/src/mt-settings.c b/src/mt-settings.c
index 65a2500..ce74bd5 100644
--- a/src/mt-settings.c
+++ b/src/mt-settings.c
@@ -36,7 +36,8 @@ enum
PROP_DWELL_GESTURE_SECONDARY,
PROP_SSC_ENABLED,
PROP_CTW_VISIBLE,
- PROP_CTW_STYLE
+ PROP_CTW_STYLE,
+ PROP_CTW_ORIENTATION
};
G_DEFINE_TYPE (MtSettings, mt_settings, G_TYPE_OBJECT)
@@ -47,6 +48,7 @@ mt_settings_init (MtSettings *ms)
ms->mt_settings = g_settings_new (MOUSETWEAKS_SCHEMA_ID);
BIND_PROP (ms->mt_settings, "ctw-style", KEY_CTW_STYLE);
+ BIND_PROP (ms->mt_settings, "ctw-orientation", KEY_CTW_ORIENTATION);
ms->a11y_settings = g_settings_new (A11Y_MOUSE_SCHEMA_ID);
@@ -119,7 +121,10 @@ mt_settings_set_property (GObject *object,
ms->ctw_visible = g_value_get_boolean (value);
break;
case PROP_CTW_STYLE:
- ms->ctw_style = g_value_get_int (value);
+ ms->ctw_style = g_value_get_enum (value);
+ break;
+ case PROP_CTW_ORIENTATION:
+ ms->ctw_orientation = g_value_get_enum (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -164,7 +169,10 @@ mt_settings_get_property (GObject *object,
g_value_set_boolean (value, ms->ctw_visible);
break;
case PROP_CTW_STYLE:
- g_value_set_int (value, ms->ctw_style);
+ g_value_set_enum (value, ms->ctw_style);
+ break;
+ case PROP_CTW_ORIENTATION:
+ g_value_set_enum (value, ms->ctw_orientation);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
@@ -242,15 +250,25 @@ mt_settings_class_init (MtSettingsClass *klass)
g_object_class_install_property (object_class,
PROP_CTW_VISIBLE,
g_param_spec_boolean ("ctw-visible",
- "CTW visible",
- "Show click-type window",
+ "Click-type window visibility",
+ "Click-type window visibility",
TRUE, 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_param_spec_enum ("ctw-style",
+ "Click-type window style",
+ "Button style of the click-type window",
+ MT_TYPE_CLICK_TYPE_WINDOW_STYLE,
+ MT_CLICK_TYPE_WINDOW_STYLE_BOTH,
+ PFLAGS));
+ g_object_class_install_property (object_class,
+ PROP_CTW_ORIENTATION,
+ g_param_spec_enum ("ctw-orientation",
+ "Click-type window orientation",
+ "Orientation of the click-type window",
+ MT_TYPE_CLICK_TYPE_WINDOW_ORIENTATION,
+ MT_CLICK_TYPE_WINDOW_ORIENTATION_HORIZONTAL,
+ PFLAGS));
}
MtSettings *
diff --git a/src/mt-settings.h b/src/mt-settings.h
index e416996..38c3d2b 100644
--- a/src/mt-settings.h
+++ b/src/mt-settings.h
@@ -35,21 +35,24 @@ typedef struct _MtSettings MtSettings;
struct _MtSettings
{
- GObject parent;
-
- GSettings *mt_settings;
- GSettings *a11y_settings;
-
- GDesktopMouseDwellMode dwell_mode;
- GDesktopMouseDwellDirection dwell_gesture_single;
- GDesktopMouseDwellDirection dwell_gesture_double;
- GDesktopMouseDwellDirection dwell_gesture_drag;
- GDesktopMouseDwellDirection dwell_gesture_secondary;
- gint dwell_threshold;
- gint ctw_style;
- guint dwell_enabled : 1;
- guint ssc_enabled : 1;
- guint ctw_visible : 1;
+ GObject parent;
+
+ GSettings *mt_settings;
+ GSettings *a11y_settings;
+
+ gint dwell_threshold;
+ GDesktopMouseDwellMode dwell_mode;
+ GDesktopMouseDwellDirection dwell_gesture_single;
+ GDesktopMouseDwellDirection dwell_gesture_double;
+ GDesktopMouseDwellDirection dwell_gesture_drag;
+ GDesktopMouseDwellDirection dwell_gesture_secondary;
+
+ MtClickTypeWindowStyle ctw_style;
+ MtClickTypeWindowOrientation ctw_orientation;
+
+ guint dwell_enabled : 1;
+ guint ssc_enabled : 1;
+ guint ctw_visible : 1;
};
GType mt_settings_get_type (void) G_GNUC_CONST;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]