This repository has been archived by the owner on Aug 2, 2022. It is now read-only.
/
liblookit.py
69 lines (55 loc) · 1.73 KB
/
liblookit.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import os
import pynotify
import time
import about
import lookitconfig
import preferences
import screencapper
import selector
import uploader
XDG_CACHE_HOME = os.environ.get('XDG_CACHE_HOME', os.path.expanduser('~/.cache'))
CONFIG_FILE = os.path.expanduser('~/.config/lookit.conf')
LOG_FILE = os.path.join(XDG_CACHE_HOME, 'lookit.log')
VERSION = (1, 1, 0)
VERSION_STR = '.'.join(str(num) for num in VERSION)
def enum(*sequential, **named):
enums = dict(zip(sequential, range(len(sequential))), **named)
return type('Enum', (), enums)
def str_to_tuple(s):
return tuple(int(x) for x in s.split('.'))
def get_data_dir():
p = os.path.abspath(__file__)
p = os.path.dirname(p)
p = os.path.join(p, 'data')
return p
def show_notification(title, message):
pynotify.init('Lookit')
n = pynotify.Notification(title, message, 'lookit')
n.set_hint_string('append', '')
n.show()
def upload_file(filename, existing_file=False):
uploader.upload_file(filename, existing_file)
def handle_delay():
delay_value = int(lookitconfig.quickget('General', 'delay'))
print delay_value
time.sleep(delay_value)
def do_capture_area():
handle_delay()
selection = selector.Selector().get_selection()
if selection is None:
show_notification('Lookit', 'Selection cancelled')
return
pb = screencapper.capture_selection(selection)
uploader.upload_pixbuf(pb)
def do_capture_window():
handle_delay()
pb = screencapper.capture_active_window()
uploader.upload_pixbuf(pb)
def do_capture_screen():
handle_delay()
pb = screencapper.capture_screen()
uploader.upload_pixbuf(pb)
def do_preferences():
preferences.PrefDialog().run()
def do_about():
about.AboutDialog().run()