[gnome-clocks] Rename 'src' dir to 'gnomeclocks'



commit 3ffb4fc004651038a103264d3a7c73322d50756e
Author: Paolo Borelli <pborelli gnome org>
Date:   Tue Aug 14 22:03:37 2012 +0200

    Rename 'src' dir to 'gnomeclocks'
    
    This is in preparation to making the application installable:
    gnomeclocks will be the directory under python's site-packages.
    While at it, strip trailing whitespaces from the files.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=681883

 {src => gnomeclocks}/alarm.py        |   90 +++++++++---------
 {src => gnomeclocks}/clocks.py       |   80 ++++++++--------
 {src => gnomeclocks}/gnome_clocks.py |    0
 {src => gnomeclocks}/storage.py      |   41 +++++----
 {src => gnomeclocks}/timer.py        |   15 ++--
 {src => gnomeclocks}/widgets.py      |  166 +++++++++++++++++-----------------
 6 files changed, 196 insertions(+), 196 deletions(-)
---
diff --git a/src/alarm.py b/gnomeclocks/alarm.py
similarity index 66%
rename from src/alarm.py
rename to gnomeclocks/alarm.py
index a940a2e..993e32e 100644
--- a/src/alarm.py
+++ b/gnomeclocks/alarm.py
@@ -3,33 +3,33 @@ import datetime, vobject, time, os
 class ICSHandler():
     def __init__(self):
         self.ics_file = 'alarms.ics'
-        
-    def add_vevent(self, vobj):        
-        with open(self.ics_file, 'r+') as ics:        
-            content = ics.read()        
+
+    def add_vevent(self, vobj):
+        with open(self.ics_file, 'r+') as ics:
+            content = ics.read()
             ics.seek(0)
-            vcal = vobject.readOne(content)                  
-            vcal.add(vobj)        
-            ics.write(vcal.serialize())                  
-                
-    def load_vevents(self):                
-        alarms = [] 
+            vcal = vobject.readOne(content)
+            vcal.add(vobj)
+            ics.write(vcal.serialize())
+
+    def load_vevents(self):
+        alarms = []
         if os.path.exists(self.ics_file):
-            with open(self.ics_file, 'r') as ics:                            
-                vcal = vobject.readOne(ics.read())          
-                for item in vcal.components():            
-                    alarms.append(item)                                
+            with open(self.ics_file, 'r') as ics:
+                vcal = vobject.readOne(ics.read())
+                for item in vcal.components():
+                    alarms.append(item)
         else:
             self.generate_ics_file()
         return alarms
-        
+
     def generate_ics_file(self):
         vcal = vobject.iCalendar()
-        ics = open('alarms.ics', 'w')      
+        ics = open('alarms.ics', 'w')
         ics.write(vcal.serialize())
-        ics.close()  
-        
-        
+        ics.close()
+
+
     def delete_alarm(self, alarm_uid):
         with open('alarms.ics', 'r+') as ics:
             data = vobject.readOne(ics.read())
@@ -37,7 +37,7 @@ class ICSHandler():
             if alarm.uid.value == alarm_uid:
                 #delete event
                 break
-      
+
     def edit_alarm(self, alarm_uid, new_name=None, new_hour=None, new_mins=None, new_p=None, new_repeat=None):
         with open(self.ics_file, 'r+') as ics:
             vcal = vobject.readOne(ics.read())
@@ -49,36 +49,36 @@ class ICSHandler():
 
 class AlarmItem:
     def __init__(self, name=None, repeat=None, h=None, m=None, p=None):
-        self.name = name        
+        self.name = name
         self.repeat = repeat
         self.vevent = None
         self.uid = None
         self.h = h
         self.m = m
         self.p = p
-            
-    def new_from_vevent(self, vevent):        
-        self.name = vevent.summary.value        
+
+    def new_from_vevent(self, vevent):
+        self.name = vevent.summary.value
         self.time = vevent.dtstart.value
         self.h = int(self.time.strftime("%H"))
         self.m = int(self.time.strftime("%M"))
         self.p = self.time.strftime("%p")
-        self.uid = vevent.uid.value        
+        self.uid = vevent.uid.value
 
     def set_alarm_time(self, h, m, p):
         self.h = h
         self.m = m
         self.p = p
-        
-    def get_alarm_time(self):        
+
+    def get_alarm_time(self):
         time = {}
-        time['h'] = self.h 
-        time['m'] = self.m        
+        time['h'] = self.h
+        time['m'] = self.m
         time['p'] = self.p
         return self.time
-        
+
     def get_time_12h_as_string(self):
-        if self.p == 'AM' or self.p == 'PM':        
+        if self.p == 'AM' or self.p == 'PM':
             if self.h == 12 or self.h == 0:
                 h = 12
             else:
@@ -86,35 +86,35 @@ class AlarmItem:
         else:
             h = self.h
         return "%2i:%2i %s" % (h, self.m, self.p)
-        
-                    
+
+
     def get_time_24h_as_string(self):
-        if self.p == 'AM' or self.p == 'PM':        
+        if self.p == 'AM' or self.p == 'PM':
             h = self.h + 12
             if h == 24:
                 h = 12
         else:
             h = self.h
         return "%2i:%2i" % (h, self.m)
-        
+
     def set_alarm_name(self, name):
         self.name = name
-    
+
     def get_alarm_name(self):
         return self.name
-        
+
     def set_alarm_repeat(self, repeat):
         self.repeat = repeat
 
     def get_alarm_repeat(self):
         return self.repeat
-        
+
     def get_uid(self):
         return self.vevent.uid.value
-    
-    def get_vevent(self):                
-        self.vevent = vevent = vobject.newFromBehavior('vevent')                    
-        vevent.add('summary').value = self.name               
+
+    def get_vevent(self):
+        self.vevent = vevent = vobject.newFromBehavior('vevent')
+        vevent.add('summary').value = self.name
         h = self.h
         m = self.m
         if self.p == "PM":
@@ -123,11 +123,11 @@ class AlarmItem:
                 h = 12
         elif self.p == "AM":
             if h == 12:
-                h = 0        
-        vevent.add('dtstart').value = datetime.datetime.combine(datetime.date.today(), datetime.time(h, m))                      
+                h = 0
+        vevent.add('dtstart').value = datetime.datetime.combine(datetime.date.today(), datetime.time(h, m))
         vevent.add('dtend').value = datetime.datetime.combine(datetime.date.today(), datetime.time(h, 59))
         if len(self.repeat) == 0:
             vevent.add('rrule').value = 'FREQ=DAILY;'
         else:
-            vevent.add('rrule').value = 'FREQ=WEEKLY;BYDAY=%s' % ','.join(self.repeat)        
+            vevent.add('rrule').value = 'FREQ=WEEKLY;BYDAY=%s' % ','.join(self.repeat)
         return vevent
diff --git a/src/clocks.py b/gnomeclocks/clocks.py
similarity index 93%
rename from src/clocks.py
rename to gnomeclocks/clocks.py
index 9a05e22..da4aca1 100644
--- a/src/clocks.py
+++ b/gnomeclocks/clocks.py
@@ -10,11 +10,11 @@
  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 Gnome Documents; if not, write to the Free Software Foundation,
  Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- 
+
  Author: Seif Lotfy <seif lotfy collabora co uk>
 """
 
@@ -51,7 +51,7 @@ class ToggleButton(Gtk.ToggleButton):
         self.add(self.label)
         self.connect("toggled", self._on_toggled)
         self.set_size_request(100, 34)
-        
+
     def _on_toggled(self, label):
         if self.get_active():
             self.label.set_markup("<b>%s</b>"%self.text)
@@ -69,16 +69,16 @@ class Clock (Gtk.EventBox):
         self.button = ToggleButton (label)
         self.hasNew = hasNew
         self.get_style_context ().add_class ('grey-bg')
-    
+
     def open_new_dialog(self):
         pass
-        
+
     def close_new_dialog(self):
         pass
-    
+
     def add_new_clock(self):
         pass
-        
+
     def unselect_all (self):
         pass
 
@@ -86,12 +86,12 @@ class World (Clock):
     def __init__ (self):
         Clock.__init__ (self, "World", True)
         self.addButton = None
-        
+
         self.liststore = liststore = Gtk.ListStore(Pixbuf, str, GObject.TYPE_PYOBJECT)
         self.iconview = iconview = Gtk.IconView.new()
-        
+
         self.empty_view = WorldEmpty ()
-        
+
         iconview.set_model(liststore)
         iconview.set_spacing(3)
         iconview.set_pixbuf_column(0)
@@ -183,64 +183,64 @@ class World (Clock):
 class Alarm (Clock):
     def __init__ (self):
         Clock.__init__ (self, "Alarm", True)
-        
+
         self.liststore = liststore = Gtk.ListStore(Pixbuf, str, GObject.TYPE_PYOBJECT)
         self.iconview = iconview = Gtk.IconView.new()
-        
+
         iconview.set_model(liststore)
         iconview.set_spacing(3)
-        iconview.set_pixbuf_column(0)        
+        iconview.set_pixbuf_column(0)
         iconview.get_style_context ().add_class ('grey-bg')
 
         renderer_text = Gtk.CellRendererText()
-        renderer_text.set_alignment (0.5, 0.5)                
-        iconview.pack_start(renderer_text, True)                
-        iconview.add_attribute(renderer_text, "markup", 1)        
+        renderer_text.set_alignment (0.5, 0.5)
+        iconview.pack_start(renderer_text, True)
+        iconview.add_attribute(renderer_text, "markup", 1)
 
         scrolledwindow = Gtk.ScrolledWindow()
         scrolledwindow.add(iconview)
         self.add(scrolledwindow)
-        
+
         self.alarms = []
         self.load_alarms()
         self.show_all()
-    
+
     def get_system_clock_format(self):
         settings = Gio.Settings.new('org.gnome.desktop.interface')
         systemClockFormat = settings.get_string('clock-format')
         return systemClockFormat
-        
+
     def load_alarms(self):
         handler = ICSHandler()
-        vevents = handler.load_vevents()        
+        vevents = handler.load_vevents()
         if vevents:
-            for vevent in vevents:         
+            for vevent in vevents:
                 alarm = AlarmItem()
-                alarm.new_from_vevent(vevent)                        
+                alarm.new_from_vevent(vevent)
                 scf = self.get_system_clock_format()
                 if scf == "12h":
-                    d = AlarmWidget(alarm.get_time_12h_as_string())                        
+                    d = AlarmWidget(alarm.get_time_12h_as_string())
                 else:
-                    d = AlarmWidget(alarm.get_time_24h_as_string())                        
+                    d = AlarmWidget(alarm.get_time_24h_as_string())
                 view_iter = self.liststore.append([d.drawing.pixbuf, "<b>" + alarm.get_alarm_name() + "</b>", d])
-                d.set_iter(self.liststore, view_iter)          
+                d.set_iter(self.liststore, view_iter)
         self.show_all()
-      
+
     def add_alarm(self, alarm):
         handler = ICSHandler()
-        handler.add_vevent(alarm.get_vevent())        
+        handler.add_vevent(alarm.get_vevent())
         scf = self.get_system_clock_format()
         if scf == "12h":
             d = AlarmWidget(alarm.get_time_12h_as_string())
         else:
-            d = AlarmWidget(alarm.get_time_24h_as_string())                               
+            d = AlarmWidget(alarm.get_time_24h_as_string())
         view_iter = self.liststore.append([d.drawing.pixbuf, "<b>" + alarm.get_alarm_name() + "</b>", d])
         d.set_iter(self.liststore, view_iter)
         self.show_all()
 
     def open_new_dialog(self):
         parent = self.get_parent ().get_parent ().get_parent ()
-        window = NewAlarmDialog (parent)        
+        window = NewAlarmDialog (parent)
         window.connect("add-alarm", lambda w, l: self.add_alarm(l))
         window.show_all ()
 
@@ -253,9 +253,9 @@ class Stopwatch (Clock):
 
     def __init__ (self):
         Clock.__init__ (self, "Stopwatch")
-        vbox = Gtk.Box (orientation = Gtk.Orientation.VERTICAL)        
-        self.add (vbox)        
-        
+        vbox = Gtk.Box (orientation = Gtk.Orientation.VERTICAL)
+        self.add (vbox)
+
         top_spacer = Gtk.Box()
         center = Gtk.Box (orientation=Gtk.Orientation.VERTICAL)
         bottom_spacer = Gtk.Box (orientation=Gtk.Orientation.VERTICAL)
@@ -280,7 +280,7 @@ class Stopwatch (Clock):
         hbox.pack_start (Gtk.Box(), True, False, 0)
         hbox.pack_start (self.leftButton, False, False, 0)
         hbox.pack_start (Gtk.Box(), False, False, 24)
-        hbox.pack_start (self.rightButton, False, False, 0)            
+        hbox.pack_start (self.rightButton, False, False, 0)
         hbox.pack_start (Gtk.Box(), True, False, 0)
 
         self.leftLabel.set_markup (STOPWATCH_BUTTON_MARKUP%("Start"))
@@ -292,7 +292,7 @@ class Stopwatch (Clock):
         space = Gtk.EventBox()
         center.pack_start (Gtk.Box (), True, True, 41)
         center.pack_start (hbox, False, False, 0)
-        
+
         self.state = 0
         self.g_id = 0
         self.start_time = 0
@@ -302,10 +302,10 @@ class Stopwatch (Clock):
         vbox.pack_start (center, False, False, 0)
         vbox.pack_start (Gtk.Box (), True, True, 1)
         vbox.pack_start (Gtk.Box (), True, True, 41)
-        
+
         self.leftButton.connect("clicked", self._on_left_button_clicked)
         self.rightButton.connect("clicked", self._on_right_button_clicked)
-    
+
     def _on_left_button_clicked (self, widget):
         if self.state == 0 or self.state == 2:
             self.state = 1
@@ -327,7 +327,7 @@ class Stopwatch (Clock):
             pass
         if self.state == 2:
             self.state = 0
-            self.time_diff = 0          
+            self.time_diff = 0
             self.leftLabel.set_markup (STOPWATCH_BUTTON_MARKUP%("Start"))
             self.leftButton.get_style_context ().add_class ("clocks-start")
             #self.rightButton.get_style_context ().add_class ("clocks-lap")
@@ -409,7 +409,7 @@ class Timer (Clock):
         self.timer_welcome_screen.hours.down.set_sensitive(False)
 
     def start(self):
-        if self.g_id == 0: 
+        if self.g_id == 0:
             hours = self.timer_welcome_screen.hours.get_value()
             minutes = self.timer_welcome_screen.minutes.get_value()
             seconds = self.timer_welcome_screen.seconds.get_value()
@@ -452,12 +452,12 @@ class Timer (Clock):
 
 class Alert:
     def __init__(self):
-        Gst.init('gst') 
+        Gst.init('gst')
 
     def do_alert(self, msg):
         if Notify.init("GNOME Clocks"):
             Alert = Notify.Notification.new("Clocks", msg, 'test')
-            Alert.show()    
+            Alert.show()
             playbin = Gst.ElementFactory.make('playbin', None)
             playbin.set_property('uri', 'file:///usr/share/sounds/gnome/default/alerts/glass.ogg')
             playbin.set_state(Gst.State.PLAYING)
diff --git a/src/gnome_clocks.py b/gnomeclocks/gnome_clocks.py
similarity index 100%
rename from src/gnome_clocks.py
rename to gnomeclocks/gnome_clocks.py
diff --git a/src/storage.py b/gnomeclocks/storage.py
similarity index 75%
rename from src/storage.py
rename to gnomeclocks/storage.py
index aa1cd0e..d480a60 100644
--- a/src/storage.py
+++ b/gnomeclocks/storage.py
@@ -10,11 +10,11 @@
  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 Gnome Documents; if not, write to the Free Software Foundation,
  Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- 
+
  Author: Seif Lotfy <seif lotfy collabora co uk>
 """
 
@@ -23,11 +23,13 @@ import pickle
 from xdg import BaseDirectory
 from gi.repository import GWeather
 
+
 DATA_PATH = BaseDirectory.save_data_path("clocks") + "/clocks"
 
-class Location ():
-    def __init__ (self, location):
-        self._id = location.get_city_name ()
+
+class Location():
+    def __init__(self, location):
+        self._id = location.get_city_name()
         self._location = location
 
     @property
@@ -38,38 +40,39 @@ class Location ():
     def location(self):
         return self._location
 
-class WorldClockStorage ():
-    def __init__ (self):
+
+class WorldClockStorage():
+    def __init__(self):
         world = GWeather.Location.new_world(True)
         self.searchEntry = GWeather.LocationEntry.new(world)
         self.searchEntry.show_all ()
         self.locations_dump = ""
         pass
 
-    def save_clocks (self, locations):
+    def save_clocks(self, locations):
         self.locations_dump = locations = "|".join([location.id + "---" + location.location.get_code () for location in locations])
-        f = open (DATA_PATH, "wb")
-        pickle.dump (locations, f)
-        f.close ()
+        f = open(DATA_PATH, "wb")
+        pickle.dump(locations, f)
+        f.close()
 
-    def load_clocks (self):
+    def load_clocks(self):
         try:
-          f = open (DATA_PATH, "rb")
+          f = open(DATA_PATH, "rb")
           self.locations_dump = locations = pickle.load (f)
           f.close ()
-          locations = locations.split ("|")
+          locations = locations.split("|")
           clocks = []
           for location in locations:
-              loc = location.split ("---")
-              if self.searchEntry.set_city (loc[0], loc[1]):
+              loc = location.split("---")
+              if self.searchEntry.set_city(loc[0], loc[1]):
                   loc = self.searchEntry.get_location ()
-                  loc = Location (self.searchEntry.get_location ())
-                  clocks.append (loc)
+                  loc = Location(self.searchEntry.get_location ())
+                  clocks.append(loc)
           return clocks
         except Exception, e:
           print "--", e
           return []
-          
+
     def delete_all_clocks(self):
         f = open(DATA_PATH, "w")
         f.write("")
diff --git a/src/timer.py b/gnomeclocks/timer.py
similarity index 97%
rename from src/timer.py
rename to gnomeclocks/timer.py
index 6294ac5..be885bc 100644
--- a/src/timer.py
+++ b/gnomeclocks/timer.py
@@ -11,7 +11,7 @@
  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 Gnome Documents; if not, write to the Free Software Foundation,
  Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
@@ -25,6 +25,7 @@ TIMER_LABEL_MARKUP = "<span font_desc=\"64.0\">%02i:%02i:%02i</span>"
 TIMER = "<span font_desc=\"64.0\">%02i</span>"
 TIMER_BUTTON_MARKUP = "<span font_desc=\"24.0\">%s</span>"
 
+
 class Spinner(Gtk.Box):
     def __init__(self, value_type, timer_welcome_screen):
         super(Spinner, self).__init__()
@@ -46,7 +47,7 @@ class Spinner(Gtk.Box):
         #Down Button
         self.down = Gtk.Button()
         self.down.set_image(imageDown)
-        self.down.set_relief(Gtk.ReliefStyle.NONE)        
+        self.down.set_relief(Gtk.ReliefStyle.NONE)
         #
         self.pack_start(self.up, False, False, 0)
         self.pack_start(self.value, True, True, 0)
@@ -67,7 +68,7 @@ class Spinner(Gtk.Box):
             if value == 24:
                 value = 0
             else:
-                value += 1                
+                value += 1
         elif self.vType == 'minutes':
               if value == 59:
                   value = 0
@@ -101,6 +102,7 @@ class Spinner(Gtk.Box):
         self.set_value(value)
         self.timer_welcome_screen.update_start_button_status()
 
+
 class TimerScreen (Gtk.Box):
     def __init__(self, timer):
         super(TimerScreen, self).__init__()
@@ -119,7 +121,7 @@ class TimerScreen (Gtk.Box):
         center.pack_start (self.timerLabel, False, True, 6)
         center.pack_start (Gtk.Label (""), False, True, 24)
 
-        hbox = Gtk.Box()		
+        hbox = Gtk.Box()
         self.leftButton = Gtk.Button ()
         self.leftButton.set_size_request(200, -1)
         self.leftLabel = Gtk.Label ()
@@ -145,10 +147,9 @@ class TimerScreen (Gtk.Box):
         self.rightButton.connect('clicked', self._on_right_button_clicked)
 
         self.pack_start(Gtk.Box (), False, False, 7)
-        self.pack_start(center, False, False, 6)		
+        self.pack_start(center, False, False, 6)
         self.pack_start(hbox, False, False, 5)
 
-
     def _on_right_button_clicked(self, data):
         self.timer.reset()
 
@@ -203,7 +204,6 @@ class TimerWelcomeScreen (Gtk.Box):
         self.startButton.connect('clicked', self._on_start_clicked)
         bottom_spacer.pack_start (self.startButton, False, False, 0)
 
-
         center.pack_start (Gtk.Label (""), False, True, 16)
         center.pack_start (spinner, False, True, 5)
         center.pack_start (Gtk.Label (""), False, True, 3)
@@ -220,7 +220,6 @@ class TimerWelcomeScreen (Gtk.Box):
         else:
             self.startButton.set_sensitive(True)
 
-
     def _on_start_clicked(self, data):
         if self.timer.state == 0:
             self.timer.start()
diff --git a/src/widgets.py b/gnomeclocks/widgets.py
similarity index 90%
rename from src/widgets.py
rename to gnomeclocks/widgets.py
index ab73c31..a8d8add 100644
--- a/src/widgets.py
+++ b/gnomeclocks/widgets.py
@@ -10,16 +10,15 @@
  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 Gnome Documents; if not, write to the Free Software Foundation,
  Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
- 
+
  Author: Seif Lotfy <seif lotfy collabora co uk>
 """
 
-from gi.repository import Gtk, GObject, Gio, PangoCairo, Pango, GWeather
-from gi.repository import Gdk, GdkPixbuf
+from gi.repository import Gtk, Gdk, GdkPixbuf, GObject, Gio, PangoCairo, Pango, GWeather
 from storage import Location
 from alarm import AlarmItem
 import cairo, time
@@ -49,13 +48,13 @@ class NewWorldClockDialog (Gtk.Dialog):
         self.searchEntry = GWeather.LocationEntry.new(world)
         self.find_gicon = Gio.ThemedIcon.new_with_default_fallbacks('edit-find-symbolic')
         self.clear_gicon = Gio.ThemedIcon.new_with_default_fallbacks('edit-clear-symbolic')
-        self.searchEntry.set_icon_from_gicon(Gtk.EntryIconPosition.SECONDARY, self.find_gicon)				
-				#self.searchEntry.set_can_focus(False)
+        self.searchEntry.set_icon_from_gicon(Gtk.EntryIconPosition.SECONDARY, self.find_gicon)
+        #self.searchEntry.set_can_focus(False)
         self.searchEntry.set_placeholder_text("Search for a city or a time zone...")
 
         header = Gtk.Label("Add New Clock")
         header.set_markup("<span size='x-large'><b>Add a New World Clock</b></span>")
-        
+
         btnBox = Gtk.Box()
 
         self.add_buttons("Cancel", 0, "Save", 1)
@@ -91,11 +90,11 @@ class NewWorldClockDialog (Gtk.Dialog):
         if location:
             widget.set_sensitive(True)
         else:
-            widget.set_sensitive(False)        
+            widget.set_sensitive(False)
 
     def get_selection (self):
         return self.location
-        
+
     def _icon_released(self, icon_pos, event, data):
         if self.searchEntry.get_icon_gicon(Gtk.EntryIconPosition.SECONDARY) == self.clear_gicon:
             self.searchEntry.set_text('')
@@ -135,7 +134,7 @@ class DigitalClock ():
         settings = Gio.Settings.new('org.gnome.desktop.interface')
         systemClockFormat = settings.get_string('clock-format')
         return systemClockFormat
-    
+
     def get_image(self):
         local_time = self.get_local_time ()
         if local_time.tm_hour > 7 and local_time.tm_hour < 19:
@@ -169,10 +168,10 @@ class DigitalClock ():
     def set_iter (self, list_store, view_iter):
         self.view_iter = view_iter
         self.list_store = list_store
-        
+
     def get_standalone_widget (self):
         return self.standalone
-      
+
 class DigitalClockStandalone (Gtk.VBox):
     def __init__ (self, location):
         Gtk.VBox.__init__ (self, False)
@@ -229,7 +228,7 @@ class DigitalClockStandalone (Gtk.VBox):
         sunbox = Gtk.VBox (True, 3)
         sunbox.pack_start (sunrise_hbox, False, False, 3)
         sunbox.pack_start (sunset_hbox, False, False, 3)
-        
+
         hbox = Gtk.HBox ()
         hbox.pack_start (Gtk.Label (), True, True, 0)
         hbox.pack_start (sunbox, False, False, 0)
@@ -256,7 +255,7 @@ class DigitalClockStandalone (Gtk.VBox):
             self.sunrise_time_label.set_markup (sunrise_markup)
             self.sunset_time_label.set_markup (sunset_markup)
         self.systemClockFormat = systemClockFormat
-        
+
 class DigitalClockDrawing (Gtk.DrawingArea):
     width = 160
     height = 160
@@ -264,13 +263,12 @@ class DigitalClockDrawing (Gtk.DrawingArea):
     def __init__(self):
         Gtk.DrawingArea.__init__(self)
         #self.set_size_request(width,height)
-        
+
         self.pango_context = None
         self.ctx = None
         self.pixbuf = None
         self.surface = None
         self.show_all()
-        
 
     def render(self, text, img, isDay):
         print "updating"
@@ -293,10 +291,10 @@ class DigitalClockDrawing (Gtk.DrawingArea):
         else:
             ctx.set_source_rgba(1.0, 1.0, 1.0, 0.7)
 
-        ctx.arc(x + width - radius, y + radius, radius, -90 * degrees, 0 * degrees);
-        ctx.arc(x + width - radius, y + height - radius, radius, 0 * degrees, 90 * degrees);
-        ctx.arc(x + radius, y + height - radius, radius, 90 * degrees, 180 * degrees);
-        ctx.arc(x + radius, y + radius, radius, 180 * degrees, 270 * degrees);
+        ctx.arc(x + width - radius, y + radius, radius, -90 * degrees, 0 * degrees)
+        ctx.arc(x + width - radius, y + height - radius, radius, 0 * degrees, 90 * degrees)
+        ctx.arc(x + radius, y + height - radius, radius, 90 * degrees, 180 * degrees)
+        ctx.arc(x + radius, y + radius, radius, 180 * degrees, 270 * degrees)
         ctx.close_path()
         ctx.fill()
 
@@ -317,9 +315,9 @@ class DigitalClockDrawing (Gtk.DrawingArea):
         return self.pixbuf
 
 class AlarmWidget():
-    def __init__(self, time_given):                              
-        self.drawing = DigitalClockDrawing ()        
-        clockformat = self.get_system_clock_format()            
+    def __init__(self, time_given):
+        self.drawing = DigitalClockDrawing ()
+        clockformat = self.get_system_clock_format()
         t = time_given
         isDay = self.get_is_day(t)
         if isDay == True:
@@ -327,24 +325,24 @@ class AlarmWidget():
         else:
             img = "../data/cities/night.png"
         self.drawing.render(t, img, isDay)
-    
+
     def get_system_clock_format(self):
         settings = Gio.Settings.new('org.gnome.desktop.interface')
         systemClockFormat = settings.get_string('clock-format')
         return systemClockFormat
-        
+
     def get_is_day(self, t):
         if t[6:8] == 'AM':
             return True
         else:
             return False
-        
+
     def set_iter (self, list_store, view_iter):
         self.view_iter = view_iter
         self.list_store = list_store
 
 class NewAlarmDialog (Gtk.Dialog):
-    
+
     __gsignals__ = {'add-alarm': (GObject.SignalFlags.RUN_LAST,
                     None, (GObject.TYPE_PYOBJECT,))}
 
@@ -358,21 +356,21 @@ class NewAlarmDialog (Gtk.Dialog):
 
         self.cf = cf = self.get_system_clock_format()
         if cf == "12h":
-            table1 = Gtk.Table(4, 6, False) 
+            table1 = Gtk.Table(4, 6, False)
         else:
-            table1 = Gtk.Table(4, 5, False) 
+            table1 = Gtk.Table(4, 5, False)
         table1.set_row_spacings(9)
         table1.set_col_spacings(9)
-        content_area = self.get_content_area ()        
+        content_area = self.get_content_area ()
         content_area.pack_start(table1, True, True, 0)
-        self.add_buttons("Cancel", 0, "Save", 1)        
+        self.add_buttons("Cancel", 0, "Save", 1)
         self.connect("response", self.on_response)
         table1.set_border_width (5)
-        
-        t = time.localtime()        
+
+        t = time.localtime()
         h = t.tm_hour
         m = t.tm_min
-        p = time.strftime("%p", t)        
+        p = time.strftime("%p", t)
         time_label = Gtk.Label ("Time")
         time_label.set_alignment(1.0, 0.5)
         points = Gtk.Label (":")
@@ -380,53 +378,53 @@ class NewAlarmDialog (Gtk.Dialog):
 
         if cf == "12h":
             if p == "PM":
-                h = h-12            
+                h = h-12
             self.hourselect = hourselect = AlarmDialogSpin(h, 1, 12)
         else:
-            self.hourselect = hourselect = AlarmDialogSpin(h, 0, 23)                 
+            self.hourselect = hourselect = AlarmDialogSpin(h, 0, 23)
         self.minuteselect = minuteselect = AlarmDialogSpin(m, 0, 59)
-        
-        
-        
+
+
+
         if cf == "12h":
-            self.ampm = ampm = Gtk.ComboBoxText()             
+            self.ampm = ampm = Gtk.ComboBoxText()
             ampm.append_text("AM")
             ampm.append_text("PM")
             if p == 'AM':
                 ampm.set_active(0)
             else:
-                ampm.set_active(1)    
-            
+                ampm.set_active(1)
+
             table1.attach (time_label, 0, 1, 0, 1)
             table1.attach (hourselect, 1, 2, 0, 1)
             table1.attach (points, 2, 3, 0, 1)
-            table1.attach (minuteselect, 3, 4, 0, 1)  
-            table1.attach (ampm, 4, 5, 0, 1)  
+            table1.attach (minuteselect, 3, 4, 0, 1)
+            table1.attach (ampm, 4, 5, 0, 1)
         else:
             table1.attach (time_label, 0, 1, 0, 1)
             table1.attach (hourselect, 1, 2, 0, 1)
             table1.attach (points, 2, 3, 0, 1)
-            table1.attach (minuteselect, 3, 4, 0, 1)              
-            
+            table1.attach (minuteselect, 3, 4, 0, 1)
+
         name = Gtk.Label ("Name")
         name.set_alignment(1.0, 0.5)
         repeat = Gtk.Label ("Repeat Every")
         repeat.set_alignment(1.0, 0.5)
         sound = Gtk.Label ("Sound")
         sound.set_alignment(1.0, 0.5)
-        
+
         table1.attach(name, 0, 1, 1, 2)
         table1.attach(repeat, 0, 1, 2, 3)
         #table1.attach(sound, 0, 1, 3, 4)
-        
+
         self.entry = entry = Gtk.Entry ()
         entry.set_text("New Alarm")
         entry.set_editable (True)
         if cf == "12h":
-            table1.attach(entry, 1, 5, 1, 2) 
+            table1.attach(entry, 1, 5, 1, 2)
         else:
-            table1.attach(entry, 1, 4, 1, 2) 
-        
+            table1.attach(entry, 1, 4, 1, 2)
+
         buttond1 = Gtk.ToggleButton(label="Mon")
         buttond1.connect("clicked", self.on_d1_clicked)
         buttond2 = Gtk.ToggleButton(label="Tue")
@@ -441,7 +439,7 @@ class NewAlarmDialog (Gtk.Dialog):
         buttond6.connect("clicked", self.on_d6_clicked)
         buttond7 = Gtk.ToggleButton(label="Sun")
         buttond7.connect("clicked", self.on_d7_clicked)
-        
+
         # create a box and put them all in it
         box = Gtk.Box (True, 0)
         box.get_style_context().add_class("linked")
@@ -453,25 +451,25 @@ class NewAlarmDialog (Gtk.Dialog):
         box.pack_start (buttond6, True, True, 0)
         box.pack_start (buttond7, True, True, 0)
         if cf == "12h":
-            table1.attach(box, 1, 5, 2, 3) 
+            table1.attach(box, 1, 5, 2, 3)
         else:
-            table1.attach(box, 1, 4, 2, 3) 
-       
+            table1.attach(box, 1, 4, 2, 3)
+
         soundbox = Gtk.ComboBox ()
         #table1.attach(soundbox, 1, 3, 3, 4)
-        
+
     def get_system_clock_format(self):
         settings = Gio.Settings.new('org.gnome.desktop.interface')
         systemClockFormat = settings.get_string('clock-format')
         return systemClockFormat
-      
+
     def on_response(self, widget, id):
         if id == 0:
             self.destroy ()
         if id == 1:
-            name = self.entry.get_text()  #Perfect            
+            name = self.entry.get_text()  #Perfect
             repeat = self.repeat_days
-            h = self.hourselect.get_value_as_int()            
+            h = self.hourselect.get_value_as_int()
             m = self.minuteselect.get_value_as_int()
             if self.cf == "12h":
                 r = self.ampm.get_active()
@@ -481,55 +479,55 @@ class NewAlarmDialog (Gtk.Dialog):
                     p = "PM"
             else:
                 p = None
-            new_alarm = AlarmItem(name, repeat, h, m, p)              
+            new_alarm = AlarmItem(name, repeat, h, m, p)
             self.emit('add-alarm', new_alarm)
             self.destroy ()
         else:
             pass
-                
-                    
-    def on_d1_clicked(self, btn):        
+
+
+    def on_d1_clicked(self, btn):
         if btn.get_active() == True:
             self.repeat_days.append('MO')
         if btn.get_active() == False:
             self.repeat_days.remove('MO')
-                      
-    def on_d2_clicked(self, btn):    
+
+    def on_d2_clicked(self, btn):
         if btn.get_active() == True:
             self.repeat_days.append('TU')
         else:
-            self.repeat_days.remove('TU')        
-    
-    def on_d3_clicked(self, btn):        
+            self.repeat_days.remove('TU')
+
+    def on_d3_clicked(self, btn):
         if btn.get_active() == True:
             self.repeat_days.append('WE')
         else:
             self.repeat_days.remove('WE')
-    
+
     def on_d4_clicked(self, btn):
         if btn.get_active() == True:
             self.repeat_days.append('TH')
         else:
             self.repeat_days.remove('TH')
-    
-    def on_d5_clicked(self, btn):        
+
+    def on_d5_clicked(self, btn):
         if btn.get_active() == True:
             self.repeat_days.append('FR')
         else:
             self.repeat_days.remove('FR')
-    
-    def on_d6_clicked(self, btn):        
+
+    def on_d6_clicked(self, btn):
         if btn.get_active() == True:
             self.repeat_days.append('SA')
         else:
             self.repeat_days.remove('SA')
-    
-    def on_d7_clicked(self, btn):        
+
+    def on_d7_clicked(self, btn):
         if btn.get_active() == True:
             self.repeat_days.append('SU')
         else:
             self.repeat_days.remove('SU')
-            
+
 class AlarmDialogSpin(Gtk.Box):
     def __init__(self, value, min_num, max_num):
         Gtk.Box.__init__(self)
@@ -537,15 +535,15 @@ class AlarmDialogSpin(Gtk.Box):
         self.max_num = max_num
         self.min_num = min_num
         #
-        group = Gtk.SizeGroup()        
-        group.set_mode(Gtk.SizeGroupMode.VERTICAL)        
+        group = Gtk.SizeGroup()
+        group.set_mode(Gtk.SizeGroupMode.VERTICAL)
         self.entry = entry = Gtk.Entry()
         entry.set_size_request(-1, -1)
         self.entry.set_text(str(value))
         self.entry.set_max_length(2)
         self.entry.set_alignment(1)
         height = self.entry.get_allocated_height()
-        
+
         group.add_widget(entry)
         #
         m_gicon = Gio.ThemedIcon.new_with_default_fallbacks("list-remove-symbolic")
@@ -558,7 +556,7 @@ class AlarmDialogSpin(Gtk.Box):
         #
         p_gicon = Gio.ThemedIcon.new_with_default_fallbacks("list-add-symbolic")
         p_img = Gtk.Image.new_from_gicon(p_gicon, Gtk.IconSize.MENU)
-        plus = Gtk.Button()        
+        plus = Gtk.Button()
         #plus.set_size_request(-1, 10)
         plus.set_image(p_img)
         plus.connect("clicked", self._on_click_plus)
@@ -568,11 +566,11 @@ class AlarmDialogSpin(Gtk.Box):
         self.pack_start(minus, False, False, 0)
         self.pack_start(plus, False, False, 0)
         self.show_all()
-        
+
     def get_value_as_int(self):
         text = self.entry.get_text()
         return int(text)
-        
+
     def _on_click_minus(self, btn):
         value = self.get_value_as_int()
         if value == self.min_num:
@@ -580,7 +578,7 @@ class AlarmDialogSpin(Gtk.Box):
         else:
             new_value = value - 1
         self.entry.set_text(str(new_value))
-        
+
     def _on_click_plus(self, btn):
         value = self.get_value_as_int()
         if value == self.max_num:
@@ -588,7 +586,7 @@ class AlarmDialogSpin(Gtk.Box):
         else:
             new_value = value + 1
         self.entry.set_text(str(new_value))
-        
+
 class WorldEmpty(Gtk.Box):
     def __init__(self):
         Gtk.Box.__init__(self)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]