[Sugar-devel] [PATCH Read 2/2] pep8 cleanup: fix whitespace
Sascha Silbe
sascha-pgp at silbe.org
Sun Dec 5 07:00:22 EST 2010
Signed-off-by: Sascha Silbe <sascha-pgp at silbe.org>
diff --git a/epubadapter.py b/epubadapter.py
index c740451..2bea967 100644
--- a/epubadapter.py
+++ b/epubadapter.py
@@ -3,9 +3,12 @@ import logging
import epubview
+
_logger = logging.getLogger('read-activity')
+
class View(epubview.EpubView):
+
def __init__(self):
epubview.EpubView.__init__(self)
@@ -35,7 +38,7 @@ class View(epubview.EpubView):
def get_current_page(self):
return int(self._loaded_page - 1)
- def find_changed(self, job, page = None):
+ def find_changed(self, job, page=None):
self._find_changed(job)
def handle_link(self, link):
@@ -43,6 +46,7 @@ class View(epubview.EpubView):
class EpubDocument(epubview.Epub):
+
def __init__(self, view, docpath):
epubview.Epub.__init__(self, docpath)
self._page_cache = view
@@ -59,6 +63,8 @@ class EpubDocument(epubview.Epub):
def get_links_model(self):
return self.get_toc_model()
+
class JobFind(epubview.JobFind):
+
def __init__(self, document, start_page, n_pages, text, case_sensitive=False):
epubview.JobFind.__init__(self, document, start_page, n_pages, text, case_sensitive=False)
diff --git a/epubview/epub.py b/epubview/epub.py
index 86f6ec9..9a05abf 100644
--- a/epubview/epub.py
+++ b/epubview/epub.py
@@ -61,7 +61,6 @@ class _Epub(object):
self._zobject.extract(name)
os.chdir(orig_cwd)
-
def _get_opf(self):
containerfile = self._zobject.open('META-INF/container.xml')
@@ -79,7 +78,6 @@ class _Epub(object):
containerfile.close()
-
def _get_ncx(self):
opffile = self._zobject.open(self._opfpath)
diff --git a/epubview/epubinfo.py b/epubview/epubinfo.py
index 27cfe3e..f781c25 100644
--- a/epubview/epubinfo.py
+++ b/epubview/epubinfo.py
@@ -17,7 +17,6 @@ class EpubInfo(): #TODO: Cover the entire DC range
self.identifier = self._get_identifier()
self.language = self._get_language()
-
def _get_data(self, tagname):
element = self._e_metadata.find(tagname)
return element.text
@@ -67,7 +66,7 @@ class EpubInfo(): #TODO: Cover the entire DC range
element = self._e_metadata.find('.//{http://purl.org/dc/elements/1.1/}identifier')
if element is not None:
- return {'id':element.get('id'), 'value':element.text}
+ return {'id': element.get('id'), 'value': element.text}
else:
return None
diff --git a/epubview/epubview.py b/epubview/epubview.py
index e9cc276..31acb3f 100644
--- a/epubview/epubview.py
+++ b/epubview/epubview.py
@@ -33,20 +33,21 @@ LOADING_HTML = '''
</div>
'''
+
class _View(gtk.HBox):
+
__gproperties__ = {
- 'has-selection' : (gobject.TYPE_BOOLEAN, 'whether has selection',
- 'whether the widget has selection or not',
- 0, gobject.PARAM_READABLE),
- 'zoom' : (gobject.TYPE_FLOAT, 'the zoom level',
- 'the zoom level of the widget',
- 0.5, 4.0, 1.0, gobject.PARAM_READWRITE)
+ 'has-selection': (gobject.TYPE_BOOLEAN, 'whether has selection',
+ 'whether the widget has selection or not',
+ 0, gobject.PARAM_READABLE),
+ 'zoom': (gobject.TYPE_FLOAT, 'the zoom level',
+ 'the zoom level of the widget',
+ 0.5, 4.0, 1.0, gobject.PARAM_READWRITE),
}
__gsignals__ = {
- 'page-changed': (gobject.SIGNAL_RUN_FIRST,
- gobject.TYPE_NONE,
- ([]))
+ 'page-changed': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([])),
}
+
def __init__(self):
gobject.threads_init()
gtk.HBox.__init__(self)
@@ -92,10 +93,10 @@ class _View(gtk.HBox):
self._scrollbar.set_update_policy(gtk.UPDATE_DISCONTINUOUS)
self._scrollbar_change_value_cb_id = self._scrollbar.connect('change-value', \
self._scrollbar_change_value_cb)
- self.pack_start(self._sw, expand = True, fill = True)
- self.pack_start(self._scrollbar, expand = False, fill = False)
+ self.pack_start(self._sw, expand=True, fill=True)
+ self.pack_start(self._scrollbar, expand=False, fill=False)
- self._view.set_flags(gtk.CAN_DEFAULT|gtk.CAN_FOCUS)
+ self._view.set_flags(gtk.CAN_DEFAULT | gtk.CAN_FOCUS)
def set_document(self, epubdocumentinstance):
'''
@@ -367,7 +368,7 @@ class _View(gtk.HBox):
remfactor = self._paginator.get_remfactor_for_file(filename)
pages = self._paginator.get_pagecount_for_file(filename)
- extra = int(math.ceil(remfactor * self._view.get_page_height()/(pages-remfactor)))
+ extra = int(math.ceil(remfactor * self._view.get_page_height() / (pages - remfactor)))
if extra > 0:
self._view.add_bottom_padding(extra)
@@ -390,13 +391,12 @@ class _View(gtk.HBox):
if scroll_upper == 0: # This is a one page file
pageno = base_pageno
else:
- offset = (scrollval/scroll_upper) * self._paginator.get_pagecount_for_file(filename)
+ offset = (scrollval / scroll_upper) * self._paginator.get_pagecount_for_file(filename)
pageno = math.floor(base_pageno + offset)
if pageno != self._loaded_page:
self._on_page_changed(int(pageno))
-
def _scroll_page_end(self):
v_upper = self._v_vscrollbar.props.adjustment.props.upper
v_page_size = self._v_vscrollbar.props.adjustment.props.page_size
@@ -439,7 +439,7 @@ class _View(gtk.HBox):
scrollfactor_next = self._paginator.get_scrollfactor_pos_for_pageno(self._loaded_page + 1)
if scrollval > 0:
- scrollfactor = scrollval/(scroll_upper - scroll_page_size)
+ scrollfactor = scrollval / (scroll_upper - scroll_page_size)
else:
scrollfactor = 0
if scrollfactor >= scrollfactor_next:
@@ -451,7 +451,7 @@ class _View(gtk.HBox):
scrollfactor_cur = self._paginator.get_scrollfactor_pos_for_pageno(self._loaded_page)
if scrollval > 0:
- scrollfactor = scrollval/(scroll_upper - scroll_page_size)
+ scrollfactor = scrollval / (scroll_upper - scroll_page_size)
else:
scrollfactor = 0
@@ -556,8 +556,5 @@ class _View(gtk.HBox):
if self._loaded_page < 1:
self._load_page(1)
-
-
def _destroy_cb(self, widget):
self._epub.close()
-
diff --git a/epubview/jobs.py b/epubview/jobs.py
index 6fe5b25..8dc26c7 100644
--- a/epubview/jobs.py
+++ b/epubview/jobs.py
@@ -32,19 +32,21 @@ import threading
PAGE_WIDTH = 135
PAGE_HEIGHT = 216
+
def _pixel_to_mm(pixel, dpi):
- inches = pixel/dpi
- return int(inches/0.03937)
+ inches = pixel / dpi
+ return int(inches / 0.03937)
+
def _mm_to_pixel(mm, dpi):
inches = mm * 0.03937
return int(inches * dpi)
-
class SearchThread(threading.Thread):
+
def __init__(self, obj):
- threading.Thread.__init__ (self)
+ threading.Thread.__init__(self)
self.obj = obj
self.stopthread = threading.Event()
@@ -76,20 +78,19 @@ class SearchThread(threading.Thread):
return False
- def run (self):
+ def run(self):
self._start_search()
def stop(self):
self.stopthread.set()
-
class _JobPaginator(gobject.GObject):
+
__gsignals__ = {
- 'paginated': (gobject.SIGNAL_RUN_FIRST,
- gobject.TYPE_NONE,
- ([]))
+ 'paginated': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([])),
}
+
def __init__(self, filelist):
gobject.GObject.__init__(self)
@@ -145,19 +146,19 @@ class _JobPaginator(gobject.GObject):
if pageheight <= _mm_to_pixel(PAGE_HEIGHT, self._dpi):
pages = 1
else:
- pages = pageheight/float(_mm_to_pixel(PAGE_HEIGHT, self._dpi))
+ pages = pageheight / float(_mm_to_pixel(PAGE_HEIGHT, self._dpi))
for i in range(1, int(math.ceil(pages) + 1)):
if pages - i < 0:
- pagelen = (pages - math.floor(pages))/pages
+ pagelen = (pages - math.floor(pages)) / pages
else:
- pagelen = 1/pages
- self._pagemap[float(self._pagecount + i)] = (f.props.uri, (i-1)/math.ceil(pages), pagelen)
+ pagelen = 1 / pages
+ self._pagemap[float(self._pagecount + i)] = (f.props.uri, (i - 1) / math.ceil(pages), pagelen)
self._pagecount += math.ceil(pages)
self._filedict[f.props.uri.replace('file://', '')] = (math.ceil(pages), math.ceil(pages) - pages)
self._bookheight += pageheight
- if self._count+1 >= len(self._filelist):
+ if self._count + 1 >= len(self._filelist):
self._temp_win.destroy()
self._screen.set_font_options(self._old_fontoptions)
self.emit('paginated')
@@ -165,7 +166,6 @@ class _JobPaginator(gobject.GObject):
self._count += 1
self._temp_view.open(self._filelist[self._count])
-
def get_file_for_pageno(self, pageno):
'''
Returns the file in which pageno occurs
@@ -221,10 +221,9 @@ class _JobPaginator(gobject.GObject):
class _JobFind(gobject.GObject):
__gsignals__ = {
- 'updated': (gobject.SIGNAL_RUN_FIRST,
- gobject.TYPE_NONE,
- ([]))
+ 'updated': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([])),
}
+
def __init__(self, document, start_page, n_pages, text, case_sensitive=False):
gobject.GObject.__init__(self)
gtk.gdk.threads_init()
diff --git a/epubview/navmap.py b/epubview/navmap.py
index 314752a..ac479cd 100644
--- a/epubview/navmap.py
+++ b/epubview/navmap.py
@@ -1,8 +1,10 @@
from lxml import etree
import gtk
+
class NavPoint(object):
- def __init__(self, label, contentsrc, children = []):
+
+ def __init__(self, label, contentsrc, children=[]):
self._label = label
self._contentsrc = contentsrc
self._children = children
@@ -59,7 +61,7 @@ class NavMap(object):
text = navpoint.find('./{http://www.daisy.org/z3986/2005/ncx/}content/')
return self._basepath + text.get('src')
- def _process_navpoint(self, navpoint, parent = None):
+ def _process_navpoint(self, navpoint, parent=None):
title = self._gettitle(navpoint)
content = self._getcontent(navpoint)
@@ -72,7 +74,7 @@ class NavMap(object):
if len(childnavpointlist):
for childnavpoint in childnavpointlist:
- self._process_navpoint(childnavpoint, parent = iter)
+ self._process_navpoint(childnavpoint, parent=iter)
else:
return
diff --git a/epubview/widgets.py b/epubview/widgets.py
index 0458573..7ab1585 100644
--- a/epubview/widgets.py
+++ b/epubview/widgets.py
@@ -28,4 +28,3 @@ class _WebView(webkit.WebView):
'''
js = ('var newdiv = document.createElement("div");newdiv.style.height = "%dpx";document.body.appendChild(newdiv);' % incr)
self.execute_script(js)
-
diff --git a/readactivity.py b/readactivity.py
index d855d2a..5aff808 100644
--- a/readactivity.py
+++ b/readactivity.py
@@ -66,12 +66,15 @@ _TOOLBAR_READ = 2
_logger = logging.getLogger('read-activity')
+
def _get_screen_dpi():
xft_dpi = gtk.settings_get_default().get_property('gtk-xft-dpi')
_logger.debug('Setting dpi to %f', float(xft_dpi / 1024))
return float(xft_dpi / 1024)
-def get_md5(filename): #FIXME: Should be moved somewhere else
+
+def get_md5(filename):
+ #FIXME: Should be moved somewhere else
filename = filename.replace('file://', '') #XXX: hack
fh = open(filename)
digest = md5.new()
@@ -83,6 +86,7 @@ def get_md5(filename): #FIXME: Should be moved somewhere else
fh.close()
return digest.hexdigest()
+
class ReadHTTPRequestHandler(network.ChunkedGlibHTTPRequestHandler):
"""HTTP Request Handler for transferring document while collaborating.
@@ -91,6 +95,7 @@ class ReadHTTPRequestHandler(network.ChunkedGlibHTTPRequestHandler):
mainloop between chunks.
"""
+
def translate_path(self, path):
"""Return the filepath to the shared document."""
return self.server.filepath
@@ -98,6 +103,7 @@ class ReadHTTPRequestHandler(network.ChunkedGlibHTTPRequestHandler):
class ReadHTTPServer(network.GlibTCPServer):
"""HTTP Server for transferring document while collaborating."""
+
def __init__(self, server_address, filepath):
"""Set up the GlibTCPServer with the ReadHTTPRequestHandler.
@@ -125,8 +131,10 @@ class ReadURLDownloader(network.GlibURLDownloader):
READ_STREAM_SERVICE = 'read-activity-http'
+
class ReadActivity(activity.Activity):
"""The Read sugar activity."""
+
def __init__(self, handle):
activity.Activity.__init__(self, handle)
@@ -255,13 +263,13 @@ class ReadActivity(activity.Activity):
self._vbox.show()
self._topbar = TopBar()
- self._vbox.pack_start(self._topbar, expand = False, fill = False)
+ self._vbox.pack_start(self._topbar, expand=False, fill=False)
self._hbox = gtk.HBox()
self._hbox.show()
self._hbox.pack_start(self._sidebar, expand=False, fill=False)
- self._vbox.pack_start(self._hbox, expand = True, fill = True)
+ self._vbox.pack_start(self._hbox, expand=True, fill=True)
self.set_canvas(self._vbox)
# Set up for idle suspend
@@ -330,10 +338,10 @@ class ReadActivity(activity.Activity):
back.set_tooltip(_('Back'))
back.props.sensitive = False
palette = back.get_palette()
- previous_page = MenuItem(text_label= _("Previous page"))
+ previous_page = MenuItem(text_label=_("Previous page"))
palette.menu.append(previous_page)
previous_page.show_all()
- previous_bookmark = MenuItem(text_label= _("Previous bookmark"))
+ previous_bookmark = MenuItem(text_label=_("Previous bookmark"))
palette.menu.append(previous_bookmark)
previous_bookmark.show_all()
back.connect('clicked', self.__go_back_cb)
@@ -346,10 +354,10 @@ class ReadActivity(activity.Activity):
forward.set_tooltip(_('Forward'))
forward.props.sensitive = False
palette = forward.get_palette()
- next_page = MenuItem(text_label= _("Next page"))
+ next_page = MenuItem(text_label=_("Next page"))
palette.menu.append(next_page)
next_page.show_all()
- next_bookmark = MenuItem(text_label= _("Next bookmark"))
+ next_bookmark = MenuItem(text_label=_("Next bookmark"))
palette.menu.append(next_bookmark)
next_bookmark.show_all()
forward.connect('clicked', self.__go_forward_cb)
@@ -448,7 +456,7 @@ class ReadActivity(activity.Activity):
else:
self._sidebar.del_bookmark(page)
- def __page_changed_cb(self, page, proxy = None):
+ def __page_changed_cb(self, page, proxy=None):
self._update_nav_buttons()
if hasattr(self._document, 'has_document_links'):
if self._document.has_document_links():
@@ -514,7 +522,6 @@ class ReadActivity(activity.Activity):
current_link = self._toc_model.get(iter, 1)[0]
current_page = self._document.get_page_cache().get_current_page()
-
if not hasattr(current_link, 'get_page'):
filepath = self._view.get_current_file()
if filepath is None or filepath.endswith(current_link):
@@ -781,7 +788,6 @@ class ReadActivity(activity.Activity):
self._hbox.pack_start(self._scrolled, expand=True, fill=True)
self._scrolled.show()
-
def _load_document(self, filepath):
"""Load the specified document and set up the UI.
diff --git a/readbookmark.py b/readbookmark.py
index 27b1319..6a8e96c 100644
--- a/readbookmark.py
+++ b/readbookmark.py
@@ -17,7 +17,9 @@
import cjson
+
class Bookmark:
+
def __init__(self, data):
self.md5 = data[0]
self.page_no = data[1]
@@ -46,5 +48,3 @@ class Bookmark:
note = cjson.decode(self.content)
return note['body']
-
-
diff --git a/readdb.py b/readdb.py
index e8bc02a..fe4ef90 100644
--- a/readdb.py
+++ b/readdb.py
@@ -28,6 +28,7 @@ from readbookmark import Bookmark
_logger = logging.getLogger('read-activity')
+
def _init_db():
dbdir = os.path.join(os.environ['SUGAR_ACTIVITY_ROOT'], 'data')
dbpath = os.path.join(dbdir, 'read_v1.db')
@@ -65,7 +66,9 @@ def _init_db():
# Should not reach this point
return None
+
class BookmarkManager:
+
def __init__(self, filehash):
self._filehash = filehash
@@ -76,7 +79,6 @@ class BookmarkManager:
self._conn = sqlite3.connect(dbpath)
self._conn.text_factory = lambda x: unicode(x, "utf-8", "ignore")
-
self._bookmarks = []
self._populate_bookmarks()
@@ -108,7 +110,7 @@ class BookmarkManager:
def _populate_bookmarks(self):
# TODO: Figure out if caching the entire set of bookmarks is a good idea or not
- rows = self._conn.execute('select * from bookmarks where md5=? order by page', (self._filehash,))
+ rows = self._conn.execute('select * from bookmarks where md5=? order by page', (self._filehash, ))
for row in rows:
self._bookmarks.append(Bookmark(row))
@@ -126,30 +128,28 @@ class BookmarkManager:
self._bookmarks = []
self._populate_bookmarks()
-
- def get_prev_bookmark_for_page(self, page, wrap = True):
+ def get_prev_bookmark_for_page(self, page, wrap=True):
if not len(self._bookmarks):
return None
if page <= self._bookmarks[0].page_no and wrap:
return self._bookmarks[-1]
else:
- for i in range(page-1, -1, -1):
+ for i in range(page - 1, -1, -1):
for bookmark in self._bookmarks:
if bookmark.belongstopage(i):
return bookmark
return None
-
- def get_next_bookmark_for_page(self, page, wrap = True):
+ def get_next_bookmark_for_page(self, page, wrap=True):
if not len(self._bookmarks):
return None
if page >= self._bookmarks[-1].page_no and wrap:
return self._bookmarks[0]
else:
- for i in range(page+1, self._bookmarks[-1].page_no + 1):
+ for i in range(page + 1, self._bookmarks[-1].page_no + 1):
for bookmark in self._bookmarks:
if bookmark.belongstopage(i):
return bookmark
diff --git a/readdialog.py b/readdialog.py
index d30e222..61d5672 100644
--- a/readdialog.py
+++ b/readdialog.py
@@ -11,7 +11,9 @@ from sugar.graphics.toolbutton import ToolButton
from gettext import gettext as _
import cjson
+
class BaseReadDialog(gtk.Window):
+
def __init__(self, parent_xid, dialog_title):
gtk.Window.__init__(self)
@@ -61,7 +63,7 @@ class BaseReadDialog(gtk.Window):
self.toolbar.show()
self._event_box = gtk.EventBox()
- _vbox.pack_start(self._event_box, expand=True, fill = True)
+ _vbox.pack_start(self._event_box, expand=True, fill=True)
self._canvas = None
def set_canvas(self, canvas):
@@ -101,7 +103,7 @@ class BookmarkDialog(BaseReadDialog):
vbox = gtk.VBox()
thbox = gtk.HBox()
- vbox.pack_start(thbox, expand = False, fill = False)
+ vbox.pack_start(thbox, expand=False, fill=False)
thbox.set_border_width(style.DEFAULT_SPACING * 2)
thbox.set_spacing(style.DEFAULT_SPACING)
thbox.show()
@@ -111,7 +113,7 @@ class BookmarkDialog(BaseReadDialog):
label_title.set_alignment(1, 0.5)
label_title.modify_fg(gtk.STATE_NORMAL,
style.COLOR_SELECTION_GREY.get_gdk_color())
- thbox.pack_start(label_title, expand=False, fill = False)
+ thbox.pack_start(label_title, expand=False, fill=False)
label_title.show()
self._title_entry = gtk.Entry()
@@ -121,16 +123,15 @@ class BookmarkDialog(BaseReadDialog):
style.COLOR_WHITE.get_gdk_color())
self._title_entry.set_size_request(int(gtk.gdk.screen_width() / 3), -1)
- thbox.pack_start(self._title_entry, expand = False, fill = False)
+ thbox.pack_start(self._title_entry, expand=False, fill=False)
self._title_entry.show()
if bookmark_title is not None:
self._title_entry.set_text(bookmark_title)
-
cvbox = gtk.VBox()
- vbox.pack_start(cvbox, expand = True, fill = True)
+ vbox.pack_start(cvbox, expand=True, fill=True)
cvbox.set_border_width(style.DEFAULT_SPACING * 2)
- cvbox.set_spacing(style.DEFAULT_SPACING/2)
+ cvbox.set_spacing(style.DEFAULT_SPACING / 2)
cvbox.show()
label_content = gtk.Label(_('<b>Details</b>:'))
@@ -138,7 +139,7 @@ class BookmarkDialog(BaseReadDialog):
label_content.set_alignment(0, 0)
label_content.modify_fg(gtk.STATE_NORMAL,
style.COLOR_SELECTION_GREY.get_gdk_color())
- cvbox.pack_start(label_content, expand=False, fill = False)
+ cvbox.pack_start(label_content, expand=False, fill=False)
label_content.show()
sw = gtk.ScrolledWindow()
@@ -150,7 +151,7 @@ class BookmarkDialog(BaseReadDialog):
sw.add(self._content_entry)
sw.set_shadow_type(gtk.SHADOW_ETCHED_IN)
- cvbox.pack_start(sw, expand = True, fill = True)
+ cvbox.pack_start(sw, expand=True, fill=True)
self._content_entry.show()
if bookmark_content is not None:
buffer = self._content_entry.get_buffer()
@@ -158,25 +159,29 @@ class BookmarkDialog(BaseReadDialog):
self.set_canvas(vbox)
+
class BookmarkAddDialog(BookmarkDialog):
+
def __init__(self, parent_xid, dialog_title, bookmark_title, bookmark_content, page, sidebarinstance):
BookmarkDialog.__init__(self, parent_xid, dialog_title, bookmark_title, bookmark_content, page, sidebarinstance)
def accept_clicked_cb(self, widget):
title = self._title_entry.get_text()
details = self._content_entry.get_buffer().props.text
- content = {'title' : unicode(title), 'body' : unicode(details)}
+ content = {'title': unicode(title), 'body': unicode(details)}
self._sidebarinstance._real_add_bookmark(self._page, cjson.encode(content))
self.destroy()
+
class BookmarkEditDialog(BookmarkDialog):
+
def __init__(self, parent_xid, dialog_title, bookmark_title, bookmark_content, page, sidebarinstance):
BookmarkDialog.__init__(self, parent_xid, dialog_title, bookmark_title, bookmark_content, page, sidebarinstance)
def accept_clicked_cb(self, widget):
title = self._title_entry.get_text()
details = self._content_entry.get_buffer().props.text
- content = {'title' : unicode(title), 'body' : unicode(details)}
+ content = {'title': unicode(title), 'body': unicode(details)}
self._sidebarinstance.del_bookmark(self._page)
self._sidebarinstance._real_add_bookmark(self._page, cjson.encode(content))
self.destroy()
diff --git a/readsidebar.py b/readsidebar.py
index 0df3993..c22d462 100644
--- a/readsidebar.py
+++ b/readsidebar.py
@@ -31,11 +31,14 @@ from readdialog import BookmarkAddDialog, BookmarkEditDialog
from gettext import gettext as _
+
_logger = logging.getLogger('read-activity')
#TODO: Add support for multiple bookmarks in a single page (required when sharing)
+
class Sidebar(gtk.EventBox):
+
def __init__(self):
gtk.EventBox.__init__(self)
self.set_size_request(20, -1)
@@ -58,8 +61,8 @@ class Sidebar(gtk.EventBox):
def _add_bookmark_icon(self, bookmark):
xocolor = XoColor(bookmark.color)
- self._bookmark_icon = Icon(icon_name = 'emblem-favorite', \
- pixel_size = 18, xo_color = xocolor)
+ self._bookmark_icon = Icon(icon_name='emblem-favorite', pixel_size=18,
+ xo_color=xocolor)
self._bookmark_icon.props.has_tooltip = True
self.__bookmark_icon_query_tooltip_cb_id = \
@@ -69,7 +72,7 @@ class Sidebar(gtk.EventBox):
self.__event_cb_id = \
self.connect('event', self.__event_cb, bookmark)
- self._box.pack_start(self._bookmark_icon ,expand=False,fill=False)
+ self._box.pack_start(self._bookmark_icon, expand=False, fill=False)
self._bookmark_icon.show_all()
if bookmark.is_local():
@@ -89,7 +92,7 @@ class Sidebar(gtk.EventBox):
l.set_use_markup(True)
l.set_width_chars(40)
l.set_line_wrap(True)
- vbox.pack_start(l, expand = False, fill = False)
+ vbox.pack_start(l, expand=False, fill=False)
l.show()
l = gtk.Label('%s' % tooltip_body)
@@ -99,14 +102,14 @@ class Sidebar(gtk.EventBox):
l.set_width_chars(40)
l.set_line_wrap(True)
l.set_justify(gtk.JUSTIFY_FILL)
- vbox.pack_start(l, expand = True, fill = True)
+ vbox.pack_start(l, expand=True, fill=True)
l.show()
l = gtk.Label('<small><i>%s</i></small>' % tooltip_footer)
l.set_use_markup(True)
l.set_width_chars(40)
l.set_line_wrap(True)
- vbox.pack_start(l, expand = False, fill = False)
+ vbox.pack_start(l, expand=False, fill=False)
l.show()
tip.set_custom(vbox)
@@ -120,11 +123,12 @@ class Sidebar(gtk.EventBox):
bookmark_title = bookmark.get_note_title()
bookmark_content = bookmark.get_note_body()
- dialog = BookmarkEditDialog(parent_xid = self.get_toplevel().window.xid, \
- dialog_title = _("Add notes for bookmark: "), \
- bookmark_title = bookmark_title, \
- bookmark_content = bookmark_content, page = bookmark.page_no, \
- sidebarinstance = self)
+ dialog = BookmarkEditDialog(
+ parent_xid=self.get_toplevel().window.xid,
+ dialog_title=_("Add notes for bookmark: "),
+ bookmark_title=bookmark_title,
+ bookmark_content=bookmark_content, page=bookmark.page_no,
+ sidebarinstance=self)
dialog.show_all()
return False
@@ -160,11 +164,12 @@ class Sidebar(gtk.EventBox):
def add_bookmark(self, page):
bookmark_title = (_("%s's bookmark") % profile.get_nick_name())
bookmark_content = (_("Bookmark for page %d") % page)
- dialog = BookmarkAddDialog(parent_xid = self.get_toplevel().window.xid, \
- dialog_title = _("Add notes for bookmark: "), \
- bookmark_title = bookmark_title, \
- bookmark_content = bookmark_content, page = page, \
- sidebarinstance = self)
+ dialog = BookmarkAddDialog(
+ parent_xid=self.get_toplevel().window.xid,
+ dialog_title=_("Add notes for bookmark: "),
+ bookmark_title=bookmark_title,
+ bookmark_content=bookmark_content, page=page,
+ sidebarinstance=self)
dialog.show_all()
def _real_add_bookmark(self, page, content):
@@ -177,4 +182,3 @@ class Sidebar(gtk.EventBox):
def is_showing_local_bookmark(self):
return self._is_showing_local_bookmark
-
diff --git a/readtoolbar.py b/readtoolbar.py
index 4d5bcb8..acd459f 100644
--- a/readtoolbar.py
+++ b/readtoolbar.py
@@ -30,7 +30,9 @@ from sugar.graphics.menuitem import MenuItem
from sugar.graphics import iconentry
from sugar.activity import activity
+
class EditToolbar(activity.EditToolbar):
+
__gtype_name__ = 'EditToolbar'
def __init__(self):
@@ -133,7 +135,7 @@ class EditToolbar(activity.EditToolbar):
def _find_changed_cb(self, page, spec):
self._update_find_buttons()
- def _find_updated_cb(self, job, page = None):
+ def _find_updated_cb(self, job, page=None):
self._evince_view.find_changed(job, page)
def _find_prev_cb(self, button):
@@ -169,12 +171,9 @@ class ViewToolbar(gtk.Toolbar):
__gtype_name__ = 'ViewToolbar'
__gsignals__ = {
- 'needs-update-size': (gobject.SIGNAL_RUN_FIRST,
- gobject.TYPE_NONE,
+ 'needs-update-size': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
([])),
- 'go-fullscreen': (gobject.SIGNAL_RUN_FIRST,
- gobject.TYPE_NONE,
- ([]))
+ 'go-fullscreen': (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, ([])),
}
def __init__(self):
@@ -252,7 +251,6 @@ class ViewToolbar(gtk.Toolbar):
self._update_zoom_buttons()
-
def _zoom_spin_notify_value_cb(self, zoom_spin, pspec):
if not self._view_notify_zoom_handler:
return
diff --git a/readtopbar.py b/readtopbar.py
index 6883474..630601b 100644
--- a/readtopbar.py
+++ b/readtopbar.py
@@ -24,6 +24,7 @@ from sugar.graphics.icon import Icon, get_icon_state
from gettext import gettext as _
+
_LEVEL_PROP = 'battery.charge_level.percentage'
_CHARGING_PROP = 'battery.rechargeable.is_charging'
_DISCHARGING_PROP = 'battery.rechargeable.is_discharging'
@@ -31,17 +32,15 @@ _PRESENT_PROP = 'battery.present'
_ICON_NAME = 'battery'
+
# Taken from sugar/extensions/deviceicon/battery.py
class BattMan(gobject.GObject):
+
__gproperties__ = {
- 'level' : (int, None, None, 0, 100, 0,
- gobject.PARAM_READABLE),
- 'charging' : (bool, None, None, False,
- gobject.PARAM_READABLE),
- 'discharging' : (bool, None, None, False,
- gobject.PARAM_READABLE),
- 'present' : (bool, None, None, False,
- gobject.PARAM_READABLE)
+ 'level': (int, None, None, 0, 100, 0, gobject.PARAM_READABLE),
+ 'charging': (bool, None, None, False, gobject.PARAM_READABLE),
+ 'discharging': (bool, None, None, False, gobject.PARAM_READABLE),
+ 'present': (bool, None, None, False, gobject.PARAM_READABLE),
}
def __init__(self, udi):
@@ -121,14 +120,14 @@ class BattMan(gobject.GObject):
class _TopBar(gtk.HBox):
__gproperties__ = {
- 'completion-level' : (float, None, None, 0.0, 100.0, 0.0,
- gobject.PARAM_READWRITE),
+ 'completion-level': (float, None, None, 0.0, 100.0, 0.0,
+ gobject.PARAM_READWRITE),
}
def __init__(self):
gtk.HBox.__init__(self)
- self.set_border_width(int(style.DEFAULT_SPACING/2.0))
+ self.set_border_width(int(style.DEFAULT_SPACING / 2.0))
self.set_spacing(style.DEFAULT_SPACING * 4)
self._completion_level = 0
@@ -164,23 +163,25 @@ class _TopBar(gtk.HBox):
def set_completion_level(self, value):
self._completion_level = value
- self._progressbar.set_fraction(self._completion_level/100.0)
+ self._progressbar.set_fraction(self._completion_level / 100.0)
def _setup(self):
self._progressbar = gtk.ProgressBar()
self._progressbar.props.discrete_blocks = 10
- self._progressbar.set_fraction(self._completion_level/100.0)
- self.pack_start(self._progressbar, expand = True, fill = True)
+ self._progressbar.set_fraction(self._completion_level / 100.0)
+ self.pack_start(self._progressbar, expand=True, fill=True)
if self._battery is not None:
icon_name = get_icon_state(_ICON_NAME, self._battery.props.level, step=-5)
self._icon = Icon(icon_name=icon_name)
- self.pack_start(self._icon, expand = False, fill = False)
+ self.pack_start(self._icon, expand=False, fill=False)
def _battery_level_changed_cb(self, pspec, param):
icon_name = get_icon_state(_ICON_NAME, self._battery.props.level, step=-5)
self._icon.props.icon_name = icon_name
+
class TopBar(_TopBar):
+
def __init__(self):
_TopBar.__init__(self)
self._document = None
@@ -191,14 +192,11 @@ class TopBar(_TopBar):
page_cache = self._document.get_page_cache()
page_cache.connect('page-changed', self._page_changed_cb)
- def _page_changed_cb(self, page, proxy = None):
+ def _page_changed_cb(self, page, proxy=None):
current_page = self._document.get_page_cache().get_current_page()
n_pages = self._document.get_n_pages()
- self.set_completion_level(current_page * 100/n_pages)
+ self.set_completion_level(current_page * 100 / n_pages)
#TRANS: Translate this as Page i of m (eg: Page 4 of 334)
self._progressbar.set_text(_("Page %i of %i") % (current_page, n_pages))
-
-
-
diff --git a/setup.py b/setup.py
index d3ab3a3..aa56bce 100755
--- a/setup.py
+++ b/setup.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-
# Copyright (C) 2006, Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify
--
1.7.2.3
More information about the Sugar-devel
mailing list