Switch to unified view

a/src/desktop/hotrecoll.py b/src/desktop/hotrecoll.py
...
...
11
11
12
import gtk
12
import gtk
13
import wnck
13
import wnck
14
import os
14
import os
15
import sys
15
import sys
16
from optparse import OptionParser
16
17
17
def main():
18
def main():
18
    # We try to establish a timestamp for the calls to activate(), but
19
    parser = OptionParser()
19
    # usually fail (the event_peek() calls return None). 
20
    parser.add_option("-m", "--move-away", action="store_true", default=False,
20
    #
21
                      dest="clear_workspace", 
21
    # Try to find a nice default value. The x server timestamp is
22
                      help="iconify to other workspace to avoid crowding panel")
22
    # millisecond from last reset, it wraps around in 49 days, half
23
    (options, args) = parser.parse_args()
23
    # the space is set aside for the past So a value just below 2**31
24
24
    # should be most recent if the server is not too old?
25
    # The right way to do this would probably be to create an unmapped
26
    # window and arrange to receive some real event.
27
    timestamp = 2**31 - 1
28
    screen = wnck.screen_get_default()
25
    screen = wnck.screen_get_default()
29
    while gtk.events_pending():
26
    while gtk.events_pending():
30
        event = gtk.gdk.event_peek()
31
        if event != None and event.get_time() != 0:
32
            timestamp = event.get_time()
33
        gtk.main_iteration()
27
        gtk.main_iteration()
34
28
35
    recollMain = ""
29
    recollMain = ""
36
    recollwins = [];
30
    recollwins = [];
37
    for window in screen.get_windows():
31
    for window in screen.get_windows():
38
        if window.get_class_group().get_name() == "Recoll":
32
        if window.get_class_group().get_name() == "Recoll":
39
            # print "win name: [%s], class: [%s]" % \
40
            #      (window.get_name(), window.get_class_group().get_name())
41
            if window.get_name() == "Recoll":
33
            if window.get_name() == "Recoll":
42
                recollMain = window
34
                recollMain = window
43
            recollwins.append(window)
35
            recollwins.append(window)
44
36
45
    if not recollMain:
37
    if not recollMain:
46
        os.system("recoll&")
38
        os.system("recoll&")
47
        sys.exit(0)
39
        sys.exit(0)
48
40
49
    # Check the main window state, and either activate or minimize all
41
    # Check the main window state, and either activate or minimize all
42
    # recoll windows.
50
    workspace = screen.get_active_workspace()
43
    workspace = screen.get_active_workspace()
51
    if not recollMain.is_visible_on_workspace(workspace):
44
    if not recollMain.is_visible_on_workspace(workspace):
52
        for win in recollwins:
45
        for win in recollwins:
53
            win.move_to_workspace(workspace)
46
            win.move_to_workspace(workspace)
54
            win.activate(timestamp)
47
            if win != recollMain:
48
                win.unminimize(gtk.get_current_event_time())
49
        recollMain.activate(gtk.get_current_event_time())
55
    else:
50
    else:
51
        otherworkspace = None
52
        if options.clear_workspace:
53
            # We try to minimize to another workspace
54
            wkspcs = screen.get_workspaces()
55
            for wkspc in wkspcs:
56
                if wkspc.get_number() != workspace.get_number():
57
                    otherworkspace = wkspc
58
                    break
56
        for win in recollwins:
59
        for win in recollwins:
60
            if otherworkspace:
61
                win.move_to_workspace(otherworkspace)
57
            win.minimize()
62
            win.minimize()
58
63
59
if __name__ == '__main__':
64
if __name__ == '__main__':
60
  main()
65
  main()
61
  
66