def relayout(self): position = 0 for group_n, group in enumerate(self.layout): orientation = group["orientation"] if orientation == "right": position = self.window.get_size()[0] - group["position"] objects = group["objects"] objects.reverse() elif orientation == "left": position = group["position"] objects = group["objects"] for obj_n, obj in enumerate(objects): if obj["type"] == "applet": applet = obj["instance"] if orientation == "right": position -= applet.get_allocation()[0] applet.set_position(position, 0) elif orientation == "left": applet.set_position(position, 0) position += applet.get_allocation()[0] elif obj["type"] == "space": if orientation == "right": position -= obj["size"] elif orientation == "left": position += obj["size"] if orientation == "right": objects.reverse() self.window.window.invalidate_rect( gtk.gdk.Rectangle(0, 0, self.window.get_size()[0], self.window.get_size()[1]), True )
def relayout(self): position = 0 for group_n, group in enumerate(self.layout): orientation = group['orientation'] if orientation == 'right': position = self.window.get_size()[0] - group['position'] objects = group['objects'] objects.reverse() elif orientation == 'left': position = group['position'] objects = group['objects'] for obj_n, obj in enumerate(objects): if obj['type'] == 'applet': applet = obj['instance'] if orientation == 'right': position -= applet.get_allocation()[0] applet.set_position(position, 0) elif orientation == 'left': applet.set_position(position, 0) position += applet.get_allocation()[0] elif obj['type'] == 'space': if orientation == 'right': position -= obj['size'] elif orientation == 'left': position += obj['size'] if orientation == 'right': objects.reverse() self.window.window.invalidate_rect( gtk.gdk.Rectangle(0, 0, self.window.get_size()[0], self.window.get_size()[1]), True)
def render_request_cb(self, applet): x, y = applet.get_position() width, height = applet.get_allocation() self.window.window.invalidate_rect( gtk.gdk.Rectangle(int(x), int(y), int(width), int(height)), True)
def get_applet_at_coords(self, x, y): for group_n, group in enumerate(self.layout): orientation = group["orientation"] position = group["position"] for obj_n, obj in enumerate(group["objects"]): if obj["type"] == "applet": applet = obj["instance"] w, h = applet.get_allocation() x0, y0 = applet.get_position() x1, y1 = x0 + w, y0 + h if x >= x0 and x <= x1 and y >= y0 and y <= y1: return applet return None
def get_applet_at_coords(self, x, y): for group_n, group in enumerate(self.layout): orientation = group['orientation'] position = group['position'] for obj_n, obj in enumerate(group['objects']): if obj['type'] == 'applet': applet = obj['instance'] w, h = applet.get_allocation() x0, y0 = applet.get_position() x1, y1 = x0 + w, y0 + h if x >= x0 and x <= x1 and y >= y0 and y <= y1: return applet return None
def expose_cb(self, *args): ctx = self.window.window.cairo_create() for group_n, group in enumerate(self.layout): orientation = group["orientation"] position = group["position"] for obj_n, obj in enumerate(group["objects"]): if obj["type"] == "applet": applet = obj["instance"] ctx.save() x, y = applet.get_position() width, height = applet.get_allocation() ctx.translate(x, y) ctx.rectangle(0, 0, width, height) ctx.clip() applet.render(ctx) ctx.restore()
def expose_cb(self, *args): ctx = self.window.window.cairo_create() for group_n, group in enumerate(self.layout): orientation = group['orientation'] position = group['position'] for obj_n, obj in enumerate(group['objects']): if obj['type'] == 'applet': applet = obj['instance'] ctx.save() x, y = applet.get_position() width, height = applet.get_allocation() ctx.translate(x, y) ctx.rectangle(0, 0, width, height) ctx.clip() applet.render(ctx) ctx.restore()
def render_request_cb(self, applet): x, y = applet.get_position() width, height = applet.get_allocation() self.window.window.invalidate_rect(gtk.gdk.Rectangle(int(x), int(y), int(width), int(height)), True)