diff options
author | Perberos <[email protected]> | 2011-12-01 23:53:21 -0300 |
---|---|---|
committer | Perberos <[email protected]> | 2011-12-01 23:53:21 -0300 |
commit | 505cabbd3036081f26586cabc64c26e7769c0ec9 (patch) | |
tree | 09e0498bf572128f5c9ab551531cb28d6d75e992 /plugins/keybindings | |
download | mate-settings-daemon-505cabbd3036081f26586cabc64c26e7769c0ec9.tar.bz2 mate-settings-daemon-505cabbd3036081f26586cabc64c26e7769c0ec9.tar.xz |
moving from https://github.com/perberos/mate-desktop-environment
Diffstat (limited to 'plugins/keybindings')
-rw-r--r-- | plugins/keybindings/Makefile.am | 51 | ||||
-rw-r--r-- | plugins/keybindings/Makefile.in | 682 | ||||
-rw-r--r-- | plugins/keybindings/gsd-keybindings-manager.c | 758 | ||||
-rw-r--r-- | plugins/keybindings/gsd-keybindings-manager.h | 61 | ||||
-rw-r--r-- | plugins/keybindings/gsd-keybindings-plugin.c | 104 | ||||
-rw-r--r-- | plugins/keybindings/gsd-keybindings-plugin.h | 63 | ||||
-rw-r--r-- | plugins/keybindings/keybindings.mate-settings-plugin.in | 8 |
7 files changed, 1727 insertions, 0 deletions
diff --git a/plugins/keybindings/Makefile.am b/plugins/keybindings/Makefile.am new file mode 100644 index 0000000..c4fe7b2 --- /dev/null +++ b/plugins/keybindings/Makefile.am @@ -0,0 +1,51 @@ +NULL = + +plugin_LTLIBRARIES = \ + libkeybindings.la \ + $(NULL) + +libkeybindings_la_SOURCES = \ + gsd-keybindings-plugin.h \ + gsd-keybindings-plugin.c \ + gsd-keybindings-manager.h \ + gsd-keybindings-manager.c \ + $(NULL) + +libkeybindings_la_CPPFLAGS = \ + -I$(top_srcdir)/mate-settings-daemon \ + -I$(top_srcdir)/plugins/common \ + -DMATE_SETTINGS_LOCALEDIR=\""$(datadir)/locale"\" \ + $(AM_CPPFLAGS) + +libkeybindings_la_CFLAGS = \ + $(SETTINGS_PLUGIN_CFLAGS) \ + $(AM_CFLAGS) + +libkeybindings_la_LDFLAGS = \ + $(GSD_PLUGIN_LDFLAGS) \ + $(NULL) + +libkeybindings_la_LIBADD = \ + $(top_builddir)/plugins/common/libcommon.la \ + $(SETTINGS_PLUGIN_LIBS) \ + $(NULL) + +plugin_in_files = \ + keybindings.mate-settings-plugin.in \ + $(NULL) + +plugin_DATA = $(plugin_in_files:.mate-settings-plugin.in=.mate-settings-plugin) + +EXTRA_DIST = \ + $(plugin_in_files) \ + $(NULL) + +CLEANFILES = \ + $(plugin_DATA) \ + $(NULL) + +DISTCLEANFILES = \ + $(plugin_DATA) \ + $(NULL) + +@GSD_INTLTOOL_PLUGIN_RULE@ diff --git a/plugins/keybindings/Makefile.in b/plugins/keybindings/Makefile.in new file mode 100644 index 0000000..698ff16 --- /dev/null +++ b/plugins/keybindings/Makefile.in @@ -0,0 +1,682 @@ +# Makefile.in generated by automake 1.11.1 from Makefile.am. +# @configure_input@ + +# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, +# 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, +# Inc. +# This Makefile.in is free software; the Free Software Foundation +# gives unlimited permission to copy and/or distribute it, +# with or without modifications, as long as this notice is preserved. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY, to the extent permitted by law; without +# even the implied warranty of MERCHANTABILITY or FITNESS FOR A +# PARTICULAR PURPOSE. + +@SET_MAKE@ + + +VPATH = @srcdir@ +pkgdatadir = $(datadir)/@PACKAGE@ +pkgincludedir = $(includedir)/@PACKAGE@ +pkglibdir = $(libdir)/@PACKAGE@ +pkglibexecdir = $(libexecdir)/@PACKAGE@ +am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd +install_sh_DATA = $(install_sh) -c -m 644 +install_sh_PROGRAM = $(install_sh) -c +install_sh_SCRIPT = $(install_sh) -c +INSTALL_HEADER = $(INSTALL_DATA) +transform = $(program_transform_name) +NORMAL_INSTALL = : +PRE_INSTALL = : +POST_INSTALL = : +NORMAL_UNINSTALL = : +PRE_UNINSTALL = : +POST_UNINSTALL = : +build_triplet = @build@ +host_triplet = @host@ +subdir = plugins/keybindings +DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 +am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ + $(top_srcdir)/configure.ac +am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ + $(ACLOCAL_M4) +mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs +CONFIG_HEADER = $(top_builddir)/config.h +CONFIG_CLEAN_FILES = +CONFIG_CLEAN_VPATH_FILES = +am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; +am__vpath_adj = case $$p in \ + $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ + *) f=$$p;; \ + esac; +am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; +am__install_max = 40 +am__nobase_strip_setup = \ + srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` +am__nobase_strip = \ + for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" +am__nobase_list = $(am__nobase_strip_setup); \ + for p in $$list; do echo "$$p $$p"; done | \ + sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ + $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ + if (++n[$$2] == $(am__install_max)) \ + { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ + END { for (dir in files) print dir, files[dir] }' +am__base_list = \ + sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ + sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' +am__installdirs = "$(DESTDIR)$(plugindir)" "$(DESTDIR)$(plugindir)" +LTLIBRARIES = $(plugin_LTLIBRARIES) +am__DEPENDENCIES_1 = +libkeybindings_la_DEPENDENCIES = \ + $(top_builddir)/plugins/common/libcommon.la \ + $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) +am__objects_1 = +am_libkeybindings_la_OBJECTS = \ + libkeybindings_la-gsd-keybindings-plugin.lo \ + libkeybindings_la-gsd-keybindings-manager.lo $(am__objects_1) +libkeybindings_la_OBJECTS = $(am_libkeybindings_la_OBJECTS) +libkeybindings_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \ + $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(libkeybindings_la_CFLAGS) $(CFLAGS) \ + $(libkeybindings_la_LDFLAGS) $(LDFLAGS) -o $@ +DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) +depcomp = $(SHELL) $(top_srcdir)/depcomp +am__depfiles_maybe = depfiles +am__mv = mv -f +COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ + $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +LTCOMPILE = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ + $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) +CCLD = $(CC) +LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \ + --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \ + $(LDFLAGS) -o $@ +SOURCES = $(libkeybindings_la_SOURCES) +DIST_SOURCES = $(libkeybindings_la_SOURCES) +DATA = $(plugin_DATA) +ETAGS = etags +CTAGS = ctags +DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) +ACLOCAL = @ACLOCAL@ +ALL_LINGUAS = @ALL_LINGUAS@ +AMTAR = @AMTAR@ +AR = @AR@ +AUTOCONF = @AUTOCONF@ +AUTOHEADER = @AUTOHEADER@ +AUTOMAKE = @AUTOMAKE@ +AWK = @AWK@ +CATALOGS = @CATALOGS@ +CATOBJEXT = @CATOBJEXT@ +CC = @CC@ +CCDEPMODE = @CCDEPMODE@ +CFLAGS = @CFLAGS@ +CPP = @CPP@ +CPPFLAGS = @CPPFLAGS@ +CXX = @CXX@ +CXXCPP = @CXXCPP@ +CXXDEPMODE = @CXXDEPMODE@ +CXXFLAGS = @CXXFLAGS@ +CYGPATH_W = @CYGPATH_W@ +DATADIRNAME = @DATADIRNAME@ +DBUS_SYS_DIR = @DBUS_SYS_DIR@ +DEBUG_CFLAGS = @DEBUG_CFLAGS@ +DEFS = @DEFS@ +DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ +DSYMUTIL = @DSYMUTIL@ +DUMPBIN = @DUMPBIN@ +ECHO_C = @ECHO_C@ +ECHO_N = @ECHO_N@ +ECHO_T = @ECHO_T@ +EGREP = @EGREP@ +EXEEXT = @EXEEXT@ +FGREP = @FGREP@ +FONTCONFIG_CFLAGS = @FONTCONFIG_CFLAGS@ +FONTCONFIG_LIBS = @FONTCONFIG_LIBS@ +GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ +GIOUNIX_CFLAGS = @GIOUNIX_CFLAGS@ +GIOUNIX_LIBS = @GIOUNIX_LIBS@ +GLIB_GENMARSHAL = @GLIB_GENMARSHAL@ +GMOFILES = @GMOFILES@ +GMSGFMT = @GMSGFMT@ +GREP = @GREP@ +GSD_INTLTOOL_PLUGIN_RULE = @GSD_INTLTOOL_PLUGIN_RULE@ +GSD_PLUGIN_LDFLAGS = @GSD_PLUGIN_LDFLAGS@ +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +INSTALL_SCRIPT = @INSTALL_SCRIPT@ +INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +INSTOBJEXT = @INSTOBJEXT@ +INTLLIBS = @INTLLIBS@ +INTLTOOL_EXTRACT = @INTLTOOL_EXTRACT@ +INTLTOOL_MERGE = @INTLTOOL_MERGE@ +INTLTOOL_PERL = @INTLTOOL_PERL@ +INTLTOOL_UPDATE = @INTLTOOL_UPDATE@ +LD = @LD@ +LDFLAGS = @LDFLAGS@ +LIBEXECDIR = @LIBEXECDIR@ +LIBMATEKBDUI_CFLAGS = @LIBMATEKBDUI_CFLAGS@ +LIBMATEKBDUI_LIBS = @LIBMATEKBDUI_LIBS@ +LIBMATENOTIFY_CFLAGS = @LIBMATENOTIFY_CFLAGS@ +LIBMATENOTIFY_LIBS = @LIBMATENOTIFY_LIBS@ +LIBOBJS = @LIBOBJS@ +LIBS = @LIBS@ +LIBTOOL = @LIBTOOL@ +LIPO = @LIPO@ +LN_S = @LN_S@ +LTLIBOBJS = @LTLIBOBJS@ +MAKEINFO = @MAKEINFO@ +MANIFEST_TOOL = @MANIFEST_TOOL@ +MATECONFTOOL = @MATECONFTOOL@ +MATECONF_SCHEMA_CONFIG_SOURCE = @MATECONF_SCHEMA_CONFIG_SOURCE@ +MATECONF_SCHEMA_FILE_DIR = @MATECONF_SCHEMA_FILE_DIR@ +MATE_KEYBINDINGS_KEYSDIR = @MATE_KEYBINDINGS_KEYSDIR@ +MKDIR_P = @MKDIR_P@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +MSGFMT = @MSGFMT@ +MSGFMT_OPTS = @MSGFMT_OPTS@ +MSGMERGE = @MSGMERGE@ +NM = @NM@ +NMEDIT = @NMEDIT@ +NSS_CFLAGS = @NSS_CFLAGS@ +NSS_DATABASE = @NSS_DATABASE@ +NSS_LIBS = @NSS_LIBS@ +OBJDUMP = @OBJDUMP@ +OBJEXT = @OBJEXT@ +OTOOL = @OTOOL@ +OTOOL64 = @OTOOL64@ +PACKAGE = @PACKAGE@ +PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ +PACKAGE_NAME = @PACKAGE_NAME@ +PACKAGE_STRING = @PACKAGE_STRING@ +PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ +PACKAGE_VERSION = @PACKAGE_VERSION@ +PATH_SEPARATOR = @PATH_SEPARATOR@ +PKG_CONFIG = @PKG_CONFIG@ +PKG_CONFIG_LIBDIR = @PKG_CONFIG_LIBDIR@ +PKG_CONFIG_PATH = @PKG_CONFIG_PATH@ +POFILES = @POFILES@ +POLKIT_CFLAGS = @POLKIT_CFLAGS@ +POLKIT_LIBS = @POLKIT_LIBS@ +POSUB = @POSUB@ +PO_IN_DATADIR_FALSE = @PO_IN_DATADIR_FALSE@ +PO_IN_DATADIR_TRUE = @PO_IN_DATADIR_TRUE@ +PULSE_CFLAGS = @PULSE_CFLAGS@ +PULSE_LIBS = @PULSE_LIBS@ +RANLIB = @RANLIB@ +SED = @SED@ +SETTINGS_DAEMON_CFLAGS = @SETTINGS_DAEMON_CFLAGS@ +SETTINGS_DAEMON_LIBS = @SETTINGS_DAEMON_LIBS@ +SETTINGS_PLUGIN_CFLAGS = @SETTINGS_PLUGIN_CFLAGS@ +SETTINGS_PLUGIN_LIBS = @SETTINGS_PLUGIN_LIBS@ +SET_MAKE = @SET_MAKE@ +SHELL = @SHELL@ +STRIP = @STRIP@ +USE_NLS = @USE_NLS@ +VERSION = @VERSION@ +WARN_CFLAGS = @WARN_CFLAGS@ +X11_LIBS = @X11_LIBS@ +XF86MISC_LIBS = @XF86MISC_LIBS@ +XGETTEXT = @XGETTEXT@ +XINPUT_LIBS = @XINPUT_LIBS@ +XMKMF = @XMKMF@ +X_CFLAGS = @X_CFLAGS@ +X_EXTRA_LIBS = @X_EXTRA_LIBS@ +X_LIBS = @X_LIBS@ +X_PRE_LIBS = @X_PRE_LIBS@ +abs_builddir = @abs_builddir@ +abs_srcdir = @abs_srcdir@ +abs_top_builddir = @abs_top_builddir@ +abs_top_srcdir = @abs_top_srcdir@ +ac_ct_AR = @ac_ct_AR@ +ac_ct_CC = @ac_ct_CC@ +ac_ct_CXX = @ac_ct_CXX@ +ac_ct_DUMPBIN = @ac_ct_DUMPBIN@ +am__include = @am__include@ +am__leading_dot = @am__leading_dot@ +am__quote = @am__quote@ +am__tar = @am__tar@ +am__untar = @am__untar@ +bindir = @bindir@ +build = @build@ +build_alias = @build_alias@ +build_cpu = @build_cpu@ +build_os = @build_os@ +build_vendor = @build_vendor@ +builddir = @builddir@ +datadir = @datadir@ +datarootdir = @datarootdir@ +docdir = @docdir@ +dvidir = @dvidir@ +exec_prefix = @exec_prefix@ +host = @host@ +host_alias = @host_alias@ +host_cpu = @host_cpu@ +host_os = @host_os@ +host_vendor = @host_vendor@ +htmldir = @htmldir@ +includedir = @includedir@ +infodir = @infodir@ +install_sh = @install_sh@ +libdir = @libdir@ +libexecdir = @libexecdir@ +localedir = @localedir@ +localstatedir = @localstatedir@ +mandir = @mandir@ +mkdir_p = @mkdir_p@ +oldincludedir = @oldincludedir@ +pdfdir = @pdfdir@ +plugindir = @plugindir@ +prefix = @prefix@ +program_transform_name = @program_transform_name@ +psdir = @psdir@ +sbindir = @sbindir@ +sharedstatedir = @sharedstatedir@ +srcdir = @srcdir@ +sysconfdir = @sysconfdir@ +target_alias = @target_alias@ +top_build_prefix = @top_build_prefix@ +top_builddir = @top_builddir@ +top_srcdir = @top_srcdir@ +NULL = +plugin_LTLIBRARIES = \ + libkeybindings.la \ + $(NULL) + +libkeybindings_la_SOURCES = \ + gsd-keybindings-plugin.h \ + gsd-keybindings-plugin.c \ + gsd-keybindings-manager.h \ + gsd-keybindings-manager.c \ + $(NULL) + +libkeybindings_la_CPPFLAGS = \ + -I$(top_srcdir)/mate-settings-daemon \ + -I$(top_srcdir)/plugins/common \ + -DMATE_SETTINGS_LOCALEDIR=\""$(datadir)/locale"\" \ + $(AM_CPPFLAGS) + +libkeybindings_la_CFLAGS = \ + $(SETTINGS_PLUGIN_CFLAGS) \ + $(AM_CFLAGS) + +libkeybindings_la_LDFLAGS = \ + $(GSD_PLUGIN_LDFLAGS) \ + $(NULL) + +libkeybindings_la_LIBADD = \ + $(top_builddir)/plugins/common/libcommon.la \ + $(SETTINGS_PLUGIN_LIBS) \ + $(NULL) + +plugin_in_files = \ + keybindings.mate-settings-plugin.in \ + $(NULL) + +plugin_DATA = $(plugin_in_files:.mate-settings-plugin.in=.mate-settings-plugin) +EXTRA_DIST = \ + $(plugin_in_files) \ + $(NULL) + +CLEANFILES = \ + $(plugin_DATA) \ + $(NULL) + +DISTCLEANFILES = \ + $(plugin_DATA) \ + $(NULL) + +all: all-am + +.SUFFIXES: +.SUFFIXES: .c .lo .o .obj +$(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) + @for dep in $?; do \ + case '$(am__configure_deps)' in \ + *$$dep*) \ + ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ + && { if test -f $@; then exit 0; else break; fi; }; \ + exit 1;; \ + esac; \ + done; \ + echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu plugins/keybindings/Makefile'; \ + $(am__cd) $(top_srcdir) && \ + $(AUTOMAKE) --gnu plugins/keybindings/Makefile +.PRECIOUS: Makefile +Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status + @case '$?' in \ + *config.status*) \ + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ + *) \ + echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ + esac; + +$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh + +$(top_srcdir)/configure: $(am__configure_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(ACLOCAL_M4): $(am__aclocal_m4_deps) + cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh +$(am__aclocal_m4_deps): +install-pluginLTLIBRARIES: $(plugin_LTLIBRARIES) + @$(NORMAL_INSTALL) + test -z "$(plugindir)" || $(MKDIR_P) "$(DESTDIR)$(plugindir)" + @list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \ + list2=; for p in $$list; do \ + if test -f $$p; then \ + list2="$$list2 $$p"; \ + else :; fi; \ + done; \ + test -z "$$list2" || { \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(plugindir)'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(plugindir)"; \ + } + +uninstall-pluginLTLIBRARIES: + @$(NORMAL_UNINSTALL) + @list='$(plugin_LTLIBRARIES)'; test -n "$(plugindir)" || list=; \ + for p in $$list; do \ + $(am__strip_dir) \ + echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(plugindir)/$$f'"; \ + $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(plugindir)/$$f"; \ + done + +clean-pluginLTLIBRARIES: + -test -z "$(plugin_LTLIBRARIES)" || rm -f $(plugin_LTLIBRARIES) + @list='$(plugin_LTLIBRARIES)'; for p in $$list; do \ + dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \ + test "$$dir" != "$$p" || dir=.; \ + echo "rm -f \"$${dir}/so_locations\""; \ + rm -f "$${dir}/so_locations"; \ + done +libkeybindings.la: $(libkeybindings_la_OBJECTS) $(libkeybindings_la_DEPENDENCIES) + $(libkeybindings_la_LINK) -rpath $(plugindir) $(libkeybindings_la_OBJECTS) $(libkeybindings_la_LIBADD) $(LIBS) + +mostlyclean-compile: + -rm -f *.$(OBJEXT) + +distclean-compile: + -rm -f *.tab.c + +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libkeybindings_la-gsd-keybindings-manager.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libkeybindings_la-gsd-keybindings-plugin.Plo@am__quote@ + +.c.o: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c $< + +.c.obj: +@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'` + +.c.lo: +@am__fastdepCC_TRUE@ $(LTCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $< + +libkeybindings_la-gsd-keybindings-plugin.lo: gsd-keybindings-plugin.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libkeybindings_la_CPPFLAGS) $(CPPFLAGS) $(libkeybindings_la_CFLAGS) $(CFLAGS) -MT libkeybindings_la-gsd-keybindings-plugin.lo -MD -MP -MF $(DEPDIR)/libkeybindings_la-gsd-keybindings-plugin.Tpo -c -o libkeybindings_la-gsd-keybindings-plugin.lo `test -f 'gsd-keybindings-plugin.c' || echo '$(srcdir)/'`gsd-keybindings-plugin.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libkeybindings_la-gsd-keybindings-plugin.Tpo $(DEPDIR)/libkeybindings_la-gsd-keybindings-plugin.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gsd-keybindings-plugin.c' object='libkeybindings_la-gsd-keybindings-plugin.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libkeybindings_la_CPPFLAGS) $(CPPFLAGS) $(libkeybindings_la_CFLAGS) $(CFLAGS) -c -o libkeybindings_la-gsd-keybindings-plugin.lo `test -f 'gsd-keybindings-plugin.c' || echo '$(srcdir)/'`gsd-keybindings-plugin.c + +libkeybindings_la-gsd-keybindings-manager.lo: gsd-keybindings-manager.c +@am__fastdepCC_TRUE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libkeybindings_la_CPPFLAGS) $(CPPFLAGS) $(libkeybindings_la_CFLAGS) $(CFLAGS) -MT libkeybindings_la-gsd-keybindings-manager.lo -MD -MP -MF $(DEPDIR)/libkeybindings_la-gsd-keybindings-manager.Tpo -c -o libkeybindings_la-gsd-keybindings-manager.lo `test -f 'gsd-keybindings-manager.c' || echo '$(srcdir)/'`gsd-keybindings-manager.c +@am__fastdepCC_TRUE@ $(am__mv) $(DEPDIR)/libkeybindings_la-gsd-keybindings-manager.Tpo $(DEPDIR)/libkeybindings_la-gsd-keybindings-manager.Plo +@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='gsd-keybindings-manager.c' object='libkeybindings_la-gsd-keybindings-manager.lo' libtool=yes @AMDEPBACKSLASH@ +@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ +@am__fastdepCC_FALSE@ $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libkeybindings_la_CPPFLAGS) $(CPPFLAGS) $(libkeybindings_la_CFLAGS) $(CFLAGS) -c -o libkeybindings_la-gsd-keybindings-manager.lo `test -f 'gsd-keybindings-manager.c' || echo '$(srcdir)/'`gsd-keybindings-manager.c + +mostlyclean-libtool: + -rm -f *.lo + +clean-libtool: + -rm -rf .libs _libs +install-pluginDATA: $(plugin_DATA) + @$(NORMAL_INSTALL) + test -z "$(plugindir)" || $(MKDIR_P) "$(DESTDIR)$(plugindir)" + @list='$(plugin_DATA)'; test -n "$(plugindir)" || list=; \ + for p in $$list; do \ + if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ + echo "$$d$$p"; \ + done | $(am__base_list) | \ + while read files; do \ + echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(plugindir)'"; \ + $(INSTALL_DATA) $$files "$(DESTDIR)$(plugindir)" || exit $$?; \ + done + +uninstall-pluginDATA: + @$(NORMAL_UNINSTALL) + @list='$(plugin_DATA)'; test -n "$(plugindir)" || list=; \ + files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ + test -n "$$files" || exit 0; \ + echo " ( cd '$(DESTDIR)$(plugindir)' && rm -f" $$files ")"; \ + cd "$(DESTDIR)$(plugindir)" && rm -f $$files + +ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + mkid -fID $$unique +tags: TAGS + +TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + set x; \ + here=`pwd`; \ + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + shift; \ + if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ + test -n "$$unique" || unique=$$empty_fix; \ + if test $$# -gt 0; then \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + "$$@" $$unique; \ + else \ + $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ + $$unique; \ + fi; \ + fi +ctags: CTAGS +CTAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ + $(TAGS_FILES) $(LISP) + list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \ + unique=`for i in $$list; do \ + if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ + done | \ + $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ + END { if (nonempty) { for (i in files) print i; }; }'`; \ + test -z "$(CTAGS_ARGS)$$unique" \ + || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ + $$unique + +GTAGS: + here=`$(am__cd) $(top_builddir) && pwd` \ + && $(am__cd) $(top_srcdir) \ + && gtags -i $(GTAGS_ARGS) "$$here" + +distclean-tags: + -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags + +distdir: $(DISTFILES) + @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ + list='$(DISTFILES)'; \ + dist_files=`for file in $$list; do echo $$file; done | \ + sed -e "s|^$$srcdirstrip/||;t" \ + -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ + case $$dist_files in \ + */*) $(MKDIR_P) `echo "$$dist_files" | \ + sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ + sort -u` ;; \ + esac; \ + for file in $$dist_files; do \ + if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ + if test -d $$d/$$file; then \ + dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ + if test -d "$(distdir)/$$file"; then \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ + cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ + find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ + fi; \ + cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ + else \ + test -f "$(distdir)/$$file" \ + || cp -p $$d/$$file "$(distdir)/$$file" \ + || exit 1; \ + fi; \ + done +check-am: all-am +check: check-am +all-am: Makefile $(LTLIBRARIES) $(DATA) +installdirs: + for dir in "$(DESTDIR)$(plugindir)" "$(DESTDIR)$(plugindir)"; do \ + test -z "$$dir" || $(MKDIR_P) "$$dir"; \ + done +install: install-am +install-exec: install-exec-am +install-data: install-data-am +uninstall: uninstall-am + +install-am: all-am + @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am + +installcheck: installcheck-am +install-strip: + $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ + `test -z '$(STRIP)' || \ + echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install +mostlyclean-generic: + +clean-generic: + -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES) + +distclean-generic: + -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) + -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) + -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES) + +maintainer-clean-generic: + @echo "This command is intended for maintainers to use" + @echo "it deletes files that may require special tools to rebuild." +clean: clean-am + +clean-am: clean-generic clean-libtool clean-pluginLTLIBRARIES \ + mostlyclean-am + +distclean: distclean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags + +dvi: dvi-am + +dvi-am: + +html: html-am + +html-am: + +info: info-am + +info-am: + +install-data-am: install-pluginDATA install-pluginLTLIBRARIES + +install-dvi: install-dvi-am + +install-dvi-am: + +install-exec-am: + +install-html: install-html-am + +install-html-am: + +install-info: install-info-am + +install-info-am: + +install-man: + +install-pdf: install-pdf-am + +install-pdf-am: + +install-ps: install-ps-am + +install-ps-am: + +installcheck-am: + +maintainer-clean: maintainer-clean-am + -rm -rf ./$(DEPDIR) + -rm -f Makefile +maintainer-clean-am: distclean-am maintainer-clean-generic + +mostlyclean: mostlyclean-am + +mostlyclean-am: mostlyclean-compile mostlyclean-generic \ + mostlyclean-libtool + +pdf: pdf-am + +pdf-am: + +ps: ps-am + +ps-am: + +uninstall-am: uninstall-pluginDATA uninstall-pluginLTLIBRARIES + +.MAKE: install-am install-strip + +.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \ + clean-libtool clean-pluginLTLIBRARIES ctags distclean \ + distclean-compile distclean-generic distclean-libtool \ + distclean-tags distdir dvi dvi-am html html-am info info-am \ + install install-am install-data install-data-am install-dvi \ + install-dvi-am install-exec install-exec-am install-html \ + install-html-am install-info install-info-am install-man \ + install-pdf install-pdf-am install-pluginDATA \ + install-pluginLTLIBRARIES install-ps install-ps-am \ + install-strip installcheck installcheck-am installdirs \ + maintainer-clean maintainer-clean-generic mostlyclean \ + mostlyclean-compile mostlyclean-generic mostlyclean-libtool \ + pdf pdf-am ps ps-am tags uninstall uninstall-am \ + uninstall-pluginDATA uninstall-pluginLTLIBRARIES + + +@GSD_INTLTOOL_PLUGIN_RULE@ + +# Tell versions [3.59,3.63) of GNU make to not export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/plugins/keybindings/gsd-keybindings-manager.c b/plugins/keybindings/gsd-keybindings-manager.c new file mode 100644 index 0000000..74014cc --- /dev/null +++ b/plugins/keybindings/gsd-keybindings-manager.c @@ -0,0 +1,758 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- + * + * Copyright (C) 2007 William Jon McCann <[email protected]> + * + * 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 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. + * + */ + +#include "config.h" + +#include <sys/types.h> +#include <sys/wait.h> +#include <stdlib.h> +#include <stdio.h> +#include <unistd.h> +#include <string.h> +#include <errno.h> + +#include <locale.h> + +#include <glib.h> +#include <glib/gi18n.h> +#include <gdk/gdk.h> +#include <gdk/gdkx.h> +#include <gtk/gtk.h> +#include <X11/keysym.h> +#include <mateconf/mateconf-client.h> + +#include "mate-settings-profile.h" +#include "gsd-keybindings-manager.h" + +#include "gsd-keygrab.h" +#include "eggaccelerators.h" + +#define MATECONF_BINDING_DIR "/desktop/mate/keybindings" +#define ALLOWED_KEYS_KEY MATECONF_BINDING_DIR "/allowed_keys" + +#define GSD_KEYBINDINGS_MANAGER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GSD_TYPE_KEYBINDINGS_MANAGER, GsdKeybindingsManagerPrivate)) + +typedef struct { + char *binding_str; + char *action; + char *mateconf_key; + Key key; + Key previous_key; +} Binding; + +struct GsdKeybindingsManagerPrivate +{ + GSList *binding_list; + GSList *allowed_keys; + GSList *screens; + guint notify; +}; + +static void gsd_keybindings_manager_class_init (GsdKeybindingsManagerClass *klass); +static void gsd_keybindings_manager_init (GsdKeybindingsManager *keybindings_manager); +static void gsd_keybindings_manager_finalize (GObject *object); + +G_DEFINE_TYPE (GsdKeybindingsManager, gsd_keybindings_manager, G_TYPE_OBJECT) + +static gpointer manager_object = NULL; + +static GSList * +get_screens_list (void) +{ + GdkDisplay *display = gdk_display_get_default(); + int n_screens; + GSList *list = NULL; + int i; + + n_screens = gdk_display_get_n_screens (display); + + if (n_screens == 1) { + list = g_slist_append (list, gdk_screen_get_default ()); + } else { + for (i = 0; i < n_screens; i++) { + GdkScreen *screen; + + screen = gdk_display_get_screen (display, i); + if (screen != NULL) { + list = g_slist_prepend (list, screen); + } + } + list = g_slist_reverse (list); + } + + return list; +} + +static char * +entry_get_string (MateConfEntry *entry) +{ + MateConfValue *value = mateconf_entry_get_value (entry); + + if (value == NULL || value->type != MATECONF_VALUE_STRING) { + return NULL; + } + + return g_strdup (mateconf_value_get_string (value)); +} + +static gboolean +parse_binding (Binding *binding) +{ + gboolean success; + + g_return_val_if_fail (binding != NULL, FALSE); + + binding->key.keysym = 0; + binding->key.state = 0; + g_free (binding->key.keycodes); + binding->key.keycodes = NULL; + + if (binding->binding_str == NULL || + binding->binding_str[0] == '\0' || + strcmp (binding->binding_str, "Disabled") == 0) { + return FALSE; + } + + success = egg_accelerator_parse_virtual (binding->binding_str, + &binding->key.keysym, + &binding->key.keycodes, + &binding->key.state); + + if (!success) + g_warning (_("Key binding (%s) is invalid"), binding->mateconf_key); + + return success; +} + +static gint +compare_bindings (gconstpointer a, + gconstpointer b) +{ + Binding *key_a = (Binding *) a; + char *key_b = (char *) b; + + return strcmp (key_b, key_a->mateconf_key); +} + +static gboolean +bindings_get_entry (GsdKeybindingsManager *manager, + MateConfClient *client, + const char *subdir) +{ + Binding *new_binding; + GSList *tmp_elem; + GSList *list; + GSList *li; + char *mateconf_key; + char *action = NULL; + char *key = NULL; + + g_return_val_if_fail (subdir != NULL, FALSE); + + mateconf_key = g_path_get_basename (subdir); + + if (!mateconf_key) { + return FALSE; + } + + /* Get entries for this binding */ + list = mateconf_client_all_entries (client, subdir, NULL); + + for (li = list; li != NULL; li = li->next) { + MateConfEntry *entry = li->data; + char *key_name = g_path_get_basename (mateconf_entry_get_key (entry)); + + if (key_name == NULL) { + /* ignore entry */ + } else if (strcmp (key_name, "action") == 0) { + action = entry_get_string (entry); + } else if (strcmp (key_name, "binding") == 0) { + key = entry_get_string (entry); + } + + g_free (key_name); + mateconf_entry_free (entry); + } + + g_slist_free (list); + + if (!action || !key) { + g_warning (_("Key binding (%s) is incomplete"), mateconf_key); + g_free (mateconf_key); + g_free (action); + g_free (key); + return FALSE; + } + + tmp_elem = g_slist_find_custom (manager->priv->binding_list, + mateconf_key, + compare_bindings); + + if (!tmp_elem) { + new_binding = g_new0 (Binding, 1); + } else { + new_binding = (Binding *) tmp_elem->data; + g_free (new_binding->binding_str); + g_free (new_binding->action); + g_free (new_binding->mateconf_key); + + new_binding->previous_key.keysym = new_binding->key.keysym; + new_binding->previous_key.state = new_binding->key.state; + new_binding->previous_key.keycodes = new_binding->key.keycodes; + new_binding->key.keycodes = NULL; + } + + new_binding->binding_str = key; + new_binding->action = action; + new_binding->mateconf_key = mateconf_key; + + if (parse_binding (new_binding)) { + if (!tmp_elem) + manager->priv->binding_list = g_slist_prepend (manager->priv->binding_list, new_binding); + } else { + g_free (new_binding->binding_str); + g_free (new_binding->action); + g_free (new_binding->mateconf_key); + g_free (new_binding->previous_key.keycodes); + g_free (new_binding); + + if (tmp_elem) + manager->priv->binding_list = g_slist_delete_link (manager->priv->binding_list, tmp_elem); + return FALSE; + } + + return TRUE; +} + +static gboolean +same_keycode (const Key *key, const Key *other) +{ + if (key->keycodes != NULL && other->keycodes != NULL) { + guint *c; + + for (c = key->keycodes; *c; ++c) { + if (key_uses_keycode (other, *c)) + return TRUE; + } + } + return FALSE; +} + +static gboolean +same_key (const Key *key, const Key *other) +{ + if (key->state == other->state) { + if (key->keycodes != NULL && other->keycodes != NULL) { + guint *c1, *c2; + + for (c1 = key->keycodes, c2 = other->keycodes; + *c1 || *c2; ++c1, ++c2) { + if (*c1 != *c2) + return FALSE; + } + } else if (key->keycodes != NULL || other->keycodes != NULL) + return FALSE; + + + return TRUE; + } + + return FALSE; +} + +static gboolean +key_already_used (GsdKeybindingsManager *manager, + Binding *binding) +{ + GSList *li; + + for (li = manager->priv->binding_list; li != NULL; li = li->next) { + Binding *tmp_binding = (Binding*) li->data; + + if (tmp_binding != binding && + same_keycode (&tmp_binding->key, &binding->key) && + tmp_binding->key.state == binding->key.state) { + return TRUE; + } + } + + return FALSE; +} + +static void +binding_unregister_keys (GsdKeybindingsManager *manager) +{ + GSList *li; + gboolean need_flush = FALSE; + + gdk_error_trap_push (); + + for (li = manager->priv->binding_list; li != NULL; li = li->next) { + Binding *binding = (Binding *) li->data; + + if (binding->key.keycodes) { + need_flush = TRUE; + grab_key_unsafe (&binding->key, FALSE, manager->priv->screens); + } + } + + if (need_flush) + gdk_flush (); + gdk_error_trap_pop (); +} + +static void +binding_register_keys (GsdKeybindingsManager *manager) +{ + GSList *li; + gboolean need_flush = FALSE; + + gdk_error_trap_push (); + + /* Now check for changes and grab new key if not already used */ + for (li = manager->priv->binding_list; li != NULL; li = li->next) { + Binding *binding = (Binding *) li->data; + + if (manager->priv->allowed_keys != NULL && + !g_slist_find_custom (manager->priv->allowed_keys, + binding->mateconf_key, + (GCompareFunc) g_strcmp0)) { + continue; + } + + if (!same_key (&binding->previous_key, &binding->key)) { + /* Ungrab key if it changed and not clashing with previously set binding */ + if (!key_already_used (manager, binding)) { + gint i; + + need_flush = TRUE; + if (binding->previous_key.keycodes) { + grab_key_unsafe (&binding->previous_key, FALSE, manager->priv->screens); + } + grab_key_unsafe (&binding->key, TRUE, manager->priv->screens); + + binding->previous_key.keysym = binding->key.keysym; + binding->previous_key.state = binding->key.state; + g_free (binding->previous_key.keycodes); + for (i = 0; binding->key.keycodes[i]; ++i); + binding->previous_key.keycodes = g_new0 (guint, i); + for (i = 0; binding->key.keycodes[i]; ++i) + binding->previous_key.keycodes[i] = binding->key.keycodes[i]; + } else + g_warning ("Key binding (%s) is already in use", binding->binding_str); + } + } + + if (need_flush) + gdk_flush (); + if (gdk_error_trap_pop ()) + g_warning ("Grab failed for some keys, another application may already have access the them."); +} + +extern char **environ; + +static char * +screen_exec_display_string (GdkScreen *screen) +{ + GString *str; + const char *old_display; + char *p; + + g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL); + + old_display = gdk_display_get_name (gdk_screen_get_display (screen)); + + str = g_string_new ("DISPLAY="); + g_string_append (str, old_display); + + p = strrchr (str->str, '.'); + if (p && p > strchr (str->str, ':')) { + g_string_truncate (str, p - str->str); + } + + g_string_append_printf (str, ".%d", gdk_screen_get_number (screen)); + + return g_string_free (str, FALSE); +} + +/** + * get_exec_environment: + * + * Description: Modifies the current program environment to + * ensure that $DISPLAY is set such that a launched application + * inheriting this environment would appear on screen. + * + * Returns: a newly-allocated %NULL-terminated array of strings or + * %NULL on error. Use g_strfreev() to free it. + * + * mainly ripped from egg_screen_exec_display_string in + * mate-panel/egg-screen-exec.c + **/ +static char ** +get_exec_environment (XEvent *xevent) +{ + char **retval = NULL; + int i; + int display_index = -1; + GdkScreen *screen = NULL; + GdkWindow *window = gdk_xid_table_lookup (xevent->xkey.root); + + if (window) { + screen = gdk_drawable_get_screen (GDK_DRAWABLE (window)); + } + + g_return_val_if_fail (GDK_IS_SCREEN (screen), NULL); + + for (i = 0; environ [i]; i++) { + if (!strncmp (environ [i], "DISPLAY", 7)) { + display_index = i; + } + } + + if (display_index == -1) { + display_index = i++; + } + + retval = g_new (char *, i + 1); + + for (i = 0; environ [i]; i++) { + if (i == display_index) { + retval [i] = screen_exec_display_string (screen); + } else { + retval [i] = g_strdup (environ [i]); + } + } + + retval [i] = NULL; + + return retval; +} + +static GdkFilterReturn +keybindings_filter (GdkXEvent *gdk_xevent, + GdkEvent *event, + GsdKeybindingsManager *manager) +{ + XEvent *xevent = (XEvent *) gdk_xevent; + GSList *li; + + if (xevent->type != KeyPress) { + return GDK_FILTER_CONTINUE; + } + + for (li = manager->priv->binding_list; li != NULL; li = li->next) { + Binding *binding = (Binding *) li->data; + + if (match_key (&binding->key, xevent)) { + GError *error = NULL; + gboolean retval; + gchar **argv = NULL; + gchar **envp = NULL; + + g_return_val_if_fail (binding->action != NULL, GDK_FILTER_CONTINUE); + + if (!g_shell_parse_argv (binding->action, + NULL, &argv, + &error)) { + return GDK_FILTER_CONTINUE; + } + + envp = get_exec_environment (xevent); + + retval = g_spawn_async (NULL, + argv, + envp, + G_SPAWN_SEARCH_PATH, + NULL, + NULL, + NULL, + &error); + g_strfreev (argv); + g_strfreev (envp); + + if (!retval) { + GtkWidget *dialog = gtk_message_dialog_new (NULL, 0, GTK_MESSAGE_WARNING, + GTK_BUTTONS_CLOSE, + _("Error while trying to run (%s)\n"\ + "which is linked to the key (%s)"), + binding->action, + binding->binding_str); + g_signal_connect (dialog, + "response", + G_CALLBACK (gtk_widget_destroy), + NULL); + gtk_widget_show (dialog); + } + return GDK_FILTER_REMOVE; + } + } + return GDK_FILTER_CONTINUE; +} + +static void +bindings_callback (MateConfClient *client, + guint cnxn_id, + MateConfEntry *entry, + GsdKeybindingsManager *manager) +{ + char** key_elems; + char* binding_entry; + + if (strcmp (mateconf_entry_get_key (entry), ALLOWED_KEYS_KEY) == 0) { + g_slist_foreach (manager->priv->allowed_keys, (GFunc)g_free, NULL); + g_slist_free (manager->priv->allowed_keys); + manager->priv->allowed_keys = mateconf_client_get_list (client, + ALLOWED_KEYS_KEY, + MATECONF_VALUE_STRING, + NULL); + } + else { + /* ensure we get binding dir not a sub component */ + key_elems = g_strsplit (mateconf_entry_get_key (entry), "/", 15); + binding_entry = g_strdup_printf ("/%s/%s/%s/%s", + key_elems[1], + key_elems[2], + key_elems[3], + key_elems[4]); + g_strfreev (key_elems); + + bindings_get_entry (manager, client, binding_entry); + g_free (binding_entry); + } + + binding_register_keys (manager); +} + +static guint +register_config_callback (GsdKeybindingsManager *manager, + MateConfClient *client, + const char *path, + MateConfClientNotifyFunc func) +{ + mateconf_client_add_dir (client, path, MATECONF_CLIENT_PRELOAD_RECURSIVE, NULL); + return mateconf_client_notify_add (client, path, func, manager, NULL, NULL); +} + +gboolean +gsd_keybindings_manager_start (GsdKeybindingsManager *manager, + GError **error) +{ + MateConfClient *client; + GSList *list; + GSList *li; + GdkDisplay *dpy; + GdkScreen *screen; + int screen_num; + int i; + + g_debug ("Starting keybindings manager"); + mate_settings_profile_start (NULL); + + client = mateconf_client_get_default (); + + manager->priv->notify = register_config_callback (manager, + client, + MATECONF_BINDING_DIR, + (MateConfClientNotifyFunc) bindings_callback); + + manager->priv->allowed_keys = mateconf_client_get_list (client, + ALLOWED_KEYS_KEY, + MATECONF_VALUE_STRING, + NULL); + + dpy = gdk_display_get_default (); + screen_num = gdk_display_get_n_screens (dpy); + + for (i = 0; i < screen_num; i++) { + screen = gdk_display_get_screen (dpy, i); + gdk_window_add_filter (gdk_screen_get_root_window (screen), + (GdkFilterFunc) keybindings_filter, + manager); + } + + list = mateconf_client_all_dirs (client, MATECONF_BINDING_DIR, NULL); + manager->priv->screens = get_screens_list (); + + for (li = list; li != NULL; li = li->next) { + bindings_get_entry (manager, client, li->data); + g_free (li->data); + } + + g_slist_free (list); + g_object_unref (client); + + binding_register_keys (manager); + + mate_settings_profile_end (NULL); + + return TRUE; +} + +void +gsd_keybindings_manager_stop (GsdKeybindingsManager *manager) +{ + GsdKeybindingsManagerPrivate *p = manager->priv; + GSList *l; + + g_debug ("Stopping keybindings manager"); + + if (p->notify != 0) { + MateConfClient *client = mateconf_client_get_default (); + mateconf_client_remove_dir (client, MATECONF_BINDING_DIR, NULL); + mateconf_client_notify_remove (client, p->notify); + g_object_unref (client); + p->notify = 0; + } + + for (l = p->screens; l; l = l->next) { + GdkScreen *screen = l->data; + gdk_window_remove_filter (gdk_screen_get_root_window (screen), + (GdkFilterFunc) keybindings_filter, + manager); + } + + binding_unregister_keys (manager); + + g_slist_free (p->screens); + p->screens = NULL; + + for (l = p->binding_list; l; l = l->next) { + Binding *b = l->data; + g_free (b->binding_str); + g_free (b->action); + g_free (b->mateconf_key); + g_free (b->previous_key.keycodes); + g_free (b->key.keycodes); + g_free (b); + } + g_slist_free (p->binding_list); + p->binding_list = NULL; +} + +static void +gsd_keybindings_manager_set_property (GObject *object, + guint prop_id, + const GValue *value, + GParamSpec *pspec) +{ + GsdKeybindingsManager *self; + + self = GSD_KEYBINDINGS_MANAGER (object); + + switch (prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static void +gsd_keybindings_manager_get_property (GObject *object, + guint prop_id, + GValue *value, + GParamSpec *pspec) +{ + GsdKeybindingsManager *self; + + self = GSD_KEYBINDINGS_MANAGER (object); + + switch (prop_id) { + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); + break; + } +} + +static GObject * +gsd_keybindings_manager_constructor (GType type, + guint n_construct_properties, + GObjectConstructParam *construct_properties) +{ + GsdKeybindingsManager *keybindings_manager; + GsdKeybindingsManagerClass *klass; + + klass = GSD_KEYBINDINGS_MANAGER_CLASS (g_type_class_peek (GSD_TYPE_KEYBINDINGS_MANAGER)); + + keybindings_manager = GSD_KEYBINDINGS_MANAGER (G_OBJECT_CLASS (gsd_keybindings_manager_parent_class)->constructor (type, + n_construct_properties, + construct_properties)); + + return G_OBJECT (keybindings_manager); +} + +static void +gsd_keybindings_manager_dispose (GObject *object) +{ + GsdKeybindingsManager *keybindings_manager; + + keybindings_manager = GSD_KEYBINDINGS_MANAGER (object); + + G_OBJECT_CLASS (gsd_keybindings_manager_parent_class)->dispose (object); +} + +static void +gsd_keybindings_manager_class_init (GsdKeybindingsManagerClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + + object_class->get_property = gsd_keybindings_manager_get_property; + object_class->set_property = gsd_keybindings_manager_set_property; + object_class->constructor = gsd_keybindings_manager_constructor; + object_class->dispose = gsd_keybindings_manager_dispose; + object_class->finalize = gsd_keybindings_manager_finalize; + + g_type_class_add_private (klass, sizeof (GsdKeybindingsManagerPrivate)); +} + +static void +gsd_keybindings_manager_init (GsdKeybindingsManager *manager) +{ + manager->priv = GSD_KEYBINDINGS_MANAGER_GET_PRIVATE (manager); + +} + +static void +gsd_keybindings_manager_finalize (GObject *object) +{ + GsdKeybindingsManager *keybindings_manager; + + g_return_if_fail (object != NULL); + g_return_if_fail (GSD_IS_KEYBINDINGS_MANAGER (object)); + + keybindings_manager = GSD_KEYBINDINGS_MANAGER (object); + + g_return_if_fail (keybindings_manager->priv != NULL); + + G_OBJECT_CLASS (gsd_keybindings_manager_parent_class)->finalize (object); +} + +GsdKeybindingsManager * +gsd_keybindings_manager_new (void) +{ + if (manager_object != NULL) { + g_object_ref (manager_object); + } else { + manager_object = g_object_new (GSD_TYPE_KEYBINDINGS_MANAGER, NULL); + g_object_add_weak_pointer (manager_object, + (gpointer *) &manager_object); + } + + return GSD_KEYBINDINGS_MANAGER (manager_object); +} diff --git a/plugins/keybindings/gsd-keybindings-manager.h b/plugins/keybindings/gsd-keybindings-manager.h new file mode 100644 index 0000000..7de64d9 --- /dev/null +++ b/plugins/keybindings/gsd-keybindings-manager.h @@ -0,0 +1,61 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- + * + * Copyright (C) 2007 William Jon McCann <[email protected]> + * + * 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 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. + * + */ + +#ifndef __GSD_KEYBINDINGS_MANAGER_H +#define __GSD_KEYBINDINGS_MANAGER_H + +#include <glib-object.h> + +#ifdef __cplusplus +extern "C" { +#endif + +#define GSD_TYPE_KEYBINDINGS_MANAGER (gsd_keybindings_manager_get_type ()) +#define GSD_KEYBINDINGS_MANAGER(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSD_TYPE_KEYBINDINGS_MANAGER, GsdKeybindingsManager)) +#define GSD_KEYBINDINGS_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GSD_TYPE_KEYBINDINGS_MANAGER, GsdKeybindingsManagerClass)) +#define GSD_IS_KEYBINDINGS_MANAGER(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSD_TYPE_KEYBINDINGS_MANAGER)) +#define GSD_IS_KEYBINDINGS_MANAGER_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSD_TYPE_KEYBINDINGS_MANAGER)) +#define GSD_KEYBINDINGS_MANAGER_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSD_TYPE_KEYBINDINGS_MANAGER, GsdKeybindingsManagerClass)) + +typedef struct GsdKeybindingsManagerPrivate GsdKeybindingsManagerPrivate; + +typedef struct +{ + GObject parent; + GsdKeybindingsManagerPrivate *priv; +} GsdKeybindingsManager; + +typedef struct +{ + GObjectClass parent_class; +} GsdKeybindingsManagerClass; + +GType gsd_keybindings_manager_get_type (void); + +GsdKeybindingsManager * gsd_keybindings_manager_new (void); +gboolean gsd_keybindings_manager_start (GsdKeybindingsManager *manager, + GError **error); +void gsd_keybindings_manager_stop (GsdKeybindingsManager *manager); + +#ifdef __cplusplus +} +#endif + +#endif /* __GSD_KEYBINDINGS_MANAGER_H */ diff --git a/plugins/keybindings/gsd-keybindings-plugin.c b/plugins/keybindings/gsd-keybindings-plugin.c new file mode 100644 index 0000000..a96f420 --- /dev/null +++ b/plugins/keybindings/gsd-keybindings-plugin.c @@ -0,0 +1,104 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- + * + * Copyright (C) 2007 William Jon McCann <[email protected]> + * + * 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, 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 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. + * + */ + +#include "config.h" + +#include <glib/gi18n-lib.h> +#include <gmodule.h> + +#include "mate-settings-plugin.h" +#include "gsd-keybindings-plugin.h" +#include "gsd-keybindings-manager.h" + +struct GsdKeybindingsPluginPrivate { + GsdKeybindingsManager *manager; +}; + +#define GSD_KEYBINDINGS_PLUGIN_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), GSD_TYPE_KEYBINDINGS_PLUGIN, GsdKeybindingsPluginPrivate)) + +MATE_SETTINGS_PLUGIN_REGISTER (GsdKeybindingsPlugin, gsd_keybindings_plugin) + +static void +gsd_keybindings_plugin_init (GsdKeybindingsPlugin *plugin) +{ + plugin->priv = GSD_KEYBINDINGS_PLUGIN_GET_PRIVATE (plugin); + + g_debug ("GsdKeybindingsPlugin initializing"); + + plugin->priv->manager = gsd_keybindings_manager_new (); +} + +static void +gsd_keybindings_plugin_finalize (GObject *object) +{ + GsdKeybindingsPlugin *plugin; + + g_return_if_fail (object != NULL); + g_return_if_fail (GSD_IS_KEYBINDINGS_PLUGIN (object)); + + g_debug ("GsdKeybindingsPlugin finalizing"); + + plugin = GSD_KEYBINDINGS_PLUGIN (object); + + g_return_if_fail (plugin->priv != NULL); + + if (plugin->priv->manager != NULL) { + g_object_unref (plugin->priv->manager); + } + + G_OBJECT_CLASS (gsd_keybindings_plugin_parent_class)->finalize (object); +} + +static void +impl_activate (MateSettingsPlugin *plugin) +{ + gboolean res; + GError *error; + + g_debug ("Activating keybindings plugin"); + + error = NULL; + res = gsd_keybindings_manager_start (GSD_KEYBINDINGS_PLUGIN (plugin)->priv->manager, &error); + if (! res) { + g_warning ("Unable to start keybindings manager: %s", error->message); + g_error_free (error); + } +} + +static void +impl_deactivate (MateSettingsPlugin *plugin) +{ + g_debug ("Deactivating keybindings plugin"); + gsd_keybindings_manager_stop (GSD_KEYBINDINGS_PLUGIN (plugin)->priv->manager); +} + +static void +gsd_keybindings_plugin_class_init (GsdKeybindingsPluginClass *klass) +{ + GObjectClass *object_class = G_OBJECT_CLASS (klass); + MateSettingsPluginClass *plugin_class = MATE_SETTINGS_PLUGIN_CLASS (klass); + + object_class->finalize = gsd_keybindings_plugin_finalize; + + plugin_class->activate = impl_activate; + plugin_class->deactivate = impl_deactivate; + + g_type_class_add_private (klass, sizeof (GsdKeybindingsPluginPrivate)); +} diff --git a/plugins/keybindings/gsd-keybindings-plugin.h b/plugins/keybindings/gsd-keybindings-plugin.h new file mode 100644 index 0000000..dea237d --- /dev/null +++ b/plugins/keybindings/gsd-keybindings-plugin.h @@ -0,0 +1,63 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- + * + * Copyright (C) 2007 William Jon McCann <[email protected]> + * + * 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, 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 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. + * + */ + +#ifndef __GSD_KEYBINDINGS_PLUGIN_H__ +#define __GSD_KEYBINDINGS_PLUGIN_H__ + +#include <glib.h> +#include <glib-object.h> +#include <gmodule.h> + +#include "mate-settings-plugin.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define GSD_TYPE_KEYBINDINGS_PLUGIN (gsd_keybindings_plugin_get_type ()) +#define GSD_KEYBINDINGS_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GSD_TYPE_KEYBINDINGS_PLUGIN, GsdKeybindingsPlugin)) +#define GSD_KEYBINDINGS_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GSD_TYPE_KEYBINDINGS_PLUGIN, GsdKeybindingsPluginClass)) +#define GSD_IS_KEYBINDINGS_PLUGIN(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GSD_TYPE_KEYBINDINGS_PLUGIN)) +#define GSD_IS_KEYBINDINGS_PLUGIN_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GSD_TYPE_KEYBINDINGS_PLUGIN)) +#define GSD_KEYBINDINGS_PLUGIN_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GSD_TYPE_KEYBINDINGS_PLUGIN, GsdKeybindingsPluginClass)) + +typedef struct GsdKeybindingsPluginPrivate GsdKeybindingsPluginPrivate; + +typedef struct +{ + MateSettingsPlugin parent; + GsdKeybindingsPluginPrivate *priv; +} GsdKeybindingsPlugin; + +typedef struct +{ + MateSettingsPluginClass parent_class; +} GsdKeybindingsPluginClass; + +GType gsd_keybindings_plugin_get_type (void) G_GNUC_CONST; + +/* All the plugins must implement this function */ +G_MODULE_EXPORT GType register_mate_settings_plugin (GTypeModule *module); + +#ifdef __cplusplus +} +#endif + +#endif /* __GSD_KEYBINDINGS_PLUGIN_H__ */ diff --git a/plugins/keybindings/keybindings.mate-settings-plugin.in b/plugins/keybindings/keybindings.mate-settings-plugin.in new file mode 100644 index 0000000..f9c7208 --- /dev/null +++ b/plugins/keybindings/keybindings.mate-settings-plugin.in @@ -0,0 +1,8 @@ +[MATE Settings Plugin] +Module=keybindings +IAge=0 +_Name=Keybindings +_Description=Keybindings plugin +Authors=AUTHOR +Copyright=Copyright © 2007 AUTHOR +Website= |