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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
|
#!/usr/bin/env python
# Alarm Clock is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# Alarm Clock is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with Alarm Clock; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
# Copyright 2007-2008 Tomasz Salacinski <tsalacinski@gmail.com>
try:
import gtk
import pygtk
import gtk.glade
import gobject
import shutil
import time
except:
print "Error loading GTK+ libraries. Check if they are properly"
print "installed on your system."
exit(1)
import os
class Setup:
def __init__(self):
self.gui = gtk.glade.XML('setup.glade', 'main_dialog')
self.g = self.gui.get_widget('main_dialog')
self.dic = { "delete" : self.deleteme,
"cancel_click" : self.deleteme2,
"ok_click" : self.proceed, }
self.gui.signal_autoconnect(self.dic)
self.p = "/usr/share/alarm-clock"
self.gui.get_widget('path_entry').set_text(self.p)
self.g.show()
def deleteme(self,obj,v):
if self.gui.get_widget('notebook1').get_current_page() == 1:
gtk.main_quit()
return
self.msgDialog = gtk.MessageDialog(self.g, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_YES_NO, "Are you sure you want to quit the setup program?")
self.value = self.msgDialog.run()
if self.value == gtk.RESPONSE_YES:
gtk.main_quit()
else:
self.msgDialog.destroy()
return True
def deleteme2(self,obj):
if self.gui.get_widget('notebook1').get_current_page() == 1:
gtk.main_quit()
self.deleteme(self.g, None)
def proceed(self,obj):
if self.gui.get_widget('notebook1').get_current_page() == 1:
gtk.main_quit()
return
if self.gui.get_widget('path_entry').get_text() == "":
self.msgDialog = gtk.MessageDialog(self.g, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "Wrong path entered.")
self.msgDialog.run()
self.msgDialog.destroy()
return
#try:
try:
os.mkdir(self.gui.get_widget('path_entry').get_text())
except:
pass
try:
os.mkdir(self.gui.get_widget('path_entry').get_text() + "/gfx")
except:
pass
try:
os.mkdir(self.gui.get_widget('path_entry').get_text() + "/sound")
except:
pass
shutil.copyfile('gfx/alarm-clock.svg', self.gui.get_widget('path_entry').get_text() + '/gfx/alarm-clock.svg')
shutil.copyfile('gfx/alarm-clock.svg', '/usr/share/pixmaps/alarm-clock.svg')
shutil.copyfile('gfx/alarm-caution.svg', self.gui.get_widget('path_entry').get_text() + '/gfx/alarm-caution.svg')
shutil.copyfile('main.glade', self.gui.get_widget('path_entry').get_text() + '/main.glade')
shutil.copyfile('pyalarm.py', self.gui.get_widget('path_entry').get_text() + '/pyalarm.py')
shutil.copyfile('alarm-clock.py', self.gui.get_widget('path_entry').get_text() + '/alarm-clock.py')
shutil.copyfile('sound/ring.wav', self.gui.get_widget('path_entry').get_text() + '/sound/ring.wav')
shutil.copyfile('alarm-clock.desktop', "/usr/share/applications/alarm-clock.desktop")
#except:
# msgDialog = gtk.MessageDialog(None, 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "Error!")
# msgDialog.format_secondary_text("Error installing the program. You need to be root in order to install alarm-clock.")
# msgDialog.run()
# msgDialog.destroy()
#Installing language files
## POLISH ##
try:
os.system('msgfmt po/pl.po -o po/pyalarm.mo')
shutil.copyfile('po/pyalarm.mo', '/usr/share/locale/pl/LC_MESSAGES/pyalarm.mo')
os.system('rm -fr po/pyalarm.mo')
except:
msgDialog = gtk.MessageDialog(None, 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "Error!")
msgDialog.format_secondary_text("Setup wizard is unable to install POLISH translation. Please report bug to tsalacinski@gmail.com.")
msgDialog.run()
msgDialog.destroy()
## SERBIAN @ CYRILIC ##
try:
os.system('msgfmt po/sr.po -o po/pyalarm.mo')
shutil.copyfile('po/pyalarm.mo', '/usr/share/locale/sr/LC_MESSAGES/pyalarm.mo')
os.system('rm -fr po/pyalarm.mo')
except:
msgDialog = gtk.MessageDialog(None, 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "Error!")
msgDialog.format_secondary_text("Setup wizard is unable to install SERBIAN translation. Please report bug to tsalacinski@gmail.com.")
msgDialog.run()
msgDialog.destroy()
## SERBIAN @ LATIN ##
try:
os.system('msgfmt po/sr@latin.po -o po/pyalarm.mo')
shutil.copyfile('po/pyalarm.mo', '/usr/share/locale/sr@Latn/LC_MESSAGES/pyalarm.mo')
os.system('rm -fr po/pyalarm.mo')
except:
msgDialog = gtk.MessageDialog(None, 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "Error!")
msgDialog.format_secondary_text("Setup wizard is unable to install SERBIAN LATIN translation. Please report bug to tsalacinski@gmail.com.")
msgDialog.run()
msgDialog.destroy()
## GERMAN ##
try:
os.system('msgfmt po/de_DE.po -o po/pyalarm.mo')
shutil.copyfile('po/pyalarm.mo', '/usr/share/locale/de/LC_MESSAGES/pyalarm.mo')
os.system('rm -fr po/pyalarm.mo')
except:
msgDialog = gtk.MessageDialog(None, 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "Error!")
msgDialog.format_secondary_text("Setup wizard is unable to install GERMAN translation. Please report bug to tsalacinski@gmail.com.")
msgDialog.run()
msgDialog.destroy()
## SPANISH ##
try:
os.system('msgfmt po/es.po -o po/pyalarm.mo')
shutil.copyfile('po/pyalarm.mo', '/usr/share/locale/es/LC_MESSAGES/pyalarm.mo')
os.system('rm -fr po/pyalarm.mo')
except:
msgDialog = gtk.MessageDialog(None, 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, "Error!")
msgDialog.format_secondary_text("Setup wizard is unable to install SPANISH translation. Please report bug to tsalacinski@gmail.com.")
msgDialog.run()
msgDialog.destroy()
self.d = file("/usr/bin/alarm-clock", "w")
self.d.write ("cd %s\n" % self.gui.get_widget('path_entry').get_text())
self.d.write ("./alarm-clock.py $1\n")
self.d.close()
os.system('chmod +x /usr/bin/alarm-clock')
os.system('chmod +x /usr/share/alarm-clock/alarm-clock.py')
self.gui.get_widget('cancelbutton1').hide()
self.gui.get_widget('notebook1').set_current_page(1)
if __name__ == '__main__':
Setup()
gtk.main()
|