Changeset 188
- Timestamp:
- 07/19/2006 05:16:47 PM (2 years ago)
- Location:
- trunk
- Files:
-
- 3 modified
-
examples/plpwm.py (modified) (12 diffs)
-
plwm/input.py (modified) (4 diffs)
-
plwm/pane_utilities.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/examples/plpwm.py
r180 r188 1 1 #!/usr/bin/env python 2 # $Id: plpwm.py,v 1.4 0 2005-09-08 00:18:03mwm Exp $2 # $Id: plpwm.py,v 1.41 2006-07-19 22:16:47 mwm Exp $ 3 3 # 4 4 # plpwm.py -- Example PLWM window manager configuration with panes. … … 96 96 client_class = MyClient 97 97 screen_class = MyScreen 98 panes_maxsize_gravity = X.NorthGravity 98 99 99 100 … … 113 114 114 115 # Commands for navigating and manipulating panes 115 def M4_Escape(my, event): my.wm.quit()116 117 116 def C_0(my, event): 118 117 "Go to the pane numbered by the keycode." … … 127 126 def M4_0(my, event): 128 127 pane = my.wm.panes_list[my.wm.panes_current] 129 splitpane(pane, pane.horizontal_split )128 splitpane(pane, pane.horizontal_split, paneWindow) 130 129 131 130 def S_M4_0(my, event): … … 152 151 runcommand(my.wm.panes_list[my.wm.panes_current], paneWindow) 153 152 153 def M4_a(my, event): 154 getapp(my.wm.panes_list[my.wm.panes_current], 155 ".aw", "applix -wp") 156 154 157 def M4_b(my, event): 155 158 getapp(my.wm.panes_list[my.wm.panes_current], "w3m") 156 159 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 157 165 def M4_c(my, event): 166 getapp(my.wm.panes_list[my.wm.panes_current], 'Sunbird', 'sunbird') 167 168 def M4_C(my, event): 158 169 getapp(my.wm.panes_list[my.wm.panes_current], "xclipboard") 159 170 160 171 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") 164 178 165 179 def M4_e(my, event): … … 169 183 def M4_f(my, event): 170 184 # 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") 173 187 174 188 def M4_g(my, event): … … 179 193 def M4_G(my, event): 180 194 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") 182 201 183 202 def M4_i(my, event): … … 187 206 188 207 def M4_I(my, event): 189 def firefox(url):208 def dillo(url): 190 209 assert "'" not in url 191 my.wm.system(" firefox'%s' &" % url)210 my.wm.system("dillo '%s' &" % url) 192 211 193 212 websearch(my.wm.panes_list[my.wm.panes_current], MyEditHandler, 194 213 "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§ion=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 204 234 205 235 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): 206 241 websearch(my.wm.panes_list[my.wm.panes_current], MyEditHandler, 207 242 "Webster Thesaurus", paneWindow, … … 210 245 def M4_w(my, event): 211 246 websearch(my.wm.panes_list[my.wm.panes_current], MyEditHandler, 212 "W ebsterDictionary", 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") 214 249 215 250 # Keystrokes for window manager operations … … 238 273 MenuKeys(my.wm, event.time) 239 274 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 240 312 def M4_r(my, event): 241 313 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") 242 317 243 318 def M4_x(my, event): … … 321 396 my._cleanup() 322 397 323 Any_g = Any_Escape = keys.KeyGrabKeyboard._timeout398 C_g = Any_Escape = keys.KeyGrabKeyboard._timeout 324 399 325 400 … … 374 449 wm.panes_number(4) 375 450 pane = wm.panes_list[5] 376 pane.horizontal_split(16. / 45.) 377 pane.horizontal_split(24. / 29.) 451 pane.horizontal_split(25. / 29.) 378 452 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) 379 458 wm.panes_goto(0) 380 459 wm.panes_restore() -
trunk/plwm/input.py
r119 r188 52 52 timeout = None 53 53 54 def __init__(my, handler, display ):54 def __init__(my, handler, display, initial=''): 55 55 """Init with a handler and display. 56 56 … … 63 63 my.handler = handler 64 64 my.left = "" 65 my.right = ""65 my.right = initial 66 66 if isinstance(handler, Window): 67 67 my.selection = my.wm.display.intern_atom("SELECTION") … … 184 184 my.window.dispatch.add_handler(X.Expose, my.redraw) 185 185 186 def read(my, action, handlertype, x = 0, y = 0 ):186 def read(my, action, handlertype, x = 0, y = 0, initial=''): 187 187 "Open the window at x, y, using handlertype, and doing action." 188 188 … … 191 191 my.window.configure(x = x, y = y, width = width, height = height) 192 192 my.window.map() 193 handlertype(my.window, my )193 handlertype(my.window, my, initial) 194 194 195 195 def raisewindow(my, event): -
trunk/plwm/pane_utilities.py
r179 r188 1 1 #!/usr/bin/env python 2 # $Id: pane_utilities.py,v 1. 3 2005-08-10 13:30:38mwm Exp $2 # $Id: pane_utilities.py,v 1.4 2006-07-19 22:16:47 mwm Exp $ 3 3 # 4 4 # pane_utilities.py -- Utility clases and functions for use with panes … … 65 65 66 66 67 68 67 class windowmenu: 69 68 "Create a menu of windows to add to a pane." 70 69 71 def __init__(my, pane, filter = cfilter.true, list = None):70 def __init__(my, pane, filter = cfilter.true, startlist = None): 72 71 labels = [] 73 72 clients = {} 73 clientlist = startlist or pane.screen.query_clients(filter, 1) 74 clientlist.sort(key=lambda c: c.get_title().lower()) 74 75 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: 76 78 l = "%c: %s" % (i, c.get_title()) 77 79 labels.append(l) … … 124 126 "Launch a browser with a web search from the user." 125 127 128 previous = '' 129 126 130 def __init__(my, pane, editHandler, name, winclass, format, browser = None): 127 131 my.format = format 128 132 my.browser = browser 129 133 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) 132 136 133 137 def __call__(my, string): 138 websearch.previous = string 134 139 query = my.format % quote(string) 135 140 if my.browser: … … 190 195 clients = my.pane.screen.query_clients(cfilter.re_title(name + ".*"), 1) 191 196 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) 193 198 else: 194 199 width, height = my.pane.screen.message_make("No windows") … … 229 234 230 235 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) 232 237 elif clients: pane.add_window(clients[0]) 233 238 else: pane.screen.system((command or name) + " &")
