コード例 #1
0
 def create(self):
     """
     Create the clutter object
     """
     self.delayed = []
     self.obj = clutter.Texture()
     self.obj.hide()
コード例 #2
0
    def show_contacts(self):
        data = {}
        accounts = app.contacts._accounts
        for account in accounts:
            if not app.account_is_connected(account):
                continue
            for contact in accounts[account].contacts._contacts:
                pep = accounts[account].contacts._contacts[contact][0].pep
                if 'location' not in pep:
                    continue
                lat = pep['location'].data.get('lat', None)
                lon = pep['location'].data.get('lon', None)
                if not lat or not lon:
                    continue
                name = accounts[account].contacts.get_first_contact_from_jid(
                    contact).get_shown_name()
                data[contact] = (lat, lon, name)

        self.contacts_layer = Champlain.MarkerLayer()
        for jid in data:
            path = self.get_path_to_generic_or_avatar(self.path_to_image,
                                                      jid=jid,
                                                      suffix='')
            texture = Clutter.Texture()
            texture.set_from_file(path)
            texture.set_size(32, 32)
            marker = Champlain.Label.new_with_image(texture)
            marker.set_text(data[jid][2])
            marker.set_location(float(data[jid][0]), float(data[jid][1]))
            self.contacts_layer.add_marker(marker)

        self.view.add_layer(self.contacts_layer)
        self.contacts_layer.animate_in_all_markers()
        self.markers_is_visible = True
コード例 #3
0
ファイル: clutter_experiment.py プロジェクト: peterlevi/ojo
def get_texture(img):
    pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(img, 800, 600, True)

    t = Clutter.Texture()
    t.set_from_rgb_data(pixbuf.get_pixels(), pixbuf.get_has_alpha(),
                        pixbuf.get_width(), pixbuf.get_height(),
                        pixbuf.get_rowstride(),
                        4 if pixbuf.get_has_alpha() else 3,
                        Clutter.TextureFlags.NONE)
    return t
コード例 #4
0
    def __init__(self, r, g, b, a):
        Clutter.Group.__init__(self)

        self.rectangle = Clutter.Rectangle(color=Clutter.Color(r, g, b, a))
        self.hand      = Clutter.Texture(filename="../data/redhand.png")

        for actor in self.rectangle, self.hand:
            actor.set_size(ACTOR_WIDTH, ACTOR_HEIGHT)

        self.add(self.rectangle, self.hand)
コード例 #5
0
    def __init__(self, **kw):
        kw.setdefault("layout-manager", Clutter.BinLayout())
        super(PhotosImageWidget, self).__init__(**kw)
        self._ratio = 1.0

        self._base_image = Clutter.Texture()
        self.add_child(self._base_image)
        self._border_image = Clutter.Texture()
        self.add_child(self._border_image)

        self._crop_overlay = CropOverlay()
        self.add_child(self._crop_overlay)
        self._crop_overlay.hide_crop_overlay()
        self.crop_overlay_visible = False

        bind_overlay_size = Clutter.BindConstraint(
            coordinate=Clutter.BindCoordinate.SIZE, source=self._base_image)
        self._crop_overlay.add_constraint(bind_overlay_size)

        self.connect('allocation-changed', self.alloc_changed)
コード例 #6
0
    np2 = lambda n: 2 ** math.ceil(math.log(n, 2))

    actor.set_shader_param_float("x_step", 1.0 / np2(actor.get_width()))
    actor.set_shader_param_float("x_step", 1.0 / np2(actor.get_height()))

if __name__ == "__main__":
    stage = Clutter.Stage()

    stage.set_title("Shaders")
    stage.set_color(Clutter.Color.new(0x61, 0x64, 0x8c, 0xff))
    stage.set_size(512, 384)
    stage.connect("destroy", Clutter.main_quit)

    # Here we create a texture-based actor from the file on disk.
    # Our actor will toggle through shading on right/left click. Unlike the
    # normal example, we'll start with the basic redhand to let you see how
    # things change...

    actor = Clutter.Texture(filename="../../data/redhand.png")

    actor.set_position(100, 100)
    actor.set_reactive(True)
    actor.connect("button-release-event", button_release_cb, None)

    stage.add_actor(actor)
    stage.show_all()

    Clutter.main()

コード例 #7
0
    np2 = lambda n: 2**math.ceil(math.log(n, 2))

    actor.set_shader_param_float("x_step", 1.0 / np2(actor.get_width()))
    actor.set_shader_param_float("x_step", 1.0 / np2(actor.get_height()))


if __name__ == "__main__":
    stage = Clutter.Stage()

    stage.set_title("Shaders")
    stage.set_color(Clutter.Color.new(0x61, 0x64, 0x8c, 0xff))
    stage.set_size(512, 384)
    stage.connect("destroy", lambda *x: Clutter.main_quit())

    # Here we create a texture-based actor from the file on disk.
    # Our actor will toggle through shading on right/left click. Unlike the
    # normal example, we'll start with the basic redhand to let you see how
    # things change...

    actor = Clutter.Texture(filename="logo.png")

    actor.set_position(100, 100)
    actor.set_reactive(True)
    actor.connect("button-release-event", button_release_cb, None)

    stage.add_actor(actor)
    stage.show_all()

    Clutter.main()
コード例 #8
0
ファイル: cluttergst_test.py プロジェクト: peterlevi/ojo
from gi.repository import Clutter, ClutterGst, Gst
import sys

ClutterGst.init(sys.argv)

stage = Clutter.Stage()
stage.set_size(800, 600)
stage.connect('destroy', lambda x: Clutter.main_quit())

texture = Clutter.Texture()
pipeline = Gst.parse_launch("playbin2 uri=http://docs.gstreamer.com/media/sintel_trailer-480p.webm")
sink = Gst.ElementFactory.make("autocluttersink", None)
sink.set_property("texture", texture)
pipeline.set_property("video-sink", sink)
Gst.Element.set_state(pipeline, Gst.State.PLAYING)

stage.add_actor(texture)
#texture.set_opacity(0)

timeline = Clutter.Timeline()
timeline.set_duration(2500)
#timeline.set_delay(50)
timeline.set_loop(False)
alpha = Clutter.Alpha()
alpha.set_timeline(timeline)
alpha.set_func(lambda a, d: a.get_timeline().get_progress(), None)
behaviour = Clutter.BehaviourRotate(alpha=alpha, angle_start=180, angle_end=0, axis=Clutter.RotateAxis.Y_AXIS, direction = "ccw")
behaviour.apply(texture)
timeline.start()

stage.show_all()
コード例 #9
0
    scrollable.animate(Clutter.AnimationMode.EASE_OUT_CUBIC, 300, "y", y)

    return False


image_file_path = "../../data/redhand.png"

if len(sys.argv) > 1:
    image_file_path = sys.argv[1]

stage = Clutter.Stage()
stage.set_size(STAGE_WIDTH, STAGE_HEIGHT)
stage.connect("destroy", Clutter.main_quit)

# the scrollable actor
texture = Clutter.Texture(filename=image_file_path)
texture.set_keep_aspect_ratio(True)

# set the texture's height so it's as tall as the stage
texture.set_request_mode(Clutter.RequestMode.WIDTH_FOR_HEIGHT)
texture.set_height(STAGE_HEIGHT)

# the viewport which the box is scrolled within
viewport = Clutter.Group()
viewport.set_size(STAGE_WIDTH, STAGE_HEIGHT * 0.5)

# align the viewport to the center of the stage's y axis
viewport.add_constraint(Clutter.AlignConstraint.new(stage, Clutter.AlignAxis.Y_AXIS, 0.5))

# viewport needs to respond to scroll events
viewport.set_reactive(True)
コード例 #10
0
stage = Clutter.Stage()
stage.set_color(Clutter.Color.from_string("#333355"))
stage.set_size(400, 400)
stage.connect("destroy", Clutter.main_quit)

rect = Clutter.Rectangle()
rect.set_color(Clutter.Color.from_string("#aa9900"))
rect.set_size(300, 300)
rect.add_constraint(
    Clutter.AlignConstraint.new(stage, Clutter.AlignAxis.X_AXIS, 0.5))
rect.add_constraint(
    Clutter.AlignConstraint.new(stage, Clutter.AlignAxis.Y_AXIS, 0.5))

stage.add_actor(rect)

canvas = Clutter.Texture()
canvas.set_size(300, 300)
canvas.add_constraint(
    Clutter.AlignConstraint.new(rect, Clutter.AlignAxis.X_AXIS, 0))
canvas.add_constraint(
    Clutter.AlignConstraint.new(rect, Clutter.AlignAxis.Y_AXIS, 0))
canvas.set_reactive(True)

stage.add_actor(canvas)
canvas.raise_top()

canvas.connect("motion-event", pointer_motion_cb, path)
canvas.connect("enter-event", pointer_enter_cb, path)
# For the use of connect_after here see comment in canvas_paint_cb
canvas.connect_after("paint", canvas_paint_cb, path)
コード例 #11
0
    def on_run(self):
        if not self.is_active:
            pres_keys = sorted(self.plugin.config['presets'].keys())
            for key in pres_keys:
                self.preset_liststore.append((key, ))

        for name in self.plugin.config_default_values:
            if name == 'presets':
                continue
            widget = self.xml.get_object(name)
            widget.set_text(str(self.plugin.config[name]))

        map_placeholder = self.xml.get_object('map_placeholder')
        dependency_bar = self.xml.get_object('dependency_warning')

        if CHAMPLAIN_AVAILABLE and not self.is_active:
            map_placeholder.set_no_show_all(True)
            map_placeholder.hide()
            dependency_bar.hide()
            map_box = self.xml.get_object('map_box')
            map_box.set_size_request(400, -1)

            embed = GtkChamplain.Embed()

            self.view = embed.get_view()
            self.view.set_reactive(True)
            self.view.set_property('kinetic-mode', True)
            self.view.set_property('zoom-level', 12)
            self.view.connect('button-release-event', self.map_clicked,
                              self.view)

            scale = Champlain.Scale()
            scale.connect_view(self.view)
            self.view.add_child(scale)

            lat = self.plugin.config['lat']
            lon = self.plugin.config['lon']
            if not self.is_valid_coord(lat, lon):
                self.lat = self.lon = 0.0
                self.xml.get_object('lat').set_text('0.0')
                self.xml.get_object('lon').set_text('0.0')
            self.view.center_on(self.lat, self.lon)

            self.path_to_image = os.path.abspath(
                gtkgui_helpers.get_icon_path('org.gajim.Gajim', 16))
            map_box.pack_start(embed, expand=True, fill=True, padding=0)

            self.is_active = True
            self.layer = Champlain.MarkerLayer()
            texture = Clutter.Texture()
            texture.set_from_file(self.path_to_image)
            texture.set_size(32, 32)
            self.marker = Champlain.Label.new_with_image(texture)
            self.marker.set_location(self.lat, self.lon)
            self.marker.set_text(_('Your location'))
            self.view.add_layer(self.layer)
            self.layer.add_marker(self.marker)
            self.markers_is_visible = False
            self.xml.get_object('lat').connect('changed',
                                               self.on_latlon_changed)
            self.xml.get_object('lon').connect('changed',
                                               self.on_latlon_changed)
            self.layer.animate_in_all_markers()
            self.contacts_layer = Champlain.MarkerLayer()