[gnome-clocks] Clean up code



commit b49868a447858682e8ae592b298bc899527cdf14
Author: Seif Lotfy <seif lotfy com>
Date:   Fri Aug 17 14:34:35 2012 +0200

    Clean up code
    
    Used pyflakes to remove unused variables and stuff

 gnomeclocks/alarm.py   |    9 ++-------
 gnomeclocks/app.py     |    4 +++-
 gnomeclocks/clocks.py  |   12 ++----------
 gnomeclocks/storage.py |    1 -
 gnomeclocks/timer.py   |   11 ++++-------
 gnomeclocks/widgets.py |    6 ------
 6 files changed, 11 insertions(+), 32 deletions(-)
---
diff --git a/gnomeclocks/alarm.py b/gnomeclocks/alarm.py
index de545c4..a4690ef 100644
--- a/gnomeclocks/alarm.py
+++ b/gnomeclocks/alarm.py
@@ -18,7 +18,6 @@
 
 import datetime
 import vobject
-import time
 import os
 
 
@@ -52,12 +51,8 @@ class ICSHandler():
         ics.close()
 
     def delete_alarm(self, alarm_uid):
-        with open('alarms.ics', 'r+') as ics:
-            data = vobject.readOne(ics.read())
-        for alarm in vcal.vevent_list:
-            if alarm.uid.value == alarm_uid:
-                #delete event
-                break
+        # TODO: Add alarm deletion support
+        pass
 
     def edit_alarm(self, alarm_uid, new_name=None, new_hour=None,
                    new_mins=None, new_p=None, new_repeat=None):
diff --git a/gnomeclocks/app.py b/gnomeclocks/app.py
index d57b63c..6ee90d5 100644
--- a/gnomeclocks/app.py
+++ b/gnomeclocks/app.py
@@ -32,6 +32,8 @@ class Window(Gtk.ApplicationWindow):
                                        application=app,
                                        hide_titlebar_when_maximized=True)
 
+        self.app = app
+
         css_provider = Gtk.CssProvider()
         css_provider.load_from_path(os.path.join(Dirs.get_data_dir(),
                                                  "gtk-style.css"))
@@ -135,7 +137,7 @@ class Window(Gtk.ApplicationWindow):
             if keyname == 'n':
                 self.toolbar._on_new_clicked(None)
             elif keyname in ('q', 'w'):
-                app.quit()
+                self.app.quit()
 
 
 class ClocksToolbar(Gtk.Toolbar):
diff --git a/gnomeclocks/clocks.py b/gnomeclocks/clocks.py
index 45bdf09..5f2a593 100644
--- a/gnomeclocks/clocks.py
+++ b/gnomeclocks/clocks.py
@@ -16,21 +16,17 @@
 #
 # Author: Seif Lotfy <seif lotfy collabora co uk>
 
-from gi.repository import Gtk, GObject, Gio, Gdk, Gst, Notify, cairo
+from gi.repository import Gtk, GObject, Gio, Gst, Notify
 from gi.repository.GdkPixbuf import Pixbuf
 
 from widgets import NewWorldClockDialog, NewAlarmDialog
 from widgets import DigitalClock, AlarmWidget, WorldEmpty, AlarmsEmpty
 from storage import worldclockstorage
 
-from datetime import datetime, timedelta
-from pytz import timezone
-from timer import TimerWelcomeScreen, TimerScreen, Spinner
+from timer import TimerWelcomeScreen, TimerScreen
 from alarm import AlarmItem, ICSHandler
 
-import pytz
 import time
-import os
 
 STOPWATCH_LABEL_MARKUP = "<span font_desc=\"64.0\">%02i:%02i</span>"
 STOPWATCH_BUTTON_MARKUP = "<span font_desc=\"18.0\">%s</span>"
@@ -282,9 +278,7 @@ class Stopwatch(Clock):
         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)
 
         self.stopwatchLabel = Gtk.Label()
         self.stopwatchLabel.set_alignment(0.5, 0.5)
@@ -315,7 +309,6 @@ class Stopwatch(Clock):
         self.rightLabel.set_padding(6, 0)
 
         center.pack_start(self.stopwatchLabel, False, False, 0)
-        space = Gtk.EventBox()
         center.pack_start(Gtk.Box(), True, True, 41)
         center.pack_start(hbox, False, False, 0)
 
@@ -379,7 +372,6 @@ class Stopwatch(Clock):
     def count(self):
         timediff = time.time() - self.start_time + self.time_diff
         elapsed_minutes, elapsed_seconds = divmod(timediff, 60)
-        elapsed_milli_seconds = int((elapsed_seconds * 100) % 100)
         self.stopwatchLabel.set_markup(STOPWATCH_LABEL_MARKUP %
             (elapsed_minutes, elapsed_seconds))
         return True
diff --git a/gnomeclocks/storage.py b/gnomeclocks/storage.py
index 4655453..b33ad61 100644
--- a/gnomeclocks/storage.py
+++ b/gnomeclocks/storage.py
@@ -16,7 +16,6 @@
 #
 # Author: Seif Lotfy <seif lotfy collabora co uk>
 
-import os
 import errno
 import pickle
 from xdg import BaseDirectory
diff --git a/gnomeclocks/timer.py b/gnomeclocks/timer.py
index 2b26c9e..9ed34a3 100644
--- a/gnomeclocks/timer.py
+++ b/gnomeclocks/timer.py
@@ -16,11 +16,11 @@
 #
 # Author: Seif Lotfy <seif lotfy collabora co uk>
 
-from gi.repository import Gtk, Gio, Gdk
+from gi.repository import Gtk, Gio
 
-TIMER = "<span font_desc=\"64.0\">% 02i</span>"
-TIMER_LABEL_MARKUP = "<span font_desc=\"64.0\">% 02i:% 02i:% 02i</span>"
-TIMER = "<span font_desc=\"64.0\">% 02i</span>"
+TIMER = "<span font_desc=\"64.0\">%02i</span>"
+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=\"18.0\">% s</span>"
 
 
@@ -86,9 +86,7 @@ class TimerScreen(Gtk.Box):
         self.set_orientation(Gtk.Orientation.VERTICAL)
         self.timer = timer
 
-        top_spacer = Gtk.Box()
         center = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
-        bottom_spacer = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
 
         self.timerLabel = Gtk.Label()
         self.timerLabel.set_alignment(0.5, 0.5)
@@ -149,7 +147,6 @@ class TimerWelcomeScreen(Gtk.Box):
         self.timer = timer
         self.set_orientation(Gtk.Orientation.VERTICAL)
 
-        top_spacer = Gtk. Box()
         center = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
         bottom_spacer = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
 
diff --git a/gnomeclocks/widgets.py b/gnomeclocks/widgets.py
index 92fc0ef..23a7286 100644
--- a/gnomeclocks/widgets.py
+++ b/gnomeclocks/widgets.py
@@ -60,8 +60,6 @@ class NewWorldClockDialog(Gtk.Dialog):
         header.set_markup("<span size='medium'><b>%s</b></span>"
           % (_("Add a New World Clock")))
 
-        btnBox = Gtk.Box()
-
         self.add_buttons(_("Cancel"), 0, _("Add"), 1)
         widget = self.get_widget_for_response(1)
         widget.set_sensitive(False)
@@ -345,7 +343,6 @@ class DigitalClockDrawing(Gtk.DrawingArea):
 class AlarmWidget():
     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:
@@ -497,9 +494,6 @@ class NewAlarmDialog(Gtk.Dialog):
         else:
             table1.attach(box, 1, 4, 2, 3)
 
-        soundbox = Gtk.ComboBox()
-        #table1.attach(soundbox, 1, 3, 3, 4)
-
     def show_leading_zeros(self, spin_button):
         spin_button.set_text('{: 02d}'.format(spin_button.get_value_as_int()))
         return True



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