bulk commit

This commit is contained in:
josch 2014-06-28 11:25:19 +02:00
parent 6e0f06bab5
commit b9bf9f18e0
2 changed files with 34 additions and 4 deletions

View file

@ -102,7 +102,10 @@ def markup_escape_text(text):
"""
if not text:
return ""
try:
return GLib.markup_escape_text(text)
except UnicodeEncodeError:
return "UnicodeEncodeError"
class TabLabel(Gtk.HBox):
"""A class for Tab labels"""
@ -135,8 +138,8 @@ class TabLabel(Gtk.HBox):
self.pack_start(self.label, True, True, 0)
self.pack_start(close_button, False, False, 0)
self.set_data("label", self.label)
self.set_data("close-button", close_button)
#self.set_data("label", self.label)
#self.set_data("close-button", close_button)
def tab_label_style_set_cb (tab_label, style):
context = tab_label.get_pango_context()
@ -714,6 +717,23 @@ class FeedTree(Gtk.TreeView):
itc = self.model.iter_next(itc)
it = self.model.iter_next(it)
def update_view(self, feedurl):
it = self.model.get_iter_first()
feed_iter = None
while (it) and not feed_iter:
itc = self.model.iter_children(it)
while (itc) and not feed_iter:
if self.model.get_value(itc, 0) == feedurl:
feed_iter = itc
itc = self.model.iter_next(itc)
it = self.model.iter_next(it)
feed = self.feeddb.get_feed(feedurl)
title = markup_escape_text(feed['title'])
unread = feed['unread']
if unread > 0:
title = "<b>"+title+" (%d)"%unread+"</b>"
self.model.set_value(feed_iter, 1, title)
def update_feed_all(self):
self.emit("refresh-begin")
@ -1034,7 +1054,7 @@ class FeedReaderWindow(Gtk.Window):
content_pane.load_string(content_string+item['content'], item['link'])
toolbar.location_set_text(item['link'])
self.set_title(_("PyFeRea - %s")%item['title'])
feedtree.update_view_all()
feedtree.update_view(feedurl)
entries.connect("item-selected", item_selected_cb)
feedtree = FeedTree(config, feeddb)
@ -1059,6 +1079,8 @@ class FeedReaderWindow(Gtk.Window):
def timeout_cb(foo):
if feedtree.updating: return True
feedtree.update_feed_all()
#from meliae import scanner
#scanner.dump_all_objects('filename.json')
return True
GLib.timeout_add_seconds(3600, timeout_cb, None)

View file

@ -54,6 +54,7 @@ class SQLStorage():
dbcreate(self.conn)
def get_feed(self, feed):
print "get_feed"
result = self.conn.execute("""SELECT title, favicon, etag, lastmodified, unread FROM feeds WHERE feed=?""", (feed,)).fetchone()
if result:
return dict(zip(('title', 'favicon', 'etag', 'lastmodified', 'unread'), result))
@ -61,6 +62,7 @@ class SQLStorage():
return dict()
def get_entry(self, feed, entry):
print "get_entry"
result = self.conn.execute("""SELECT title, content, link, date, unread, categories FROM entries WHERE feed=? AND entry=?""", (feed, entry)).fetchone()
if result:
return dict(zip(('title', 'content', 'link', 'date', 'unread', 'categories'), result))
@ -68,6 +70,7 @@ class SQLStorage():
return dict()
def get_entries_all(self, feed):
print "get_entries_all"
result = self.conn.execute(
"""SELECT entry, title, date, unread FROM entries WHERE feed=? ORDER BY date DESC""",
(feed,)).fetchall()
@ -77,25 +80,30 @@ class SQLStorage():
return list()
def add_entry(self, feed, entry, values):
print "add_entry"
self.conn.execute("""REPLACE INTO entries (feed, entry, title, content, link, date, unread, categories) VALUES (?, ?, ?, ?, ?, ?, ?, ?)""",
(feed, entry, values['title'], values['content'], values['link'], values['date'], values['unread'], values['categories']))
self.conn.commit()
def update_feed(self, feed, values):
print "update_feed"
self.conn.execute("""REPLACE INTO feeds (feed, title, favicon, etag, lastmodified, unread) VALUES (?,?,?,?,?,?)""",
(feed, values['title'], values.get('favicon'), values.get('etag'), values.get('lastmodified'), values['unread']))
self.conn.commit()
def set_favicon(self, feed, favicon):
print "set_favicon"
self.conn.execute("""UPDATE feeds SET favicon=? WHERE feed=?""", (favicon, feed))
self.conn.commit()
def mark_read(self, feed, entry):
print "mark_read"
self.conn.execute("""UPDATE entries SET unread=0 WHERE feed=? AND entry=?""", (feed, entry))
self.conn.execute("""UPDATE feeds SET unread=unread-1 WHERE feed=?""", (feed,))
self.conn.commit()
def mark_read_feed(self, feed):
print "mark_read_feed"
self.conn.execute("""UPDATE entries SET unread=0 WHERE unread=1""")
self.conn.execute("""UPDATE feeds set unread=0 WHERE feed=?""", (feed,))
self.conn.commit()