Changeset 188

Show
Ignore:
Timestamp:
07/19/2006 05:16:47 PM (2 years ago)
Author:
mwm
Message:

Update my exaple file. Fixes to the input and pane_utilities for dealing with lots of windows in an input menu.

Location:
trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/examples/plpwm.py

    r180 r188  
    11#!/usr/bin/env python 
    2 # $Id: plpwm.py,v 1.40 2005-09-08 00:18:03 mwm Exp $ 
     2# $Id: plpwm.py,v 1.41 2006-07-19 22:16:47 mwm Exp $ 
    33# 
    44# plpwm.py -- Example PLWM window manager configuration with panes. 
     
    9696    client_class = MyClient 
    9797    screen_class = MyScreen 
     98    panes_maxsize_gravity = X.NorthGravity 
    9899 
    99100 
     
    113114 
    114115    # Commands for navigating and manipulating panes 
    115     def M4_Escape(my, event): my.wm.quit() 
    116  
    117116    def C_0(my, event): 
    118117        "Go to the pane numbered by the keycode." 
     
    127126    def M4_0(my, event): 
    128127        pane = my.wm.panes_list[my.wm.panes_current] 
    129         splitpane(pane, pane.horizontal_split) 
     128        splitpane(pane, pane.horizontal_split, paneWindow) 
    130129 
    131130    def S_M4_0(my, event): 
     
    152151        runcommand(my.wm.panes_list[my.wm.panes_current], paneWindow) 
    153152 
     153    def M4_a(my, event): 
     154        getapp(my.wm.panes_list[my.wm.panes_current], 
     155               ".aw", "applix -wp") 
     156 
    154157    def M4_b(my, event): 
    155158        getapp(my.wm.panes_list[my.wm.panes_current], "w3m") 
    156159 
     160    def M4_B(my, event): 
     161        websearch(my.wm.panes_list[my.wm.panes_current], MyEditHandler, 
     162                  "Amazon", paneWindow, 
     163                  'http://www.amazon.com/exec/obidos/search-handle-url/index=blended&field-keywords=%s') 
     164 
    157165    def M4_c(my, event): 
     166        getapp(my.wm.panes_list[my.wm.panes_current], 'Sunbird', 'sunbird') 
     167 
     168    def M4_C(my, event): 
    158169        getapp(my.wm.panes_list[my.wm.panes_current], "xclipboard") 
    159170 
    160171    def M4_d(my, event): 
    161         websearch(my.wm.panes_list[my.wm.panes_current], MyEditHandler, 
    162                   "Google Directory", paneWindow, 
    163                   "http://www.google.com/search?q=%s&it=ISO-8859-1&oe=ISO-8859-1&cat=gwd%%2FTop") 
     172        getapp(my.wm.panes_list[my.wm.panes_current], 'Dillo', 'dillo') 
     173 
     174    def M4_D(my, event): 
     175        websearch(my.wm.panes_list[my.wm.panes_current], MyEditHandler, 
     176                  "Webster Dictionary", paneWindow, 
     177                  "http://www.webster.com/cgi-bin/dictionary?book=Dictionary&va=%s") 
    164178 
    165179    def M4_e(my, event): 
     
    169183    def M4_f(my, event): 
    170184        # Damn Firefox doesn't set the title properly when running tabbed, 
    171         # just uses "firefox-bin". So we chop the leading F off. 
    172         getapp(my.wm.panes_list[my.wm.panes_current], "irefox", "firefox") 
     185        # just uses "firefox-bin". So we try both cases. 
     186        getapp(my.wm.panes_list[my.wm.panes_current], "[fF]irefox", "firefox") 
    173187 
    174188    def M4_g(my, event): 
     
    179193    def M4_G(my, event): 
    180194        getapp(my.wm.panes_list[my.wm.panes_current], 
    181                "GnuCash", "gnucash") 
     195               "Accounts", "gnucash") 
     196 
     197    def M4_j(my, event): 
     198        websearch(my.wm.panes_list[my.wm.panes_current], MyEditHandler, 
     199                  "Jargon file", paneWindow, 
     200                  "http://www.google.com/search?as_q=%s&as_sitesearch=www.catb.org&btnG=Google+Search") 
    182201 
    183202    def M4_i(my, event): 
     
    187206 
    188207    def M4_I(my, event): 
    189         def firefox(url): 
     208        def dillo(url): 
    190209            assert "'" not in url 
    191             my.wm.system("firefox '%s' &" % url) 
     210            my.wm.system("dillo '%s' &" % url) 
    192211 
    193212        websearch(my.wm.panes_list[my.wm.panes_current], MyEditHandler, 
    194213                  "Google Images", paneWindow, 
    195                   'http://images.google.com/images?q=%s&ie=ISO-8859-1&oe=ISO-8859-1', 
    196                   firefox) 
    197  
    198     def M4_I(my, event): 
    199         getapp(my.wm.panes_list[my.wm.panes_current], 
    200                "/home/mwm/axhome/axMail/Inbox.sp", "applix -inbox") 
    201  
    202     def M4_j(my, event): 
    203         getapp(my.wm.panes_list[my.wm.panes_current], "J-Pilot", "jpilot") 
     214                  'http://images.google.com/images?q=%s&ie=ISO-8859-1&oe=ISO-8859-1&imgsz=xxlarge&safe=off', 
     215                  dillo) 
     216 
     217    def M4_l(my, event): 
     218        getapp(my.wm.panes_list[my.wm.panes_current], 'LyX', 'lyx') 
     219 
     220    def M4_M(my, event): 
     221        getapp(my.wm.panes_list[my.wm.panes_current], 'Mozilla[^ ]', 'mozilla') 
     222 
     223    def M4_p(my, event): 
     224        websearch(my.wm.panes_list[my.wm.panes_current], MyEditHandler, 
     225                  "Python Cookbook", paneWindow, 
     226                  "http://aspn.activestate.com/ASPN/search?query=%s&section=PYTHONCKBK&type=Subsection&x=13&y=3") 
     227 
     228    def M4_P(my, event): 
     229        websearch(my.wm.panes_list[my.wm.panes_current], MyEditHandler, 
     230                  "Python Documentation", paneWindow, 
     231                  'http://starship.python.net/crew/theller/pyhelp.cgi?keyword=%s&version=current') 
     232 
     233    M4_S = M4_c         # Sunbird, to match the Mac  
    204234 
    205235    def M4_t(my, event): 
     236        websearch(my.wm.panes_list[my.wm.panes_current], MyEditHandler, 
     237                  "TV Tome Search", paneWindow, 
     238                  "http://www.tv.com/search.php?type=11&stype=all&qs=%s&x=0&y=0") 
     239 
     240    def M4_T(my, event): 
    206241        websearch(my.wm.panes_list[my.wm.panes_current], MyEditHandler, 
    207242                  "Webster Thesaurus", paneWindow, 
     
    210245    def M4_w(my, event): 
    211246        websearch(my.wm.panes_list[my.wm.panes_current], MyEditHandler, 
    212                   "Webster Dictionary", paneWindow, 
    213                   "http://www.webster.com/cgi-bin/dictionary?book=Dictionary&va=%s") 
     247                  "Wikipedia Dictionary", paneWindow, 
     248                  "http://en.wikipedia.org/wiki/Special:Search?search=%s&go=Go") 
    214249 
    215250    # Keystrokes for window manager operations 
     
    238273        MenuKeys(my.wm, event.time) 
    239274 
     275    def M4_M(my, event): 
     276        def nop(): 
     277            pass 
     278 
     279        codemenu(my.wm.panes_list[my.wm.panes_current], 
     280                 {"Next pane (tab)": (my.M4_Tab, (event,)), 
     281                  "Previous pane (shift tab)": (my.S_M4_Tab, (event,)), 
     282                  "Maximize (1)": (my.M4_1, (event,)), 
     283                  "Command (!)": (my.M4_exclam, (event,)), 
     284                  "Applix Mail (a)": (my.M4_a, (event,)), 
     285                  "Browser (b)": (my.M4_b, (event,)), 
     286                  "Clipboard (c)": (my.M4_c, (event,)), 
     287                  "Directory search (d)": (my.M4_d, (event,)), 
     288                  "Emacs (e)": (my.M4_e, (event,)), 
     289                  "Firefox (f)": (my.M4_f, (event,)), 
     290                  "Scroogle search (g)": (my.M4_g, (event,)), 
     291                  "Gnucash (G)": (my.M4_G, (event,)), 
     292                  "Image search (I)": (my.M4_I, (event,)), 
     293                  "IMDB search (i)": (my.M4_i, (event,)), 
     294                  "J-Pilot (j)": (my.M4_j, (event,)), 
     295                  "Thesaurus search (t)": (my.M4_t, (event,)), 
     296                  "Webster search (w)": (my.M4_w, (event,)), 
     297                  "Pane renumber (=)": (my.M4_equal, (event,)), 
     298                  "Pull window (')": (my.M4_quoteright, (event,)), 
     299                  'Goto window (")': (my.M4_quotedbl, (event,)), 
     300                  "Next window (shift space)": (my.M4_space, (event,)), 
     301                  "Previous Window (space)": (my.S_M4_space, (event,)), 
     302                  "Close window (k)": (my.M4_k, (event,)), 
     303                  "Kill window (K)": (my.S_M4_k, (event,)), 
     304                  "Menus (m)": (my.M4_m, (event,)), 
     305                  "This menu (M)": (nop, ()), 
     306                  "Quit (Q)": (my.M4_Q, (event,)), 
     307                  "Force window resize (r)": (my.M4_r, (event,)), 
     308                  "Iconify window (x)": (my.M4_x, (event,))}) 
     309 
     310    def M4_Q(my, event): my.wm.quit() 
     311 
    240312    def M4_r(my, event): 
    241313        my.wm.panes_list[my.wm.panes_current].force_window() 
     314 
     315    def M4_v(my, event): 
     316        getapp(my.wm.panes_list[my.wm.panes_current], "TightVNC", "vncviewer") 
    242317 
    243318    def M4_x(my, event): 
     
    321396        my._cleanup() 
    322397 
    323     Any_g = Any_Escape = keys.KeyGrabKeyboard._timeout 
     398    C_g = Any_Escape = keys.KeyGrabKeyboard._timeout 
    324399     
    325400 
     
    374449    wm.panes_number(4) 
    375450    pane = wm.panes_list[5] 
    376     pane.horizontal_split(16. / 45.) 
    377     pane.horizontal_split(24. / 29.) 
     451    pane.horizontal_split(25. / 29.) 
    378452    wm.panes_number(6) 
     453 
     454    # 524 bhuda 362 student 921 total 
     455    pane = wm.panes_list[6] 
     456    pane.horizontal_split(.43) 
     457    #wm.panes_number(7) 
    379458    wm.panes_goto(0) 
    380459    wm.panes_restore() 
  • trunk/plwm/input.py

    r119 r188  
    5252    timeout = None 
    5353 
    54     def __init__(my, handler, display): 
     54    def __init__(my, handler, display, initial=''): 
    5555        """Init with a handler and display. 
    5656 
     
    6363        my.handler = handler 
    6464        my.left = "" 
    65         my.right = "" 
     65        my.right = initial 
    6666        if isinstance(handler, Window): 
    6767            my.selection = my.wm.display.intern_atom("SELECTION") 
     
    184184        my.window.dispatch.add_handler(X.Expose, my.redraw) 
    185185 
    186     def read(my, action, handlertype, x = 0, y = 0): 
     186    def read(my, action, handlertype, x = 0, y = 0, initial=''): 
    187187        "Open the window at x, y, using handlertype, and doing action." 
    188188 
     
    191191        my.window.configure(x = x, y = y, width = width, height = height) 
    192192        my.window.map() 
    193         handlertype(my.window, my) 
     193        handlertype(my.window, my, initial) 
    194194 
    195195    def raisewindow(my, event): 
  • trunk/plwm/pane_utilities.py

    r179 r188  
    11#!/usr/bin/env python 
    2 # $Id: pane_utilities.py,v 1.3 2005-08-10 13:30:38 mwm Exp $ 
     2# $Id: pane_utilities.py,v 1.4 2006-07-19 22:16:47 mwm Exp $ 
    33# 
    44# pane_utilities.py -- Utility clases and functions for use with panes 
     
    6565 
    6666 
    67  
    6867class windowmenu: 
    6968    "Create a menu of windows to add to a pane." 
    7069 
    71     def __init__(my, pane, filter = cfilter.true, list = None): 
     70    def __init__(my, pane, filter = cfilter.true, startlist = None): 
    7271        labels = [] 
    7372        clients = {} 
     73        clientlist = startlist or pane.screen.query_clients(filter, 1) 
     74        clientlist.sort(key=lambda c: c.get_title().lower()) 
    7475        i = 'a' 
    75         for c in list or pane.screen.query_clients(filter, 1): 
     76        # We really need to deal with window lists longer than 26. 
     77        for c in clientlist: 
    7678            l = "%c: %s" % (i, c.get_title()) 
    7779            labels.append(l) 
     
    124126    "Launch a browser with a web search from the user." 
    125127 
     128    previous = '' 
     129 
    126130    def __init__(my, pane, editHandler, name, winclass, format, browser = None): 
    127131        my.format = format 
    128132        my.browser = browser 
    129133        my.pane = pane 
    130         window = winclass("Search %s: " % name, pane.screen, length = 50) 
    131         window.read(my, editHandler, pane.x, pane.y) 
     134        window = winclass("Search %s: " % name, pane.screen, length=50) 
     135        window.read(my, editHandler, pane.x, pane.y, websearch.previous) 
    132136 
    133137    def __call__(my, string): 
     138        websearch.previous = string 
    134139        query = my.format % quote(string) 
    135140        if my.browser: 
     
    190195        clients = my.pane.screen.query_clients(cfilter.re_title(name + ".*"), 1) 
    191196        if len(clients) == 1: my.pane.add_window(clients[0]) 
    192         elif clients: windowmenu(my.pane, list = clients) 
     197        elif clients: windowmenu(my.pane, startlist = clients) 
    193198        else: 
    194199            width, height = my.pane.screen.message_make("No windows") 
     
    229234 
    230235    clients = pane.screen.query_clients(cfilter.re_title(".*%s.*" % name), 1) 
    231     if len(clients) > 1: windowmenu(pane, list = clients) 
     236    if len(clients) > 1: windowmenu(pane, startlist = clients) 
    232237    elif clients: pane.add_window(clients[0]) 
    233238    else: pane.screen.system((command or name) + " &")