From 98bbb7218c22dfe89f071899532b68aeb23d2383 Mon Sep 17 00:00:00 2001 From: Philippe Brochard Date: Sun, 27 Feb 2011 22:58:01 +0100 Subject: [PATCH] src/clfswm-util.lisp (query-yes-or-no): New function. --- ChangeLog | 2 ++ src/clfswm-configuration.lisp | 19 ++++--------------- src/clfswm-layout.lisp | 9 +++------ src/clfswm-util.lisp | 8 ++++++++ 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index e504769..c6075df 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2011-02-27 Philippe Brochard + * src/clfswm-util.lisp (query-yes-or-no): New function. + * src/clfswm-configuration.lisp (reset-all-config-variables): New function and menu entry. (query-conf-value): Add the ability to leave the field blank to diff --git a/src/clfswm-configuration.lisp b/src/clfswm-configuration.lisp index aae9a54..a45702b 100644 --- a/src/clfswm-configuration.lisp +++ b/src/clfswm-configuration.lisp @@ -137,20 +137,13 @@ (labels ((warn-wrong-type (result original) (if (equal (simple-type-of result) (simple-type-of original)) result - (if (string-equal - (query-string - (format nil "~S and ~S are not of the same type (~A and ~A). Do you really want to use this value?" - result original (type-of result) (type-of original)) - "" '("yes" "no")) - "yes") + (if (query-yes-or-no "~S and ~S are not of the same type (~A and ~A). Do you really want to use this value?" + result original (type-of result) (type-of original)) result original))) (ask-set-default-value (original-val) (let ((default (extract-config-default-value var))) - (if (string-equal - (query-string (format nil "Reset ~A from ~A to ~A?" var original default) - "" '("yes" "no")) - "yes") + (if (query-yes-or-no "Reset ~A from ~A to ~A?" var original default) (get-config-value default) original-val)))) (multiple-value-bind (result return) @@ -239,11 +232,7 @@ (defun reset-all-config-variables () "Reset all configuration variables to there default values" - (when (string-equal - (query-string - "Do you really want to reset all values to there default?" - "" '("yes" "no")) - "yes") + (when (query-yes-or-no "Do you really want to reset all values to there default?") (with-all-internal-symbols (symbol :clfswm) (when (is-config-p symbol) (reset-config-to-default-value symbol)))) diff --git a/src/clfswm-layout.lisp b/src/clfswm-layout.lisp index 1a8bfe2..c72e95b 100644 --- a/src/clfswm-layout.lisp +++ b/src/clfswm-layout.lisp @@ -188,12 +188,9 @@ ;;; Tile layout (defun tile-layout-ask-keep-position () (when (frame-p *current-child*) - (let ((keep-position (query-string "Keep frame children positions?" "" '("yes" "no")))) - (if (or (string= keep-position "") - (char= (char keep-position 0) #\y) - (char= (char keep-position 0) #\Y)) - (setf (frame-data-slot *current-child* :tile-layout-keep-positiion) :yes) - (remove-frame-data-slot *current-child* :tile-layout-keep-positiion))))) + (if (query-yes-or-no "Keep frame children positions?") + (setf (frame-data-slot *current-child* :tile-layout-keep-positiion) :yes) + (remove-frame-data-slot *current-child* :tile-layout-keep-positiion)))) (defun set-layout-managed-children () diff --git a/src/clfswm-util.lisp b/src/clfswm-util.lisp index b8f518d..ec0188f 100644 --- a/src/clfswm-util.lisp +++ b/src/clfswm-util.lisp @@ -64,6 +64,14 @@ +(defun query-yes-or-no (formatter &rest args) + (let ((rep (query-string (apply #'format nil formatter args) "" '("yes" "no")))) + (or (string= rep "") + (char= (char rep 0) #\y) + (char= (char rep 0) #\Y)))) + + + (defun rename-current-child () "Rename the current child" -- 2.11.4.GIT