2
2
# -*- coding: utf-8 -*-
3
from gi.repository import Gtk, GObject
4
from gi.repository import AppIndicator3 as AI
5
from prayertime import *
11
from prayertime import *
12
from HijriCal import *
14
class IndicatorPrayerTimes():
14
from gi.repository import Notify
17
class IndicatorPrayerTimes:
15
18
def __init__(self):
17
self.Indicator = appindicator.Indicator("indicator-prayer-times","indicator-prayer-times",appindicator.CATEGORY_APPLICATION_STATUS)
18
self.Indicator.set_status(appindicator.STATUS_ACTIVE)
20
self.Indicator = AI.Indicator.new("indicator-prayer-times","indicator-prayer-times",
21
AI.IndicatorCategory.APPLICATION_STATUS)
22
self.Indicator.set_status(AI.IndicatorStatus.ACTIVE)
19
23
self.Indicator.set_icon(self.Icon())
24
#setup Settings Window
25
self.configer = Configer()
21
self.Menu = gtk.Menu()
27
self.Menu = Gtk.Menu()
23
29
self.Hijri()# Fills Menu with Hijri Date
24
self.Menu.append(gtk.SeparatorMenuItem())
30
self.Menu.append(Gtk.SeparatorMenuItem())
26
32
self.Times()# Fills Menu with Prayer Times
27
self.Menu.append(gtk.SeparatorMenuItem())
33
self.Menu.append(Gtk.SeparatorMenuItem())
29
self.NextPrayerItem = gtk.MenuItem('Next Prayer')# Next PrayerTime's Item
35
self.NextPrayerItem = Gtk.MenuItem('Next Prayer')# Next PrayerTime's Item
30
36
self.Menu.append(self.NextPrayerItem)
31
self.Menu.append(gtk.SeparatorMenuItem())
37
self.Menu.append(Gtk.SeparatorMenuItem())
34
AboutItem = gtk.MenuItem('About')
40
AboutItem = Gtk.MenuItem('About')
35
41
self.Menu.append(AboutItem)
36
42
AboutItem.connect('activate',self.AboutDialog, None)
38
SettingsItem = gtk.MenuItem('Settings')
44
SettingsItem = Gtk.MenuItem('Settings')
39
45
self.Menu.append(SettingsItem)
40
SettingsItem.connect('activate',self.Settings, None)
46
#SettingsItem.connect('activate',self.Settings, None)
47
SettingsItem.connect('activate', self.ShowSettings, None)
42
ExitItem = gtk.MenuItem('Quit')
49
ExitItem = Gtk.MenuItem('Quit')
43
50
self.Menu.append(ExitItem)
44
ExitItem.connect('activate',gtk.main_quit, None)
51
ExitItem.connect('activate',Gtk.main_quit, None)
46
53
self.Loop()# Run Application's Loop
47
54
self.Menu.show_all()# Show All Items
48
55
self.Indicator.set_menu(self.Menu)# Assign Menu To Indicator
49
self.GobjectLoop = gobject.timeout_add_seconds(1,self.Loop)# Run Loop
56
self.GobjectLoop = GObject.timeout_add_seconds(1,self.Loop)# Run Loop
52
59
global NextPrayerDT
120
127
self.NextPrayerItem.set_label("Previous Prayer was %s" % (PrevPrayer))
121
128
for time in PrayerTimes:
122
129
if time == TenMinutes:
123
pynotify.init("Indicator Prayer Times")
124
Notif=pynotify.Notification('Get Ready','10 minutes left until the %s prayer.' %(NextPrayer), self.Icon())
130
Notify.init("Indicator Prayer Times")
131
Notif = Notify.Notification.new('Get Ready','10 minutes left until the %s prayer.' %(NextPrayer), self.Icon())
127
pynotify.init("Indicator Prayer Times")
128
Notif=pynotify.Notification('Prayer time for %s' % CurrentPrayer,"It's time for the %s prayer." %(CurrentPrayer), self.Icon())
134
Notify.init("Indicator Prayer Times")
135
Notif=Notify.Notification.new('Prayer time for %s' % CurrentPrayer,"It's time for the %s prayer." %(CurrentPrayer), self.Icon())
157
164
def Times(self):# Fills Menu With Prayer Times
158
165
PT = Prayertime(self.GetSettings(2),self.GetSettings(1), self.GetSettings(3), datetime.datetime.now().year, datetime.datetime.now().month, datetime.datetime.now().day, self.GetSettings(4), self.GetSettings(5), Season.Winter)
160
self.Menu.append(gtk.MenuItem("Prayer Times for %s" % self.GetSettings(0)))
161
self.Menu.append(gtk.SeparatorMenuItem())
162
self.Menu.append(gtk.MenuItem("Fajr %s" % self.get_times(PT.fajr_time())))
163
self.Menu.append(gtk.MenuItem("Dhuhr %s" % self.get_times(PT.zuhr_time())))
164
self.Menu.append(gtk.MenuItem("Asr %s" % self.get_times(PT.asr_time())))
165
self.Menu.append(gtk.MenuItem("Maghrib %s" % self.get_times(PT.maghrib_time())))
166
self.Menu.append(gtk.MenuItem("Isha %s" % self.get_times(PT.isha_time())))
167
self.Menu.append(Gtk.MenuItem("Prayer Times for %s" % self.GetSettings(0)))
168
self.Menu.append(Gtk.SeparatorMenuItem())
169
self.Menu.append(Gtk.MenuItem("Fajr %s" % self.get_times(PT.fajr_time())))
170
self.Menu.append(Gtk.MenuItem("Dhuhr %s" % self.get_times(PT.zuhr_time())))
171
self.Menu.append(Gtk.MenuItem("Asr %s" % self.get_times(PT.asr_time())))
172
self.Menu.append(Gtk.MenuItem("Maghrib %s" % self.get_times(PT.maghrib_time())))
173
self.Menu.append(Gtk.MenuItem("Isha %s" % self.get_times(PT.isha_time())))
167
174
def get_times(self, prayer):# If User Sets Clock Format 12hr or 24hr Return It As He Likes!
168
175
if self.GetSettings(6)=='12h':
169
176
return self.timeto12(prayer)
242
249
timezone = %s''' % (city_name,calcmthd,mazhab,clockfmt,lat,lon,tz)
243
250
config.write(Text)
253
def ShowSettings(self, widget, data):
254
self.configer.show_all()
255
self.configer.SetLayout()
245
257
def Hijri(self):# Fill Menu With Hijri Date
246
258
wd=datetime.datetime.now().strftime("%A")
254
266
h_date = '%i %s %i' % ( h_day+1, h_months[h_month-1], h_year)
256
self.Menu.append(gtk.MenuItem(wd+" "+h_date))
268
self.Menu.append(Gtk.MenuItem(wd+" "+h_date))
257
269
def AboutDialog(self,widget,data=None):# The About Dialog
258
AboutDialog = gtk.AboutDialog()
270
AboutDialog = Gtk.AboutDialog()
260
272
AboutDialog.set_program_name("Indicator Prayer Times")
261
273
AboutDialog.set_website("https://launchpad.net/indicator-prayer-times")
262
274
AboutDialog.set_website_label("Launchpad project page")
263
AboutDialog.set_authors(["Mohamed Alaa <m.alaa8@gmail.com>"])
275
AboutDialog.set_authors(["Mohamed Alaa <m.alaa8@gmail.com>","Eslam Mostafa <CsEslam@gmail.com>"])
264
276
AboutDialog.set_license('''Indicator Prayer Times, A Prayer Times displayer for Indicator Applet.
265
Copyright © 2012 Mohamed Alaa
277
Copyright © 2011-2012 Mohamed Alaa
278
Copyright © 2012 Indicator-prayer-times Developers
267
280
This program is free software: you can redistribute it and/or modify
268
281
it under the terms of the GNU General Public License as published by
277
290
You should have received a copy of the GNU General Public License
278
291
along with this program. If not, see <http://www.gnu.org/licenses/>.''')
279
AboutDialog.set_version("0.1")
292
AboutDialog.set_version("0.2")
280
293
AboutDialog.set_comments("A Prayer Times displayer for Indicator Applet.")
281
AboutDialog.set_copyright("Copyright © 2012 Mohamed Alaa")
294
AboutDialog.set_copyright("Copyright © 2011-2012 Mohamed Alaa\nCopyright © 2012 Indicator-prayer-times Developers")
282
295
AboutDialog.run()
283
296
AboutDialog.destroy()
288
301
if __name__ == '__main__':
289
302
ipm = IndicatorPrayerTimes()