home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / gwm18a.zip / data / vtwm-icon-mgr.gwm < prev    next >
Text File  |  1995-07-03  |  23KB  |  650 lines

  1. ;; vtwm-icon-mgr.gwm --- Multiple Icon Managers for VTWM Profile
  2. ;;
  3. ;; Author: Anders Holst  (aho@sans.kth.se)  
  4. ;; Copyright (C) 1995  Anders Holst
  5. ;; Version: vtwm-1.0
  6. ;; Last change: 17/6 1995
  7. ;;
  8. ;; This file is copyrighted under the same terms as the rest of GWM
  9. ;; (see the X Inc license for details). There is no warranty that it
  10. ;; works. 
  11. ;;
  12. ;; --------------------------------------------------------------------- 
  13. ;;
  14. ;; This file implements icon managers for the VTWM profile.
  15. ;;
  16. ;; This file is highly inspired by "twm-icon-mgr.gwm" by Arup Mukherjee. 
  17. ;; However it is thoroughly rewritten, to, among other things, handle 
  18. ;; multiple icon managers.
  19. ;;
  20. ;; By default the "default icon manager" handles all windows not in
  21. ;; 'icon-mgr-omit-list'. In addition, you can add icon managers with
  22. ;; '(make-icon-mgr NAME XPOS YPOS CONDITION)' which then "steals"
  23. ;; windows from the default icon manager.
  24. ;; CONDITION can be (as can the elements of 'icon-mgr-omit-list')
  25. ;; an atom representing a client class, a string representing a window
  26. ;; name regexp, a list mathced by 'match-windowspec, or an arbitrary
  27. ;; WOOL expression. 
  28. ;; NOTE: If you create multiple managers from your vtwmrc.gwm, put the
  29. ;; calls to 'make-icon-mgr' in 'to-be-done-after-setup'.
  30. ;;
  31. ;; In addition to the variables below, you might want to copy the
  32. ;; setting of 'icon-mgr-behavior' to "vtwmrc.gwm" and change it.
  33. ;;
  34. ;; To use these icon managers in other profiles than VTWM, load the
  35. ;; file "load-icon-mgr.gwm" which sets up the necessary environment.
  36. ;;
  37.  
  38. (declare-screen-dependent
  39.   icon-mgr-name
  40.   icon-mgr-xpos
  41.   icon-mgr-ypos
  42.   show-default-icon-mgr
  43.   show-icon-mgr
  44.   icon-mgr-hide-if-empty
  45.   iconify-by-unmapping
  46.   iconify-unmanaged-by-icon
  47.   iconify-by-icon-list
  48.   iconify-on-start-list
  49.   icon-mgr-omit-list
  50.   icon-mgr-sort
  51.   icon-mgr-font
  52.   icon-mgr-width
  53.   icon-mgr-foreground
  54.   icon-mgr-background
  55.   icon-mgr-title-foreground
  56.   icon-mgr-title-background
  57.   icon-mgr-no-title
  58.   icon-mgr-framed-bars
  59.   icon-mgr-fancy-colors
  60.   default-icon-mgr
  61.   icon-mgr-list
  62.   icon-mgr-window-feedback
  63.   icon-mgr-pixmap-name
  64. )
  65.  
  66. ;;
  67. ;;    USER CUSTOMIZABLE VARIABLES
  68. ;;    ---------------------------  
  69. ;;    Adjust these in your own profile
  70. ;;
  71. (for screen (list-of-screens)
  72.      (defaults-to
  73.        icon-mgr-name "Icon Manager"   ; Default name of icon manager     
  74.        icon-mgr-xpos 0                ; Default x position               
  75.        icon-mgr-ypos 0                ; Default y position               
  76.        show-default-icon-mgr t        ; Default icon manager is used     
  77.        show-icon-mgr t                ; Use icon managers                
  78.        icon-mgr-hide-if-empty t       ; Don't show empty managers        
  79.        iconify-by-unmapping t         ; Do not use icons by default      
  80.        iconify-unmanaged-by-icon t    ; Use an icon if not in any manager
  81.        iconify-by-icon-list ()        ; Always use icons for these
  82.        iconify-on-start-list () ; List of window types to iconify on start   
  83.        icon-mgr-omit-list ()    ; Window types not handled in default manager
  84.        icon-mgr-sort ()               ; Sort the entries in an icon manager
  85.        icon-mgr-font (font-make "8x13")   ; Font in icon managers
  86.        icon-mgr-width 150             ; Width of icon manager
  87.        icon-mgr-foreground black      ; Foreground of icon managers
  88.        icon-mgr-background white      ; Background of icon managers
  89.        icon-mgr-title-foreground ()
  90.        icon-mgr-title-background ()
  91.        icon-mgr-no-title ()           ; Inhibits the icon manager title
  92.        icon-mgr-framed-bars ()        ; Makes it look more like in real VTWM
  93.        icon-mgr-fancy-colors ()       ; List of (wintype fg bg) specifications
  94.        icon-mgr-window-feedback t     ; Rely on focus feedback from windows
  95.        icon-mgr-pixmap-name (if (boundp 'iconify-pixmap-name)
  96.                                 iconify-pixmap-name
  97.                               "iconify2") ; Pixmap file for iconified symbol
  98.          ; In addition, the property 'icon-mgr-special-pixmap' can be set on
  99.          ; a window to the pixmap to use in the icon manager for that window.
  100.        )
  101. )
  102.  
  103.  
  104. (for screen (list-of-screens)
  105.   (with (imcond '(not (matches-list icon-mgr-omit-list)))
  106.     (defaults-to default-icon-mgr (list () () () () imcond ()))
  107.     (defaults-to icon-mgr-list (list default-icon-mgr)))
  108. )
  109.  
  110. (if (not (boundp 'iconify-before-icon-mgr))
  111.     (: iconify-before-icon-mgr iconify-window))
  112.  
  113. ;; Redefine iconify-window
  114. ;; During the time a window is "iconified by unmapping" the "wm-state-icon"
  115. ;; is set to the real icon, and the "wm-state" to 'icon, to fool the client 
  116. ;; that the window is iconified when it is really withdrawn.
  117. (defun iconify-window ()
  118.   (if (# 'icon? window-window)
  119.       (iconify-before-icon-mgr)
  120.     (if (= window-status 'icon)
  121.         (progn
  122.           (map-window window-window)
  123.           (window-wm-state-icon 0))
  124.       (progn 
  125.         (window-wm-state-icon (window-icon))
  126.         (unmap-window window-window)
  127.         (window-wm-state-update 'icon))))
  128.   (if raise-on-iconify 
  129.       (raise-window-orig))
  130.   (icon-mgr-update)
  131.   (virtual-update))
  132.  
  133.  
  134. ;; Some useful functions for iconification
  135. (defun window-iconified ()
  136.   (= (window-wm-state) 'icon))
  137. ;;  (not (with (wob window-window) window-is-mapped)))
  138.  
  139. (defun de-iconify-window ()
  140.   (if (with (wob window-window)
  141.         (not window-is-mapped))
  142.       (with (wob (window-icon))
  143.         (iconify-window))))
  144.  
  145. (defun do-iconify-window ()
  146.   (if (not (window-iconified))
  147.       (with (wob window-window)
  148.         (iconify-window))))
  149.  
  150. (defun toggle-iconify-window ()
  151.   (if (with (wob window-window)
  152.         (not window-is-mapped))
  153.       (with (wob (window-icon))
  154.         (iconify-window))
  155.     (with (wob window-window)
  156.       (iconify-window))))
  157.  
  158.  
  159. (defun icon-mgr-focusin ()
  160.   (with (prop (# 'imgr-bar window))
  161.     (if (and (# 1 prop) (wob-is-valid (# 1 prop)))
  162.         (send-user-event 'imgr-focusin (# 1 prop)))))
  163.  
  164. (defun icon-mgr-focusout ()
  165.   (with (prop (# 'imgr-bar window))
  166.     (if (and (# 1 prop) (wob-is-valid (# 1 prop)))
  167.         (send-user-event 'imgr-focusout (# 1 prop)))))
  168.  
  169. (defun icon-mgr-update ()
  170.   (with (prop (# 'imgr-bar window-window))
  171.     (if (and (# 1 prop) (wob-is-valid (# 1 prop)))
  172.         (send-user-event 'imgr-rethink (# 1 prop)))))
  173.  
  174.  
  175. (defun icon-mgr-raise-all ()
  176.   (for ele icon-mgr-list
  177.        (if (and (# 0 ele) (wob-is-valid (# 0 ele)))
  178.            (with (wob (# 0 ele))
  179.              (if (wob-is-valid wob-parent)
  180.                  (with (wob wob-parent)
  181.                    (raise-window-orig)))))))
  182.  
  183. (defun icon-mgr-lower-all ()
  184.   (for ele icon-mgr-list
  185.        (if (and (# 0 ele) (wob-is-valid (# 0 ele)))
  186.            (with (wob (# 0 ele))
  187.              (if (wob-is-valid wob-parent)
  188.                  (with (wob wob-parent)
  189.                    (lower-window-orig)))))))
  190.  
  191. (if (not (boundp 'icon-mgr-header-behavior))
  192. (: icon-mgr-header-behavior
  193.    (state-make
  194.      (on (buttonpress 1 alone)
  195.          (icon-mgr-raise-all))
  196.      (on (buttonpress 2 alone)
  197.          (move-window))
  198.      (on (buttonpress 3 alone)
  199.          (icon-mgr-lower-all))))
  200. )
  201.  
  202. (defun imgr-header-fsm ()
  203.   (fsm-make
  204.     (state-make
  205.      icon-mgr-header-behavior
  206.      (if (boundp 'standard-title-behavior)
  207.          standard-title-behavior)
  208.      (if (boundp 'standard-behavior)
  209.          standard-behavior))))
  210.  
  211. (defunq icon-mgr-with-window body
  212.   (with (wob (# 'window wob-property))
  213.         (eval (+ '(progn)
  214.                  body))
  215.         (if autofocus
  216.             (set-focus))))
  217.  
  218. (if (not (boundp 'icon-mgr-behavior))
  219. (: icon-mgr-behavior
  220.    (state-make
  221.      (on (buttonpress 1 any)
  222.          (icon-mgr-with-window
  223.            (de-iconify-window)
  224.            (raise-window)
  225.            (if (not autofocus)
  226.                (set-focus window))))
  227.      (on (buttonpress 2 any)
  228.          (icon-mgr-with-window
  229.            (toggle-iconify-window)))
  230.      (on (buttonpress 3 any)
  231.      (icon-mgr-with-window
  232.            (de-iconify-window)
  233.            (lower-window)))
  234.      ))
  235. )
  236.  
  237. (: imgr-bar-behavior
  238.    (state-make
  239.      (on enter-window
  240.          (progn
  241.            (if autofocus
  242.                (set-focus (# 'window wob-property)))
  243.            (if (not icon-mgr-window-feedback)
  244.                (wob-borderpixel (with (wob (# 'window wob-property)
  245.                                        cols (matches-cond icon-mgr-fancy-colors))
  246.                                   (or (# 0 cols) icon-mgr-foreground))))))
  247.      (on leave-window
  248.          (progn
  249.            (if autofocus
  250.                (set-focus ()))
  251.            (if (not icon-mgr-window-feedback)
  252.                (wob-borderpixel (with (wob (# 'window wob-property)
  253.                                        cols (matches-cond icon-mgr-fancy-colors))
  254.                                   (or (# 1 cols) icon-mgr-background))))))
  255.      (on (user-event 'imgr-install-yourself)
  256.          (with (barwob wob
  257.                 menuwob wob-parent
  258.                 wob (# 'window wob-property))
  259.            (## 'imgr-bar wob (list menuwob barwob))))
  260.      (on (user-event 'imgr-focusin)
  261.          (wob-borderpixel (with (wob (# 'window wob-property)
  262.                                  cols (matches-cond icon-mgr-fancy-colors))
  263.                             (or (# 0 cols) icon-mgr-foreground))))
  264.      (on (user-event 'imgr-focusout)
  265.          (wob-borderpixel (with (wob (# 'window wob-property)
  266.                                  cols (matches-cond icon-mgr-fancy-colors))
  267.                             (or (# 1 cols) icon-mgr-background))))))
  268.  
  269. (defun imgr-bar-fsm ()
  270.    (fsm-make
  271.     (state-make
  272.      imgr-bar-behavior
  273.      icon-mgr-behavior
  274.      )))
  275.  
  276. (defun imgr-icon-pixmap ()
  277.   (or (# 'icon-mgr-special-pixmap window)
  278.       (if (= (type icon-mgr-pixmap-name) 'pixmap)
  279.           icon-mgr-pixmap-name)
  280.       (pixmap-make icon-mgr-background
  281.                    icon-mgr-pixmap-name
  282.                    icon-mgr-foreground)))
  283.  
  284. (defun imgr-empty-pixmap (icon-pmap)
  285.   (with (foreground icon-mgr-background)
  286.     (pixmap-make (width icon-pmap)
  287.                  (height icon-pmap))))
  288.  
  289. (defun imgr-smart-icon-name ()
  290.   (if (= window-icon-name "icon") ; Means that no icon name was specified
  291.       window-name
  292.     window-icon-name))
  293.  
  294. (: imgr-icon-fsm
  295.    (fsm-make
  296.     (state-make
  297.      (on (user-event 'imgr-rethink)
  298.          (if (with (wob (# 'window wob-property))
  299.                (window-iconified))
  300.              (wob-tile (# 'icon-pixmap wob-property))
  301.            (wob-tile (# 'empty-pixmap wob-property)))))))
  302.  
  303. (: imgr-label-fsm
  304.    (fsm-make
  305.     (state-make
  306.      (on (user-event 'imgr-rethink)
  307.      (with (borderwidth 0
  308.                 cols (with (wob (# 'window wob-property))
  309.                            (matches-cond icon-mgr-fancy-colors))
  310.                 icon-mgr-foreground (or (# 0 cols) icon-mgr-foreground)
  311.                 icon-mgr-background (or (# 1 cols) icon-mgr-background)
  312.                 background icon-mgr-background
  313.                 foreground icon-mgr-foreground
  314.                 borderpixel icon-mgr-background
  315.                 font icon-mgr-font   
  316.                 dumb-temporary     
  317.            (active-label-make (with (wob (# 'window wob-property))
  318.                         (imgr-smart-icon-name))))
  319.          (wob-tile dumb-temporary))))))
  320.  
  321. (defun imgr-make-bar (wind)
  322.   (with (wob wind
  323.          plug-separator 0
  324.          cols (matches-cond icon-mgr-fancy-colors)
  325.          icon-mgr-foreground (or (# 0 cols) icon-mgr-foreground)
  326.          icon-mgr-background (or (# 1 cols) icon-mgr-background)
  327.          foreground icon-mgr-foreground
  328.          background icon-mgr-background
  329.          borderpixel icon-mgr-background
  330.          font icon-mgr-font
  331.          fsm (imgr-bar-fsm)
  332.          icon-pmap (imgr-icon-pixmap)
  333.          empty-pmap (imgr-empty-pixmap icon-pmap)
  334.          property (+ (list 'window window 
  335.                            'icon-pixmap icon-pmap 
  336.                            'empty-pixmap empty-pmap)
  337.                      property))
  338.     (list wind
  339.           (if icon-mgr-framed-bars
  340.               (with (borderwidth 2)
  341.                 (bar-make
  342.                  (with (borderwidth 0
  343.                         fsm ())
  344.                    (bar-make
  345.                     (with (borderwidth 1
  346.                            borderpixel icon-mgr-foreground)
  347.                       (bar-make
  348.                        (with (borderwidth 0
  349.                               bar-min-width 3)
  350.                          (bar-make ))
  351.                        (with (borderwidth 0
  352.                               fsm imgr-icon-fsm)
  353.                          (if (window-iconified)
  354.                              (plug-make icon-pmap)
  355.                            (plug-make empty-pmap)))
  356.                        (with (borderwidth 0
  357.                               bar-min-width 3)
  358.                          (bar-make ))
  359.                        (with (borderwidth 0
  360.                               fsm imgr-label-fsm)
  361.                          (plug-make (active-label-make (imgr-smart-icon-name))))
  362.                        ()))))))
  363.             (with (borderwidth 1)
  364.               (bar-make
  365.                (with (fsm imgr-icon-fsm)
  366.                  (if (window-iconified)
  367.                      (plug-make icon-pmap)
  368.                    (plug-make empty-pmap)))
  369.                (with (fsm imgr-label-fsm)
  370.                      (plug-make (active-label-make (imgr-smart-icon-name))))
  371.                ()))))))
  372.   
  373. (defun imgr-create-barlist (imcond)
  374.     (with (barlist ())
  375.       (for wob (list-of-windows 'window)
  376.            (if (eval imcond)
  377.                (: barlist (+ (list (imgr-make-bar window))
  378.                              barlist))))
  379.       (if icon-mgr-sort
  380.           (sort barlist
  381.                 (lambdaq (e1 e2)
  382.                   (compare (with (wob (# 0 e1)) (imgr-smart-icon-name))
  383.                            (with (wob (# 0 e2)) (imgr-smart-icon-name)))))
  384.         barlist)))
  385.  
  386. (defun imgr-add-barlist (wind lst)
  387.   (with (ibar (imgr-make-bar wind))
  388.     (if icon-mgr-sort
  389.         (with (i 0
  390.                len (length lst)
  391.                name (with (wob wind) (imgr-smart-icon-name)))
  392.           (while (and (< i len)
  393.                       (le 0 (compare name 
  394.                                      (with (wob (# 0 (# i lst)))
  395.                                            (imgr-smart-icon-name)))))
  396.             (: i (+ 1 i)))
  397.           (+ (sublist 0 i lst) (list ibar) (sublist i len lst)))
  398.       (+ lst (list ibar)))))
  399.             
  400. (defun imgr-remove-barlist (wind lst)
  401.   (with (i 0
  402.          len (length lst))
  403.     (while (and (< i len)
  404.                 (not (= wind (# 0 (# i lst)))))
  405.       (: i (+ 1 i)))
  406.     (delete-nth i lst)))
  407.     
  408. (defun imgr-redraw-focus ()
  409.   (if (and autofocus icon-mgr-window-feedback)
  410.       (with (pos (current-mouse-position)
  411.              wind (wob-at-coords (# 0 pos) (# 1 pos)))
  412.         (if wind
  413.             (with (wob wind)
  414.               (if (not (= window-client-class 'Gwm))
  415.                   (set-focus window))
  416.               (icon-mgr-focusin)
  417.               )))))
  418.  
  419. (defun imgr-make-header-bar (name)
  420.   (with (fsm (imgr-header-fsm)
  421.          font icon-mgr-font
  422.          plug-separator 0
  423.          background (or icon-mgr-title-background
  424.                         icon-mgr-background)
  425.          foreground (or icon-mgr-title-foreground
  426.                         icon-mgr-foreground))
  427.     (if icon-mgr-framed-bars
  428.         (with (borderwidth 0
  429.                borderpixel background)
  430.           (bar-make (bar-make 
  431.                      (with (borderwidth 2
  432.                             fsm ())
  433.                        (bar-make
  434.                         (with (borderwidth 0)
  435.                           (bar-make
  436.                            (with (borderwidth 2
  437.                                   borderpixel foreground)
  438.                              (bar-make
  439.                               ()
  440.                               (with (borderwidth 0)
  441.                                 (plug-make (active-label-make name)))
  442.                               ()))))))
  443.                      (with (borderwidth 0
  444.                             borderpixel background
  445.                             bar-min-width 1
  446.                             background foreground)
  447.                        (bar-make )))))
  448.       (with (borderwidth 1
  449.              borderpixel foreground)
  450.         (bar-make
  451.          ()
  452.          (with (borderpixel background)
  453.                (plug-make (active-label-make name)))
  454.          ())))))
  455.  
  456. (defun imgr-create-menu (name barlist)
  457.   (with (header (if (not icon-mgr-no-title)
  458.                     (imgr-make-header-bar))
  459.          allmenu (with (menu-max-width icon-mgr-width 
  460.                         menu-min-width icon-mgr-width
  461.                         direction vertical
  462.                         borderwidth 0
  463.                         background (or icon-mgr-title-background
  464.                                        icon-mgr-background)
  465.                         foreground (or icon-mgr-title-foreground
  466.                                        icon-mgr-foreground)
  467.                         borderpixel foreground
  468.                         fsm ())
  469.                    (eval (+ '(menu-make)
  470.                             (if header (list header)) 
  471.                             (mapfor ele barlist (# 1 ele))))))
  472.     (send-user-event 'imgr-install-yourself (menu-wob allmenu))
  473.     (send-user-event 'imgr-rethink (menu-wob allmenu))
  474.     (imgr-redraw-focus)
  475.     allmenu))
  476.  
  477. (defun imgr-decouple-all ()
  478.   (for wob (list-of-windows 'window)
  479.     (if (# 'imgr-bar window)
  480.         (## 'imgr-bar wob ()))))
  481.   
  482. (defun imgr-reconsider-icons ()
  483.   (for wob (list-of-windows 'window)
  484.     (if (or (not iconify-by-unmapping)
  485.             (matches-list iconify-by-icon-list)
  486.             (and iconify-unmanaged-by-icon
  487.                  (not (# 'imgr-bar window))))
  488.         (progn
  489.           (## 'icon? wob t)
  490.           (if (and (window-iconified)
  491.                    (with (wob (window-icon))
  492.                          (not window-is-mapped)))
  493.               (iconify-before-icon-mgr))
  494.           (window-wm-state-icon 0))
  495.       (progn
  496.         (## 'icon? wob ())
  497.         (if (window-iconified)
  498.             (if (with (wob (window-icon))
  499.                       (window-is-mapped))
  500.                 (progn
  501.                   (window-wm-state-icon (window-icon))
  502.                   (unmap-window (window-icon))
  503.                   (window-wm-state-update 'icon)))
  504.           (window-wm-state-icon 0))))))
  505.  
  506. (defun imgr-xpos (ele)
  507.   (with (wob (# 0 ele)
  508.          xpos (or (# 2 ele) icon-mgr-xpos))
  509.     (if (< xpos 0)
  510.         (- (+ screen-width xpos) (width wob))
  511.       xpos)))
  512.  
  513. (defun imgr-ypos (ele)
  514.   (with (wob (# 0 ele)
  515.          ypos (or (# 3 ele) icon-mgr-ypos))
  516.     (if (< ypos 0)
  517.         (- (+ screen-height ypos) (height wob))
  518.       ypos)))
  519.  
  520. (defun imgr-save-pos (ele)
  521.   (with (wob (# 0 ele)
  522.          xpos (# 2 ele)
  523.          ypos (# 3 ele))
  524.     (setq xpos (if (< xpos 0)
  525.                    (+ wob-x window-client-x window-client-borderwidth 
  526.                       (- screen-width) (width wob))
  527.                  (+ wob-x window-client-x window-client-borderwidth)))
  528.     (setq ypos (if (< ypos 0)
  529.                    (+ wob-y window-client-y window-client-borderwidth
  530.                       (- screen-height) (height wob))
  531.                  (+ wob-y window-client-y window-client-borderwidth)))
  532.     (## 2 ele xpos)
  533.     (## 3 ele ypos)))
  534.  
  535. (defun imgr-delete-menu (ele)
  536.   (if (and (# 0 ele) (wob-is-valid (# 0 ele)))
  537.       (with (wob (# 0 ele))
  538.         (imgr-save-pos ele)
  539.         (if (wob-is-valid wob-parent)
  540.             (delete-window wob-parent)))))
  541.  
  542. (defun imgr-show-menu (ele)
  543.   (with (menuwob (if (and (# 0 ele) (wob-is-valid (# 0 ele))) (# 0 ele))
  544.          menu ()
  545.          name (or (# 1 ele) icon-mgr-name)
  546.          imcond (list 'and 
  547.                       '(not (= window-client-class 'Gwm))
  548.                       '(not (# 'imgr-bar window))
  549.                       (list 'matches-token (list 'quote (# 4 ele))))
  550.          barlist (# 5 ele)
  551.          property property
  552.          reenter-on-opening ())
  553.      (if (not barlist)
  554.          (## 5 ele (: barlist (imgr-create-barlist imcond))))
  555.      (if menuwob
  556.          (progn
  557.            (if (and (wob-is-valid menuwob)
  558.                     (with (wob menuwob) (wob-is-valid wob-parent)))
  559.                (setq property (with (wob menuwob) 
  560.                                 (with (wob wob-parent)
  561.                                   wob-property))))
  562.            (imgr-delete-menu ele)))
  563.      (if (or (> (length barlist) 0)  ; Get around bug: non-nil empty list
  564.              (not icon-mgr-hide-if-empty))
  565.          (progn
  566.            (## 0 ele (: menuwob
  567.                         (menu-wob (: menu 
  568.                                      (imgr-create-menu name barlist)))))
  569.            (place-menu name
  570.                        menu
  571.                        (imgr-xpos ele)
  572.                        (imgr-ypos ele)))
  573.        (## 0 ele ()))))
  574.  
  575. (defun icon-mgr-add ()
  576.   (if (and (not (= window-status 'icon))
  577.            (not (= window-client-class 'Gwm)))
  578.       (progn
  579.         (tag done
  580.              (if show-icon-mgr
  581.                  (for ele icon-mgr-list
  582.                       (if (and (matches-token (# 4 ele))
  583.                                (or show-default-icon-mgr
  584.                                    (not (= ele default-icon-mgr))))
  585.                           (exit done
  586.                                 (## 5 ele (imgr-add-barlist window (# 5 ele)))
  587.                                 (if setup-done   ; Only if already realised
  588.                                     (imgr-show-menu ele))))))
  589.              (if iconify-unmanaged-by-icon
  590.                  (## 'icon? window t)))
  591.         (if (or (not iconify-by-unmapping)
  592.                 (matches-list iconify-by-icon-list))
  593.             (## 'icon? window t))
  594.         (if (matches-list iconify-on-start-list)
  595.             (: window-starts-iconic t)))))
  596.  
  597. (defun icon-mgr-remove ()
  598.   (with (prop (# 'imgr-bar window))
  599.     (if (and show-icon-mgr (# 0 prop) (wob-is-valid (# 0 prop)))
  600.         (tag done
  601.              (for ele icon-mgr-list
  602.                   (if (and (= (# 0 prop) (# 0 ele))
  603.                            (or show-default-icon-mgr
  604.                                (not (= ele default-icon-mgr))))
  605.                       (exit done
  606.                             (## 5 ele (imgr-remove-barlist window
  607.                                                            (# 5 ele)))
  608.                             (if setup-done   ; Only if already realised
  609.                                 (imgr-show-menu ele)))))))
  610.     ))
  611.  
  612. (defun icon-mgr-show ()
  613.   (for ele icon-mgr-list
  614.        (## 5 ele ()))
  615.   (imgr-decouple-all)
  616.   (if show-icon-mgr
  617.       (for ele icon-mgr-list
  618.            (if (and (not show-default-icon-mgr)
  619.                     (= ele default-icon-mgr))
  620.                (imgr-delete-menu default-icon-mgr)
  621.              (imgr-show-menu ele)))
  622.     (for ele icon-mgr-list
  623.          (imgr-delete-menu ele)
  624.          (## 0 ele ())))
  625.   (imgr-reconsider-icons))
  626.  
  627. (defun icon-mgr-toggle ()
  628.   (: show-icon-mgr (not show-icon-mgr))
  629.   (icon-mgr-show))
  630.  
  631. (defun make-icon-mgr (name xpos ypos imcond)
  632.   (: icon-mgr-list (+ (sublist 0 (- (length icon-mgr-list) 1) icon-mgr-list)
  633.                       (list (list () name xpos ypos imcond ()))
  634.                       (list default-icon-mgr)))
  635.   (icon-mgr-show))
  636.  
  637. (defun remove-icon-mgr (name)
  638.   (with (ind 0
  639.          len (length icon-mgr-list)
  640.          ele (# 0 icon-mgr-list))
  641.     (while (and (< ind len)
  642.                 (not (= name (# 1 ele))))
  643.       (setq ind (+ 1 ind))
  644.       (setq ele (# ind icon-mgr-list)))
  645.     (if (and (< ind len))
  646.         (progn
  647.           (imgr-delete-menu ele)
  648.           (delete-nth ind icon-mgr-list)
  649.           (icon-mgr-show)))))
  650.