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 setStyle(widget, text, shadow, size): karamba.changeTextSize(widget, text, size) karamba.changeTextFont(widget, text, "arialbd") karamba.changeTextShadow(widget, text, shadow)
def widgetUpdated(widget): global texts, b, a b = (b + 1) % 2 # Create & delete if texts[0]: karamba.deleteText(widget, texts[0]) texts[0] = 0 else: texts[0] = karamba.createText(widget, 0, 20, 200, 20, "Text meter") # size & resize size = karamba.getTextSize(widget, texts[1]) print "getTextSize: " + str(size) size = ((b * 200) + 200, size[1]) karamba.resizeText(widget, texts[1], size[0], size[1]) # pos & move pos = karamba.getTextPos(widget, texts[2]) print "getTextPos: " + str(pos) pos = (b * 200, pos[1]) karamba.moveText(widget, texts[2], pos[0], pos[1]) # Hide & Show if b: karamba.hideText(widget, texts[3]) else: karamba.showText(widget, texts[3]) # Sensor sensor = karamba.getTextSensor(widget, texts[4]) print "getSensor: " + str(sensor) if b: karamba.setTextSensor(widget, texts[4], 'SENSOR=SENSOR TYPE="cpu_temp"') else: karamba.setTextSensor(widget, texts[4], "SENSOR=CPU") # Value v = karamba.getTextValue(widget, texts[5]) print "getTextValue: ", v v += "." karamba.changeText(widget, texts[5], v) # Shadow v = karamba.getTextShadow(widget, texts[6]) print "getTextShadow: ", v v = (v + 1) % 10 karamba.changeTextShadow(widget, texts[6], v) # Font size v = karamba.getTextFontSize(widget, texts[7]) print "getTextFontSize: ", v v = 10 + ((v - 10) + 1) % 10 karamba.changeTextSize(widget, texts[7], v) # Text color v = karamba.getTextColor(widget, texts[8]) print "getTextColor: ", v karamba.changeTextColor(widget, texts[8], b * 255, b * 255, b * 255) # Text Font v = karamba.getTextFont(widget, texts[9]) print "getTextFont: ", v if b: v = "Bitstream Vera Sans" else: v = "Bitstream Vera Serif" karamba.changeTextFont(widget, texts[9], v) # Text Alignment a = (a + 1) % 3 v = karamba.getTextAlign(widget, texts[10]) print "getTextAlign: ", v karamba.setTextAlign(widget, texts[10], align[a])
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)
titletext_color = karamba.readConfigEntry(widget, "titletext_color") if titletext_color == None or titletext_color == "": try: r, g, b = theme_cfg.get("karamba", "titletext_color").split(",", 2) karamba.changeTextColor(widget, titletext, int(r), int(g), int(b)) except ConfigParser.NoOptionError, (strerror): print "Warning: " + str(strerror) + ". Using default." else: r, g, b = titletext_color.split(",", 2) karamba.changeTextColor(widget, titletext, int(r), int(g), int(b)) titletext_shadow = karamba.readConfigEntry(widget, "titletext_shadow") if titletext_shadow == None or str(titletext_shadow) == "": try: titletext_shadow = theme_cfg.getint("karamba", "titletext_shadow") karamba.changeTextShadow(widget, titletext, int(titletext_shadow)) except ConfigParser.NoOptionError, (strerror): print "Warning: " + str(strerror) + ". Using default." else: karamba.changeTextShadow(widget, titletext, int(titletext_shadow)) titletext_size = karamba.readConfigEntry(widget, "titletext_size") if titletext_size == None or int(titletext_size) < 1: try: titletext_size = theme_cfg.getint("karamba", "titletext_size") karamba.changeTextSize(widget, titletext, int(titletext_size)) except ConfigParser.NoOptionError, (strerror): print "Warning: " + str(strerror) + ". Using default." else: karamba.changeTextSize(widget, titletext, int(titletext_size))
def widgetUpdated(widget): global texts, b, a b = (b + 1) % 2 # Create & delete if (texts[0]): karamba.deleteText(widget, texts[0]) texts[0] = 0 else: texts[0] = karamba.createText(widget, 0, 20, 200, 20, "Text meter") # size & resize size = karamba.getTextSize(widget, texts[1]) print "getTextSize: " + str(size) size = ((b * 200) + 200, size[1]) karamba.resizeText(widget, texts[1], size[0], size[1]) # pos & move pos = karamba.getTextPos(widget, texts[2]) print "getTextPos: " + str(pos) pos = (b * 200, pos[1]) karamba.moveText(widget, texts[2], pos[0], pos[1]) # Hide & Show if (b): karamba.hideText(widget, texts[3]) else: karamba.showText(widget, texts[3]) # Sensor sensor = karamba.getTextSensor(widget, texts[4]) print "getSensor: " + str(sensor) if (b): karamba.setTextSensor(widget, texts[4], 'SENSOR=SENSOR TYPE="cpu_temp"') else: karamba.setTextSensor(widget, texts[4], 'SENSOR=CPU') # Value v = karamba.getTextValue(widget, texts[5]) print "getTextValue: ", v v += '.' karamba.changeText(widget, texts[5], v) # Shadow v = karamba.getTextShadow(widget, texts[6]) print "getTextShadow: ", v v = (v + 1) % 10 karamba.changeTextShadow(widget, texts[6], v) # Font size v = karamba.getTextFontSize(widget, texts[7]) print "getTextFontSize: ", v v = 10 + ((v - 10) + 1) % 10 karamba.changeTextSize(widget, texts[7], v) # Text color v = karamba.getTextColor(widget, texts[8]) print "getTextColor: ", v karamba.changeTextColor(widget, texts[8], b * 255, b * 255, b * 255) # Text Font v = karamba.getTextFont(widget, texts[9]) print "getTextFont: ", v if (b): v = 'Bitstream Vera Sans' else: v = 'Bitstream Vera Serif' karamba.changeTextFont(widget, texts[9], v) # Text Alignment a = (a + 1) % 3 v = karamba.getTextAlign(widget, texts[10]) print "getTextAlign: ", v karamba.setTextAlign(widget, texts[10], align[a])
titletext_color = karamba.readConfigEntry(widget, "titletext_color") if titletext_color == None or titletext_color == "": try: r, g, b = theme_cfg.get( "karamba", "titletext_color" ).split(",", 2) karamba.changeTextColor(widget, titletext, int(r), int(g), int(b)) except ConfigParser.NoOptionError, (strerror): print "Warning: " + str(strerror) + ". Using default." else: r, g, b = titletext_color.split(",", 2) karamba.changeTextColor(widget, titletext, int(r), int(g), int(b)) titletext_shadow = karamba.readConfigEntry(widget, "titletext_shadow") if titletext_shadow == None or str(titletext_shadow) == "": try: titletext_shadow = theme_cfg.getint( "karamba", "titletext_shadow" ) karamba.changeTextShadow(widget, titletext, int(titletext_shadow)) except ConfigParser.NoOptionError, (strerror): print "Warning: " + str(strerror) + ". Using default." else: karamba.changeTextShadow(widget, titletext, int(titletext_shadow)) titletext_size = karamba.readConfigEntry(widget, "titletext_size") if titletext_size == None or int(titletext_size) < 1: try: titletext_size = theme_cfg.getint( "karamba", "titletext_size" ) karamba.changeTextSize(widget, titletext, int(titletext_size)) except ConfigParser.NoOptionError, (strerror): print "Warning: " + str(strerror) + ". Using default." else: karamba.changeTextSize(widget, titletext, int(titletext_size))