commit 0fe9c60b66890d5bb049e7a010f6328df4d51fdc Author: Andrew Williams Date: Sat Apr 26 22:45:22 2008 +0100 Inital commit diff --git a/mythview/bbc1.jpg b/mythview/bbc1.jpg new file mode 100644 index 0000000..6b54b9f Binary files /dev/null and b/mythview/bbc1.jpg differ diff --git a/mythview/mythconnector.pyc b/mythview/mythconnector.pyc new file mode 100644 index 0000000..5c182e8 Binary files /dev/null and b/mythview/mythconnector.pyc differ diff --git a/mythview/mythicon.py b/mythview/mythicon.py new file mode 100644 index 0000000..5f2deae --- /dev/null +++ b/mythview/mythicon.py @@ -0,0 +1,48 @@ +import sys +import os.path + +try: + import gtk +except: + print "GTK/GDK binding not found, exiting..." + sys.exit(1) + +from urllib import urlopen +from MythTV import * + +class MythIcon: + + def __init__(self, id, h, w): + + self.loaded = False + mythtv = MythTV() + pixbufload = gtk.gdk.PixbufLoader() + + if os.path.isfile("/tmp/mythtv/%d.jpg" % id): + # File has been cached before, reload from cache + urlstr = 'file:///tmp/mythtv/%d.jpg' % id + else: + urlstr = 'http://%s:%d/Myth/GetChannelIcon?ChanId=%s' % (mythtv.master_host, mythtv.master_port + 1, id) + + url = urlopen(urlstr) + for data in url: + pixbufload.write(data) + if pixbufload.get_pixbuf() != None: + self.pixbuf = pixbufload.get_pixbuf() + self.loaded = True + pixbufload.close() + + if os.path.exists('/tmp/mythtv') == False: + os.mkdir('/tmp/mythtv') + self.save('/tmp/mythtv/%d.jpg' % id, "jpeg", {}) + + if h or w: + self.resize(h,w) + + def resize(self, h, w): + if self.loaded: + self.pixbuf = self.pixbuf.scale_simple(w,h,gtk.gdk.INTERP_BILINEAR) + + def save(self, filename, type, opt): + if filename and self.loaded: + self.pixbuf.save(filename, type, opt) diff --git a/mythview/mythicon.pyc b/mythview/mythicon.pyc new file mode 100644 index 0000000..cd25854 Binary files /dev/null and b/mythview/mythicon.pyc differ diff --git a/mythview/mythtv.py b/mythview/mythtv.py new file mode 100644 index 0000000..cd3c697 --- /dev/null +++ b/mythview/mythtv.py @@ -0,0 +1,5 @@ +# MythTV Interface module + +class MythConnector: + + diff --git a/mythview/mythview.glade b/mythview/mythview.glade new file mode 100644 index 0000000..6143ef2 --- /dev/null +++ b/mythview/mythview.glade @@ -0,0 +1,92 @@ + + + + + + Myth View + 500 + 500 + + + True + + + True + + + True + Connect + gtk-connect + + + False + + + + + True + Refresh + gtk-refresh + + + False + + + + + False + + + + + True + True + True + + + 1 + + + + + True + 2 + + + False + 2 + + + + + + + 5 + About Glade + False + GTK_WIN_POS_CENTER_ON_PARENT + GDK_WINDOW_TYPE_HINT_DIALOG + False + Myth View + 0.1 + + + True + 2 + + + + + + True + GTK_BUTTONBOX_END + + + False + GTK_PACK_END + + + + + + diff --git a/mythview/mythview.py b/mythview/mythview.py new file mode 100755 index 0000000..d29916a --- /dev/null +++ b/mythview/mythview.py @@ -0,0 +1,66 @@ +#!/usr/bin/env python +# example base.py + +import sys +try: + import pygtk + pygtk.require("2.0") +except: + pass +try: + import gtk + import gtk.glade +except: + sys.exit(1) + +from mythicon import MythIcon + +class MythViewUI: + def __init__(self): + + #Set the Glade file + self.gladefile = "mythview.glade" + self.wTree = gtk.glade.XML(self.gladefile) + + #Get the Main Window, and connect the "destroy" event + 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) + + # Setup the TreeView + def addTreeColumn(tree, title, ctype, datafunc, visible,size): + column = gtk.TreeViewColumn(title, ctype) + if datafunc: column.set_cell_data_func(ctype, datafunc) + column.set_resizable(False) + column.set_expand(True) + column.set_visible(visible) + #if size: + # column.set_width(size) + tree.append_column(column) + + self.channelTree = self.wTree.get_widget("ChannelView") + addTreeColumn(self.channelTree, "Channel", gtk.CellRendererText(), None, False,64) + addTreeColumn(self.channelTree, "Icon", gtk.CellRendererPixbuf(), self.FillChanIcon, True, 0) + addTreeColumn(self.channelTree, "Now", gtk.CellRendererText(), None, True, 0) + + # Test Data + self.channelStore.append([1,MythIcon(1126,64,64).pixbuf,"test 1"]) + self.channelStore.append([2,None,"test 2"]) + + self.channelTree.set_model(self.channelStore) + + self.window.show() + + def FillChanIcon(self, column, cell, model, iter): + cell.set_property('pixbuf', model.get_value(iter, 1) ) + return + + def main(self): + gtk.main() + +print __name__ +if __name__ == "__main__": + base = MythViewUI() + base.main() diff --git a/mythview/sql.txt b/mythview/sql.txt new file mode 100644 index 0000000..f55aa85 --- /dev/null +++ b/mythview/sql.txt @@ -0,0 +1,7 @@ +SELECT channel.chanid, 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 +WHERE program.chanid = channel.chanid +AND program.starttime <= NOW( ) +AND program.endtime >= NOW( ) +AND channum <> 0 +ORDER BY channum