mirror of
https://github.com/nikdoof/mythview.git
synced 2025-12-22 23:29:28 +00:00
Refresh button works, More columns, and now/next shows correct humanized
time.
This commit is contained in:
@@ -11,8 +11,7 @@ class MythNowNext:
|
||||
def get_nownext(self):
|
||||
c = self.db.cursor()
|
||||
|
||||
c.execute("""
|
||||
SELECT channel.chanid, channel.icon, cast(channel.channum as signed) as channum,
|
||||
c.execute(""" SELECT channel.chanid, channel.icon, cast(channel.channum as signed) as channum,
|
||||
channel.name, program.title,
|
||||
time_to_sec(timediff(time(program.endtime), time(now()) )) as timetoend
|
||||
FROM channel, program
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
|
||||
<!--Generated with glade3 3.4.3 on Sat Apr 26 23:58:28 2008 -->
|
||||
<!--Generated with glade3 3.4.3 on Sun Apr 27 00:43:06 2008 -->
|
||||
<glade-interface>
|
||||
<widget class="GtkWindow" id="MainWindow">
|
||||
<property name="title" translatable="yes">Myth View</property>
|
||||
@@ -15,7 +15,6 @@
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<widget class="GtkToolButton" id="btnConnect">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Connect</property>
|
||||
<property name="stock_id">gtk-connect</property>
|
||||
</widget>
|
||||
@@ -28,6 +27,7 @@
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Refresh</property>
|
||||
<property name="stock_id">gtk-refresh</property>
|
||||
<signal name="clicked" handler="on_btnRefresh_clicked"/>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
||||
@@ -30,8 +30,9 @@ class MythViewUI:
|
||||
self.window = self.wTree.get_widget("MainWindow")
|
||||
if (self.window):
|
||||
self.window.connect("destroy", gtk.main_quit)
|
||||
|
||||
self.channelStore = gtk.ListStore(int, gtk.gdk.Pixbuf, str)
|
||||
self.wTree.signal_autoconnect({"on_btnRefresh_clicked" : self.btnRefresh_clicked})
|
||||
|
||||
self.channelStore = gtk.ListStore(int, int, gtk.gdk.Pixbuf, str, str)
|
||||
|
||||
# Setup the TreeView
|
||||
def addTreeColumn(title, ctype, visible,size):
|
||||
@@ -45,8 +46,10 @@ class MythViewUI:
|
||||
self.channelTree.append_column(column)
|
||||
|
||||
self.channelTree = self.wTree.get_widget("ChannelView")
|
||||
addTreeColumn("Channel", gtk.CellRendererText(), False,64)
|
||||
addTreeColumn("Channel ID", gtk.CellRendererText(), False,64)
|
||||
addTreeColumn("Channel #", gtk.CellRendererText(), True, 0)
|
||||
addTreeColumn("Icon", gtk.CellRendererPixbuf(), True, 0)
|
||||
addTreeColumn("Name", gtk.CellRendererText(), True, 0)
|
||||
addTreeColumn("Now", gtk.CellRendererText(), True, 0)
|
||||
|
||||
self.UpdateTree()
|
||||
@@ -54,31 +57,52 @@ class MythViewUI:
|
||||
self.window.show()
|
||||
|
||||
def UpdateTree(self):
|
||||
# Test Data
|
||||
#self.channelStore.append([1,MythIcon(1805,64,64).pixbuf,"BBC One"])
|
||||
#self.channelStore.append([2,MythIcon(1172,64,64).pixbuf,"BBC Two"])
|
||||
|
||||
print "Refresh Fired"
|
||||
|
||||
rows = MythNowNext(self.mythtv).get_nownext()
|
||||
|
||||
self.channelStore.clear()
|
||||
|
||||
for row in rows:
|
||||
|
||||
if row[1]:
|
||||
self.channelStore.append([row[0], MythIcon(self.mythtv, row[0], 64, 64).pixbuf, row[3]])
|
||||
icon = MythIcon(self.mythtv, row[0], 64, 64).pixbuf
|
||||
else:
|
||||
self.channelStore.append([row[0], None, row[3]])
|
||||
icon = None
|
||||
|
||||
# http://www.goldb.org/goldblog/2008/02/06/PythonConvertSecsIntoHumanReadableTimeStringHHMMSS.aspx
|
||||
def humanize_time(secs):
|
||||
mins, secs = divmod(secs, 60)
|
||||
hours, mins = divmod(mins, 60)
|
||||
return '%02d:%02d:%02d' % (hours, mins, secs)
|
||||
|
||||
print row[0]
|
||||
now = "%s\n%s remaning" % (row[4], humanize_time(row[5]))
|
||||
|
||||
self.channelStore.append([row[0], row[2], icon, row[3], now])
|
||||
|
||||
self.channelTree.set_model(self.channelStore)
|
||||
|
||||
def FillCellIcon(self, column, cell, model, iter):
|
||||
|
||||
if column.get_title() == 'Channel ID':
|
||||
cell.set_property('text', model.get_value(iter, 0))
|
||||
if column.get_title() == 'Channel #':
|
||||
cell.set_property('text', model.get_value(iter, 1))
|
||||
if column.get_title() == 'Icon':
|
||||
cell.set_property('pixbuf', model.get_value(iter, 1) )
|
||||
cell.set_property('pixbuf', model.get_value(iter, 2))
|
||||
if column.get_title() == 'Name':
|
||||
cell.set_property('text', model.get_value(iter, 3))
|
||||
if column.get_title() == 'Now':
|
||||
cell.set_property('text', model.get_value(iter, 2))
|
||||
cell.set_property('text', model.get_value(iter, 4))
|
||||
return
|
||||
|
||||
|
||||
#### Events
|
||||
|
||||
def btnRefresh_clicked(self, *args):
|
||||
self.UpdateTree()
|
||||
|
||||
def main(self):
|
||||
gtk.main()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user