summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKai Huuhko <kai.huuhko@gmail.com>2015-03-30 15:39:15 +0300
committerKai Huuhko <kai.huuhko@gmail.com>2015-03-30 15:40:33 +0300
commit26bfed0a85135415641b0d9335c33894b5a20d7d (patch)
tree15ce59c6e4e89960748da42258b912cabff2138a
parent078f35dda33f82c58714cd697bc655868f68d22f (diff)
Add setup script, desktop file, and update bin scriptv0.1.0
-rw-r--r--.gitignore1
-rw-r--r--README.md6
-rwxr-xr-xbin/lekha31
-rw-r--r--lekha.desktop11
-rw-r--r--lekha/app.py5
-rwxr-xr-xsetup.py28
6 files changed, 58 insertions, 24 deletions
diff --git a/.gitignore b/.gitignore
index 78ec7b1..3e6c432 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,3 @@
1__pycache__/ 1__pycache__/
2*.py[co] 2*.py[co]
3build/
diff --git a/README.md b/README.md
index d99a960..42b2294 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,12 @@
1Requirements: 1Requirements:
2 2
3 - >=python-efl-1.14.0 3 - >=python-efl-1.13.99
4 - PyPDF2 4 - PyPDF2
5 - pyxdg 5 - pyxdg
6 6
7Test run from top directory: 7Install:
8 8
9 python -m lekha.app [pdf ...] 9 (sudo) python setup.py install
10 10
11 11
12![screenshot](https://www.enlightenment.org/ss/e-55107cddb2ba83.22412110.jpg "Screenshot") 12![screenshot](https://www.enlightenment.org/ss/e-55107cddb2ba83.22412110.jpg "Screenshot")
diff --git a/bin/lekha b/bin/lekha
index aa6afb6..0b83efb 100755
--- a/bin/lekha
+++ b/bin/lekha
@@ -28,11 +28,11 @@ from xdg import BaseDirectory
28import efl.elementary as elm 28import efl.elementary as elm
29import efl.evas as evas 29import efl.evas as evas
30 30
31from lekha import AppWindow 31from lekha.app import AppWindow
32 32
33parser = argparse.ArgumentParser(description="Presenter of writings") 33parser = argparse.ArgumentParser(description="Presenter of writings")
34parser.add_argument( 34parser.add_argument(
35 'documents', metavar='pdf', type=str, nargs='+', 35 'documents', metavar='pdf', type=str, nargs='*',
36 help='documents you may want to display') 36 help='documents you may want to display')
37args = parser.parse_args() 37args = parser.parse_args()
38 38
@@ -46,14 +46,14 @@ efl_log.addHandler(handler)
46 46
47log = logging.getLogger("lekha") 47log = logging.getLogger("lekha")
48log.addHandler(handler) 48log.addHandler(handler)
49log.setLevel(logging.ERROR) 49log.setLevel(logging.WARN)
50 50
51evas.init() 51evas.init()
52elm.init() 52elm.init()
53 53
54elm.policy_set(elm.ELM_POLICY_QUIT, elm.ELM_POLICY_QUIT_LAST_WINDOW_CLOSED) 54elm.policy_set(elm.ELM_POLICY_QUIT, elm.ELM_POLICY_QUIT_LAST_WINDOW_CLOSED)
55 55
56docs_pos = {} 56doc_specs = {}
57 57
58cfg_base_path = BaseDirectory.save_config_path("lekha") 58cfg_base_path = BaseDirectory.save_config_path("lekha")
59cfg_file_path = os.path.join(cfg_base_path, "document_positions") 59cfg_file_path = os.path.join(cfg_base_path, "document_positions")
@@ -66,36 +66,29 @@ if not os.path.exists(cfg_file_path):
66 66
67with open(cfg_file_path, "r") as fp: 67with open(cfg_file_path, "r") as fp:
68 try: 68 try:
69 docs_pos = json.load(fp) 69 doc_specs = json.load(fp)
70 except Exception: 70 except Exception:
71 log.info("document positions could not be restored") 71 log.info("document positions could not be restored")
72 72
73app = AppWindow() 73app = AppWindow(doc_specs)
74 74
75docs = [] 75docs = []
76 76
77for doc_path in args.documents: 77for doc_path in args.documents:
78 try: 78 app.document_open(doc_path)
79 doc_zoom, doc_pos = docs_pos[doc_path] 79
80 assert isinstance(doc_zoom, float), "zoom is not float" 80app.show()
81 assert isinstance(doc_pos, list), "pos is not tuple"
82 assert len(doc_pos) == 4, "pos len is not 4"
83 except Exception as e:
84 log.info("document zoom and position could not be restored because: %r", e)
85 doc_pos = (0, 0, 0, 0)
86 doc_zoom = 1.0
87 docs.append(app.document_open(doc_path, doc_zoom, doc_pos))
88 81
89elm.run() 82elm.run()
90 83
91for d in docs: 84for d in app.docs:
92 path = d.doc_path 85 path = d.doc_path
93 zoom = d.zoom 86 zoom = d.zoom
94 pos = d.doc_pos 87 pos = d.doc_pos
95 docs_pos[path] = (zoom, pos) 88 doc_specs[path] = (zoom, pos)
96 89
97with open(cfg_file_path, "w") as fp: 90with open(cfg_file_path, "w") as fp:
98 json.dump(docs_pos, fp, indent=4, separators=(',', ': ')) 91 json.dump(doc_specs, fp, indent=4, separators=(',', ': '))
99 92
100elm.shutdown() 93elm.shutdown()
101evas.shutdown() 94evas.shutdown()
diff --git a/lekha.desktop b/lekha.desktop
new file mode 100644
index 0000000..f0501fe
--- /dev/null
+++ b/lekha.desktop
@@ -0,0 +1,11 @@
1[Desktop Entry]
2Name=Lekha
3GenericName=PDF Viewer
4Comment=A simple PDF viewer
5Exec=lekha
6Icon=accessories-document-viewer
7Terminal=false
8Type=Application
9Categories=Office;Viewer;X-EFL;
10Actions=Window;Document;
11StartupWMClass=lekha
diff --git a/lekha/app.py b/lekha/app.py
index 81aa117..2b8a526 100644
--- a/lekha/app.py
+++ b/lekha/app.py
@@ -67,6 +67,8 @@ from xdg import BaseDirectory
67 67
68from .tabbedbox import Tabs, Tab 68from .tabbedbox import Tabs, Tab
69 69
70log = logging.getLogger("lekha")
71
70 72
71class AppWindow(StandardWindow): 73class AppWindow(StandardWindow):
72 74
@@ -737,9 +739,8 @@ if __name__ == "__main__":
737 efl_log = logging.getLogger("efl") 739 efl_log = logging.getLogger("efl")
738 efl_log.addHandler(handler) 740 efl_log.addHandler(handler)
739 741
740 log = logging.getLogger("lekha")
741 log.addHandler(handler) 742 log.addHandler(handler)
742 log.setLevel(logging.WARN) 743 log.setLevel(logging.DEBUG)
743 744
744 evas.init() 745 evas.init()
745 elm.init() 746 elm.init()
diff --git a/setup.py b/setup.py
new file mode 100755
index 0000000..70c5be0
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,28 @@
1from distutils.core import setup
2
3setup(
4 name='Lekha',
5 description='A simple PDF viewer',
6 version="0.1.0",
7 author='Kai Huuhko',
8 author_email='kai.huuhko@gmail.com',
9 url='http://www.enlightenment.org/',
10 keywords="efl enlightenment pdf",
11 classifiers=[
12 'Development Status :: 3 - Alpha',
13 'Environment :: X11 Applications',
14 'Intended Audience :: End Users/Desktop',
15 'License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)',
16 'Operating System :: POSIX',
17 'Programming Language :: Python',
18 'Topic :: Other/Nonlisted Topic',
19 ],
20 packages=['lekha'],
21 scripts=['bin/lekha'],
22 data_files=[('/usr/share/applications', ['lekha.desktop'])],
23 requires=[
24 "efl (>=1.13.99)",
25 "PyPDF2",
26 "xdg",
27 ],
28)