Changeset 195

Show
Ignore:
Timestamp:
07/14/2007 04:19:34 AM (18 months ago)
Author:
mwm
Message:

Move pane configuration data into the xml config file. Update config example to include that and the websearch config as well.

Location:
trunk/examples
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/examples/plpwm.py

    r193 r195  
    11#!/usr/bin/env python 
    2 # $Id: plpwm.py,v 1.43 2007-07-14 07:38:12 mwm Exp $ 
     2# $Id: plpwm.py,v 1.44 2007-07-14 09:19:34 mwm Exp $ 
    33# 
    44# plpwm.py -- Example PLWM window manager configuration with panes. 
     
    213213 
    214214    def M1_k(my, event): 
     215        my.wm.panes_list[my.wm.panes_current].window.delete(1) 
     216 
     217    def M1_K(my, event): 
    215218        my.wm.panes_list[my.wm.panes_current].window.destroy() 
    216219 
     
    238241            my.menus = load_menus(my.menu_file) 
    239242 
    240         codemenu(my.wm.panes_list[my.wm.panes_current], 
    241                  {'1: Restore': (restore, (my.wm,)), 
    242                   '2: Reload': (reload_menus, ()), 
    243                   '3: Restart': (os.execvp, (sys.executable, 
    244                                              [sys.executable] + sys.argv)), 
    245                   '4: Quit': (my.wm.quit, ()) 
    246                  }) 
     243        def restore_menu(wm): 
     244            view_menu(pane, XML_controller(my.menus.find('paneconfigmenus'), 
     245                                           dict(paneconfig=lambda x: restore(wm, x)))) 
     246 
     247        pane = my.wm.panes_list[my.wm.panes_current] 
     248        codemenu(pane, {'1: Restore': (restore_menu, (my.wm,)), 
     249                        '2: Reload': (reload_menus, ()), 
     250                        '3: Restart': (os.execvp, (sys.executable, 
     251                                                   [sys.executable] + sys.argv)), 
     252                        '4: Quit': (my.wm.quit, ()) 
     253                        }) 
    247254 
    248255    def M1_s(my, event): 
     
    252259        def dowebsearch(node): 
    253260            if node.get('images'): 
    254                 websearch(pane, node.get('label'), paneWindow, node.get('url'), dillo) 
     261                websearch(pane, node.get('label'), paneWindow, node.get('url'), 
     262                          dillo) 
    255263            else: 
    256264                websearch(pane, node.get('label'), paneWindow, node.get('url')) 
     
    293301 
    294302 
    295 def restore(wm): 
     303def restore(wm, config): 
    296304    "Build my standard work environment." 
    297305 
     
    307315    pane.window = None 
    308316 
    309     # If we don't have Xinerama working, fake it by splitting the one 
    310     # *big* screen. 
    311     pane.vertical_split(1920. / 3520.) 
    312  
    313     # Create the panes 
    314     pane.vertical_split() 
    315     pane.horizontal_split(.06) 
    316     pane.vertical_split(.75) 
    317     pane.horizontal_split(.06) 
    318     pane.horizontal_split(.45) 
    319     pane = wm.panes_list[4] 
    320     pane.horizontal_split(.42) 
    321     pane.horizontal_split() 
    322  
    323     # Now number them. 
    324     wm.panes_goto(2) 
    325     wm.panes_number(0) 
    326     wm.panes_goto(4) 
    327     wm.panes_number(1) 
    328     wm.panes_goto(8) 
    329     wm.panes_number(2) 
    330     wm.panes_goto(7) 
    331     wm.panes_number(3) 
    332     wm.panes_goto(7) 
    333     wm.panes_number(4) 
    334     wm.panes_goto(8) 
    335     wm.panes_number(5) 
    336     wm.panes_goto(8) 
    337     wm.panes_number(7) 
    338      
    339     # Set up the second screen 
    340     #wm.panes_list[7].vertical_split() 
    341  
    342     # And make the world sane 
     317    for node in config: 
     318        if node.tag == 'vertical': 
     319            pane.vertical_split(float(node.get('fraction'))) 
     320        elif node.tag == 'horizontal': 
     321            pane.horizontal_split(float(node.get('fraction'))) 
     322        elif node.tag == 'newpane': 
     323            pane = wm.panes_list[int(node.get('pane'))] 
     324        elif node.tag == 'goto': 
     325            wm.panes_goto(int(node.get('number'))) 
     326        elif node.tag == 'number': 
     327            wm.panes_number(int(node.get('number'))) 
     328        else: 
     329            raise ValueError, 'Unrecognized pane config element %s' % node 
     330 
     331 
     332    # And now make the world sane 
    343333    wm.panes_goto(0) 
    344334    wm.panes_restore() 
  • trunk/examples/plpwmrc.xml

    r194 r195  
    1 <?xml version="1.0" encoding="utf-8"?> 
     1<?xml version="1.0" encoding="utf-8"?> 
    22<plpwm xmlns:xi="http://www.w3.org/2001/XInclude"> 
    33  <functionmenu> 
    4     <getapp label="a: Audio" title='VCL' command='vlc' /> 
    5     <getapp label="b: Browser" title='w3m:' command='w3m' /> 
    6     <getapp label="c: Calendar" title='Sunbird' command='sunbird' /> 
    7     <getapp label="d: Documents" title='LyX' command='lyx' /> 
    8     <getapp label="e: Editor" title="emacs@" command="emacs" /> 
    9     <getapp label="f: Finances" title="data - " command="gnucash" /> 
    10     <getapp label="i: IM" title="Buddy" command="gaim" /> 
    11     <getapp label="m: Mail" title='Claws Mail' command='claws-mail' /> 
    12     <getapp label="o: Office" title='OpenOffice.org' command='openoffice.org' /> 
    13     <getapp label="p: Pdf viewer" title="Xpdf:" command="xpdf" /> 
    14     <getapp label="x: XClipboard" title="xclipboard" /> 
     4    <getapp label="a: Audio" title="VCL" command="vlc"/> 
     5    <getapp label="b: Browser" title="w3m:" command="w3m"/> 
     6    <getapp label="c: Calendar" title="Sunbird" command="sunbird"/> 
     7    <getapp label="d: Documents" title="LyX" command="lyx"/> 
     8    <getapp label="e: Editor" title="emacs@" command="emacs"/> 
     9    <getapp label="f: Finances" title="data - " command="gnucash"/> 
     10    <getapp label="i: IM" title="Buddy" command="gaim"/> 
     11    <getapp label="m: Mail" title="Claws Mail" command="claws-mail"/> 
     12    <getapp label="o: Office" title="OpenOffice.org" command="openoffice.org"/> 
     13    <getapp label="p: Pdf viewer" title="Xpdf:" command="xpdf"/> 
     14    <getapp label="x: XClipboard" title="xclipboard"/> 
    1515  </functionmenu> 
    1616  <namemenu> 
    17     <getapp label="d: Dillo" title='Dillo' command='dillo' /> 
    18     <getapp label="e: Emacs" title="emacs@" command="emacs" /> 
     17    <getapp label="d: Dillo" title="Dillo" command="dillo"/> 
     18    <getapp label="e: Emacs" title="emacs@" command="emacs"/> 
    1919    <!-- Damn Firefox doesn't set the title properly when running tabbed, just 
    2020         uses "firefox-bin". So we try both cases. --> 
    21     <getapp label="f: Firefox" title='[fF]irefox' command='firefox' /> 
    22     <getapp label="g: Gkrellm" title="gkrellm" /> 
    23     <getapp label="l: LyX" title='LyX' command='lyx' /> 
    24     <getapp label="o: OpenOffice" title='OpenOffice.org' command='openoffice.org' /> 
    25     <getapp label="s: Sunbird" title='Sunbird' command='sunbird' /> 
    26     <getapp label="v: VNC" title='TightVNC' command='vncviewer' /> 
    27     <run label="w w3m" command="/home/mwm/bin/w3m" /> 
    28     <getapp label="x: XClipboard" title='xclipboard' /> 
     21    <getapp label="f: Firefox" title="[fF]irefox" command="firefox"/> 
     22    <getapp label="g: Gkrellm" title="gkrellm"/> 
     23    <getapp label="l: LyX" title="LyX" command="lyx"/> 
     24    <getapp label="o: OpenOffice" title="OpenOffice.org" command="openoffice.org"/> 
     25    <getapp label="s: Sunbird" title="Sunbird" command="sunbird"/> 
     26    <getapp label="v: VNC" title="TightVNC" command="vncviewer"/> 
     27    <run label="w w3m" command="/home/mwm/bin/w3m"/> 
     28    <getapp label="x: XClipboard" title="xclipboard"/> 
    2929  </namemenu> 
    3030  <itunesmenu> 
    31     <itunes label="1: Pause" command="pause" /> 
    32     <itunes label="2: Play" command="play" /> 
    33     <itunes label="3: Stop" command="stop" /> 
     31    <itunes label="1: Pause" command="pause"/> 
     32    <itunes label="2: Play" command="play"/> 
     33    <itunes label="3: Stop" command="stop"/> 
    3434  </itunesmenu> 
    35   <xi:include href=".websearches.xml" /> 
     35  <websearches> 
     36    <search label="Amazon" shortcut="a" url="http://www.amazon.com/exec/obidos/search-handle-url/index=blended;field-keywords=%s"/> 
     37    <search label="Code" shortcut="c" url="http://www.google.com/codesearch?q=%s"/> 
     38    <search label="Dictionary" shortcut="d" url="http://www.webster.com/cgi-bin/dictionary?book=Dictionary&amp;va=%s"/> 
     39    <search label="Google" shortcut="g" url="http://www.google.com/search?q=%s&amp;hl=en&amp;safe=off"/> 
     40    <search label="IMDB" shortcut="i" url="http://www.imdb.com/find?tt=on&amp;nm=on&amp;mx=20&amp;q=%s"/> 
     41    <search label="Images" shortcut="I" images="1" url="http://images.google.com/images?q=%s&amp;ie=ISO-8859-1&amp;oe=ISO-8859-1&amp;imgsz=xxlarge&amp;safe=o"/> 
     42    <search label="Jargon" shortcut="j" url="http://www.google.com/search?as_q=%s&amp;as_sitesearch=www.catb.org&amp;btnI=I%27m+feeling+lucky"/> 
     43    <search label="Netflix" shortcut="n" url="http://www.netflix.com/Search?v1=%s"/> 
     44    <search label="Python documentation" shortcut="p" url="http://starship.python.net/crew/theller/pyhelp.cgi?keyword=%s&amp;version=current"/> 
     45    <search label="Python cookbook" shortcut="P" url="http://aspn.activestate.com/ASPN/search?query=%s&amp;section=PYTHONCKBK&amp;type=Subsection&amp;x=13&amp;y=3"/> 
     46    <search label="Quotes" shortcut="q" url="http://en.wikiquote.org/w/index.php?title=Special%%3ASearch&amp;search=%s&amp;fulltext=Search"/> 
     47    <search label="TV" shortcut="t" url="http://www.tv.com/search.php?type=11&amp;stype=all&amp;qs=%s&amp;x=0&amp;y=0"/> 
     48    <search label="Thesaurs" shortcut="T" url="http://www.webster.com/cgi-bin/thesaurus?book=Thesaurus&amp;va=%s"/> 
     49    <search label="Wikipedia" shortcut="w" url="http://en.wikipedia.org/wiki/Special:Search?search=%s&amp;go=Go"/> 
     50    <search label="Wiktionary" shortcut="W" url="http://en.wiktionary.org/wiki/Special:Search?search=%s&amp;go=Go"/> 
     51  </websearches> 
     52  <paneconfigmenus> 
     53    <paneconfig label="0: Working"> 
     54      <vertical fraction=".545454"/> 
     55      <vertical fraction=".5"/> 
     56      <horizontal fraction=".06"/> 
     57      <vertical fraction=".75"/> 
     58      <horizontal fraction=".06"/> 
     59      <horizontal fraction=".45"/> 
     60      <newpane pane="4"/> 
     61      <horizontal fraction=".42"/> 
     62      <horizontal fraction=".5"/> 
     63      <goto number="2"/> 
     64      <number number="0"/> 
     65      <goto number="4"/> 
     66      <number number="1"/> 
     67      <goto number="8"/> 
     68      <number number="2"/> 
     69      <goto number="7"/> 
     70      <number number="3"/> 
     71      <goto number="7"/> 
     72      <number number="4"/> 
     73      <goto number="8"/> 
     74      <number number="5"/> 
     75      <goto number="8"/> 
     76      <number number="7"/> 
     77      <newpane pane="8"/> 
     78      <vertical fraction=".5"/> 
     79    </paneconfig> 
     80    <paneconfig label="1: Big right"> 
     81      <vertical fraction=".545454"/> 
     82      <vertical fraction=".5"/> 
     83      <horizontal fraction=".06"/> 
     84      <vertical fraction=".75"/> 
     85      <horizontal fraction=".06"/> 
     86      <horizontal fraction=".45"/> 
     87      <newpane pane="4"/> 
     88      <horizontal fraction=".42"/> 
     89      <horizontal fraction=".5"/> 
     90      <goto number="2"/> 
     91      <number number="0"/> 
     92      <goto number="4"/> 
     93      <number number="1"/> 
     94      <goto number="8"/> 
     95      <number number="2"/> 
     96      <goto number="7"/> 
     97      <number number="3"/> 
     98      <goto number="7"/> 
     99      <number number="4"/> 
     100      <goto number="8"/> 
     101      <number number="5"/> 
     102      <goto number="8"/> 
     103      <number number="7"/> 
     104      <newpane pane="7"/> 
     105      <vertical fraction=".5"/> 
     106    </paneconfig> 
     107    <paneconfig label="2: Screens"> 
     108      <vertical fraction=".545454"/> 
     109    </paneconfig> 
     110  </paneconfigmenus> 
    36111</plpwm> 
    37  
    38