[uim-commit] r404 - trunk/scm
yamaken at freedesktop.org
yamaken at freedesktop.org
Sun Jan 30 16:13:03 PST 2005
Author: yamaken
Date: 2005-01-30 16:13:01 -0800 (Sun, 30 Jan 2005)
New Revision: 404
Modified:
trunk/scm/action.scm
trunk/scm/anthy-custom.scm
trunk/scm/anthy.scm
trunk/scm/custom-rt.scm
trunk/scm/custom.scm
trunk/scm/im-custom.scm
trunk/scm/load-action.scm
Log:
* This commit makes toolbar of Anthy configurable via uim-pref
* scm/custom.scm
- (custom-choice-range-reflect-olist-val,
custom-call-all-hook-procs, custom-touch-value!, custom-type-info,
custom-set-type-info!): New procedure
- (custom-set-value!): Add lacking custom-update-hooks invocation
for the value itself rather than activity change
- (custom-reload-customs): Add invocation for custom-set-hooks
* scm/custom-rt.scm
- (custom-choice-range-reflect-olist-val): New procedure
* scm/action.scm
- (indication-rec-spec, record indication): Move to load-action.scm
* scm/load-action.scm
- (indication-rec-spec, record indication): Moved from action.scm
- (indication-alist-entry-extract-choice, action-id-list->choice,
indication-alist-indicator): New procedure
* scm/im-custom.scm
- (custom-im-list-as-choice-rec): gettextize
- (custom-group toolbar): New custom group
- (custom toolbar-show-switcher-button?, custom
toolbar-show-pref-button?): Add toolbar as subgroup
* scm/anthy.scm
- (anthy-widgets, default-widget_anthy_input_mode,
default-widget_anthy_kana_input_method, anthy-input-mode-actions,
anthy-kana-input-method-actions): Move to anthy-custom.scm as
custom variable
- (action action_anthy_hiragana, action action_anthy_katakana,
action action_anthy_hankana, action action_anthy_direct, action
action_anthy_zenkaku, action action_anthy_roma, action
action_anthy_kana, action action_anthy_azik): Add future
replacement codes as comment
* scm/anthy-custom.scm
- (anthy-input-mode-indication-alist,
anthy-kana-input-method-indication-alist): New variable
- (custom anthy-widgets, custom default-widget_anthy_input_mode,
custom anthy-input-mode-actions, custom
default-widget_anthy_kana_input_method, custom
anthy-kana-input-method-actions): New custom variable
- Add several hooks to relate the new custom variables
Modified: trunk/scm/action.scm
===================================================================
--- trunk/scm/action.scm 2005-01-30 23:22:33 UTC (rev 403)
+++ trunk/scm/action.scm 2005-01-31 00:13:01 UTC (rev 404)
@@ -68,13 +68,6 @@
(require "util.scm")
-(define indication-rec-spec
- '((id #f) ;; must be first member
- (iconic-label "")
- (label "")
- (short-desc "")))
-(define-record 'indication indication-rec-spec)
-
;;
;; action
;;
Modified: trunk/scm/anthy-custom.scm
===================================================================
--- trunk/scm/anthy-custom.scm 2005-01-30 23:22:33 UTC (rev 403)
+++ trunk/scm/anthy-custom.scm 2005-01-31 00:13:01 UTC (rev 404)
@@ -74,3 +74,179 @@
'(string ".*")
(_ "Segment separator")
(_ "long description will be here."))
+
+;;
+;; toolbar
+;;
+
+;; Can't be unified with action definitions in anthy.scm until uim
+;; 0.4.6.
+(define anthy-input-mode-indication-alist
+ (list
+ (list 'action_anthy_direct
+ 'figure_ja_direct
+ "a"
+ (N_ "Direct input")
+ (N_ "Direct input mode"))
+ (list 'action_anthy_hiragana
+ 'figure_ja_hiragana
+ "¤¢"
+ (N_ "Hiragana")
+ (N_ "Hiragana input mode"))
+ (list 'action_anthy_katakana
+ 'figure_ja_katakana
+ "¥¢"
+ (N_ "Katakana")
+ (N_ "Katakana input mode"))
+ (list 'action_anthy_hankana
+ 'figure_ja_hankana
+ "±"
+ (N_ "Halfwidth Katakana")
+ (N_ "Halfwidth Katakana input mode"))
+ (list 'action_anthy_zenkaku
+ 'figure_ja_zenkaku
+ "£Á"
+ (N_ "Fullwidth Alphanumeric")
+ (N_ "Fullwidth Alphanumeric input mode"))))
+
+(define anthy-kana-input-method-indication-alist
+ (list
+ (list 'action_anthy_roma
+ 'figure_ja_roma
+ "£Ò"
+ (N_ "Romaji")
+ (N_ "Romaji input mode"))
+ (list 'action_anthy_kana
+ 'figure_ja_kana
+ "¤«"
+ (N_ "Kana")
+ (N_ "Kana input mode"))
+ (list 'action_anthy_azik
+ 'figure_ja_azik
+ "£Á"
+ (N_ "AZIK")
+ (N_ "AZIK extended romaji input mode"))))
+
+;;; Buttons
+
+(define-custom 'anthy-widgets '(widget_anthy_input_mode
+ widget_anthy_kana_input_method)
+ '(anthy toolbar)
+ (list 'ordered-list
+ (list 'widget_anthy_input_mode
+ (_ "Input mode")
+ (_ "Input mode"))
+ (list 'widget_anthy_kana_input_method
+ (_ "Kana input method")
+ (_ "Kana input method")))
+ (_ "Enabled toolbar buttons")
+ (_ "long description will be here."))
+
+;; dynamic reconfiguration
+;; anthy-configure-widgets is not defined at this point. So wrapping
+;; into lambda.
+(custom-add-hook 'anthy-widgets
+ 'custom-set-hooks
+ (lambda ()
+ anthy-configure-widgets))
+
+
+;;; Input mode
+
+(define-custom 'default-widget_anthy_input_mode 'action_anthy_direct
+ '(anthy toolbar)
+ (cons 'choice
+ (map indication-alist-entry-extract-choice
+ anthy-input-mode-indication-alist))
+ (_ "Default input mode")
+ (_ "long description will be here."))
+
+(define-custom 'anthy-input-mode-actions
+ (map car anthy-input-mode-indication-alist)
+ '(anthy toolbar)
+ (cons 'ordered-list
+ (map indication-alist-entry-extract-choice
+ anthy-input-mode-indication-alist))
+ (_ "Input mode menu items")
+ (_ "long description will be here."))
+
+;; value dependency
+(custom-add-hook 'anthy-input-mode-actions
+ 'custom-set-hooks
+ (lambda ()
+ (custom-choice-range-reflect-olist-val
+ 'default-widget_anthy_input_mode
+ 'anthy-input-mode-actions
+ anthy-input-mode-indication-alist)))
+
+;; activity dependency
+(custom-add-hook 'default-widget_anthy_input_mode
+ 'custom-activity-hooks
+ (lambda ()
+ (memq 'widget_anthy_input_mode anthy-widgets)))
+
+(custom-add-hook 'anthy-input-mode-actions
+ 'custom-activity-hooks
+ (lambda ()
+ (memq 'widget_anthy_input_mode anthy-widgets)))
+
+;; dynamic reconfiguration
+(custom-add-hook 'default-widget_anthy_input_mode
+ 'custom-set-hooks
+ (lambda ()
+ anthy-configure-widgets))
+
+(custom-add-hook 'anthy-input-mode-actions
+ 'custom-set-hooks
+ (lambda ()
+ anthy-configure-widgets))
+
+;;; Kana input method
+
+(define-custom 'default-widget_anthy_kana_input_method 'action_anthy_roma
+ '(anthy toolbar)
+ (cons 'choice
+ (map indication-alist-entry-extract-choice
+ anthy-kana-input-method-indication-alist))
+ (_ "Default kana input method")
+ (_ "long description will be here."))
+
+(define-custom 'anthy-kana-input-method-actions
+ (map car anthy-kana-input-method-indication-alist)
+ '(anthy toolbar)
+ (cons 'ordered-list
+ (map indication-alist-entry-extract-choice
+ anthy-kana-input-method-indication-alist))
+ (_ "Kana input method menu items")
+ (_ "long description will be here."))
+
+;; value dependency
+(custom-add-hook 'anthy-kana-input-method-actions
+ 'custom-set-hooks
+ (lambda ()
+ (custom-choice-range-reflect-olist-val
+ 'default-widget_anthy_kana_input_method
+ 'anthy-kana-input-method-actions
+ anthy-kana-input-method-indication-alist)))
+
+;; activity dependency
+(custom-add-hook 'default-widget_anthy_kana_input_method
+ 'custom-activity-hooks
+ (lambda ()
+ (memq 'widget_anthy_kana_input_method anthy-widgets)))
+
+(custom-add-hook 'anthy-kana-input-method-actions
+ 'custom-activity-hooks
+ (lambda ()
+ (memq 'widget_anthy_kana_input_method anthy-widgets)))
+
+;; dynamic reconfiguration
+(custom-add-hook 'default-widget_anthy_kana_input_method
+ 'custom-set-hooks
+ (lambda ()
+ anthy-configure-widgets))
+
+(custom-add-hook 'anthy-kana-input-method-actions
+ 'custom-set-hooks
+ (lambda ()
+ anthy-configure-widgets))
Modified: trunk/scm/anthy.scm
===================================================================
--- trunk/scm/anthy.scm 2005-01-30 23:22:33 UTC (rev 403)
+++ trunk/scm/anthy.scm 2005-01-31 00:13:01 UTC (rev 404)
@@ -72,32 +72,6 @@
(define-key anthy-next-segment-key? 'generic-go-right-key?)
(define-key anthy-prev-segment-key? 'generic-go-left-key?)
-;; widgets and actions
-
-;; anthy-widgets which controls:
-;; - what widgets will be shown for user
-;; - shown in what order
-(define anthy-widgets '(widget_anthy_input_mode
- widget_anthy_kana_input_method))
-
-;; default activity for each widgets
-(define default-widget_anthy_input_mode 'action_anthy_direct)
-(define default-widget_anthy_kana_input_method 'action_anthy_roma)
-
-;; actions of widget_anthy_input_mode
-(define anthy-input-mode-actions
- '(action_anthy_direct
- action_anthy_hiragana
- action_anthy_katakana
- action_anthy_hankana
- action_anthy_zenkaku))
-
-;; actions of widget_anthy_kana_input_method
-(define anthy-kana-input-method-actions
- '(action_anthy_roma
- action_anthy_kana
- action_anthy_azik))
-
;;; implementations
(define anthy-lib-initialized? #f)
@@ -116,6 +90,8 @@
(anthy-update-preedit ac)))
(register-action 'action_anthy_hiragana
+;; (indication-alist-indicator 'action_anthy_hiragana
+;; anthy-input-mode-indication-alist)
(lambda (ac) ;; indication handler
'(figure_ja_hiragana
"¤¢"
@@ -133,6 +109,8 @@
(anthy-context-set-kana-mode! ac anthy-type-hiragana)))
(register-action 'action_anthy_katakana
+;; (indication-alist-indicator 'action_anthy_katakana
+;; anthy-input-mode-indication-alist)
(lambda (ac)
'(figure_ja_katakana
"¥¢"
@@ -153,6 +131,8 @@
(anthy-context-set-kana-mode! ac anthy-type-katakana)))
(register-action 'action_anthy_hankana
+;; (indication-alist-indicator 'action_anthy_hankana
+;; anthy-input-mode-indication-alist)
(lambda (ac)
'(figure_ja_hankana
"±"
@@ -168,6 +148,8 @@
(anthy-context-set-kana-mode! ac anthy-type-hankana)))
(register-action 'action_anthy_direct
+;; (indication-alist-indicator 'action_anthy_direct
+;; anthy-input-mode-indication-alist)
(lambda (ac)
'(figure_ja_direct
"a"
@@ -182,6 +164,8 @@
(anthy-context-set-wide-latin! ac #f)))
(register-action 'action_anthy_zenkaku
+;; (indication-alist-indicator 'action_anthy_zenkaku
+;; anthy-input-mode-indication-alist)
(lambda (ac)
'(figure_ja_zenkaku
"£Á"
@@ -196,6 +180,8 @@
(anthy-context-set-wide-latin! ac #t)))
(register-action 'action_anthy_roma
+;; (indication-alist-indicator 'action_anthy_roma
+;; anthy-kana-input-method-indication-alist)
(lambda (ac)
'(figure_ja_roma
"£Ò"
@@ -211,6 +197,8 @@
(anthy-context-set-input-rule! ac anthy-input-rule-roma)))
(register-action 'action_anthy_kana
+;; (indication-alist-indicator 'action_anthy_kana
+;; anthy-kana-input-method-indication-alist)
(lambda (ac)
'(figure_ja_kana
"¤«"
@@ -234,6 +222,8 @@
))
(register-action 'action_anthy_azik
+;; (indication-alist-indicator 'action_anthy_azik
+;; anthy-kana-input-method-indication-alist)
(lambda (ac)
'(figure_ja_azik
"£Á"
Modified: trunk/scm/custom-rt.scm
===================================================================
--- trunk/scm/custom-rt.scm 2005-01-30 23:22:33 UTC (rev 403)
+++ trunk/scm/custom-rt.scm 2005-01-31 00:13:01 UTC (rev 404)
@@ -86,6 +86,11 @@
key))
keys)))
+;; lightweight implementation
+(define custom-choice-range-reflect-olist-val
+ (lambda (dst-sym src-sym indication-alist)
+ #f))
+
;; full implementation
(define custom-rt-add-primary-groups
(lambda (gsym)
Modified: trunk/scm/custom.scm
===================================================================
--- trunk/scm/custom.scm 2005-01-30 23:22:33 UTC (rev 403)
+++ trunk/scm/custom.scm 2005-01-31 00:13:01 UTC (rev 404)
@@ -316,6 +316,14 @@
(desc (custom-choice-rec-desc srec)))
desc)))
+(define custom-choice-range-reflect-olist-val
+ (lambda (dst-sym src-sym indication-alist)
+ (custom-set-type-info!
+ dst-sym
+ (cons (custom-type dst-sym)
+ (action-id-list->choice (custom-value src-sym)
+ indication-alist)))))
+
(define-record 'custom-group-rec
'((sym #f)
(label "")
@@ -420,6 +428,13 @@
(proc))
procs))))
+;; TODO: write test
+(define custom-call-all-hook-procs
+ (lambda (hook)
+ (for-each (lambda (pair)
+ ((cdr pair)))
+ hook)))
+
(define-record 'custom-rec
'((sym #f)
(default #f)
@@ -483,6 +498,7 @@
val
(custom-default-value sym)))))
+;; TODO: rewrite test for (custom-call-hook-procs sym custom-update-hooks)
;; API
(define custom-set-value!
(lambda (sym val)
@@ -497,6 +513,7 @@
(list 'make-key-predicate (list 'quote key-val)))
toplevel-env)))
(custom-call-hook-procs sym custom-set-hooks)
+ (custom-call-hook-procs sym custom-update-hooks)
(let ((post-activities (map custom-active? custom-syms)))
(for-each (lambda (another-sym pre post)
(if (or (eq? another-sym sym)
@@ -508,6 +525,12 @@
post-activities)
#t)))))
+;; API
+(define custom-touch-value!
+ (lambda (sym)
+ (custom-set-value! sym
+ (custom-value sym))))
+
(define custom-active?
(lambda (sym)
(let* ((procs (custom-hook-procs sym custom-activity-hooks))
@@ -544,6 +567,20 @@
(typedef (custom-rec-type crec)))
(cdr typedef))))
+;; TODO: write test
+;; API for temporary solution
+(define custom-type-info
+ (lambda (sym)
+ (custom-rec-type (custom-rec sym))))
+
+;; TODO: write test
+;; API for temporary solution
+(define custom-set-type-info!
+ (lambda (sym info)
+ (custom-rec-set-type! (custom-rec sym)
+ info)
+ (custom-call-hook-procs sym custom-update-hooks)))
+
;; API
(define custom-range
(lambda (sym)
@@ -650,6 +687,7 @@
(define custom-reload-customs
(lambda ()
- (for-each load (reverse custom-required-custom-files))))
+ (for-each load (reverse custom-required-custom-files))
+ (custom-call-all-hook-procs custom-set-hooks)))
(custom-reload-customs)
Modified: trunk/scm/im-custom.scm
===================================================================
--- trunk/scm/im-custom.scm 2005-01-30 23:22:33 UTC (rev 403)
+++ trunk/scm/im-custom.scm 2005-01-31 00:13:01 UTC (rev 404)
@@ -31,12 +31,13 @@
(require "i18n.scm")
+;; ugettext should be performed higher layer
(define custom-im-list-as-choice-rec
(lambda (lst)
(map (lambda (im)
(let ((sym (im-name im))
- (name-label (im-name-label im))
- (desc (im-short-desc im)))
+ (name-label (ugettext (im-name-label im)))
+ (desc (ugettext (im-short-desc im))))
(custom-choice-rec-new sym name-label desc)))
lst)))
@@ -49,6 +50,11 @@
(_ "Advanced settings")
(_ "long description will be here."))
+;; subgroup
+(define-custom-group 'toolbar
+ (_ "Toolbar")
+ (_ "long description will be here."))
+
;;
;; default-im-name
;;
@@ -211,13 +217,13 @@
(_ "long description will be here."))
(define-custom 'toolbar-show-switcher-button? #t
- '(global)
+ '(global toolbar)
'(boolean)
(_ "Show input method switcher button on toolbar")
(_ "long description will be here."))
(define-custom 'toolbar-show-pref-button? #t
- '(global)
+ '(global toolbar)
'(boolean)
(_ "Show uim preference tool button on toolbar")
(_ "long description will be here."))
Modified: trunk/scm/load-action.scm
===================================================================
--- trunk/scm/load-action.scm 2005-01-30 23:22:33 UTC (rev 403)
+++ trunk/scm/load-action.scm 2005-01-31 00:13:01 UTC (rev 404)
@@ -29,6 +29,49 @@
;;; SUCH DAMAGE.
;;;;
+(require "util.scm")
+(require "i18n.scm")
+
+(define indication-rec-spec
+ '((id #f) ;; must be first member
+ (iconic-label "")
+ (label "")
+ (short-desc "")))
+(define-record 'indication indication-rec-spec)
+
+(define indication-alist-entry-extract-choice
+ (lambda (entry)
+ (let ((act-id (car entry))
+ (indication (cdr entry)))
+ (list act-id
+ (ugettext (indication-label indication))
+ (ugettext (indication-short-desc indication))))))
+
+(define action-id-list->choice
+ (lambda (act-ids indication-alist)
+ (map (lambda (act)
+ (indication-alist-entry-extract-choice
+ (assq act indication-alist)))
+ act-ids)))
+
+;; Unifying custom variable definitions and actions of toolbar button
+;; widgets is impossible at current libuim implementation. It requires
+;; library-wide default encoding configurability rather than per
+;; context encoding. -- YamaKen 2005-01-31
+(define indication-alist-indicator
+ (lambda (act-id alist)
+ (let* ((indication (cdr (assq act-id alist)))
+ (orig-codeset (bind-textdomain-codeset (gettext-package) #f))
+ (cur-codeset (bind-textdomain-codeset (gettext-package) "EUC-JP"))
+ (translated (list (indication-id indication)
+ (indication-iconic-label indication)
+ (ugettext (indication-label indication))
+ (ugettext (indication-short-desc indication)))))
+ (bind-textdomain-codeset (gettext-package) (or orig-codeset
+ "UTF-8"))
+ (lambda (owner)
+ translated))))
+
(if enable-action?
(require "action.scm")
(begin
More information about the Uim-commit
mailing list