def drawTaskbar(widget):
    global taskPanels
    global taskText
    global numOfTasks

    taskList = karamba.getTaskList(widget)

    for image in taskPanels:
        karamba.hideImage(widget, image)

    for text in taskText:
        karamba.changeText(widget, text, "")
        karamba.changeTextShadow(widget, text, 0)
        karamba.changeTextColor(widget, text, 0, 0, 0)

    length = len(taskList)
    if (numOfTasks < length):
        length = numOfTasks

    knownGroups = {}
    groups = []
    groupRefs = {}

    activeGroup = 0
    groupCount = 0

    #build groups list that contains sub-lists of taskInfo sorted by group
    for j in range(len(taskList)):
        taskinfo = karamba.getTaskInfo(widget, taskList[j])

        if knownGroups.has_key(taskinfo[2]) == 0:
            groupCount = groupCount + 1
            if (taskinfo[7] == 1):
                activeGroup = groupCount
            knownGroups[taskinfo[2]] = 1
            thisGroup = []
            thisGroup.append(taskinfo)
            groupRefs[taskinfo[2]] = len(groups)
            groups.append(thisGroup)
        else:
            if (taskinfo[7] == 1):
                activeGroup = groupRefs[taskinfo[2]] + 1
            knownGroups[taskinfo[2]] = knownGroups[taskinfo[2]] + 1
            thisGroup = groups[groupRefs[taskinfo[2]]]
            thisGroup.append(taskinfo)

    #fill out the task bar
    j = 0
    for group in groups:
        #safety check (could be more task groups than bar is long)
        if (j < length):
            karamba.showImage(widget, taskPanels[j])
            if len(group) != 1:
                karamba.changeText(widget, taskText[j],
                                   group[0][2] + " [" + str(len(group)) + "]")
            else:
                karamba.changeText(widget, taskText[j], (group[0][0]))
        j = j + 1

    if (activeGroup != 0):
        karamba.changeTextShadow(widget, taskText[activeGroup - 1], 1)
        karamba.changeTextColor(widget, taskText[activeGroup - 1], 239, 220,
                                11)

    karamba.redrawWidget(widget)
Exemple #2
0
def drawTaskbar(widget):
    global taskPanels
    global taskText
    global numOfTasks

    taskList = karamba.getTaskList(widget)

    for image in taskPanels:
        karamba.hideImage(widget, image)

    for text in taskText:
        karamba.changeText(widget, text, "")
        karamba.changeTextShadow(widget, text, 0)
        karamba.changeTextColor(widget, text, 0, 0, 0)

    length = len(taskList)
    if numOfTasks < length:
        length = numOfTasks

    knownGroups = {}
    groups = []
    groupRefs = {}

    activeGroup = 0
    groupCount = 0

    # build groups list that contains sub-lists of taskInfo sorted by group
    for j in range(len(taskList)):
        taskinfo = karamba.getTaskInfo(widget, taskList[j])

        if knownGroups.has_key(taskinfo[2]) == 0:
            groupCount = groupCount + 1
            if taskinfo[7] == 1:
                activeGroup = groupCount
            knownGroups[taskinfo[2]] = 1
            thisGroup = []
            thisGroup.append(taskinfo)
            groupRefs[taskinfo[2]] = len(groups)
            groups.append(thisGroup)
        else:
            if taskinfo[7] == 1:
                activeGroup = groupRefs[taskinfo[2]] + 1
            knownGroups[taskinfo[2]] = knownGroups[taskinfo[2]] + 1
            thisGroup = groups[groupRefs[taskinfo[2]]]
            thisGroup.append(taskinfo)

            # fill out the task bar
    j = 0
    for group in groups:
        # safety check (could be more task groups than bar is long)
        if j < length:
            karamba.showImage(widget, taskPanels[j])
            if len(group) != 1:
                karamba.changeText(widget, taskText[j], group[0][2] + " [" + str(len(group)) + "]")
            else:
                karamba.changeText(widget, taskText[j], (group[0][0]))
        j = j + 1

    if activeGroup != 0:
        karamba.changeTextShadow(widget, taskText[activeGroup - 1], 1)
        karamba.changeTextColor(widget, taskText[activeGroup - 1], 239, 220, 11)

    karamba.redrawWidget(widget)
def widgetClicked(widget, x, y, button):
    global numOfTasks
    global taskMenu
    global taskMenuLookup

    taskSelected = (x - 198) / 121

    ## Make sure its a valid task
    if (0 <= taskSelected < numOfTasks):
        taskList = karamba.getTaskList(widget)

        #free last menu
        karamba.deleteMenu(widget, taskMenu)

        #create new menu
        taskMenu = karamba.createMenu(widget)
        taskMenuLoopup = {}

        length = len(taskList)
        if (numOfTasks < length):
            length = numOfTasks

        knownGroups = {}
        groups = []
        groupRefs = {}
        for j in range(len(taskList)):
            taskinfo = karamba.getTaskInfo(widget, taskList[j])

            if knownGroups.has_key(taskinfo[2]) == 0:
                knownGroups[taskinfo[2]] = 1
                thisGroup = []
                thisGroup.append(taskinfo)
                groupRefs[taskinfo[2]] = len(groups)
                groups.append(thisGroup)
            else:
                knownGroups[taskinfo[2]] = knownGroups[taskinfo[2]] + 1
                thisGroup = groups[groupRefs[taskinfo[2]]]
                thisGroup.append(taskinfo)

        if taskSelected < len(groups):
            taskGroup = groups[taskSelected]

            if len(taskGroup) == 1:
                #only one task in group - just switch to that app
                ## perform the task action (see Task API for list of numbers)
                karamba.performTaskAction(widget, taskGroup[0][8], 8)

            else:
                #more than one task in this group, make a popup
                for task in taskGroup:
                    #if it's minimized, put []'s around name
                    if task[5] == 1:
                        item = karamba.addMenuItem(widget, taskMenu,
                                                   "[ " + task[0] + " ]",
                                                   task[2])
                    else:
                        item = karamba.addMenuItem(widget, taskMenu, task[0],
                                                   task[2])
                #save the taskInfo item for later use
                    #so we will know info for the task that
                    #will be clicked in the callback
                    taskMenuLookup[item] = task

                numOfItems = len(taskGroup)
                karamba.popupMenu(widget, taskMenu, 198 + (121 * taskSelected),
                                  -1 * (numOfItems * 26))

    if (taskSelected == numOfTasks):
        karamba.toggleShowDesktop(widget)
Exemple #4
0
def widgetClicked(widget, x, y, button):
    global numOfTasks
    global taskMenu
    global taskMenuLookup

    taskSelected = (x - 198) / 121

    ## Make sure its a valid task
    if 0 <= taskSelected < numOfTasks:
        taskList = karamba.getTaskList(widget)

        # free last menu
        karamba.deleteMenu(widget, taskMenu)

        # create new menu
        taskMenu = karamba.createMenu(widget)
        taskMenuLoopup = {}

        length = len(taskList)
        if numOfTasks < length:
            length = numOfTasks

        knownGroups = {}
        groups = []
        groupRefs = {}
        for j in range(len(taskList)):
            taskinfo = karamba.getTaskInfo(widget, taskList[j])

            if knownGroups.has_key(taskinfo[2]) == 0:
                knownGroups[taskinfo[2]] = 1
                thisGroup = []
                thisGroup.append(taskinfo)
                groupRefs[taskinfo[2]] = len(groups)
                groups.append(thisGroup)
            else:
                knownGroups[taskinfo[2]] = knownGroups[taskinfo[2]] + 1
                thisGroup = groups[groupRefs[taskinfo[2]]]
                thisGroup.append(taskinfo)

        if taskSelected < len(groups):
            taskGroup = groups[taskSelected]

            if len(taskGroup) == 1:
                # only one task in group - just switch to that app
                ## perform the task action (see Task API for list of numbers)
                karamba.performTaskAction(widget, taskGroup[0][8], 8)

            else:
                # more than one task in this group, make a popup
                for task in taskGroup:
                    # if it's minimized, put []'s around name
                    if task[5] == 1:
                        item = karamba.addMenuItem(widget, taskMenu, "[ " + task[0] + " ]", task[2])
                    else:
                        item = karamba.addMenuItem(widget, taskMenu, task[0], task[2])
                        # save the taskInfo item for later use
                        # so we will know info for the task that
                        # will be clicked in the callback
                    taskMenuLookup[item] = task

                numOfItems = len(taskGroup)
                karamba.popupMenu(widget, taskMenu, 198 + (121 * taskSelected), -1 * (numOfItems * 26))

    if taskSelected == numOfTasks:
        karamba.toggleShowDesktop(widget)