def initWidget(widget): global menu1 global menu2 global id1 global id2 global id3 global id4 global id5 menu1 = karamba.createMenu(widget) print "menu 1 created!" menu2 = karamba.createMenu(widget) print "menu 2 created!" id1 = karamba.addMenuItem(widget, menu1, "menu 1 first item", "kword") print "item 1 entered in menu 1" id2 = karamba.addMenuItem(widget, menu1, "menu 1 second item", "kate") print "item 2 entered in menu 1" id3 = karamba.addMenuItem(widget, menu2, "menu 2 first item", "kword") print "item 1 entered in menu 2" id4 = karamba.addMenuItem(widget, menu2, "menu 2 second item", "kate") print "item 2 entered in menu 2" id5 = karamba.addMenuItem( widget, menu2, "menu 2 third item", "/opt/kde/share/icons/kdeclassic/16x16/apps/kicker.png" ) print "item 3 entered in menu 2"
def initWidget(widget): global menu1 global menu2 global id1 global id2 global id3 global id4 global id5 menu1 = karamba.createMenu(widget) print "menu 1 created!" menu2 = karamba.createMenu(widget) print "menu 2 created!" id1 = karamba.addMenuItem(widget, menu1, "menu 1 first item", "kword") print "item 1 entered in menu 1" id2 = karamba.addMenuItem(widget, menu1, "menu 1 second item", "kate") print "item 2 entered in menu 1" id3 = karamba.addMenuItem(widget, menu2, "menu 2 first item", "kword") print "item 1 entered in menu 2" id4 = karamba.addMenuItem(widget, menu2, "menu 2 second item", "kate") print "item 2 entered in menu 2" id5 = karamba.addMenuItem( widget, menu2, "menu 2 third item", "/opt/kde/share/icons/kdeclassic/16x16/apps/kicker.png") print "item 3 entered in menu 2"
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)
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)