For anybody with a large screen winsplit revolution is fantastic
for organizing windows http://reptils.free.fr/ (win32 only though)

Basically <Ctrl><Alt><Numpad> warps and resizes your windows
so they're tiled with minimum effort.

I've attached a first pass at a unix version (Just run from cmd line)
and would appreciate any hints for the TODO items.

1) get the usable destkop area, minus dock area
2) why does wnck.set_geometry not work for gnome-terminal?
3) How can I get the current gdk time? (0 gives a warning)

Stephen.
#! /usr/bin/env python

import wnck
import gtk
import gtk.gdk as gdk
import deskbar.core.keybinder as keybinder

wnck_WINDOW_CHANGE_ALL = (
    wnck.WINDOW_CHANGE_X|wnck.WINDOW_CHANGE_Y|wnck.WINDOW_CHANGE_WIDTH|wnck.WINDOW_CHANGE_HEIGHT)

def handle(num):
    screen = wnck.screen_get_default()
    screen.force_update()
    workspace = screen.get_active_workspace()
    window = screen.get_active_window()
    # TODO - get usable desktop size instead of hardcoding
    dx,dy, dw,dh = 0,25, workspace.get_width(), workspace.get_height()-25

    if num in (1,3,7,9): w,h = dw/2, dh/2
    elif num in (4,6):   w,h = dw/2, dh
    elif num in (8,2):   w,h = dw,   dh/2
    elif num in (5,):    w,h = dw,   dh

    if num in (1,4,7,2,5,8): x = 0
    else:                    x = dw/2

    if num in (7,8,9,4,5,6): y = 0
    else:                    y = dh/2

    # TODO - set_geometry does not work for gnome-terminal windows
    # or rather, it seems to work on the tabbed contents instead.
    print "%i pressed\nSet geometry of '%s' to %ix%i+%i+%i" % (num, window.get_name(), w,h,x,y)
    window.set_geometry(gdk.GRAVITY_NORTH_WEST, wnck_WINDOW_CHANGE_ALL, dx+x,dy+y,w,h)
    window.activate(0) # TODO - current gtk time

print """Linsplit started:
Use <Ctrl><Alt><Numpad> to move the active window
Use <Ctrl><Alt><NumpadEnter> to quit"""

for i in range(1,10):
    keybinder.tomboy_keybinder_bind( "<Ctrl><Alt>KP_%i"%i, lambda i=i: handle(i) )
keybinder.tomboy_keybinder_bind("<Ctrl><Alt>KP_Enter", gtk.main_quit)
gtk.main()

_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://www.async.com.br/faq/pygtk/

Reply via email to