67
69
locale.setlocale(locale.LC_ALL, '')
68
70
gettext.textdomain('pyalarm')
69
71
gtk.glade.textdomain('pyalarm')
70
gettext.bindtextdomain('pyalarm', "/usr/share/locale")
71
gtk.glade.bindtextdomain('pyalarm', "/usr/share/locale")
72
gettext.bindtextdomain('pyalarm', "%s/locale" % os.path.split(os.getcwd())[0])
73
gtk.glade.bindtextdomain('pyalarm', "%s/locale" % os.path.split(os.getcwd())[0])
74
gettext.bindtextdomain('pyalarm', )
789
799
def StopTheSound(self,obj):
790
800
MainWindowGlade.get_widget('stop_sound').set_sensitive(False)
791
801
player.set_state(gst.STATE_NULL)
802
player.set_property("volume", 0)
795
805
def StatusClicked(self,obj):
850
860
def ShowAboutDialog(self,obj):
851
861
self.AboutDialog = gtk.AboutDialog()
852
862
self.AboutDialog.set_name (_("Alarm Clock"))
853
self.AboutDialog.set_version('0.9.4')
863
self.AboutDialog.set_version(version.get_version())
854
864
self.AboutDialog.set_copyright(_("(c) 2008 Tomasz Sałaciński\n"
855
865
"<tsalacinski@gmail.com>\n"
902
912
self.fc = file(os.getenv("HOME") + "/.config/Alarm-Clock/configuration", "w")
903
913
print >> self.fc, [MainWindow.get_position(), MainWindow.get_size()]
915
player.set_state(gst.STATE_NULL)
907
918
def ChangeAlarmPrefs(self,obj):
2073
2084
self.SchedSignals = { "add_exception" : self.AddExceptionDialog,
2074
2085
"remove_exception" : self.RemoveExceptionDialog,
2075
2086
"load_exc_click" : self.LoadExceptionList,
2076
"save_exc_click" : self.SaveExceptionList, }
2087
"save_exc_click" : self.SaveExceptionList,
2088
"SelectAllWeekdays" : self.SelectAllWeekdays,
2089
"DeselectAllWeekdays" : self.DeselectAllWeekdays,
2090
"SelectAllMonths" : self.SelectAllMoths,
2091
"DeselectAllMonths" : self.DeselectAllMonhts, }
2078
2093
self.ScheduleProps.signal_autoconnect(self.SchedSignals)
2090
2105
self.SchedulePropsWidget.destroy()
2109
def SelectAllWeekdays(self, Button):
2110
for x in range(1,8):
2111
self.Deselect = self.ScheduleProps.get_widget("w%i" % x)
2112
self.Deselect.set_active(True)
2114
def DeselectAllWeekdays(self, Button):
2115
for x in range(1,8):
2116
self.Deselect = self.ScheduleProps.get_widget("w%i" % x)
2117
self.Deselect.set_active(False)
2119
def SelectAllMoths(self, Button):
2120
for x in range(1,13):
2121
self.Deselect = self.ScheduleProps.get_widget("m%i" % x)
2122
self.Deselect.set_active(True)
2124
def DeselectAllMonhts(self, Button):
2125
for x in range(1,13):
2126
self.Deselect = self.ScheduleProps.get_widget("m%i" % x)
2127
self.Deselect.set_active(False)
2092
2129
def AlarmPrefs(self):
2093
2130
self.AlarmProps = gtk.glade.XML('main.glade', 'alarm_props_dialog')
2094
2131
self.AlarmPropsWidget = self.AlarmProps.get_widget('alarm_props_dialog')
2926
2964
self.spac = outvol - initvol
2929
self.change = self.spac / self.sec / 100
2967
self.change = self.spac / self.sec / 1000
2935
self.volume_current = self.ivol / 100
2973
self.volume_current = self.ivol / 1000
2936
2974
player.set_property("volume", self.volume_current)
2937
2975
player.set_state(gst.STATE_PLAYING)
2978
while player.get_state()[1] != gst.STATE_NULL:
2979
isNull = player.get_state()[1]
2980
if isNull == gst.STATE_NULL:
2981
gtk.gdk.threads_enter()
2982
player.set_property("volume", 0)
2983
self.volume_current = 0
2985
self.b.set_sensitive(False)
2986
gtk.gdk.threads_leave()
2941
2990
if self.voldir == 0:
2942
2991
self.volume_current = self.volume_current - self.change
2943
2992
if self.voldir == 1:
2944
2993
self.volume_current = self.volume_current + self.change
2945
isNull = player.get_state()[1]
2946
if isNull == gst.STATE_NULL:
2947
gtk.gdk.threads_enter()
2948
self.b.set_sensitive(False)
2949
gtk.gdk.threads_leave()
2952
2995
player.set_property("volume", self.volume_current)
2953
2996
self.count = self.count + 1
2957
3000
def on_message2(self, bus, message):
2958
3001
t = message.type
2988
3031
self.CheckOldAlarms()
2993
self.CheckTodayBirthdays()
2994
self.CheckTodayAlarms()
2998
self.CheckOldAlarms()
3006
self.CheckOldAlarms()
3009
self.File = file(os.getenv("HOME") + "/.config/Alarm-Clock/lock", "w")
3010
self.File.write("%s/%s/%s %s:%s:%s" % (datetime.datetime.now().year, datetime.datetime.now().month, datetime.datetime.now().day, datetime.datetime.now().hour, datetime.datetime.now().minute, datetime.datetime.now().second))
3014
self.CheckOldAlarms()
3016
gtk.gdk.threads_enter()
3017
self.status.push(0, time.strftime(_("Current time: %c")))
3018
gtk.gdk.threads_leave()
3019
for tup in self.today:
3020
if tup[0] == time.localtime().tm_hour and tup[1] == time.localtime().tm_min and time.localtime().tm_sec == 0:
3021
self.s = file(os.getenv("HOME") + "/.config/Alarm-Clock/alarms")
3022
self.bb = self.s.readlines()
3037
self.CheckTodayBirthdays()
3038
self.CheckTodayAlarms()
3042
self.CheckOldAlarms()
3050
self.CheckOldAlarms()
3053
self.File = file(os.getenv("HOME") + "/.config/Alarm-Clock/lock", "w")
3054
self.File.write("%s/%s/%s %s:%s:%s" % (datetime.datetime.now().year, datetime.datetime.now().month, datetime.datetime.now().day, datetime.datetime.now().hour, datetime.datetime.now().minute, datetime.datetime.now().second))
3058
self.CheckOldAlarms()
3060
gtk.gdk.threads_enter()
3061
self.status.push(0, time.strftime(_("Current time: %c")))
3062
gtk.gdk.threads_leave()
3063
for tup in self.today:
3064
if tup[0] == time.localtime().tm_hour and tup[1] == time.localtime().tm_min and time.localtime().tm_sec == 0:
3065
self.s = file(os.getenv("HOME") + "/.config/Alarm-Clock/alarms")
3066
self.bb = self.s.readlines()
3067
gtk.gdk.threads_enter()
3068
StartGUI().RunAlarm(eval(self.bb[tup[2]]))
3070
gtk.gdk.threads_leave()
3073
if time.localtime().tm_hour == 0 and time.localtime().tm_min == 0 and time.localtime().tm_sec < 1 and self.RefreshList == False:
3074
self.RefreshList = True
3076
if time.localtime().tm_hour == 0 and time.localtime().tm_min == 0 and time.localtime().tm_sec > 1 and self.RefreshList == True:
3077
self.RefreshList = False
3079
self.CheckOldAlarms()
3081
if self.RefreshList == True:
3023
3082
gtk.gdk.threads_enter()
3024
StartGUI().RunAlarm(eval(self.bb[tup[2]]))
3083
self.LoadConfigFiles()
3025
3084
gtk.gdk.threads_leave()
3027
if time.localtime().tm_hour == 0 and time.localtime().tm_min == 0 and time.localtime().tm_sec < 1 and self.RefreshList == False:
3028
self.RefreshList = True
3030
if time.localtime().tm_hour == 0 and time.localtime().tm_min == 0 and time.localtime().tm_sec > 1 and self.RefreshList == True:
3031
self.RefreshList = False
3033
self.CheckOldAlarms()
3035
if self.RefreshList == True:
3036
gtk.gdk.threads_enter()
3037
self.LoadConfigFiles()
3038
gtk.gdk.threads_leave()
3044
self.CheckOldAlarms()
3085
self.RefreshList = False
3090
self.CheckOldAlarms()
3046
3095
def CheckEmail(self):
3053
3101
def CheckOldAlarms(self):
3054
gtk.gdk.threads_enter()
3056
self.AlFile = file(os.getenv("HOME") + "/.config/Alarm-Clock/alarms", "r")
3060
if self.Removed == True:
3061
self.RefreshList = True
3062
self.Removed = False
3065
self.Data = self.AlFile.readlines()
3069
for line in self.Data:
3070
self.OldLine = eval(line)
3072
if self.OldLine[2] == 1:
3073
self.Cnt = self.Cnt + 1
3078
self.Date = self.OldLine[3]
3079
self.Time = self.OldLine[1]
3081
self.date_data = re.search('(\d+)/(\d+)/(\d+)', self.Date)
3082
self.oy = int(self.date_data.group(1))
3083
self.om = int(self.date_data.group(2)) + 1
3084
self.od = int(self.date_data.group(3))
3085
self.time_data = re.search('(\d+):(\d+)', self.Time)
3086
self.oh = int(self.time_data.group(1))
3087
self.omin = int(self.time_data.group(2))
3089
self.DateOld = datetime.datetime(self.oy,self.om,self.od,self.oh,self.omin,0)
3091
self.CurrentDate = datetime.datetime.today()
3093
self.Diff = self.CurrentDate - self.DateOld
3095
if self.Diff.days > 0:
3096
self.RemoveOldAlarm(self.Cnt)
3097
self.Cnt = self.Cnt + 1
3101
if self.Diff.days == 0:
3102
if self.Diff.seconds > 0:
3103
gtk.gdk.threads_enter()
3105
self.AlFile = file(os.getenv("HOME") + "/.config/Alarm-Clock/alarms", "r")
3109
if self.Removed == True:
3110
self.RefreshList = True
3111
self.Removed = False
3114
self.Data = self.AlFile.readlines()
3118
for line in self.Data:
3119
self.OldLine = eval(line)
3121
if self.OldLine[2] == 1:
3122
self.Cnt = self.Cnt + 1
3127
self.Date = self.OldLine[3]
3128
self.Time = self.OldLine[1]
3130
self.date_data = re.search('(\d+)/(\d+)/(\d+)', self.Date)
3131
self.oy = int(self.date_data.group(1))
3132
self.om = int(self.date_data.group(2)) + 1
3133
self.od = int(self.date_data.group(3))
3134
self.time_data = re.search('(\d+):(\d+)', self.Time)
3135
self.oh = int(self.time_data.group(1))
3136
self.omin = int(self.time_data.group(2))
3138
self.DateOld = datetime.datetime(self.oy,self.om,self.od,self.oh,self.omin,0)
3140
self.CurrentDate = datetime.datetime.today()
3142
self.Diff = self.CurrentDate - self.DateOld
3144
if self.Diff.days > 0:
3103
3145
self.RemoveOldAlarm(self.Cnt)
3104
3146
self.Cnt = self.Cnt + 1
3105
3147
self.Removed = True
3150
if self.Diff.days == 0:
3151
if self.Diff.seconds > 0:
3152
self.RemoveOldAlarm(self.Cnt)
3153
self.Cnt = self.Cnt + 1
3109
self.Cnt = self.Cnt + 1
3110
gtk.gdk.threads_leave()
3158
self.Cnt = self.Cnt + 1
3159
gtk.gdk.threads_leave()
3112
3163
def RemoveOldAlarm(self,no):