~ubuntu-branches/ubuntu/oneiric/alarm-clock/oneiric

« back to all changes in this revision

Viewing changes to pyalarm.py

  • Committer: Bazaar Package Importer
  • Author(s): Marco Rodrigues
  • Date: 2008-06-10 23:16:10 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080610231610-zivb48bld7jzp4dq
Tags: 0.9.4-1
* New upstream version.
* Bump Standards-Version to 3.8.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#!/usr/bin/env python
 
2
#!coding: utf-8 -*-
2
3
 
3
4
# Alarm Clock is free software; you can redistribute it and/or modify
4
5
# it under the terms of the GNU General Public License as published by
847
848
                self.pop.popup(None, None, None, v1, v2)
848
849
 
849
850
        def ShowAboutDialog(self,obj):
850
 
                self.AboutDialog = gtk.glade.XML('main.glade', 'about_dialog').get_widget('about_dialog')
 
851
                self.AboutDialog = gtk.AboutDialog()
 
852
                self.AboutDialog.set_name (_("Alarm Clock"))
 
853
                self.AboutDialog.set_version('0.9.4')
 
854
                self.AboutDialog.set_copyright(_("(c) 2008 Tomasz Sałaciński\n"
 
855
                "<tsalacinski@gmail.com>\n"
 
856
                "\n"
 
857
                "For Kamila:)"))
 
858
                self.AboutDialog.set_icon_from_file('gfx/alarm-clock.svg')
851
859
                self.AboutDialog.set_transient_for(MainWindow)
852
 
                self.AboutDialog.set_name(_("Alarm Clock"))
853
 
                self.AboutDialog.set_version('0.9.3')
854
 
                self.AboutDialog.set_icon_from_file('gfx/alarm-clock.svg')
 
860
                self.AboutDialog.set_position(gtk.WIN_POS_CENTER_ON_PARENT)
 
861
                self.AboutDialog.set_website("http://www.alarm-clock.54.pl")
 
862
                self.Authors = [_("Programming"), "\tTomasz Sałaciński"]
 
863
                self.AboutDialog.set_authors(self.Authors)
 
864
                self.LogoPixbuf =  gtk.gdk.pixbuf_new_from_file("gfx/alarm-clock.svg")
 
865
                self.AboutDialog.set_logo(self.LogoPixbuf)
 
866
 
 
867
                self.License = """
 
868
Alarm Clock is free software; you can redistribute it and/or modify
 
869
it under the terms of the GNU General Public License as published by
 
870
the Free Software Foundation; either version 2 of the License, or
 
871
(at your option) any later version.
 
872
 
 
873
Alarm Clock is distributed in the hope that it will be useful,
 
874
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
875
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
876
GNU General Public License for more details.
 
877
 
 
878
You should have received a copy of the GNU General Public License
 
879
along with Alarm Clock; if not, write to the Free Software Foundation,
 
880
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA"""
 
881
 
 
882
                self.AboutDialog.set_license(self.License)
 
883
 
 
884
                self.Artists = ["""Alarm Clock icon come from the 
 
885
Dropline Neu! icon theme"""]
 
886
 
 
887
                self.AboutDialog.set_artists(self.Artists)
 
888
 
 
889
 
855
890
                self.AboutDialog.run()
856
891
                self.AboutDialog.destroy()
857
892
 
963
998
                self.AddAlarmTemplate = self.AddDialog.get_widget('create_from_template_radio')
964
999
                self.AddCounter = self.AddDialog.get_widget('create_counter')
965
1000
                self.hbox = self.AddDialog.get_widget('mtable')
 
1001
                self.AddAlarmNew.set_active(True)
 
1002
 
966
1003
 
967
1004
                self.AddAlarmTemplateCombo = gtk.combo_box_new_text()
968
1005
                self.hbox.attach(self.AddAlarmTemplateCombo, 1, 2, 2, 3)
1183
1220
                        dialog.destroy()
1184
1221
                        return  
1185
1222
 
1186
 
 
 
1223
        def ToggleSoundButtons(self, Object):
 
1224
                if self.Radio4.get_active():
 
1225
                        self.FChooser.set_sensitive(True)
 
1226
                else:
 
1227
                        self.FChooser.set_sensitive(False)
1187
1228
 
1188
1229
        def AddSimpleCounterDialog(self,obj = None):
1189
1230
                self.AddCounterDialog = gtk.glade.XML('main.glade', 'add_coffee')
1190
1231
                self.AddCounterDialogWidget = self.AddCounterDialog.get_widget('add_coffee')
1191
1232
                self.AddCounterDialogWidget.set_icon_from_file('gfx/alarm-clock.svg')
1192
1233
 
 
1234
                self.Radio3 = self.AddCounterDialog.get_widget("radiobutton3")
 
1235
                self.Radio4 = self.AddCounterDialog.get_widget("radiobutton4")
 
1236
                self.FChooser = self.AddCounterDialog.get_widget("sound_file_choose")
 
1237
 
 
1238
                self.file_filter = gtk.FileFilter()
 
1239
                self.file_filter.set_name(_("Audio files"))
 
1240
                self.file_filter.add_mime_type("audio/*")
 
1241
                self.file_filter.add_pattern("*.ogg")
 
1242
                self.file_filter.add_pattern("*.mp3")
 
1243
                self.file_filter.add_pattern("*.wav")
 
1244
                self.file_filter.add_pattern("*.mp4")
 
1245
                self.file_filter.add_pattern("*.flac")
 
1246
                self.FChooser.add_filter(self.file_filter)
 
1247
 
 
1248
                self.file_filter_all = gtk.FileFilter()
 
1249
                self.file_filter_all.set_name(_("All files"))
 
1250
                self.file_filter_all.add_pattern("*")
 
1251
 
 
1252
                self.FChooser.add_filter(self.file_filter_all)
 
1253
 
 
1254
                self.FChooser.set_sensitive(False)
 
1255
 
 
1256
                self.FChooser.set_current_folder(os.getenv("HOME"))
 
1257
 
 
1258
                self.signals = { "sound_toggle" : self.ToggleSoundButtons }
 
1259
 
 
1260
                self.AddCounterDialog.signal_autoconnect(self.signals)
 
1261
 
1193
1262
                self.tb = gtk.TextBuffer()
1194
1263
                self.tb.set_text(_("A simple counter."))
1195
1264
 
1210
1279
                                                       self.Newdate.strftime("%d"))
1211
1280
                        self.NewTime = ("%s:%i") % (self.Newdate.strftime("%H"), int(self.Newdate.strftime("%M")))
1212
1281
 
 
1282
#abbc
 
1283
 
 
1284
                # 7 - Boolean - whatever to play sound
 
1285
                # 8 - Boolean - Use custom sound file
 
1286
                # 9 - String - path to sound file
 
1287
                # 10 - Boolean - Constant (True) or Fade (False)
 
1288
                # 11 - Integer - Constant volume value
 
1289
                # 12 - Integer - Fade (Initial volume)
 
1290
                # 13 - Integer - Fade (Final volume)
 
1291
                # 14 - Integer - Fade (Duration in seconds)
 
1292
 
 
1293
 
1213
1294
 
1214
1295
                        self.AlarmBuffer[0] = _("Counter")
1215
1296
                        self.AlarmBuffer[1] = self.NewTime
1222
1303
                        self.AlarmBuffer[37] = _("Counter message")
1223
1304
                        self.AlarmBuffer[19] = False
1224
1305
 
 
1306
                        #Checking for sound
 
1307
 
 
1308
                        if self.Radio3.get_active():
 
1309
                                self.AlarmBuffer[7] = True
 
1310
                                self.AlarmBuffer[10] = True
 
1311
 
 
1312
                        if self.Radio4.get_active():
 
1313
                                self.AlarmBuffer[7] = True
 
1314
                                self.AlarmBuffer[8] = True
 
1315
                                self.AlarmBuffer[9] = self.FChooser.get_filename()
 
1316
                                self.AlarmBuffer[10] = True
 
1317
 
 
1318
 
1225
1319
                        self.f = file(os.getenv("HOME") + "/.config/Alarm-Clock/alarms", "a")
1226
1320
                        print >> self.f, self.AlarmBuffer
1227
1321
                        self.f.close()
1234
1328
 
1235
1329
 
1236
1330
        def NewAlarmRadioCheck(self,obj):
1237
 
                if not self.AddAlarmTemplate.get_active():
1238
 
                        self.AddAlarmTemplateCombo.set_sensitive(False)
1239
 
                else:
1240
 
                        self.AddAlarmTemplateCombo.set_sensitive(True)
 
1331
                try:
 
1332
                        if not self.AddAlarmTemplate.get_active():
 
1333
                                self.AddAlarmTemplateCombo.set_sensitive(False)
 
1334
                        else:
 
1335
                                self.AddAlarmTemplateCombo.set_sensitive(True)
 
1336
                except:
 
1337
                        pass
1241
1338
 
1242
1339
        def SoundPrefsActive(self,obj):
1243
1340
                self.sp_Glade = gtk.glade.XML('main.glade', 'sound_properties')
2512
2609
                self.msg.destroy()
2513
2610
                return
2514
2611
 
2515
 
 
2516
 
 
2517
 
 
2518
 
 
2519
 
 
2520
 
 
2521
 
 
2522
 
 
2523
 
 
2524
2612
        def TestAlarm(self,obj):
2525
2613
                self.LoadCurrentAlarm()
2526
 
 
2527
2614
                self.RunAlarm(self.AlarmBuffer)
2528
2615
 
2529
 
 
2530
 
 
2531
2616
        def on_message(self, bus, message):
2532
2617
                t = message.type
2533
2618
                if t == gst.MESSAGE_EOS:
2534
2619
                        player.set_state(gst.STATE_NULL)
2535
2620
                        MainWindowGlade.get_widget('stop_sound').set_sensitive(False)
2536
2621
 
2537
 
 
2538
 
 
2539
 
 
2540
 
 
2541
2622
        def RunAlarm(self,Al):
2542
2623
 
2543
2624
                self.c = Al
2681
2762
                                except:
2682
2763
                                        print _("Error: cannot create dialog window.")
2683
2764
 
2684
 
                                        
2685
 
 
 
2765
                                
2686
2766
 
2687
2767
                # COMMAND START
2688
2768
 
2729
2809
 
2730
2810
 
2731
2811
 
2732
 
        def CloseDialogPopup(self,obj):
2733
 
                self.dl.destroy()
 
2812
        def CloseDialogPopup(self, DialogWindow):
 
2813
                DialogWindow.get_parent_window().destroy()
2734
2814
 
2735
2815
        def SnoozeClicked(self,obj):
2736
2816
                self.dl.destroy()
2944
3024
                                        StartGUI().RunAlarm(eval(self.bb[tup[2]]))
2945
3025
                                        gtk.gdk.threads_leave()
2946
3026
 
 
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
 
3029
 
 
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
 
3032
                        
2947
3033
                        self.CheckOldAlarms()
2948
3034
 
2949
3035
                        if self.RefreshList == True:
 
3036
                                gtk.gdk.threads_enter()
2950
3037
                                self.LoadConfigFiles()
2951
 
                                self.RefreshList = False
 
3038
                                gtk.gdk.threads_leave()
 
3039
 
2952
3040
 
2953
3041
                        time.sleep(0.1)
2954
3042