[Xfce4-commits] r27063 - in xfce-mcs-plugins/branches/xfce-plugins-stephan: . dialogs/accessibility-settings dialogs/keyboard-settings dialogs/mouse-settings xfce-xkbd

Stephan Arts stephan at xfce.org
Sun Jun 15 09:59:06 CEST 2008


Author: stephan
Date: 2008-06-15 07:59:05 +0000 (Sun, 15 Jun 2008)
New Revision: 27063

Added:
   xfce-mcs-plugins/branches/xfce-plugins-stephan/xfce-xkbd/
   xfce-mcs-plugins/branches/xfce-plugins-stephan/xfce-xkbd/Makefile.am
   xfce-mcs-plugins/branches/xfce-plugins-stephan/xfce-xkbd/accessx.c
   xfce-mcs-plugins/branches/xfce-plugins-stephan/xfce-xkbd/accessx.h
   xfce-mcs-plugins/branches/xfce-plugins-stephan/xfce-xkbd/main.c
Modified:
   xfce-mcs-plugins/branches/xfce-plugins-stephan/Makefile.am
   xfce-mcs-plugins/branches/xfce-plugins-stephan/configure.ac.in
   xfce-mcs-plugins/branches/xfce-plugins-stephan/dialogs/accessibility-settings/accessibility-dialog.glade
   xfce-mcs-plugins/branches/xfce-plugins-stephan/dialogs/accessibility-settings/main.c
   xfce-mcs-plugins/branches/xfce-plugins-stephan/dialogs/accessibility-settings/xfce4-accessibility-settings.desktop.in
   xfce-mcs-plugins/branches/xfce-plugins-stephan/dialogs/keyboard-settings/xfce4-keyboard-settings.desktop.in
   xfce-mcs-plugins/branches/xfce-plugins-stephan/dialogs/mouse-settings/xfce4-mouse-settings.desktop.in
Log:
Add xfce-xkbd



Modified: xfce-mcs-plugins/branches/xfce-plugins-stephan/Makefile.am
===================================================================
--- xfce-mcs-plugins/branches/xfce-plugins-stephan/Makefile.am	2008-06-14 22:51:38 UTC (rev 27062)
+++ xfce-mcs-plugins/branches/xfce-plugins-stephan/Makefile.am	2008-06-15 07:59:05 UTC (rev 27063)
@@ -1 +1 @@
-SUBDIRS = dialogs po
+SUBDIRS = dialogs xfce-xkbd po

Modified: xfce-mcs-plugins/branches/xfce-plugins-stephan/configure.ac.in
===================================================================
--- xfce-mcs-plugins/branches/xfce-plugins-stephan/configure.ac.in	2008-06-14 22:51:38 UTC (rev 27062)
+++ xfce-mcs-plugins/branches/xfce-plugins-stephan/configure.ac.in	2008-06-15 07:59:05 UTC (rev 27063)
@@ -57,9 +57,12 @@
 XDT_CHECK_PACKAGE([DBUS_GLIB], [dbus-glib-1], [0.34])
 XDT_CHECK_PACKAGE([XFCONF], [libxfconf-0], [0])
 XDT_CHECK_PACKAGE([LIBXFCEGUI4], [libxfcegui4-1.0], [4.4.0])
+XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.4.0])
 XDT_CHECK_OPTIONAL_PACKAGE([GLADE], [libglade-2.0], [2.0.0])
 
+XDT_CHECK_PACKAGE([LIBNOTIFY], [libnotify], [0.1.3])
 
+
 dnl check for debugging support
 XDT_FEATURE_DEBUG
 
@@ -71,6 +74,7 @@
 dialogs/accessibility-settings/Makefile
 dialogs/keyboard-settings/Makefile
 dialogs/mouse-settings/Makefile
+xfce-xkbd/Makefile
 ])
 
 echo "----------------------------------------"

Modified: xfce-mcs-plugins/branches/xfce-plugins-stephan/dialogs/accessibility-settings/accessibility-dialog.glade
===================================================================
--- xfce-mcs-plugins/branches/xfce-plugins-stephan/dialogs/accessibility-settings/accessibility-dialog.glade	2008-06-14 22:51:38 UTC (rev 27062)
+++ xfce-mcs-plugins/branches/xfce-plugins-stephan/dialogs/accessibility-settings/accessibility-dialog.glade	2008-06-15 07:59:05 UTC (rev 27063)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.5 on Sat Jun 14 00:43:01 2008 -->
+<!--Generated with glade3 3.4.5 on Sat Jun 14 15:10:06 2008 -->
 <glade-interface>
   <requires lib="xfce4"/>
   <widget class="GtkDialog" id="accessibility-settings-dialog">
@@ -45,7 +45,7 @@
                               <widget class="GtkVBox" id="vbox3">
                                 <property name="visible">True</property>
                                 <child>
-                                  <widget class="GtkCheckButton" id="checkbutton1">
+                                  <widget class="GtkCheckButton" id="xkb_accessx_sticky_check">
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
                                     <property name="label" translatable="yes">Enable _Sticky Keys</property>
@@ -70,7 +70,7 @@
                                             <property name="visible">True</property>
                                             <property name="spacing">5</property>
                                             <child>
-                                              <widget class="GtkRadioButton" id="radiobutton3">
+                                              <widget class="GtkRadioButton" id="xkb_accessx_sticky_latch_mode">
                                                 <property name="visible">True</property>
                                                 <property name="can_focus">True</property>
                                                 <property name="label" translatable="yes">_Latch mode</property>
@@ -85,7 +85,7 @@
                                               </packing>
                                             </child>
                                             <child>
-                                              <widget class="GtkRadioButton" id="radiobutton4">
+                                              <widget class="GtkRadioButton" id="xkb_accessx_sticky_lock_mode">
                                                 <property name="visible">True</property>
                                                 <property name="can_focus">True</property>
                                                 <property name="label" translatable="yes">L_ock Mode</property>
@@ -93,7 +93,7 @@
                                                 <property name="response_id">0</property>
                                                 <property name="active">True</property>
                                                 <property name="draw_indicator">True</property>
-                                                <property name="group">radiobutton1</property>
+                                                <property name="group">xkb_accessx_sticky_latch_mode</property>
                                               </widget>
                                               <packing>
                                                 <property name="position">1</property>
@@ -106,7 +106,7 @@
                                           </packing>
                                         </child>
                                         <child>
-                                          <widget class="GtkCheckButton" id="checkbutton7">
+                                          <widget class="GtkCheckButton" id="xkb_accessx_sticky_two_keys_disable_check">
                                             <property name="visible">True</property>
                                             <property name="can_focus">True</property>
                                             <property name="label" translatable="yes">Disable sticky keys if _two keys are pressed together</property>
@@ -160,7 +160,7 @@
                               <widget class="GtkVBox" id="vbox4">
                                 <property name="visible">True</property>
                                 <child>
-                                  <widget class="GtkCheckButton" id="checkbutton3">
+                                  <widget class="GtkCheckButton" id="xkb_accessx_slow_check">
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
                                     <property name="label" translatable="yes">Enable Slow _Keys</property>
@@ -209,7 +209,7 @@
                                               </packing>
                                             </child>
                                             <child>
-                                              <widget class="GtkHScale" id="hscale3">
+                                              <widget class="GtkHScale" id="xkb_accessx_slow_delay_scale">
                                                 <property name="visible">True</property>
                                                 <property name="can_focus">True</property>
                                                 <property name="adjustment">0 0 100 1 10 10</property>
@@ -281,7 +281,7 @@
                               <widget class="GtkVBox" id="vbox6">
                                 <property name="visible">True</property>
                                 <child>
-                                  <widget class="GtkCheckButton" id="checkbutton4">
+                                  <widget class="GtkCheckButton" id="xkb_accessx_bounce_check">
                                     <property name="visible">True</property>
                                     <property name="can_focus">True</property>
                                     <property name="label" translatable="yes">Enable _Bounce Keys</property>
@@ -307,7 +307,7 @@
                                             <property name="xalign">0</property>
                                             <property name="label" translatable="yes">D_ebounce delay:</property>
                                             <property name="use_underline">True</property>
-                                            <property name="mnemonic_widget">hscale2</property>
+                                            <property name="mnemonic_widget">xkb_accessx_debounce_delay_scale</property>
                                           </widget>
                                           <packing>
                                             <property name="expand">False</property>
@@ -330,7 +330,7 @@
                                               </packing>
                                             </child>
                                             <child>
-                                              <widget class="GtkHScale" id="hscale2">
+                                              <widget class="GtkHScale" id="xkb_accessx_debounce_delay_scale">
                                                 <property name="visible">True</property>
                                                 <property name="can_focus">True</property>
                                                 <property name="adjustment">0 0 100 1 10 10</property>

Modified: xfce-mcs-plugins/branches/xfce-plugins-stephan/dialogs/accessibility-settings/main.c
===================================================================
--- xfce-mcs-plugins/branches/xfce-plugins-stephan/dialogs/accessibility-settings/main.c	2008-06-14 22:51:38 UTC (rev 27062)
+++ xfce-mcs-plugins/branches/xfce-plugins-stephan/dialogs/accessibility-settings/main.c	2008-06-15 07:59:05 UTC (rev 27063)
@@ -54,8 +54,36 @@
 accessibility_settings_dialog_new_from_xml (GladeXML *gxml)
 {
     XfconfChannel *xsettings_channel = xfconf_channel_new("xsettings");
+    XfconfChannel *accessx_channel = xfconf_channel_new("accessx");
 
+    GtkWidget *xkb_accessx_sticky_check = glade_xml_get_widget (gxml, "xkb_accessx_sticky_check");
+    GtkWidget *xkb_accessx_sticky_latch_mode = glade_xml_get_widget (gxml, "xkb_accessx_sticky_latch_mode");
+    GtkWidget *xkb_accessx_sticky_two_keys_disable_check = glade_xml_get_widget (gxml, "xkb_accessx_sticky_two_keys_disable_check");
+    GtkWidget *xkb_accessx_slow_check = glade_xml_get_widget (gxml, "xkb_accessx_slow_check");
+    GtkWidget *xkb_accessx_slow_delay_scale = glade_xml_get_widget (gxml, "xkb_accessx_slow_delay_scale");
+    GtkWidget *xkb_accessx_bounce_check = glade_xml_get_widget (gxml, "xkb_accessx_bounce_check");
+    GtkWidget *xkb_accessx_debounce_delay_scale = glade_xml_get_widget (gxml, "xkb_accessx_debounce_delay_scale");
+
+
+    /* Bind easy properties */
+    xfconf_g_property_bind (accessx_channel, 
+                            "/AccessX/StickyKeys",
+                            G_TYPE_BOOLEAN,
+                            (GObject *)xkb_accessx_sticky_check, "active");
+    xfconf_g_property_bind (accessx_channel, 
+                            "/AccessX/StickyKeys/LatchToLock",
+                            G_TYPE_BOOLEAN,
+                            (GObject *)xkb_accessx_sticky_latch_mode, "active");
+    xfconf_g_property_bind (accessx_channel, 
+                            "/AccessX/StickyKeys/TwoKeysDisable",
+                            G_TYPE_BOOLEAN,
+                            (GObject *)xkb_accessx_sticky_two_keys_disable_check, "active");
+
+
+
     GtkWidget *dialog = glade_xml_get_widget (gxml, "accessibility-settings-dialog");
+
+
     gtk_widget_show_all(dialog);
     gtk_widget_hide(dialog);
     return dialog;

Modified: xfce-mcs-plugins/branches/xfce-plugins-stephan/dialogs/accessibility-settings/xfce4-accessibility-settings.desktop.in
===================================================================
--- xfce-mcs-plugins/branches/xfce-plugins-stephan/dialogs/accessibility-settings/xfce4-accessibility-settings.desktop.in	2008-06-14 22:51:38 UTC (rev 27062)
+++ xfce-mcs-plugins/branches/xfce-plugins-stephan/dialogs/accessibility-settings/xfce4-accessibility-settings.desktop.in	2008-06-15 07:59:05 UTC (rev 27063)
@@ -1,10 +1,10 @@
 [Desktop Entry]
 Version=1.0
-_Name=Xfce 4 Appearance Settings
-_GenericName=Appearance Settings
-_Comment= Appearance Settings (themes and fonts)
-Exec=xfce4-appearance-settings
-Icon=preferences-desktop-theme
+_Name=Xfce 4 Accessibility Settings
+_GenericName=Accessibility Settings
+_Comment=Settings to improve usability for some people
+Exec=xfce4-accessibility-settings
+Icon=preferences-desktop-accessibility
 Terminal=false
 Type=Application
 Categories=X-XFCE;Settings;DesktopSettings;

Modified: xfce-mcs-plugins/branches/xfce-plugins-stephan/dialogs/keyboard-settings/xfce4-keyboard-settings.desktop.in
===================================================================
--- xfce-mcs-plugins/branches/xfce-plugins-stephan/dialogs/keyboard-settings/xfce4-keyboard-settings.desktop.in	2008-06-14 22:51:38 UTC (rev 27062)
+++ xfce-mcs-plugins/branches/xfce-plugins-stephan/dialogs/keyboard-settings/xfce4-keyboard-settings.desktop.in	2008-06-15 07:59:05 UTC (rev 27063)
@@ -1,10 +1,10 @@
 [Desktop Entry]
 Version=1.0
-_Name=Xfce 4 Appearance Settings
-_GenericName=Appearance Settings
-_Comment= Appearance Settings (themes and fonts)
-Exec=xfce4-appearance-settings
-Icon=preferences-desktop-theme
+_Name=Xfce 4 Keyboard Settings
+_GenericName=Keyboard Settings
+_Comment= Keyboard Settings (shortcuts and behaviour)
+Exec=xfce4-keyboard-settings
+Icon=preferences-desktop-keyboard
 Terminal=false
 Type=Application
 Categories=X-XFCE;Settings;DesktopSettings;

Modified: xfce-mcs-plugins/branches/xfce-plugins-stephan/dialogs/mouse-settings/xfce4-mouse-settings.desktop.in
===================================================================
--- xfce-mcs-plugins/branches/xfce-plugins-stephan/dialogs/mouse-settings/xfce4-mouse-settings.desktop.in	2008-06-14 22:51:38 UTC (rev 27062)
+++ xfce-mcs-plugins/branches/xfce-plugins-stephan/dialogs/mouse-settings/xfce4-mouse-settings.desktop.in	2008-06-15 07:59:05 UTC (rev 27063)
@@ -1,10 +1,10 @@
 [Desktop Entry]
 Version=1.0
-_Name=Xfce 4 Appearance Settings
-_GenericName=Appearance Settings
-_Comment= Appearance Settings (themes and fonts)
-Exec=xfce4-appearance-settings
-Icon=preferences-desktop-theme
+_Name=Xfce 4 Mouse Settings
+_GenericName=Mouse Settings
+_Comment=Mouse Settings
+Exec=xfce4-mouse-settings
+Icon=preferences-desktop-peripherals
 Terminal=false
 Type=Application
 Categories=X-XFCE;Settings;DesktopSettings;

Added: xfce-mcs-plugins/branches/xfce-plugins-stephan/xfce-xkbd/Makefile.am
===================================================================
--- xfce-mcs-plugins/branches/xfce-plugins-stephan/xfce-xkbd/Makefile.am	                        (rev 0)
+++ xfce-mcs-plugins/branches/xfce-plugins-stephan/xfce-xkbd/Makefile.am	2008-06-15 07:59:05 UTC (rev 27063)
@@ -0,0 +1,27 @@
+bin_PROGRAMS = xfce-xkbd
+
+xfce_xkbd_SOURCES = \
+	main.c \
+	accessx.c accessx.h
+
+xfce_xkbd_CFLAGS = \
+	$(GTK_CFLAGS) \
+	$(GLIB_CFLAGS) \
+	$(DBUS_GLIB_CFLAGS) \
+	$(LIBNOTIFY_CFLAGS) \
+	$(XFCONF_CFLAGS) \
+	$(LIBXFCE4UTIL_CFLAGS) \
+	-DDATADIR=\"$(datadir)\" \
+	-DSRCDIR=\"$(top_srcdir)\" \
+	-DLOCALEDIR=\"$(localedir)\"
+
+xfce_xkbd_LDADD = \
+	$(GTK_LIBS) \
+	$(GLIB_LIBS) \
+	$(DBUS_GLIB_LIBS) \
+	$(LIBNOTIFY_LIBS) \
+	$(XFCONF_LIBS) \
+	$(LIBXFCE4UTIL_LIBS)
+
+INCLUDES = \
+	-I$(top_srcdir)

Added: xfce-mcs-plugins/branches/xfce-plugins-stephan/xfce-xkbd/accessx.c
===================================================================
--- xfce-mcs-plugins/branches/xfce-plugins-stephan/xfce-xkbd/accessx.c	                        (rev 0)
+++ xfce-mcs-plugins/branches/xfce-plugins-stephan/xfce-xkbd/accessx.c	2008-06-15 07:59:05 UTC (rev 27063)
@@ -0,0 +1,263 @@
+/*
+ *  Copyright (c) 2008 Stephan Arts <stephan at xfce.org>
+ *
+ *  This program 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 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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 Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ *  XKB Extension code taken from the original mcs-keyboard-plugin written
+ *  by Olivier Fourdan.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include <X11/Xlib.h>
+
+#include <X11/XKBlib.h>
+
+#ifdef HAVE_XF86MISC
+#include <X11/extensions/xf86misc.h>
+#endif
+
+#include <glib.h>
+
+#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
+
+#include <libxfce4util/libxfce4util.h>
+#include <xfconf/xfconf.h>
+#include <libnotify/notify.h>
+
+static NotifyNotification *accessx_notification = NULL;
+
+static XfconfChannel *accessx_channel;
+static gboolean xkbpresent = FALSE;
+
+static gboolean accessx_initialized = FALSE;
+
+static void
+toggle_accessx (XfconfChannel *channel);
+
+GdkFilterReturn
+accessx_event_filter (GdkXEvent *xevent,
+                      GdkEvent *g_event,
+                      gpointer data)
+{
+    XkbEvent *event = xevent;
+
+    switch(event->any.xkb_type)
+    {
+        case XkbBellNotify:
+            break;
+        case XkbControlsNotify:
+            {
+                if(event->ctrls.enabled_ctrl_changes & XkbStickyKeysMask)
+                {
+                    if(event->ctrls.enabled_ctrls & XkbStickyKeysMask)
+                    {
+                        notify_notification_update(accessx_notification,
+                                            _("Sticky keys"),
+                                            _("Sticky keys are enabled"),
+                                            "keyboard");
+                    }
+                    else
+                    {
+                        notify_notification_update(accessx_notification,
+                                            _("Sticky keys"),
+                                            _("Sticky keys are disabled"),
+                                            "keyboard");
+                    }
+
+                     notify_notification_show(accessx_notification, NULL);
+                }
+
+                if(event->ctrls.enabled_ctrl_changes & XkbSlowKeysMask)
+                {
+                    if(event->ctrls.enabled_ctrls & XkbSlowKeysMask)
+                    {
+                        notify_notification_update(accessx_notification,
+                                            _("Slow keys"),
+                                            _("Slow keys are enabled"),
+                                            "keyboard");
+                    }
+                    else
+                    {
+                        notify_notification_update(accessx_notification,
+                                            _("Slow keys"),
+                                            _("Slow keys are disabled"),
+                                            "keyboard");
+                    }
+
+                     notify_notification_show(accessx_notification, NULL);
+                }
+
+                if(event->ctrls.enabled_ctrl_changes & XkbBounceKeysMask)
+                {
+                    if(event->ctrls.enabled_ctrls & XkbBounceKeysMask)
+                    {
+                        notify_notification_update(accessx_notification,
+                                            _("Bounce keys"),
+                                            _("Bounce keys are enabled"),
+                                            "keyboard");
+                    }
+                    else
+                    {
+                        notify_notification_update(accessx_notification,
+                                            _("Bounce keys"),
+                                            _("Bounce keys are disabled"),
+                                            "keyboard");
+                    }
+
+                     notify_notification_show(accessx_notification, NULL);
+                }
+            }
+            break;
+        default:
+            break;
+    }
+    return GDK_FILTER_CONTINUE;
+}
+
+static void
+cb_accessx_channel_property_changed(XfconfChannel *channel, const gchar *name, const GValue *value, gpointer user_data)
+{
+    toggle_accessx(channel);
+}
+
+static void
+toggle_accessx (XfconfChannel *channel)
+{
+    gboolean slow_keys = xfconf_channel_get_bool (channel, "/AccessX/SlowKeys", FALSE);
+    gboolean sticky_keys = xfconf_channel_get_bool (channel, "/AccessX/StickyKeys", FALSE);
+    gboolean bounce_keys = xfconf_channel_get_bool (channel, "/AccessX/BounceKeys", FALSE);
+    gint slow_keys_delay = xfconf_channel_get_int (channel, "/AccessX/SlowKeysDelay", 100);
+    gint debounce_delay = xfconf_channel_get_int (channel, "/AccessX/DeBounceDelay", 100);
+    gboolean sticky_keys_ltl = xfconf_channel_get_bool (channel, "/AccessX/StickyKeys/LatchToLock", FALSE);
+    gboolean sticky_keys_tk = xfconf_channel_get_bool (channel, "/AccessX/StickyKeys/TwoKeysDisable", FALSE);
+
+    if (xkbpresent)
+    {
+        XkbDescPtr xkb = XkbAllocKeyboard ();
+        if (xkb)
+        {
+            gdk_error_trap_push ();
+            XkbGetControls (GDK_DISPLAY (), XkbAllControlsMask, xkb);
+
+            /* Slow keys */
+            if(slow_keys)
+            {
+                xkb->ctrls->enabled_ctrls |= XkbSlowKeysMask;
+                xkb->ctrls->slow_keys_delay = slow_keys_delay;
+            }
+            else
+                xkb->ctrls->enabled_ctrls &= ~XkbSlowKeysMask;
+
+            /* Bounce keys */
+            if(bounce_keys)
+            {
+                xkb->ctrls->enabled_ctrls |= XkbBounceKeysMask;
+                xkb->ctrls->debounce_delay = debounce_delay;
+            }
+            else
+                xkb->ctrls->enabled_ctrls &= ~XkbBounceKeysMask;
+
+            /* Sticky keys */
+            if(sticky_keys)
+                xkb->ctrls->enabled_ctrls |= XkbStickyKeysMask;
+            else
+                xkb->ctrls->enabled_ctrls &= ~XkbStickyKeysMask;
+
+            if(sticky_keys_ltl)
+                xkb->ctrls->ax_options |= XkbAX_LatchToLockMask;
+            else
+                xkb->ctrls->ax_options &= ~XkbAX_LatchToLockMask;
+
+            if(sticky_keys_tk)
+                xkb->ctrls->ax_options |= XkbAX_TwoKeysMask;
+            else
+                xkb->ctrls->ax_options &= ~XkbAX_TwoKeysMask;
+
+            /* If any option is set, enable AccessXKeys, otherwise: don't */
+            if(sticky_keys || bounce_keys || slow_keys)
+                xkb->ctrls->enabled_ctrls |= XkbAccessXKeysMask;
+            else
+                xkb->ctrls->enabled_ctrls &= ~XkbAccessXKeysMask;
+
+            XkbSetControls (GDK_DISPLAY (), XkbControlsEnabledMask | XkbStickyKeysMask | XkbBounceKeysMask | XkbSlowKeysMask, xkb);
+            XFree (xkb);
+            gdk_flush ();
+            gdk_error_trap_pop ();
+        }
+        else
+        {
+            g_warning ("XkbAllocKeyboard() returned null pointer");
+        }
+    }
+}
+
+void
+accessx_notification_init (XfconfChannel *channel)
+{
+    g_return_if_fail (accessx_initialized == FALSE);
+
+    int xkbmajor = XkbMajorVersion, xkbminor = XkbMinorVersion;
+    int xkbopcode, xkbevent, xkberror;
+    accessx_channel = channel;
+
+#ifdef DEBUG
+    g_message ("Querying Xkb extension");
+#endif
+    if (XkbQueryExtension (GDK_DISPLAY (), &xkbopcode, &xkbevent, &xkberror, &xkbmajor, &xkbminor))
+    {
+#ifdef DEBUG
+        g_message ("Xkb extension found");
+#endif
+        xkbpresent = TRUE;
+    }
+    else
+    {
+#ifdef DEBUG
+        g_message ("Your X server does not support Xkb extension");
+#endif
+        xkbpresent = FALSE;
+    }
+#ifdef DEBUG
+    g_warning ("This build doesn't include support for Xkb extension");
+#endif
+    
+    g_signal_connect(G_OBJECT(channel), "property-changed", (GCallback)cb_accessx_channel_property_changed, NULL);
+
+    accessx_notification = notify_notification_new(
+                               _("Accessibility Notification"),
+                               _("Accessibility settings changed"),
+                               "preferences-desktop-accessibility",
+                               NULL);
+
+    XkbSelectEvents(gdk_display,
+                    XkbUseCoreKbd,
+                    XkbControlsNotifyMask,
+                    XkbControlsNotifyMask);
+
+    gdk_window_add_filter(NULL, accessx_event_filter, NULL);
+
+    toggle_accessx (channel);
+
+    accessx_initialized = TRUE;
+}
+

Added: xfce-mcs-plugins/branches/xfce-plugins-stephan/xfce-xkbd/accessx.h
===================================================================
--- xfce-mcs-plugins/branches/xfce-plugins-stephan/xfce-xkbd/accessx.h	                        (rev 0)
+++ xfce-mcs-plugins/branches/xfce-plugins-stephan/xfce-xkbd/accessx.h	2008-06-15 07:59:05 UTC (rev 27063)
@@ -0,0 +1,24 @@
+/*
+ *  Copyright (c) 2008 Stephan Arts <stephan at xfce.org>
+ *
+ *  This program 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 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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 Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ *  XKB Extension code taken from the original mcs-keyboard-plugin written
+ *  by Olivier Fourdan.
+ */
+
+
+void
+accessx_notification_init (XfconfChannel *channel);

Added: xfce-mcs-plugins/branches/xfce-plugins-stephan/xfce-xkbd/main.c
===================================================================
--- xfce-mcs-plugins/branches/xfce-plugins-stephan/xfce-xkbd/main.c	                        (rev 0)
+++ xfce-mcs-plugins/branches/xfce-plugins-stephan/xfce-xkbd/main.c	2008-06-15 07:59:05 UTC (rev 27063)
@@ -0,0 +1,123 @@
+/*
+ *  Copyright (c) 2008 Stephan Arts <stephan at xfce.org>
+ *
+ *  This program 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 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program 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 Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#include <X11/Xlib.h>
+
+#include <glib.h>
+
+#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
+
+#include <libxfce4util/libxfce4util.h>
+#include <xfconf/xfconf.h>
+#include <libnotify/notify.h>
+
+
+#include "accessx.h"
+
+#define XF_DEBUG(str) \
+    if (debug) g_print (str)
+
+static gboolean version = FALSE;
+static gboolean force_replace = FALSE;
+static gboolean running = FALSE;
+static gboolean debug = FALSE;
+
+static GList *registries = NULL;
+
+static GOptionEntry entries[] =
+{
+    {    "version", 'v', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &version,
+        N_("Version information"),
+        NULL
+    },
+    {    "debug", 'd', G_OPTION_FLAG_IN_MAIN, G_OPTION_ARG_NONE, &debug,
+        N_("Start in debug mode (don't fork to the background)"),
+        NULL
+    },
+    { NULL }
+};
+
+
+int
+main(int argc, char **argv)
+{
+    GError *cli_error = NULL;
+    GdkDisplay *gdpy;
+    gint n_screens, screen;
+    gboolean keep_running = FALSE;
+    XfconfChannel *accessx_channel;
+
+    xfce_textdomain(GETTEXT_PACKAGE, LOCALEDIR, "UTF-8");
+
+    if(!gtk_init_with_args(&argc, &argv, _(""), entries, PACKAGE, &cli_error))
+    {
+        if (cli_error != NULL)
+        {
+            g_print (_("%s: %s\nTry %s --help to see a full list of available command line options.\n"), PACKAGE, cli_error->message, PACKAGE_NAME);
+            g_error_free (cli_error);
+            return 1;
+        }
+    }
+
+    if(version)
+    {
+        g_print("xfce-xkbd %s\n", PACKAGE_VERSION);
+        return 0;
+    }
+
+    if(!xfconf_init(&cli_error))
+    {
+        g_printerr("Failed to connect to Xfconf daemon: %s\n",
+                   cli_error->message);
+        return 1;
+    }
+
+    notify_init("xfce-xkbd");
+
+    accessx_channel = xfconf_channel_new("accessx");
+
+
+    accessx_notification_init(accessx_channel);
+
+    if(!debug) /* If not in debug mode, fork to background */
+    {
+        if(!fork())
+        {
+            gtk_main();
+    
+            xfconf_shutdown();
+        }
+    }
+    else
+    {
+        gtk_main();
+
+        xfconf_shutdown();
+    }
+
+    return 0;
+}



More information about the Xfce4-commits mailing list