Exemplo n.º 1
0
 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())
Exemplo n.º 2
0
 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())
Exemplo n.º 3
0
    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)
Exemplo n.º 4
0
    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
Exemplo n.º 5
0
    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
Exemplo n.º 6
0
    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()
Exemplo n.º 7
0
    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()
Exemplo n.º 8
0
    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)
Exemplo n.º 9
0
 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)
Exemplo n.º 10
0
 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)
Exemplo n.º 11
0
 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)
Exemplo n.º 12
0
 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)