Hi, John Harper wrote:
On Aug 31, 2004, at 2:21 AM, Andreas Büsching wrote:I just ran into same trouble when adding some custom variables to my sawfish theme. I've attached the lisp of my theme in hope that someone can tell me what I'm doing wrong.I think the problem is that you're embedding the values of the custom variables into the theme definition (using the , operator)the way to avoid that is to embed functions into the theme definition that return the current value of the variablee.g. try replacing something like:(left-edge . ,(- gex:border-width))with: (left-edge . ,(lambda () (- gex:border-width))) hope that helps,
This definitely helped, but not to completely solve the problem. It looks like the variable gex:border-width is correctly evaluated in the frame definitions now, but not in functions like gex:draw-corner-item. It seems that the value of gex:border-width is still constant within these functions. Any idea?
Thanx for your help in advance crunchy PS: I've attached the new version of theme.jl -- Microsoft Certified Angry OS Rebooter
;; GEX sawfish theme -- ;; $Id$ ;; Copyright (C) 2004 Andreas Buesching <sawfish crunchy-home de> ;; This file is NOT part of sawfish. ;; sawfish 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. ;; sawfish 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 sawmill; see the file COPYING. If not, write to ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. (require 'sawfish.wm.util.gradient) (require 'gtkrc) (defgroup gex "GEX Theme" :group appearance) (defcustom gex:save-memory t "Use less memory when creating gradients, possibly affecting quality." :type boolean :group (appearance gex) :after-set after-setting-frame-option) (defcustom gex:active-text-color (get-color "white") "text color of the active window." :type color :group (appearance gex) :user-level novice :after-set after-setting-frame-option) (defcustom gex:inactive-text-color (get-color "white") "text color of the inactive windows." :type color :group (appearance gex) :user-level novice :after-set after-setting-frame-option) (defcustom gex:active-font (get-font "Sans 8") "text font of the active window." :type font :group (appearance gex) :user-level novice :after-set after-setting-frame-option) (defcustom gex:inactive-font (get-font "Sans 8") "text font of the inactive windows." :type font :group (appearance gex) :user-level novice :after-set after-setting-frame-option) (defcustom gex:theme 'sky "Predefined colors for the title bar gradient." :type (set sky wood moss fire) :group (appearance gex) :user-level novice :after-set (lambda () (gex:set-colors) (after-setting-frame-option))) (defcustom gex:button-theme 'simple "Predefined button sets." :type (set simple aqua) :group (appearance gex) :user-level novice :after-set (lambda () (gex:set-buttons) (after-setting-frame-option))) (defcustom gex:border-width 3 "width of window border." :type (number 3) :group (appearance gex) :user-level novice :after-set after-setting-frame-option) (defcustom gex:corner-size 20 "size of window corners." :type (number 3) :group (appearance gex) :user-level novice :after-set after-setting-frame-option) (defcustom gex:titlebar-height 16 "height of titlebar gradient." :type (number 16) :group (appearance gex) :user-level novice :after-set after-setting-frame-option) (defcustom gex:darker-border-color (get-color "darkgray") "darker border color." :type color :group (appearance gex) :user-level novice :after-set after-setting-frame-option) (defcustom gex:dark-border-color (get-color "black") "dark border color." :type color :group (appearance gex) :user-level novice :after-set after-setting-frame-option) (defcustom gex:light-border-color (get-color "white") "light border color." :type color :group (appearance gex) :user-level novice :after-set after-setting-frame-option) (defvar gex:active-from-color (get-color "#31a046295745")) (defvar gex:active-to-color (get-color "#92cabc03d934")) (defvar gex:normal-from-color (get-color "#b8feb500a8f4")) (defvar gex:normal-to-color (get-color "#d998d9fed9fe")) (defvar gex:close-buttons '()) (defvar gex:maximize-buttons '()) (defvar gex:iconify-buttons '()) (defun gex:set-colors () (cond ((eq gex:theme 'sky) (setq gex:active-from-color (get-color "#31a046295745")) (setq gex:active-to-color (get-color "#92cabc03d934")) (setq gex:normal-from-color (get-color "#b8feb500a8f4")) (setq gex:normal-to-color (get-color "#d998d9fed9fe"))) ((eq gex:theme 'wood) (setq gex:active-from-color (get-color "#93aa47")) (setq gex:active-to-color (get-color "#dde0b3")) (setq gex:normal-from-color (get-color "#b8feb500a8f4")) (setq gex:normal-to-color (get-color "#d993d9f9d997"))) ((eq gex:theme 'moss) (setq gex:active-from-color (get-color "#478740")) (setq gex:active-to-color (get-color "#92bf8b")) (setq gex:normal-from-color (get-color "#b8feb500a8f4")) (setq gex:normal-to-color (get-color "#d993d9f9d997"))) ((eq gex:theme 'fire) (setq gex:active-from-color (get-color "#ee8a07040704")) (setq gex:active-to-color (get-color "#ffffe4120000")) (setq gex:normal-from-color (get-color "#b8feb500a8f4")) (setq gex:normal-to-color (get-color "#d993d9f9d997"))) )) (defun gex:create-button-list (button-def) (let* ((dir (cdr (assoc 'directory button-def))) (normal (cdr (assoc 'normal button-def))) (focus (cdr (assoc 'focus button-def))) (highlighted (cdr (assoc 'highlighted button-def))) (clicked (cdr (assoc 'clicked button-def)))) (list (cdr (assoc 'position button-def)) (if (not (equal normal nil)) (make-image (concat dir "/" normal)) nil) (if (not (equal focus nil)) (make-image (concat dir "/" focus)) nil) (if (not (equal highlighted nil)) (make-image (concat dir "/" highlighted)) nil) (if (not (equal clicked nil)) (make-image (concat dir "/" clicked)) nil)))) (defun gex:set-buttons () (cond ((eq gex:button-theme 'simple) (setq gex:close-buttons (gex:create-button-list '((position . (-14 . 1)) (directory . "default") (normal . "button-close.png") (focus) (highlighted) (clicked . "button-close-clicked.png")))) (setq gex:maximize-buttons (gex:create-button-list '((position . (-14 . 14)) (directory . "default") (normal . "button-max.png") (focus) (highlighted) (clicked . "button-max-clicked.png")))) (setq gex:iconify-buttons (gex:create-button-list '((position . (-14 . 27)) (directory . "default") (normal . "button-min.png") (focus) (highlighted) (clicked . "button-min-clicked.png")))) ) ((eq gex:button-theme 'aqua) (setq gex:close-buttons (gex:create-button-list '((position . (-14 . 3)) (directory . "aqua") (normal . "button-close.png") (focus . "button-close-focus.png") (highlighted) (clicked . "button-close-clicked.png")))) (setq gex:maximize-buttons (gex:create-button-list '((position . (-14 . 19)) (directory . "aqua") (normal . "button-max.png") (focus . "button-max-focus.png") (highlighted) (clicked . "button-max-clicked.png")))) (setq gex:iconify-buttons (gex:create-button-list '((position . (-14 . 35)) (directory . "aqua") (normal . "button-min.png") (focus . "button-min-focus.png") (highlighted) (clicked . "button-min-clicked.png")))) ) )) ;; corner: top-left, top-right, bottom-left, bottom-right ;; side: left, right, top, bottom (defun gex:draw-corner-item (corner part) (cond ((eq corner 'top-left) (if (eq part 'left) (let ((image (make-sized-image gex:border-width 1 (nth 0 gtkrc-background))) (result (make-sized-image gex:border-width (+ gex:border-width gex:corner-size)))) (image-set image 0 0 (color-rgb gex:light-border-color)) (tile-image result image) result) (let ((image (make-sized-image 1 gex:border-width (nth 0 gtkrc-background))) (result (make-sized-image (+ gex:border-width gex:corner-size) gex:border-width))) (image-set image 0 0 (color-rgb gex:light-border-color)) (tile-image result image) result))) ((eq corner 'top-right) (if (eq part 'right) (let ((image (make-sized-image gex:border-width 1 (nth 0 gtkrc-background))) (result (make-sized-image gex:border-width (+ gex:border-width gex:corner-size)))) (image-set image (- gex:border-width 1) 0 (color-rgb gex:dark-border-color)) (image-set image (- gex:border-width 2) 0 (color-rgb gex:darker-border-color)) (tile-image result image) (image-set result (- gex:border-width 2) 0 (color-rgb gex:light-border-color)) result) (let ((image (make-sized-image 1 gex:border-width (nth 0 gtkrc-background))) (result (make-sized-image (+ gex:border-width gex:corner-size) gex:border-width))) (image-set image 0 0 (color-rgb gex:light-border-color)) (tile-image result image) result))) ((eq corner 'bottom-left) (if (eq part 'left) (let ((image (make-sized-image gex:border-width 1 (nth 0 gtkrc-background))) (result (make-sized-image gex:border-width (+ gex:border-width gex:corner-size)))) (image-set image 0 0 (color-rgb gex:light-border-color)) (tile-image result image) result) (let ((image (make-sized-image 1 gex:border-width (nth 0 gtkrc-background))) (result (make-sized-image (+ gex:border-width gex:corner-size) gex:border-width))) (image-set image 0 (- gex:border-width 1) (color-rgb gex:dark-border-color)) (image-set image 0 (- gex:border-width 2) (color-rgb gex:darker-border-color)) (tile-image result image) (image-set result 0 0 (color-rgb gex:light-border-color)) result))) ((eq corner 'bottom-right) (if (eq part 'right) (let ((image (make-sized-image gex:border-width 1 (nth 0 gtkrc-background))) (result (make-sized-image gex:border-width (+ gex:border-width gex:corner-size)))) (image-set image (- gex:border-width 1) 0 (color-rgb gex:dark-border-color)) (image-set image (- gex:border-width 2) 0 (color-rgb gex:darker-border-color)) (tile-image result image) (image-set result (- gex:border-width 2) (- (+ gex:border-width gex:corner-size) 1) (color-rgb gex:dark-border-color)) result) (let ((image (make-sized-image 1 gex:border-width (nth 0 gtkrc-background))) (result (make-sized-image (+ gex:border-width gex:corner-size) gex:border-width))) (image-set image 0 (- gex:border-width 1) (color-rgb gex:dark-border-color)) (image-set image 0 (- gex:border-width 2) (color-rgb gex:darker-border-color)) (tile-image result image) result))) )) ;; side: left, right, top, bottom (defun gex:draw-border-item (side) (cond ((eq side 'left) (let ((image (make-sized-image gex:border-width 1 (nth 0 gtkrc-background)))) (image-set image 0 0 (color-rgb gex:light-border-color)) image)) ((eq side 'right) (let ((image (make-sized-image gex:border-width 1 (nth 0 gtkrc-background)))) (image-set image (- gex:border-width 1) 0 (color-rgb gex:dark-border-color)) (image-set image (- gex:border-width 2) 0 (color-rgb gex:darker-border-color)) image)) ((eq side 'top) (let ((image (make-sized-image 1 gex:border-width (nth 0 gtkrc-background)))) (image-set image 0 0 (color-rgb gex:light-border-color)) image)) ((eq side 'bottom) (let ((image (make-sized-image 1 gex:border-width (nth 0 gtkrc-background)))) (image-set image 0 (- gex:border-width 1) (color-rgb gex:dark-border-color)) (image-set image 0 (- gex:border-width 2) (color-rgb gex:darker-border-color)) image)) )) (defun gex:title-width (w) (let((w-width (car (window-dimensions w)))) (max 0 (min (- w-width 70) (+ (text-width (window-name w) gex:active-font ) 40))))) (defun gex:window-width (w) (car (window-dimensions w))) (defun gex:close-images () (cdr gex:close-buttons)) (defun gex:close-images-top () (car (car gex:close-buttons))) (defun gex:close-images-right () (cdr (car gex:close-buttons))) (defun gex:iconify-images () (cdr gex:iconify-buttons)) (defun gex:iconify-images-top () (car (car gex:iconify-buttons))) (defun gex:iconify-images-right () (cdr (car gex:iconify-buttons))) (defun gex:maximize-images () (cdr gex:maximize-buttons)) (defun gex:maximize-images-top () (car (car gex:maximize-buttons))) (defun gex:maximize-images-right () (cdr (car gex:maximize-buttons))) (defun gex:text-colors () (list gex:inactive-text-color gex:active-text-color)) (defun gex:fonts () (list gex:inactive-font gex:active-font)) (defun gex:render-gradient (img state) (apply draw-horizontal-gradient img (if (or (eq state 'focused) (eq state 'highlighted) (eq state 'clicked)) (list gex:active-from-color gex:active-to-color) (list gex:normal-from-color gex:normal-to-color)))) (defun gex:render-gradient-little (img state) (apply draw-horizontal-gradient img (if (or (eq state 'focused) (eq state 'highlighted) (eq state 'clicked)) (list gex:active-to-color (nth 0 gtkrc-background)) (list gex:normal-to-color (nth 0 gtkrc-background))))) (defun gex:render-title-gradient (img state) (let* ((width (car (image-dimensions img))) (height (cdr (image-dimensions img))) (big-part (/ (* width 90) 100)) (big-image (make-sized-image big-part height)) (small-image (make-sized-image (- width big-part) height))) (progn (gex:render-gradient big-image state) (gex:render-gradient-little small-image state) (composite-images img big-image) (composite-images img small-image big-part 0)))) (defun gex:save-memory-p () (if gex:save-memory 2 1)) ;; Icon handling (defvar gex:default-icon (make-image "icon.png")) (defvar gex:common-parts `( ;; top-left corner top part ((background . ,(gex:draw-corner-item 'top-left 'top)) (left-edge . ,(lambda () (- gex:border-width))) (top-edge . ,(lambda () (- (+ gex:titlebar-height gex:border-width)))) (class . top-left-corner)) ;; top-left corner left part ((background . ,(gex:draw-corner-item 'top-left 'left)) (left-edge . ,(lambda () (- gex:border-width))) (top-edge . ,(lambda () (- (+ gex:titlebar-height (- gex:border-width 1))))) (class . top-left-corner)) ;; top border ((background . ,(gex:draw-border-item 'top)) (top-edge . ,(lambda () (- (+ gex:titlebar-height gex:border-width)))) (left-edge . ,(lambda () gex:corner-size)) (right-edge . ,(lambda () gex:corner-size)) (class . top-border)) ;; left border ((background . ,(gex:draw-border-item 'left)) (left-edge . ,(lambda () (- gex:border-width))) (top-edge . ,(lambda () (- gex:corner-size gex:titlebar-height))) (bottom-edge . ,(lambda () gex:corner-size)) (class . left-border)) ;; top-right corner right part ((background . ,(gex:draw-corner-item 'top-right 'right)) (right-edge . ,(lambda () (- gex:border-width))) (top-edge . ,(lambda () (- (+ gex:titlebar-height gex:border-width)))) (class . top-right-corner)) ;; top-right corner top part ((background . ,(gex:draw-corner-item 'top-right 'top)) (right-edge . ,(lambda () (- 2 gex:border-width))) (top-edge . ,(lambda () (- (+ gex:titlebar-height gex:border-width)))) (class . top-right-corner)) ;; right border ((background . ,(gex:draw-border-item 'right)) (right-edge . ,(lambda () (- gex:border-width))) (top-edge . ,(lambda () (- gex:corner-size gex:titlebar-height))) (bottom-edge . ,(lambda () gex:corner-size)) (class . right-border)) ;; bottom border ((background . ,(gex:draw-border-item 'bottom)) (left-edge . ,(lambda () gex:corner-size)) (right-edge . ,(lambda () gex:corner-size)) (bottom-edge . ,(lambda () (- gex:border-width))) (class . bottom-border)) ;; bottom-left corner left part ((background . ,(gex:draw-corner-item 'bottom-left 'left)) (left-edge . ,(lambda () (- gex:border-width))) (bottom-edge . ,(lambda () (- 1 gex:border-width))) (class . bottom-left-corner)) ;; bottom-left corner bottom part ((background . ,(gex:draw-corner-item 'bottom-left 'bottom)) (left-edge . ,(lambda () (- gex:border-width))) (bottom-edge . ,(lambda () (- gex:border-width))) (class . bottom-left-corner)) ;; bottom-right corner right part ((background . ,(gex:draw-corner-item 'bottom-right 'right)) (right-edge . ,(lambda () (- gex:border-width))) (bottom-edge . ,(lambda () (- gex:border-width))) (class . bottom-right-corner)) ;; bottom-right corner bottom part ((background . ,(gex:draw-corner-item 'bottom-right 'bottom)) (right-edge . ,(lambda () (- 2 gex:border-width))) (bottom-edge . ,(lambda () (- gex:border-width))) (class . bottom-right-corner)) )) (defvar gex:transient-frame (append gex:common-parts `( ;; top hot ((renderer . ,gex:render-title-gradient) (render-scale . ,gex:save-memory-p) (font . ,gex:fonts) (text . ,window-name) (foreground . ,gex:text-colors) (x-justify . 3) (y-justify . center) (top-edge . ,(lambda () (- gex:titlebar-height))) (left-edge . 0) (height . ,(lambda () gex:titlebar-height)) (below-client . t) (width . ,(lambda ( w ) (gex:window-width w ) ) ) (class . title)) ;; delete button ((background . ,gex:close-images) (right-edge . ,gex:close-images-right) (top-edge . ,gex:close-images-top) (class . close-button))))) (defvar gex:frame (append gex:common-parts `( ;; top hot ((renderer . ,gex:render-title-gradient) (render-scale . ,gex:save-memory-p) (font . ,gex:fonts) (foreground . ,gex:text-colors) (text . ,window-name) (x-justify . ,(lambda () (+ gex:titlebar-height 2))) (y-justify . center) (top-edge . ,(lambda () (- gex:titlebar-height))) (left-edge . 0) (height . ,(lambda () gex:titlebar-height)) (below-client . t) (width . ,(lambda (w) (gex:window-width w))) (class . title)) ;; menu button ((background . ,(lambda (w) (let ((icon (window-icon-image w))) (if icon icon gex:default-icon)))) (top-edge . ,(lambda () (- gex:titlebar-height))) (left-edge . 0) (width . ,(lambda () gex:titlebar-height)) (height . ,(lambda () gex:titlebar-height)) (class . menu-button)) ;; iconify button ((background . ,gex:iconify-images) (right-edge . ,gex:iconify-images-right) (top-edge . ,gex:iconify-images-top) (class . iconify-button)) ;; maximize button ((background . ,gex:maximize-images) (right-edge . ,gex:maximize-images-right) (top-edge . ,gex:maximize-images-top) (class . maximize-button)) ;; delete button ((background . ,gex:close-images) (right-edge . ,gex:close-images-right) (top-edge . ,gex:close-images-top) (class . close-button))))) (defvar gex:common-shaded-parts `( ;; left border ((background . ,(gex:draw-border-item 'left)) (left-edge . ,(lambda () (- gex:border-width))) (top-edge . ,(lambda () (- (+ gex:titlebar-height gex:border-width)))) (height . ,(lambda () (+ gex:titlebar-height (* 2 gex:border-width)))) (class . left-border)) ;; right border ((background . ,(gex:draw-border-item 'right)) (right-edge . ,(lambda () (- gex:border-width))) (top-edge . ,(lambda () (- (+ gex:titlebar-height gex:border-width)))) (height . ,(lambda () (+ gex:titlebar-height (* 2 gex:border-width)))) (class . right-border)) ;; top border ((background . ,(gex:draw-border-item 'top)) (top-edge . ,(lambda () (- (+ gex:titlebar-height gex:border-width)))) (left-edge . ,(lambda () (- 1 gex:border-width))) (right-edge . ,(lambda () (- 1 gex:border-width))) (class . top-border)) ;; bottom border ((background . ,(gex:draw-border-item 'bottom)) (left-edge . ,(lambda () (- 1 gex:border-width))) (right-edge . ,(lambda () (- 1 gex:border-width))) (top-edge . 0) (class . bottom-border)) )) (defvar gex:shaped-frame (append gex:common-shaded-parts `( ;; top hot ((renderer . ,gex:render-title-gradient) (render-scale . ,gex:save-memory-p) (font . ,gex:fonts) (foreground . ,gex:text-colors) (text . ,window-name) (x-justify . ,(lambda () (+ gex:titlebar-height 2))) (y-justify . center) (top-edge . (lambda () (- gex:titlebar-height))) (left-edge . 0) (height . ,(lambda () gex:titlebar-height)) (below-client . t) (width . ,(lambda (w) (gex:window-width w))) (class . title)) ;; menu button ((background . ,(lambda (w) (let ((icon (window-icon-image w))) (if icon icon gex:default-icon)))) (top-edge . ,(lambda () (- gex:titlebar-height))) (left-edge . 0) (width . ,(lambda () gex:titlebar-height)) (height . ,(lambda () gex:titlebar-height)) (class . menu-button)) ;; iconify button ((background . ,gex:iconify-images) (right-edge . ,gex:iconify-images-right) (top-edge . ,gex:iconify-images-top) (class . iconify-button)) ;; maximize button ((background . ,gex:maximize-images) (right-edge . ,gex:maximize-images-right) (top-edge . ,gex:maximize-images-top) (class . maximize-button)) ;; delete button ((background . ,gex:close-images) (right-edge . ,gex:close-images-right) (top-edge . ,gex:close-images-top) (class . close-button))))) (defvar gex:shaped-transient-frame (append gex:common-shaded-parts `( ;; top hot ((renderer . ,gex:render-title-gradient) (render-scale . ,gex:save-memory-p) (font . ,gex:fonts) (text . ,window-name) (foreground . ,gex:text-colors) (x-justify . 3) (y-justify . center) (top-edge . ,(lambda () (- gex:titlebar-height))) (left-edge . 0) (height . ,(lambda () gex:titlebar-height)) (below-client . t) (width . ,(lambda (w) (gex:window-width w))) (class . title)) ;; iconify button ((background . ,gex:close-images) (right-edge . ,gex:close-images-right) (top-edge . ,gex:close-images-top) (class . close-button))))) ;; (defun gex:rebuild-theme () ;; (reframe-windows-with-style 'GEX)) (gex:set-colors) (gex:set-buttons) (add-frame-style 'GEX (lambda (w type) (case type ((default) gex:frame) ((transient) gex:transient-frame) ((shaped) gex:shaped-frame) ((shaped-transient) gex:shaped-transient-frame))))
Attachment:
signature.asc
Description: OpenPGP digital signature