[uim-commit] r1868 - trunk/scm

ekato at freedesktop.org ekato at freedesktop.org
Sat Oct 22 07:40:38 PDT 2005


Author: ekato
Date: 2005-10-22 07:40:14 -0700 (Sat, 22 Oct 2005)
New Revision: 1868

Modified:
   trunk/scm/im-custom.scm
   trunk/scm/im.scm
Log:
* scm/im.scm : Add input method toggle functionality.
(toggle-im-preserved-im) : New variable.
(toggle-im-preserved-widget-states) : Ditto.
(toggle-im-alt-preserved-widget-states) : Ditto.
(toggle-im) : New function.  Toggle two input methods with
  preserving their widget states.
(key-press-handler) : Check toggle-im-key?.
* scm/im-custom.scm : Add new custom settings for im-toggle.
(enable-im-toggle?) : New setting.  It is enabled by default.
(toggle-im-key) : New key setting for im-toggle, dependent on
  enable-im-toggle? activity.
(toggle-im-alt-im) : Alternative IM for im-toggle, dependent on
  enable-im-toggle? activity.


Modified: trunk/scm/im-custom.scm
===================================================================
--- trunk/scm/im-custom.scm	2005-10-22 14:30:44 UTC (rev 1867)
+++ trunk/scm/im-custom.scm	2005-10-22 14:40:14 UTC (rev 1868)
@@ -280,6 +280,43 @@
 
 (define-key switch-im-key? '())
 
+;; im-toggle 
+(define-custom-group 'im-toggle
+		     (_ "Input method toggle")
+		     (_ "long description will be here."))
+
+(define-custom 'enable-im-toggle? #t
+  '(global im-toggle)
+  '(boolean)
+  (_ "Enable Input method toggle by hot keys")
+  (_ "long description will be here."))
+
+(define-custom 'toggle-im-key '("<Alt> " "<Meta> ")
+  '(global im-toggle)
+  '(key)
+  (_ "Input method toggle key")
+  (_ "long description will be here."))
+
+(define-custom 'toggle-im-alt-im 'direct
+  '(global im-toggle)
+  (cons
+   'choice
+   (custom-im-list-as-choice-rec (reverse im-list)))
+  (_ "Alternative input method")
+  (_ "long description will be here."))
+
+;; activity dependency
+(custom-add-hook 'toggle-im-key
+		 'custom-activity-hooks
+		 (lambda ()
+		   enable-im-toggle?))
+
+(custom-add-hook 'toggle-im-alt-im
+		 'custom-activity-hooks
+		 (lambda ()
+		   enable-im-toggle?))
+
+
 (define-custom 'uim-color 'uim-color-uim
   '(global visual-preference)
   (list 'choice

Modified: trunk/scm/im.scm
===================================================================
--- trunk/scm/im.scm	2005-10-22 14:30:44 UTC (rev 1867)
+++ trunk/scm/im.scm	2005-10-22 14:40:14 UTC (rev 1868)
@@ -197,6 +197,27 @@
   (lambda (id name)
     (uim-switch-im id (next-im name))))
 
+;; im-toggle
+(define toggle-im-preserved-im #f)
+(define toggle-im-preserved-widget-states '())
+(define toggle-im-alt-preserved-widget-states '())
+
+(define toggle-im
+  (lambda (id name)
+    (let ((widget-states (context-current-widget-states (find-context id))))
+      (if (eq? name toggle-im-alt-im)
+	  (begin
+	    (set! toggle-im-alt-preserved-widget-states widget-states)
+	    (uim-switch-im id toggle-im-preserved-im)
+	    (context-update-widget-states! (find-context id)
+					   toggle-im-preserved-widget-states))
+	  (begin
+	    (set! toggle-im-preserved-im name)
+	    (set! toggle-im-preserved-widget-states widget-states)
+	    (uim-switch-im id toggle-im-alt-im)
+	    (context-update-widget-states! (find-context id)
+	    			  toggle-im-alt-preserved-widget-states))))))
+
 ;;
 ;; context-management
 ;;
@@ -269,6 +290,9 @@
     (let* ((c (find-context id))
 	   (im (and c (context-im c))))
       (cond
+       ((and enable-im-toggle?
+	     (toggle-im-key? key state))
+	(toggle-im id (im-name im)))
        ((and enable-im-switch
 	     (switch-im-key? key state))
 	(switch-im id (im-name im)))



More information about the uim-commit mailing list