-
Notifications
You must be signed in to change notification settings - Fork 0
/
about.py
99 lines (67 loc) · 2.32 KB
/
about.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env python
"""
A GTK about dialog for the program. This file is where all the project meta-data
should be defined!
"""
NAME = "Perentie"
# VERSION is defined by the VERSION file.
COMMENTS = """
A simple debug monitor for processors and microcontrollers.
This tool is designed to be a teaching and learning aid rather than a fully
fledged debugging platform. This tool has been written based on the ideas of the
Komodo Manchester Debugger (KMD) and aims to be backwards-compatible.
"""
WEBSITE = "http://www.cs.manchester.ac.uk/"
AUTHORS = [
"Jonathan Heathcote <[email protected]>"
]
COPYRIGHT = "Copyright 2015, The University of Manchester"
# LICENSE is defined by the LICENSE file.
################################################################################
import os, glob
import gtk
def _path(*path_parts):
"""
Get the path of the given file in the root of the program.
"""
return os.path.join(os.path.dirname(__file__), *path_parts)
def _last_line(s):
"""
Get the last line of a string.
"""
return s.split("\n")[-1].strip()
def _reflow(s):
"""
Reflow a string so that all text in a paragraph (denoted by text on
consecutive lines) is merged onto one line.
"""
return s.strip().replace("\n\n", "<br>").replace("\n", " ").replace("<br>","\n\n")
################################################################################
# Defined in version file
VERSION = _last_line(open(_path("VERSION"),"r").read().strip())
# Include from file.
LICENSE = open(_path("LICENSE"),"r").read()
# Load from icon file
ICON = gtk.gdk.pixbuf_new_from_file(_path("logo", "icon_64.png"))
################################################################################
class AboutDialog(gtk.AboutDialog):
def __init__(self):
gtk.AboutDialog.__init__(self)
self.set_name(NAME)
self.set_version(VERSION)
self.set_copyright(COPYRIGHT)
self.set_comments(_reflow(COMMENTS))
self.set_license(LICENSE)
self.set_website(WEBSITE)
self.set_authors(AUTHORS)
self.set_logo(ICON)
def get_icon_list():
"""
Returns a list of pixbufs each containing different sizes of the icon for use
by window.set_icon_list.
"""
icons = []
icon_paths = glob.glob(os.path.join(os.path.dirname(__file__), "logo", "icon_*.png"))
for icon_path in icon_paths:
icons.append(gtk.gdk.pixbuf_new_from_file(icon_path))
return icons