def click_cb(self, window, event): applet = self.get_applet_at_coords(event.x, event.y) if applet is not None: if event.button == MOUSE_BUTTON_RIGHT: applet.show_menu() else: x = event.x - applet.get_position()[0] y = event.y - applet.get_position()[1] applet.emit("click", x, y) elif event.button == MOUSE_BUTTON_RIGHT: self.menu.popup(None, None, None, event.button, event.get_time())
def click_cb(self, window, event): applet = self.get_applet_at_coords(event.x, event.y) if applet is not None: if event.button == MOUSE_BUTTON_RIGHT: applet.show_menu() else: x = event.x - applet.get_position()[0] y = event.y - applet.get_position()[1] applet.emit('click', x, y) elif event.button == MOUSE_BUTTON_RIGHT: self.menu.popup(None, None, None, event.button, event.get_time())
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)
def scroll_cb(self, window, event): applet = self.get_applet_at_coords(event.x, event.y) if applet: offset_x, offset_y = applet.get_position() applet.emit("scroll", event.x - offset_x, event.y - offset_y, event.direction)
def mouse_leave_cb(self, window, event): applet = self.get_applet_at_coords(event.x, event.y) if applet: offset_x, offset_y = applet.get_position() applet.emit("mouse-leave", event.x - offset_x, event.y - offset_y)
def scroll_cb(self, window, event): applet = self.get_applet_at_coords(event.x, event.y) if applet: offset_x, offset_y = applet.get_position() applet.emit('scroll', event.x - offset_x, event.y - offset_y, event.direction)
def mouse_leave_cb(self, window, event): applet = self.get_applet_at_coords(event.x, event.y) if applet: offset_x, offset_y = applet.get_position() applet.emit('mouse-leave', event.x - offset_x, event.y - offset_y)