mirror of
https://github.com/nikdoof/mythview.git
synced 2025-12-17 21:09:22 +00:00
Inital commit
This commit is contained in:
BIN
mythview/bbc1.jpg
Normal file
BIN
mythview/bbc1.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.6 KiB |
BIN
mythview/mythconnector.pyc
Normal file
BIN
mythview/mythconnector.pyc
Normal file
Binary file not shown.
48
mythview/mythicon.py
Normal file
48
mythview/mythicon.py
Normal file
@@ -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)
|
||||
BIN
mythview/mythicon.pyc
Normal file
BIN
mythview/mythicon.pyc
Normal file
Binary file not shown.
5
mythview/mythtv.py
Normal file
5
mythview/mythtv.py
Normal file
@@ -0,0 +1,5 @@
|
||||
# MythTV Interface module
|
||||
|
||||
class MythConnector:
|
||||
|
||||
|
||||
92
mythview/mythview.glade
Normal file
92
mythview/mythview.glade
Normal file
@@ -0,0 +1,92 @@
|
||||
<?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 19:31:17 2008 -->
|
||||
<glade-interface>
|
||||
<widget class="GtkWindow" id="MainWindow">
|
||||
<property name="title" translatable="yes">Myth View</property>
|
||||
<property name="default_width">500</property>
|
||||
<property name="default_height">500</property>
|
||||
<child>
|
||||
<widget class="GtkVBox" id="Container1">
|
||||
<property name="visible">True</property>
|
||||
<child>
|
||||
<widget class="GtkToolbar" id="MainToolbar">
|
||||
<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>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkToolButton" id="btnRefresh">
|
||||
<property name="visible">True</property>
|
||||
<property name="label" translatable="yes">Refresh</property>
|
||||
<property name="stock_id">gtk-refresh</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkTreeView" id="ChannelView">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">True</property>
|
||||
<property name="headers_clickable">True</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="position">1</property>
|
||||
</packing>
|
||||
</child>
|
||||
<child>
|
||||
<widget class="GtkStatusbar" id="MainStatusBar">
|
||||
<property name="visible">True</property>
|
||||
<property name="spacing">2</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="position">2</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
<widget class="GtkAboutDialog" id="AboutWindow">
|
||||
<property name="border_width">5</property>
|
||||
<property name="title" translatable="yes">About Glade</property>
|
||||
<property name="resizable">False</property>
|
||||
<property name="window_position">GTK_WIN_POS_CENTER_ON_PARENT</property>
|
||||
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
|
||||
<property name="has_separator">False</property>
|
||||
<property name="program_name">Myth View</property>
|
||||
<property name="version">0.1</property>
|
||||
<child internal-child="vbox">
|
||||
<widget class="GtkVBox" id="dialog-vbox1">
|
||||
<property name="visible">True</property>
|
||||
<property name="spacing">2</property>
|
||||
<child>
|
||||
<placeholder/>
|
||||
</child>
|
||||
<child internal-child="action_area">
|
||||
<widget class="GtkHButtonBox" id="dialog-action_area1">
|
||||
<property name="visible">True</property>
|
||||
<property name="layout_style">GTK_BUTTONBOX_END</property>
|
||||
</widget>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
<property name="pack_type">GTK_PACK_END</property>
|
||||
</packing>
|
||||
</child>
|
||||
</widget>
|
||||
</child>
|
||||
</widget>
|
||||
</glade-interface>
|
||||
66
mythview/mythview.py
Executable file
66
mythview/mythview.py
Executable file
@@ -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()
|
||||
7
mythview/sql.txt
Normal file
7
mythview/sql.txt
Normal file
@@ -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
|
||||
Reference in New Issue
Block a user