Et le script ;-)
# SuperKaramba Glas-Bar Theme v0.1 by GeniusR13
# designed on KDE 3.0.2 and still unfinished :-D
#
# The theme is mostly configured in the .theme file as it's adopted from my very first
# karamba theme. Python is used only for the taskbar and pager stuff.
# Beware: this is my first try in python programming (oooops :-)
import karamba
import os
#----- start customizing area -----
pager_x = 212 # y/x coordinates where the pager should appear
pager_y = 9
pager_h = 35 # h/w size of the pager
pager_w = 35
pager_mainpic = "Glas/pager-" # pager picture generic name (i.e. Glas/pager-1.png)
task_x = 250 # y/x coordinates where the taskbar should appear
task_y = 8
task_h = 45 # h/w size of the taskbar
task_w = 650
task_bg_pic = "Glas/task4.png" # Background pic for task list (looks ugly without)
#----- end customizing area -----
twidth = 0 # width of a task frame pic
theight = 0 # height of a task frame pic
task_list = [] # list of current running tasks
task_oldtextlist = [] # list of displayed task text widgets
task_frametextlist = [] # list of frame pics
pager_pic = 0 # currently displayed pager picture object
#This is called when you widget is initialized
def initWidget(widget):
global pager_pic
global pager_mainpic
global pager_x
global pager_y
pager_pic = SetPager(widget, pager_pic, pager_mainpic, pager_x, pager_y, 1)
pass
#this is called everytime your widget is updated
#the update inverval is specified in the .theme file
def widgetUpdated(widget):
global task_list
global task_oldtextlist
global task_frametextlist
global task_x
global task_y
global task_h
global task_w
global task_bg_pic
global twidth
global theight
global pager_pic
global pager_mainpic
global pager_x
global pager_y
for this_task in task_oldtextlist: # cleanup all displayed tasks
karamba.deleteText(widget, this_task)
for this_task in task_frametextlist: # cleanup corresponding task pics
karamba.deleteImage(widget, this_task)
task_oldtextlist = [] # remove deleted elements from list
task_frametextlist = []
task_list = karamba.getTaskList(widget) # list of all running tasks
taskcount = len(task_list) + (len(task_list) % 2) # count of vert. fields
twidth = task_w / (taskcount / 2) # width of a textfield
theight = task_h / 2 # heigt of a textfield
tx = task_x
ty = task_y
istop = 1
for this_task in task_list: # display tasks
task_info = karamba.getTaskInfo(widget,this_task) # get info of task
this_frame = karamba.createImage(widget, tx, ty, task_bg_pic) # build display frame
karamba.resizeImage(widget,this_frame,twidth,theight) # adjust frame size
task_frametextlist.append(this_frame)
this_text = karamba.createText(widget, tx+14, ty+3, twidth-20, theight-3, task_info[0])
karamba.changeTextColor(widget, this_text, 0, 0, 0)
karamba.changeTextSize(widget, this_text, 10)
task_oldtextlist.append(this_text)
if( istop == 1 ): # calc coordinates for next task
istop = 0
ty = ty + theight
else:
istop = 1
ty = task_y
tx = tx + twidth
pager_pic = SetPager(widget, pager_pic, pager_mainpic, pager_x, pager_y, 0)
pass
def widgetClicked(widget, x, y, button):
global task_list
global task_x
global task_y
global task_h
global task_w
global twidth
global theight
global pager_x
global pager_y
global pager_h
global pager_w
# only taskbar clicks
if( (button == 1) and (task_x <= x <= (task_x+task_w)) and (task_y <= y <= (task_y+task_h)) ):
tx = x - task_x # find the selected (clicked) task by x/y position
ty = y - task_y
listnum = (tx / twidth) * 2
if( ty > theight ):
listnum = listnum + 1
karamba.performTaskAction(widget, task_list[listnum], 8) # execute "smart focus"
# only pager clicks
if( (button == 1) and (pager_x <= x <= (pager_x+pager_w)) and (pager_y <= y <= (pager_y+pager_h)) ):
if( x < (pager_x + (pager_w/2)) ):
if( y < (pager_y + (pager_h/2)) ):
os.system("dcop kwin KWinInterface setCurrentDesktop 1")
else:
os.system("dcop kwin KWinInterface setCurrentDesktop 3")
else:
if( y < (pager_y + (pager_h/2)) ):
os.system("dcop kwin KWinInterface setCurrentDesktop 2")
else:
os.system("dcop kwin KWinInterface setCurrentDesktop 4")
pass
def widgetMouseMoved(widget, x, y, button):
#Warning: Don't do anything too intensive here
#You don't want to run some complex piece of code everytime the mouse moves
pass
def SetPager(widget, pager_pic, pager_mainpic, pager_x, pager_y, isnew):
temp = os.popen("dcop kwin KWinInterface currentDesktop")
this_desk = temp.read() # get current desktop from dcop
this_desk = this_desk.splitlines()
this_desk = this_desk[0]
temp.close()
pager_file = pager_mainpic + str(this_desk) + ".png" # build filename
if( isnew == 0 ): # if not new, remove old object
karamba.deleteImage(widget, pager_pic)
pager_pic = karamba.createImage(widget, pager_x, pager_y, pager_file) # create pager pic
return pager_pic # return the new pic object
# This will be printed when the widget loads.
print "Loaded my python extension!"
Linux a un noyau, Windows a un pépin ;-)
Poste le Tuesday 28 October 2003 09:57:15