|
|
@ -34,7 +34,7 @@ havexwi = os.system("which xwininfo")
|
|
|
|
if (havexwi == 0):
|
|
|
|
if (havexwi == 0):
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
print "\nCan't find xwininfo in your path."
|
|
|
|
print("\nCan't find xwininfo in your path.")
|
|
|
|
|
|
|
|
|
|
|
|
fp = os.popen("xwininfo -root -stats")
|
|
|
|
fp = os.popen("xwininfo -root -stats")
|
|
|
|
output = fp.read()
|
|
|
|
output = fp.read()
|
|
|
@ -49,8 +49,6 @@ for x in output:
|
|
|
|
resY = int(param[1])
|
|
|
|
resY = int(param[1])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def drawTaskbar(widget):
|
|
|
|
def drawTaskbar(widget):
|
|
|
|
global taskPanels
|
|
|
|
global taskPanels
|
|
|
|
global taskText
|
|
|
|
global taskText
|
|
|
@ -82,39 +80,40 @@ def drawTaskbar(widget):
|
|
|
|
for j in range(len(taskList)):
|
|
|
|
for j in range(len(taskList)):
|
|
|
|
taskinfo = karamba.getTaskInfo(widget, taskList[j])
|
|
|
|
taskinfo = karamba.getTaskInfo(widget, taskList[j])
|
|
|
|
|
|
|
|
|
|
|
|
if knownGroups.has_key(taskinfo[2]) == 0:
|
|
|
|
if (taskinfo[2] in knownGroups) == 0:
|
|
|
|
groupCount = groupCount + 1
|
|
|
|
groupCount = groupCount + 1
|
|
|
|
if (taskinfo[7] == 1):
|
|
|
|
if (taskinfo[7] == 1):
|
|
|
|
activeGroup = groupCount
|
|
|
|
activeGroup = groupCount
|
|
|
|
knownGroups[taskinfo[2]] = 1
|
|
|
|
knownGroups[taskinfo[2]] = 1
|
|
|
|
thisGroup = []
|
|
|
|
thisGroup = []
|
|
|
|
thisGroup.append(taskinfo)
|
|
|
|
thisGroup.append(taskinfo)
|
|
|
|
groupRefs[taskinfo[2]] = len(groups)
|
|
|
|
groupRefs[taskinfo[2]] = len(groups)
|
|
|
|
groups.append(thisGroup)
|
|
|
|
groups.append(thisGroup)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
if (taskinfo[7] == 1):
|
|
|
|
if (taskinfo[7] == 1):
|
|
|
|
activeGroup = groupRefs[taskinfo[2]] + 1
|
|
|
|
activeGroup = groupRefs[taskinfo[2]] + 1
|
|
|
|
knownGroups[taskinfo[2]] = knownGroups[taskinfo[2]] + 1
|
|
|
|
knownGroups[taskinfo[2]] = knownGroups[taskinfo[2]] + 1
|
|
|
|
thisGroup = groups[groupRefs[taskinfo[2]]]
|
|
|
|
thisGroup = groups[groupRefs[taskinfo[2]]]
|
|
|
|
thisGroup.append(taskinfo)
|
|
|
|
thisGroup.append(taskinfo)
|
|
|
|
|
|
|
|
|
|
|
|
#fill out the task bar
|
|
|
|
#fill out the task bar
|
|
|
|
j = 0
|
|
|
|
j = 0
|
|
|
|
for group in groups:
|
|
|
|
for group in groups:
|
|
|
|
#safety check (could be more task groups than bar is long)
|
|
|
|
#safety check (could be more task groups than bar is long)
|
|
|
|
if (j < length):
|
|
|
|
if (j < length):
|
|
|
|
karamba.showImage(widget, taskPanels[j])
|
|
|
|
karamba.showImage(widget, taskPanels[j])
|
|
|
|
if len(group) != 1:
|
|
|
|
if len(group) != 1:
|
|
|
|
karamba.changeText(widget, taskText[j], group[0][2] + " [" + str(len(group)) + "]")
|
|
|
|
karamba.changeText(widget, taskText[j], group[0][2].decode('utf-8') + ' [' + str(len(group)) + ']')
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
karamba.changeText(widget, taskText[j], (group[0][0]))
|
|
|
|
karamba.changeText(widget, taskText[j], group[0][0].decode('utf-8'))
|
|
|
|
j = j + 1
|
|
|
|
j = j + 1
|
|
|
|
|
|
|
|
|
|
|
|
if (activeGroup != 0):
|
|
|
|
if (activeGroup != 0):
|
|
|
|
karamba.changeTextShadow(widget, taskText[activeGroup - 1], 1)
|
|
|
|
karamba.changeTextShadow(widget, taskText[activeGroup - 1], 1)
|
|
|
|
karamba.changeTextColor(widget, taskText[activeGroup - 1], 239, 220, 11)
|
|
|
|
karamba.changeTextColor(widget, taskText[activeGroup - 1], 239, 220, 11)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
karamba.moveWidget(widget, 0, resY - 32)
|
|
|
|
|
|
|
|
karamba.resizeWidget(widget, resX, resY)
|
|
|
|
karamba.redrawWidget(widget)
|
|
|
|
karamba.redrawWidget(widget)
|
|
|
|
|
|
|
|
|
|
|
|
#this is called when your widget is initialized
|
|
|
|
#this is called when your widget is initialized
|
|
|
@ -126,7 +125,7 @@ def initWidget(widget):
|
|
|
|
global timeText
|
|
|
|
global timeText
|
|
|
|
|
|
|
|
|
|
|
|
karamba.createImage(widget, resX - 149, 0, "pics/rightend_new.png")
|
|
|
|
karamba.createImage(widget, resX - 149, 0, "pics/rightend_new.png")
|
|
|
|
numOfTasks = (resX - 198 - 149)/121
|
|
|
|
numOfTasks = (resX - 198 - 149) // 121
|
|
|
|
|
|
|
|
|
|
|
|
timeText = karamba.createText(widget, resX - 149 + 54, 10, 140, 20, "time")
|
|
|
|
timeText = karamba.createText(widget, resX - 149 + 54, 10, 140, 20, "time")
|
|
|
|
karamba.changeTextColor(widget, timeText, 0,0,0)
|
|
|
|
karamba.changeTextColor(widget, timeText, 0,0,0)
|
|
|
@ -143,13 +142,13 @@ def initWidget(widget):
|
|
|
|
|
|
|
|
|
|
|
|
# called to indicate that a new task is currently started
|
|
|
|
# called to indicate that a new task is currently started
|
|
|
|
def startupAdded(widget, startup):
|
|
|
|
def startupAdded(widget, startup):
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
# called whenever a startup is removed. Which either means the task is
|
|
|
|
# called whenever a startup is removed. Which either means the task is
|
|
|
|
# successfully started (and taskAdded will be called), or the task could
|
|
|
|
# successfully started (and taskAdded will be called), or the task could
|
|
|
|
# not be started for some reason.
|
|
|
|
# not be started for some reason.
|
|
|
|
def startupRemoved(widget, startup):
|
|
|
|
def startupRemoved(widget, startup):
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
# called whenever a new task has been started
|
|
|
|
# called whenever a new task has been started
|
|
|
|
def taskAdded(widget, task):
|
|
|
|
def taskAdded(widget, task):
|
|
|
@ -190,78 +189,75 @@ def widgetClicked(widget, x, y, button):
|
|
|
|
global taskMenu
|
|
|
|
global taskMenu
|
|
|
|
global taskMenuLookup
|
|
|
|
global taskMenuLookup
|
|
|
|
|
|
|
|
|
|
|
|
taskSelected = (x-198)/121
|
|
|
|
taskSelected = (x-198) // 121
|
|
|
|
|
|
|
|
|
|
|
|
## Make sure its a valid task
|
|
|
|
## Make sure its a valid task
|
|
|
|
if (0 <= taskSelected < numOfTasks):
|
|
|
|
if (0 <= taskSelected < numOfTasks):
|
|
|
|
taskList = karamba.getTaskList(widget)
|
|
|
|
taskList = karamba.getTaskList(widget)
|
|
|
|
|
|
|
|
|
|
|
|
#free last menu
|
|
|
|
#free last menu
|
|
|
|
karamba.deleteMenu(widget, taskMenu)
|
|
|
|
karamba.deleteMenu(widget, taskMenu)
|
|
|
|
|
|
|
|
|
|
|
|
#create new menu
|
|
|
|
#create new menu
|
|
|
|
taskMenu = karamba.createMenu(widget)
|
|
|
|
taskMenu = karamba.createMenu(widget)
|
|
|
|
taskMenuLoopup = {}
|
|
|
|
taskMenuLoopup = {}
|
|
|
|
|
|
|
|
|
|
|
|
length = len(taskList)
|
|
|
|
length = len(taskList)
|
|
|
|
if (numOfTasks < length):
|
|
|
|
if (numOfTasks < length):
|
|
|
|
length = numOfTasks
|
|
|
|
length = numOfTasks
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
knownGroups = {}
|
|
|
|
knownGroups = {}
|
|
|
|
groups = []
|
|
|
|
groups = []
|
|
|
|
groupRefs = {}
|
|
|
|
groupRefs = {}
|
|
|
|
for j in range(len(taskList)):
|
|
|
|
for j in range(len(taskList)):
|
|
|
|
taskinfo = karamba.getTaskInfo(widget, taskList[j])
|
|
|
|
taskinfo = karamba.getTaskInfo(widget, taskList[j])
|
|
|
|
|
|
|
|
|
|
|
|
if knownGroups.has_key(taskinfo[2]) == 0:
|
|
|
|
if (taskinfo[2] in knownGroups) == 0:
|
|
|
|
knownGroups[taskinfo[2]] = 1
|
|
|
|
knownGroups[taskinfo[2]] = 1
|
|
|
|
thisGroup = []
|
|
|
|
thisGroup = []
|
|
|
|
thisGroup.append(taskinfo)
|
|
|
|
thisGroup.append(taskinfo)
|
|
|
|
groupRefs[taskinfo[2]] = len(groups)
|
|
|
|
groupRefs[taskinfo[2]] = len(groups)
|
|
|
|
groups.append(thisGroup)
|
|
|
|
groups.append(thisGroup)
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
knownGroups[taskinfo[2]] = knownGroups[taskinfo[2]] + 1
|
|
|
|
knownGroups[taskinfo[2]] = knownGroups[taskinfo[2]] + 1
|
|
|
|
thisGroup = groups[groupRefs[taskinfo[2]]]
|
|
|
|
thisGroup = groups[groupRefs[taskinfo[2]]]
|
|
|
|
thisGroup.append(taskinfo)
|
|
|
|
thisGroup.append(taskinfo)
|
|
|
|
|
|
|
|
|
|
|
|
if taskSelected < len(groups):
|
|
|
|
if taskSelected < len(groups):
|
|
|
|
taskGroup = groups[taskSelected]
|
|
|
|
taskGroup = groups[taskSelected]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(taskGroup) == 1:
|
|
|
|
if len(taskGroup) == 1:
|
|
|
|
#only one task in group - just switch to that app
|
|
|
|
#only one task in group - just switch to that app
|
|
|
|
## perform the task action (see Task API for list of numbers)
|
|
|
|
## perform the task action (see Task API for list of numbers)
|
|
|
|
karamba.performTaskAction(widget, taskGroup[0][8], 8)
|
|
|
|
karamba.performTaskAction(widget, taskGroup[0][8], 8)
|
|
|
|
else:
|
|
|
|
|
|
|
|
#more than one task in this group, make a popup
|
|
|
|
else:
|
|
|
|
for task in taskGroup:
|
|
|
|
#more than one task in this group, make a popup
|
|
|
|
#if it's minimized, put []'s around name
|
|
|
|
for task in taskGroup:
|
|
|
|
if task[5] == 1:
|
|
|
|
#if it's minimized, put []'s around name
|
|
|
|
item = karamba.addMenuItem(widget, taskMenu, "[ " + task[0].decode('utf-8') + " ]", task[2].decode('utf-8'))
|
|
|
|
if task[5] == 1:
|
|
|
|
else:
|
|
|
|
item = karamba.addMenuItem(widget, taskMenu, "[ " + task[0] + " ]", task[2])
|
|
|
|
item = karamba.addMenuItem(widget, taskMenu, task[0].decode('utf-8'), task[2].decode('utf-8'))
|
|
|
|
else:
|
|
|
|
#save the taskInfo item for later use
|
|
|
|
item = karamba.addMenuItem(widget, taskMenu, task[0], task[2])
|
|
|
|
#so we will know info for the task that
|
|
|
|
#save the taskInfo item for later use
|
|
|
|
#will be clicked in the callback
|
|
|
|
#so we will know info for the task that
|
|
|
|
taskMenuLookup[item] = task
|
|
|
|
#will be clicked in the callback
|
|
|
|
|
|
|
|
taskMenuLookup[item] = task
|
|
|
|
numOfItems = len(taskGroup)
|
|
|
|
|
|
|
|
karamba.popupMenu(widget, taskMenu, 198 + (121*taskSelected), -1 * (numOfItems * 26))
|
|
|
|
numOfItems = len(taskGroup)
|
|
|
|
|
|
|
|
karamba.popupMenu(widget, taskMenu, 198 + (121*taskSelected), -1 * (numOfItems * 26))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (taskSelected == numOfTasks):
|
|
|
|
if (taskSelected == numOfTasks):
|
|
|
|
karamba.toggleShowDesktop(widget)
|
|
|
|
karamba.toggleShowDesktop(widget)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#This gets called when an item is clicked in a popup menu you have created.
|
|
|
|
#This gets called when an item is clicked in a popup menu you have created.
|
|
|
|
# menu = a reference to the menu
|
|
|
|
# menu = a reference to the menu
|
|
|
|
# id = the number of the item that was clicked.
|
|
|
|
# id = the number of the item that was clicked.
|
|
|
|
def menuItemClicked(widget, menu, id):
|
|
|
|
def menuItemClicked(widget, menu, id):
|
|
|
|
global taskMenuLookup
|
|
|
|
global taskMenuLookup
|
|
|
|
|
|
|
|
|
|
|
|
taskinfo = taskMenuLookup[id]
|
|
|
|
taskinfo = taskMenuLookup[id]
|
|
|
|
karamba.performTaskAction(widget, taskinfo[8], 8)
|
|
|
|
karamba.performTaskAction(widget, taskinfo[8], 8)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|