2005年4月30日

GtkDrawingArea and GtkScrolledWindow


I saw some question asked about making flashget like progress window in gtk+. It can be simply realized using DrawingArea.



Then there is also the problem of scrolling the DrawingArea inside a ScrolledWindow. Well, this is simple. Just put a Viewport b/w the DrawingArea and the ScrolledWindow. Then do a set_size_request on the DrawingArea.





#!/usr/bin/python
import pygtk
pygtk.require('2.0')
import gtk

# 2 icons we use in our drawing area.
PICTNAME1="gdraw1.png"
PICTNAME2="gdraw2.png"
def load(pix):
'''Load GUI'''
win = gtk.Window()
gdraw = gtk.DrawingArea()
sw = gtk.ScrolledWindow()
sw.set_policy(gtk.POLICY_NEVER, gtk.POLICY_AUTOMATIC)
vp = gtk.Viewport()
sw.add(vp)
vp.add(gdraw)

win.add(sw)
win.resize(400, 200)
win.connect('delete-event', gtk.main_quit)
gdraw.connect('expose-event', expose_pix, pix)
win.show_all()

def expose_pix(gdraw, event, pix):
'''At expose event, actual draw graph.'''
pix1, pix2 = pix
gc = gdraw.window.new_gc()
pw = pix1.get_width()
ph = pix1.get_height()
geo = gdraw.window.get_geometry()
gw, gh = geo[2:4]
dx = dy = 0

# Draw 100 pixbuf on DrawingArea
for i in range(100):
if dx + pw > gw:
# Move down to the next line
dx = 0
dy += ph+1
if i % 7: # Draw a pix2 every 7 pix1
pixi = pix1
else:
pixi = pix2
gdraw.window.draw_pixbuf(gc, pixi, 0, 0,
dx, dy, pw, ph)
dx += pw+1
# Set the gdraw size request for Viewport
# to the height of our drawing.
gdraw.set_size_request(-1, dy+ph)

def main():
pix1 = gtk.gdk.pixbuf_new_from_file(PICTNAME1)
pix2 = gtk.gdk.pixbuf_new_from_file(PICTNAME2)
load((pix1, pix2))
gtk.main()

if __name__ == '__main__':
main()




Told you pygtk is very easy to program with.

2005年4月25日

CoolStreaming on Linux?

Doing wine + coolstreaming on Linux is smooth. Go Linux!!



It's still proprietary but... It's not like writing an open source equivalent is hard. It's just that it is not easy to find reliable media sources. There! This's my excuse for using coolstreaming. :)

Abit NF7-S2 board ethernet Linux driver.

The NF7-S2 board from Abit has a buildin ethernet chip. This is a NForce2 board but they do not use Nvidia's NIC. The one I got has this ICPlus IP100A 10/100 ethernet chip on it. Found that out from Abit's China site. Of cause if you are not a Chinese, you are not gonna find it out because this piece of information won't appare on any other Abit sites. Anyway, Under Linux, lspci shows it as:



Ethernet controller: Sundance Technology Inc: Unknown device 0200 (rev 31)



So it is basically a Sundance Ethernet Chip. It turns out that the Sundance driver come with Linux 2.6.11 does not work with the chip. I have to download the ICPlus IP100A Linux driver from ICPlus's own site.



After 'make all' and copy the sundance.ko (Why do they still call it sundance.ko?) to /lib/modules/2.6.11-01/kernel/drivers/net/ , "modprobe sundance". dah dah..., one more NIC on this box. :)



So now we know that one revision of Abit NF7 S2 mainboard use ICPlus IP100A ethernet chip which shows up as Sundance chip.