コード例 #1
0
ファイル: clutterembed.py プロジェクト: vindolin/ipython
 def start(self):
     """Starts the Clutter main event loop and sets our kernel startup routine.
     """
     # Register our function to initiate the kernel and start Clutter
     GObject.idle_add(self._wire_kernel)
     Clutter.init([])
     Clutter.main()
コード例 #2
0
ファイル: scanning.py プロジェクト: bjura/SwitchDJ
    def _on_lag(self, lag_type, element_to_hilite, lag_duration):
        """
        Stops ('lags') the scanning proccess for the given amount of time
        and performes all the previously ordered actions, i.e. highlights
        the current element. In the end schedules an adequate closure.

        :param lag_type: type of lag to be performed. Currently there are
        only two of them: 'start_up' that can happen before the scanning
        proccess starts and 'select', after selection of an element.
        :param element_to_hilite: element that has scanning focus during the
        lag and that should be highlighted.
        :param lag_duration: duration of the lag in miliseconds.
        """
        if self.lag_hilite_mode == "blink":
            timeout_start = time.time()
            self.blink(element_to_hilite, timeout_start, lag_duration, 
                       self.blinking_freq)
        elif self.lag_hilite_mode == "still":
            if hasattr(element_to_hilite, "enable_lag_hilite"):
                element_to_hilite.enable_lag_hilite()
        if lag_type == "start_up":
            closure = self._do_start
            param = None
        elif lag_type == "select":
            closure = self._do_select
            param = element_to_hilite
        Clutter.threads_add_timeout(0, lag_duration, closure, param)
コード例 #3
0
ファイル: smil.py プロジェクト: Kinkrsoftware/SimpleSMIL
    def clutter(self):
        if self.actor is None:
            if self._tag == 'img':
                self.actor = Clutter.Texture()
                self.actor.set_from_file(self._src)

            elif self._tag == 'video':
                self.actor = ClutterGst.VideoTexture()
                self.actor.set_seek_flags(ClutterGst.SeekFlags(1))
                self.actor.set_uri(self._src)
                self.actor.connect("eos", self._after)
            
            if self._region in region_names:
                parent = False
                for region in region_names[self._region]:
                    if not parent:
                        region.stage.add_actor(self.actor)
                        parent = True
                    else:
                        clone = Clutter.Clone.new(self.actor)
                        region.stage.add_actor(clone)
                        self.clone.append(clone)
            elif self._region in region_ids:
                region_ids[self._region].stage.add_actor(self.actor)
            else:
                stage.add_actor(self.actor)
        
        if self._tag == 'img':
            Clutter.threads_add_timeout(0, self._dur, self._after, None)
        elif self._tag == 'video':
            self.actor.set_progress(0.0)
            self.actor.set_playing(True)

        self.actor.show()
コード例 #4
0
ファイル: main.py プロジェクト: bjura/SwitchArtist
 def run(self, block):
     self.idx = 0
     self.items = block.get_children()
     self.limit = len(self.items)
     Clutter.threads_add_timeout(0, self.pace, self._on_timeout, None)
     self.is_running = True
     self._on_timeout(None)
コード例 #5
0
ファイル: app_manager.py プロジェクト: bjura/SwitchDJ
 def _do_run_app(self, app_exec):
     cmd = ["python3", app_exec]
     cmd.extend(sys.argv[1:])
     self.current_app = subprocess.Popen(cmd)
     self.current_app.wait()
     Clutter.threads_add_idle(0, self.maximize_panel, None)
     self.current_app = None
コード例 #6
0
ファイル: main.py プロジェクト: gschwind/page-launcher
	def button_press_handler(self, widget, event):
		print(event)
		if event.button == 1:
			self.dash.show(self, event.time)
			self.dash.window.focus(event.time)
		elif event.button == 3:
			Clutter.main_quit()
コード例 #7
0
    def __init__(self):
        self.stage = Clutter.Stage()
        self.stage.set_title('Clutter example')
        self.stage.set_background_color(Clutter.color_from_string('#BBB')[1])
        self.stage.set_size(300.0, 300.0)

        self.actor = Clutter.Actor()
        self.actor.set_background_color(Clutter.color_from_string('#DA0060')[1])
        self.actor.set_position(75.0, 75.0)
        self.actor.set_size(150.0, 150.0)
        self.actor.set_pivot_point(0.5, 0.5)

        self.rotation = Clutter.PropertyTransition(property_name='rotation-angle-z')
        self.rotation.set_animatable(self.actor)
        self.rotation.set_duration(5000)
        self.rotation.set_from(0.0)
        self.rotation.set_to(360.0)
        self.rotation.set_repeat_count(-1)
        self.rotation.start()

        text = Clutter.Text.new_full('Arial Black 12', 'Click me!', Clutter.color_from_string('black')[1])
        self.actor.add_child(text)

        self.stage.add_child(self.actor)
        self.stage.show()
        self.actor.set_reactive(True)

        self.stage.set_user_resizable(True)
        self.actor.connect('button-press-event', self.color_actor)
        self.stage.connect('key-press-event', self.on_key_press)
        self.stage.connect('destroy', lambda *_: Clutter.main_quit())
コード例 #8
0
ファイル: actor-model.py プロジェクト: GNOME/pyclutter
def on_key_press_event(stage, event):
    scroll = stage.get_first_child()
    menu = scroll.get_first_child()
    key = event.keyval

    if key == Clutter.KEY_q:
        Clutter.main_quit()
        return True

    if key == Clutter.KEY_Up:
        item = menu.select_prev()
        if item is not None:
            pos = Clutter.Point()
            (pos.x, pos.y) = item.get_position()
            scroll.scroll_to_point(pos)
            return True

    if key == Clutter.KEY_Down:
        item = menu.select_next()
        if item is not None:
            pos = Clutter.Point()
            (pos.x, pos.y) = item.get_position()
            scroll.scroll_to_point(pos)
            return True

    if key == Clutter.KEY_Return or key == Clutter.KEY_KP_Enter:
        menu.activate_item()
        return True

    return False
コード例 #9
0
ファイル: widgets.py プロジェクト: karolaug/pisak
 def run(self):
     """
     Run automatic slideshow. Turn on the fullscreen mode if the
     corresponding property is setted to True.
     """
     if self.slideshow_on_fullscreen:
         self.fullscreen_on = True
         self.stage = self.get_stage()
         self.cover_frame = Clutter.Actor()
         self.cover_frame.set_size(unit.size_pix[0], unit.size_pix[1])
         self.slide.remove_transition("x")
         self.remove_child(self.slide)
         self.cover_frame.add_child(self.slide)
         self.slide.set_x(0)
         cover_frame_color = Clutter.Color.new(0, 0, 0, 255)
         self.cover_frame.set_background_color(cover_frame_color)
         if (self.cached_slide_width is None and
                 self.cached_slide_height is None):
             self.cached_slide_width, self.cached_slide_height = \
                 self.slide.get_size()
         self.slide.set_size(unit.size_pix[0], unit.size_pix[1])
         self.stage.add_child(self.cover_frame)
     self.slideshow_on = True
     Clutter.threads_add_timeout(0, self.idle_duration,
                                     lambda _: self.slideshow_timeout(),
                                     None)
コード例 #10
0
    def __init__(self):
        Clutter.init([])
        self.__latitude = None
        self.__longitude = None
        self.__selected_marker = None
        self.__active_sensitive = False
        self.__marker_last_location = None

        self.__factory = Champlain.MapSourceFactory.dup_default()
        self.__set_location_context_menu = None
        self.__locations = []
        self.__task_locations = {}
        self.__tag_locations = {}
        self.__view = None
        self.__vbox_map = None
        self.__map = None
        self.__current_layer = None
        self.__menu_item_tag_sidebar = None
        self.__plugin_api = None

        self.__where = Geoclue()
        self.__where.client.connect_to_signal(
            'LocationUpdated', self._location_updated
        )
        self.__where.client.Start()
        self.__distance = 15

        self.__preferences = None
コード例 #11
0
ファイル: using_libcheese.py プロジェクト: aalex/videocontrol
   def __init__(self):
    self.stage = Clutter.Stage()
    self.stage.set_size(400, 400)
    self.layout_manager = Clutter.BoxLayout()
    self.textures_box = Clutter.Actor(layout_manager=self.layout_manager)
    self.stage.add_actor(self.textures_box)

    self.video_texture = Clutter.Texture.new()

    self.video_texture.set_keep_aspect_ratio(True)
    self.video_texture.set_size(400,400)
    self.layout_manager.pack(self.video_texture, expand=False, x_fill=False, y_fill=False, x_align=Clutter.BoxAlignment.CENTER, y_align=Clutter.BoxAlignment.CENTER)

    self.camera = Cheese.Camera.new(self.video_texture, None, 100, 100)
    Cheese.Camera.setup(self.camera, None)
    Cheese.Camera.play(self.camera)

    def added(signal, data):
        uuid=data.get_uuid()
        node=data.get_device_node()
        print "uuid is " +str(uuid)
        print "node is " +str(node)
        self.camera.set_device_by_device_node(node)
        self.camera.switch_camera_device()

    device_monitor=Cheese.CameraDeviceMonitor.new()
    device_monitor.connect("added", added)
    device_monitor.coldplug()

    self.stage.show()
    Clutter.main()
コード例 #12
0
ファイル: shapes.py プロジェクト: CodeforBirmingham/subte
 def do_leave_event (self, actor, event):
     if self._is_pressed == True:
         self._is_pressed = False
         Clutter.ungrab_pointer()
         return True
     else:
         return False
コード例 #13
0
ファイル: shapes.py プロジェクト: CodeforBirmingham/subte
 def do_button_press_event (self, actor, event):
     if event.button == 1:
         self._is_pressed = True
         Clutter.grab_pointer(self)
         return True
     else:
         return False
コード例 #14
0
ファイル: panels.py プロジェクト: karolaug/pisak
 def __init__(self, container, argv):
     PisakEduApp.APP = self
     Clutter.init(argv)
     self.stage = PisakEduStage(container)
     self.stage.connect("destroy", lambda _: Clutter.main_quit())
     self.stage.set_fullscreen(True)
     self.stage.show_all()
コード例 #15
0
ファイル: window.py プロジェクト: Sasza/pisak
    def load_popup(self, message, unwind=None, unwind_data=None,
                   container=None, timeout=5000):
        """
        Load a pop-up view with some message displayed and then, after a
        given amount of time automatically load some another view or
        perform some operation.

        :param message: message to be displayed on the screen.
        :param unwind: name of a view that should be loaded after
        the `timeout` expires or callable that should be called then or None.
        :param unwind_data: data to be passed to an unwind handler or None.
        :param container: container that popup should be added to or None,
        if None then it will be displayed as a standard standalone view.
        :param timeout: time after which the `unwind`
        will be executed automatically, in miliseconds, default is 1 second, if -1 then
        the `unwind` to will not be executed at all.

        :return: None.
        """
        if timeout >= 0 and unwind is not None:
            if callable(unwind):
                handler = (lambda *_: unwind(unwind_data)) if \
                          unwind_data is not None else lambda *_: unwind()
            else:
                handler = lambda *_: self.load_view(unwind, unwind_data)

            Clutter.threads_add_timeout(0, timeout, handler)

        if container:
            self._display_popup_widget(container, message)
        else:
            self.load_view("popup", {"message": message})
コード例 #16
0
ファイル: application.py プロジェクト: BrainTech/pisak
    def __init__(self, argv, descriptor):
        super().__init__()
        Clutter.init(sys.argv)

        # application main window, instance of :see: :class: `window.Window`:
        self.window = None

        # path to a file with style definition:
        self.style = None

        # dictionary for all the application basic elements:
        self.box = {}

        # if playing of the sound effects should be enabled:
        self.sound_effects_enabled = False

        # indicator of the application main loop status, should be used
        # with caution as there will always be some non-zero time interval
        # between setting this flag 'True' and actual launching of the loop and
        # between actual quit of the loop and setting the flag 'False':
        self.main_loop_is_running = False

        # player of any audio effects:
        self.sound_effects_player = None

        self._sound_effects = {}

        self._read_descriptor(descriptor)
        self._configure()
        self._initialize_style()
        self._initialize_window(argv, descriptor)
        self._initialize_sound_effects_player()
コード例 #17
0
ファイル: scanning.py プロジェクト: bjura/pisak
    def blink(blinking_element, timeout_start, overall_duration, freq):
        """
        Make the given element blinking.

        :param blinking_element: any :class:`Scannable` instance.
        :param timeout_start: current timestamp, helps calculating
        when the animation should be over.
        :param overall_duration: total duration of the blinking animation.
        :param freq: frequency of blinking.
        """
        hilitten = False

        def switch_hilite():
            nonlocal hilitten

            when_to_exit = timeout_start + (overall_duration
                                            - 2*freq)/1000
            if time.time() > when_to_exit:
                if hasattr(blinking_element, "disable_lag_hilite"):
                    blinking_element.disable_lag_hilite()
                return False
            else:
                if hilitten:
                    if hasattr(blinking_element, "disable_lag_hilite"):
                        blinking_element.disable_lag_hilite()
                        hilitten = False
                else:
                    if hasattr(blinking_element, "enable_lag_hilite"):
                        blinking_element.enable_lag_hilite()
                        hilitten = True
                return True
        Clutter.threads_add_timeout(0, freq, switch_hilite)
コード例 #18
0
def main(args):
    Gst.init()
    record_view = RecordView()

    if args.interactive:
        gui_thread = Thread(target=record_view.show_and_run)
        gui_thread.daemon = True
        gui_thread.start()
    else:
        record_view.show()

    while record_view.video_view is None:
        time.sleep(.1)
        print 'waiting for GUI'

    view = record_view.video_view

    def add_svg(view, svg_path):
        actor = SvgGroup.from_path(svg_path)
        view.stage.add_actor(actor)
        actor.add_constraint(Clutter.BindConstraint
                             .new(view.stage, Clutter.BindCoordinate.SIZE, 0))

    if args.svg_path is not None:
        Clutter.threads_add_idle(GLib.PRIORITY_DEFAULT, add_svg, view,
                                 args.svg_path)

    if args.interactive:
        raw_input()
    else:
        record_view.show_and_run()

    return record_view
コード例 #19
0
ファイル: main.py プロジェクト: RainCT/tortellini
def main():
    GLib.threads_init()
    Clutter.init(sys.argv)

    MainWindow()

    Clutter.main()
コード例 #20
0
ファイル: speller.py プロジェクト: karolaug/pisak
 def __init__(self, argv):
     PisakSpellerApp.APP = self
     Clutter.init(argv)
     self.stage = PisakSpellerStage()
     TimerCycle(self.stage.contents).start_cycle()
     self.stage.connect("destroy", lambda _: Clutter.main_quit())
     self.stage.set_fullscreen(True)
     self.stage.show_all()
コード例 #21
0
ファイル: shapes.py プロジェクト: CodeforBirmingham/subte
 def do_button_release_event (self, actor, event):
     if event.button == 1 and self._is_pressed == True:
         self._is_pressed = False
         Clutter.ungrab_pointer()
         self.emit('clicked')
         return True
     else:
         return False
コード例 #22
0
ファイル: pisak_text.py プロジェクト: karolaug/pisak
    def __init__(self):
        Clutter.init()

        self.stage = TextStage()
        self.stage.connect("destroy", lambda *_: Clutter.main_quit())
        self.stage.show_all()

        Clutter.main()
コード例 #23
0
ファイル: pager.py プロジェクト: BrainTech/pisak
 def run_automatic(self):
     """
     Start automatic page flipping.
     """
     if self._page_count > 1:
         self.is_running = True
         Clutter.threads_add_timeout(0, self.idle_duration,
                                     self._automatic_timeout, None)
コード例 #24
0
ファイル: canvas_app.py プロジェクト: karolaug/pisak
 def __init__(self):
     super().__init__()
     self.dynamic_canvas = DynamicCanvas()
     self.dynamic_canvas.set_x_expand(True)
     self.dynamic_canvas.set_y_expand(True)
     self.add_child(self.dynamic_canvas)
     self.layout = Clutter.BoxLayout()
     self.set_layout_manager(self.layout)
     Clutter.threads_add_timeout(0, 33, self._render, None)
コード例 #25
0
ファイル: cursor.py プロジェクト: BrainTech/pisak
    def on_new_data(self, data):
        """
        Receives new raw data, parses them and schedules
        calling the main thread callback.

        :param data: raw data.
        """
        x, y = self.parse_coords(data)
        Clutter.threads_add_timeout(-100, 20, self.on_new_coords, x, y)
コード例 #26
0
ファイル: widgets.py プロジェクト: karolaug/pisak
 def do_prediction(self, text, position):
     context = self.get_prediction_context(text[0:position])
     if context == '':
         self.content = self.basic_content
     else:
         self.content = predictor.get_predictions(context)
     if len(self.content) == 1:
         self.content[0] = self.content[0] + ' '  # automatic space if only one suggestion
     Clutter.threads_add_idle(0, self.emit, "content-update")
コード例 #27
0
ファイル: pager.py プロジェクト: Sasza/pisak
    def _schedule_sending_data(self, direction):
        """
        Schedule sending the data as soon as it is available.
        Data should be loaded in a background.

        :param direction: -1 or 1, that is whether data should be
        sent from backward or forward.
        """
        Clutter.threads_add_timeout(0, 0.1, self._send_data, direction)
コード例 #28
0
ファイル: scanning.py プロジェクト: bjura/SwitchDJ
 def _do_start(self, source=None):
     self.index = None
     self._cycle_count = 0
     self._expose_next(enforced=True)
     self.timeout_token = object()
     if hasattr(self.group, "disable_lag_hilite"):
         self.group.disable_lag_hilite()
     Clutter.threads_add_timeout(0, self.interval, self.cycle_timeout,
                                 self.timeout_token)
コード例 #29
0
ファイル: scanning.py プロジェクト: karolaug/pisak
 def start(self):
     self.compute_sequence()
     if len(self._subgroups) == 0:
         # stop immediately
         self.index = None
         Clutter.threads_add_timeout(0, self.interval, self.cycle_timeout, self.timeout_token)
     else:
         self.index = None
         self._cycle_count = 0
         self._expose_next()
         self.timeout_token = object()
         Clutter.threads_add_timeout(0, self.interval, self.cycle_timeout, self.timeout_token)
コード例 #30
0
ファイル: warp.py プロジェクト: cfobel/clutter-webcam-viewer
 def load(self, warp_path):
     warp_path = str(warp_path)
     try:
         parent_corners = pd.read_hdf(warp_path, '/corners/parent')
         child_corners = pd.read_hdf(warp_path, '/corners/child')
         self.parent_corners[:] = parent_corners
         self.child_corners[:] = child_corners
     except Exception:
         pass
     else:
         Clutter.threads_add_idle(GLib.PRIORITY_DEFAULT,
                                  self.update_transform)
コード例 #31
0
def cairo_draw(canvas, cr):
    # Rather than using GTimeDate (which I couldn't find), we'll use Python time.
    t = time.localtime()
    s = t.tm_sec * math.pi / 30.0
    m = t.tm_min * math.pi / 30.0
    h = t.tm_hour * math.pi / 6.0

    # Clear the texture contents, so that our drawing doesn't "stack."
    # If you don't call this, you'll notice lots of aliasing artifacts.
    canvas.clear()

    # Scale the modelview to the size of the surface.
    cr.scale(*canvas.get_surface_size())

    cr.set_line_cap(cairo.LINE_CAP_ROUND)
    cr.set_line_width(0.1)

    # The black rail that holds the seconds indicator.
    cr.set_source_rgb(0.0, 0.0, 0.0)
    cr.translate(0.5, 0.5)
    cr.arc(0.0, 0.0, 0.4, 0.0, math.pi * 2.0)
    cr.stroke()

    # The seconds indicator.
    cr.set_source_rgb(1.0, 1.0, 1.0)
    cr.move_to(0.0, 0.0)
    cr.arc(math.sin(s) * 0.4, -math.cos(s) * 0.4, 0.05, 0.0, math.pi * 2)
    cr.fill()

    # The minutes hand. Here we want to assign a Clutter-based color to a
    # cairo context, so we need to use Clutter wrappers.
    Clutter.cairo_set_source_color(
        cr, Clutter.Color.get_static(Clutter.StaticColor.CHAMELEON_DARK))

    cr.move_to(0.0, 0.0)
    cr.line_to(math.sin(m) * 0.4, -math.cos(m) * 0.4)
    cr.stroke()

    # The hours hand.
    cr.move_to(0.0, 0.0)
    cr.line_to(math.sin(h) * 0.2, -math.cos(h) * 0.2)
    cr.stroke()

    return True
コード例 #32
0
    def __init__(self):
        Clutter.Actor.__init__(self)

        self._path = Clutter.Path()

        self.set_reactive(True)

        # set default color to black
        color = Clutter.Color.from_string("#000")
        self.set_color(color)
コード例 #33
0
ファイル: elements.py プロジェクト: MathieuDuponchelle/Pitivi
 def _createPreview(self):
     if isinstance(self.bElement, GES.AudioUriSource):
         previewer = AudioPreviewer(self.bElement, self.timeline)
         previewer.startLevelsDiscoveryWhenIdle()
         return previewer
     if isinstance(self.bElement, GES.VideoUriSource):
         return VideoPreviewer(self.bElement, self.timeline)
     # TODO: GES.AudioTransition, GES.VideoTransition, GES.ImageSource,
     # GES.TitleSource
     return Clutter.Actor()
コード例 #34
0
 def create_line(i):
     line = Clutter.Text()
     # We must never see this color:
     line.set_color(Clutter.Color.new(255, 0, 255, 255))
     line.set_font_name(self.font)
     line.set_width(self.char_width * self.shell.cols)
     line.set_height(self.char_height)
     line.set_y(i * self.char_height)
     self.linesGroup.add_actor(line)
     return line
コード例 #35
0
    def add_point_to_bed(self, point):
        probe = Mash.Model.new_from_file(0, self.config.get("System", "probe-point"))
        probe.set_size(10, 10)
        (width, height) = probe.get_size()
        v_min = Clutter.Vertex()
        v_max = Clutter.Vertex()
        data = probe.get_property("data")
        data.get_extents(v_min, v_max)
        depth = v_max.z - v_min.z

        probe.set_y(-depth/2.0-point[2])
        probe.set_x(-width/2.0-point[0])
        probe.set_z_position(-height/2.0+point[1])
        probe.z = point[2] # Store z-value for rescaling

        probe.set_light_set(self.config.loader.model.light_set)
        probe.set_rotation_angle(Clutter.RotateAxis.X_AXIS, 90.0)
        self.config.ui.get_object("model-flipper").add_actor(probe)
        self.probe_points.append(probe)
コード例 #36
0
    def _updateScrollPosition(self, adjustment):
        self._scroll_pos_ns = Zoomable.pixelToNs(self.hadj.get_value())
        point = Clutter.Point()
        point.x = self.hadj.get_value()
        point.y = self.vadj.get_value()
        self.point = point

        self.timeline.scroll_to_point(point)
        point.x = 0
        self.controls.scroll_to_point(point)
コード例 #37
0
ファイル: application.py プロジェクト: jgrynczewski/pisak
    def create_window(self, argv, descriptor):
        """
        Create application main window as the Clutter.Stage.

        :param: argv: application arguments.
        :param descriptor: general application descriptor.
        """
        clutter_window = window.Window(self, Clutter.Stage(), descriptor)
        clutter_window.stage.set_title('PISAK')
        clutter_window.stage.set_position(unit.MONITOR_X, unit.MONITOR_Y)
        if arg_parser.get_args().debug:
            coeff = 0.7
            clutter_window.stage.set_size(coeff * unit.w(1), coeff * unit.h(1))
            clutter_window.stage.set_user_resizable(True)
        else:
            clutter_window.stage.set_size(unit.w(1), unit.h(1))
            clutter_window.stage.set_fullscreen(True)
        clutter_window.stage.connect("destroy", lambda _: Clutter.main_quit())
        return clutter_window
コード例 #38
0
 def __init__(self):
     super().__init__()
     background_image = Clutter.Canvas()
     background_image.set_size(unit.mm(2), unit.mm(2))
     background_image.connect("draw", self.fence_pattern)
     background_image.invalidate()
     self.set_content(background_image)
     self.set_content_repeat(Clutter.ContentRepeat.BOTH)
     self.set_content_scaling_filters(Clutter.ScalingFilter.TRILINEAR,
                                      Clutter.ScalingFilter.TRILINEAR)
コード例 #39
0
ファイル: animation.py プロジェクト: yysung1123/gphotoframe
    def __init__(self, actor, time=300, start=0, end=255):
        super(FadeAnimation, self).__init__()
        super(FadeAnimation, self).set_duration(time)

        alpha = Clutter.Alpha.new_full(self,
                                       Clutter.AnimationMode.EASE_OUT_SINE)
        self.behaviour = Clutter.BehaviourOpacity(alpha=alpha,
                                                  opacity_start=start,
                                                  opacity_end=end)
        self.behaviour.apply(actor)
コード例 #40
0
ファイル: scroll-actor.py プロジェクト: xrombik/pyclutter
    def __init__(self):
        Clutter.Actor.__init__(self)

        layout = Clutter.BoxLayout(orientation=Clutter.Orientation.VERTICAL,
                                   spacing=12)
        self.props.layout_manager = layout
        self.props.background_color = Clutter.Color.get_static(
            Clutter.StaticColor.BLACK)

        self._current_idx = 0
コード例 #41
0
    def __init__(self, widget):
        Clutter.Actor.__init__(self)

        self.props.reactive = True

        self._widget = widget
        self._context = widget.get_style_context()

        self._canvas = Clutter.Canvas(width=100, height=100)
        self._canvas.connect('draw', self._on_canvas_draw)
        self.props.content = self._canvas
        self.set_content_scaling_filters(Clutter.ScalingFilter.TRILINEAR,
                                         Clutter.ScalingFilter.LINEAR)

        action = Clutter.ClickAction()
        action.connect('clicked', self._on_clicked)
        self.add_action(action)

        self._crossing = False
コード例 #42
0
    def animated_move(self, x, y, mode=Clutter.AnimationMode.EASE_OUT_CUBIC):
        self._move_animation = Clutter.Animation(object=self,
                                                 mode=mode,
                                                 duration=250)
        self._move_animation.bind("antler-window-position", (x, y))

        timeline = self._move_animation.get_timeline()
        timeline.start()

        return self._move_animation
コード例 #43
0
ファイル: elements.py プロジェクト: jojva/pitivi
def get_preview_for_object(bElement, timeline):
    # Fixme special preview for transitions, titles
    if not isinstance(bElement.get_parent(), GES.UriClip):
        return Clutter.Actor()

    track_type = bElement.get_track_type()
    if track_type == GES.TrackType.AUDIO:
        # FIXME: RandomAccessAudioPreviewer doesn't work yet
        # previewers[key] = RandomAccessAudioPreviewer(instance, uri)
        # TODO: return waveform previewer
        return Clutter.Actor()
    elif track_type == GES.TrackType.VIDEO:
        if bElement.get_parent().is_image():
            # TODO: return still image previewer
            return Clutter.Actor()
        else:
            return VideoPreviewer(bElement, timeline)
    else:
        return Clutter.Actor()
コード例 #44
0
ファイル: geolocalized_tasks.py プロジェクト: whitwhittle/gtg
 def HTMLColorToRGB(self, colorstring):
     """ convert #RRGGBB to a clutter color var """
     colorstring = colorstring.strip()
     if colorstring[0] == '#':
         colorstring = colorstring[1:]
     if len(colorstring) != 6:
         raise ValueError(f"input #{colorstring} is not in #RRGGBB format")
     r, g, b = colorstring[:2], colorstring[2:4], colorstring[4:]
     r, g, b = [int(n, 16) for n in (r, g, b)]
     return Clutter.Color(r, g, b)
コード例 #45
0
 def __init__(self, size):
     super().__init__()
     self.width = size[0]
     self.height = size[1]
     self.set_size(self.width, self.height)
     self.canvas = Clutter.Canvas()
     self.canvas.set_size(self.width, self.height)
     self.canvas.connect('draw', self._draw)
     self.canvas.invalidate()
     self.set_content(self.canvas)
コード例 #46
0
ファイル: speller.py プロジェクト: karolaug/pisak
 def __init__(self, text_buffer):
     super(TextField, self).__init__()
     self.set_scroll_mode(Clutter.ScrollMode.VERTICALLY)
     self.text_buffer = text_buffer
     self.layout = Clutter.BinLayout()
     self.set_layout_manager(self.layout)
     white_color = Clutter.Color.new(255, 255, 255, 255)
     self.set_background_color(white_color)
     self.font = 'Sans 100px'
     self._init_field()
コード例 #47
0
    def __init__(self):
        super(MapShadowRectangle, self).__init__()
        self.timeline = FadeAnimationTimeline(self, end=200)

        color = Clutter.Color()
        color.from_string("black")
        self.set_color(color)

        super(MapShadowRectangle, self).show()
        self.set_opacity(100)
コード例 #48
0
 def __init__(self, container):
     super().__init__()
     self.container = container
     layout = Clutter.BinLayout()
     self.set_layout_manager(layout)
     self.set_y_expand(True)
     self.set_x_expand(True)
     self.set_reactive(True)
     self.connect('button_release_event', lambda x, y: self.exit_panel())
     self._init_elements()
コード例 #49
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
コード例 #50
0
def listbox_select(lb,
                   offset,
                   offsetType=SelectOffsetType.START,
                   animOrientation=None,
                   colorizeEffect=None,
                   scrollToView=True):
    cnt = lb.get_n_children()
    aID = lb.get_id()
    curIndex = gActors[aID]['curIndex']
    if offsetType == SelectOffsetType.CUR:
        nxtIndex = (curIndex + offset) % cnt
    elif offsetType == SelectOffsetType.START:
        nxtIndex = offset % cnt
    #while nxtIndex < 0:
    #    nxtIndex = cnt + nxtIndex
    curActor = lb.get_child_at_index(curIndex)
    nxtActor = lb.get_child_at_index(nxtIndex)
    curActor.save_easing_state()
    nxtActor.save_easing_state()
    lb.save_easing_state()
    lb.set_easing_duration(500)
    if scrollToView:
        nxtActorPos = nxtActor.get_position()
        point = Clutter.Point()
        point.x = nxtActorPos[0]
        point.y = nxtActorPos[1]
        lb.scroll_to_point(point)
    if colorizeEffect != None:
        curActor.remove_effect(colorizeEffect)
    curActor.set_scale(1, 1)
    if (animOrientation == None):
        listOrientation = lb.get_layout_manager().get_orientation()
        if listOrientation == Clutter.Orientation.HORIZONTAL:
            animOrientation = AnimOrientation.VERTICAL
        elif listOrientation == Clutter.Orientation.VERTICAL:
            animOrientation = AnimOrientation.HORIZONTAL
        else:
            print("WARN:animate_listbox:Unknown listbox Orientation")
            animOrientation = AnimOrientation.BOTH
    if (animOrientation == AnimOrientation.HORIZONTAL):
        xScale = 1 + LB_SELSCALE_PERCENT
        yScale = 1
    elif (animOrientation == AnimOrientation.VERTICAL):
        xScale = 1
        yScale = 1 + LB_SELSCALE_PERCENT
    else:
        xScale = 1 + LB_SELSCALE_PERCENT
        yScale = 1 + LB_SELSCALE_PERCENT
    nxtActor.set_scale(xScale, yScale)
    if colorizeEffect != None:
        nxtActor.add_effect(colorizeEffect)
    curActor.restore_easing_state()
    nxtActor.restore_easing_state()
    lb.restore_easing_state()
    gActors[aID]['curIndex'] = nxtIndex
コード例 #51
0
ファイル: window.py プロジェクト: jgrynczewski/pisak
    def load_popup(self,
                   message,
                   unwind=None,
                   unwind_data=None,
                   container=None,
                   timeout=5000,
                   icon=True):
        """
        Load a pop-up view with some message displayed and then, after a
        given amount of time automatically load some another view or
        perform some operation.

        :param message: message to be displayed on the screen.
        :param unwind: name of a view that should be loaded after
        the `timeout` expires or callable that should be called then or None.
        :param unwind_data: data to be passed to an unwind handler or None.
        :param container: container that popup should be added to or None,
        if None then it will be displayed as a standard standalone view.
        :param timeout: time after which the `unwind`
        will be executed automatically, in miliseconds, default is 1 second, if -1 then
        the `unwind` to will not be executed at all.
        :param icon: boolean, if icon should be displayed.

        :return: None.
        """
        if timeout >= 0 and unwind is not None:
            if callable(unwind):
                handler = (lambda *_: unwind(unwind_data)) if \
                          unwind_data is not None else lambda *_: unwind()
            else:
                if unwind.split('/')[
                        0] == 'main_panel' and self.app_name != 'main_panel':
                    handler = lambda *_: self.application.main_quit()
                else:
                    handler = lambda *_: self.load_view(unwind, unwind_data)

            Clutter.threads_add_timeout(0, timeout, handler)

        if container:
            self._display_popup_widget(container, message)
        else:
            self.load_view("popup", {"message": message, 'icon': icon})
コード例 #52
0
 def enable_sliders(self):
     for box in ["network", "wifi", "slicer", "printer"]:
         header = self.config.ui.get_object(box + "-header")
         header.set_reactive(True)
         tap = Clutter.TapAction()
         header.add_action(tap)
         tap.connect("tap", self.tap)
         body = self.config.ui.get_object(box + "-body")
         body.set_height(5)
         header.is_open = False
         header.body = body
コード例 #53
0
def create_label(color, markup):
    text = Clutter.Text()

    text.set_color(Clutter.Color.from_string(color))
    text.set_markup(markup)
    text.set_editable(False)
    text.set_selectable(False)
    text.set_single_line_mode(True)
    text.set_ellipsize(Pango.EllipsizeMode.END)

    return text
コード例 #54
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)
コード例 #55
0
    def __init__(self, *args):
        super(DraggableBorder, self).__init__(*args)

        self.line = Clutter.Actor()
        self.add_child(self.line)
        self.add_child(self.hitbox)

        self.thickness = BORDER_THICKNESS
        self.NORMAL_COLOR = Clutter.Color.from_string("#000000")[1]
        self.HIGHLIGHT_COLOR = Clutter.Color.from_string("#FFFFFF")[1]
        self.darken()
コード例 #56
0
def handle_key_press(actor, event):
    global lPos, lYRotate
    #print("INFO:KeyPress:{}:{}:{}".format(actor, event.keyval, chr(event.keyval)), event.flags, event.type, event.modifier_state)
    #CMDKEY_MODSTATE = (Clutter.ModifierType.SHIFT_MASK | Clutter.ModifierType.CONTROL_MASK)
    CMDKEY_MODSTATE = (Clutter.ModifierType.CONTROL_MASK)
    if ((event.modifier_state & CMDKEY_MODSTATE) == CMDKEY_MODSTATE):
        if (event.keyval == Clutter.KEY_A):
            cg.listbox_select(gGUI['LBCAT'], 1, cg.SelectOffsetType.CUR)
            cg.listbox_select(gGUI['LBG1'],
                              1,
                              cg.SelectOffsetType.CUR,
                              colorizeEffect=colorizeEffect1)
        elif (event.keyval == Clutter.KEY_X):
            load_screen('main')
        elif (event.keyval == Clutter.KEY_Y):
            load_screen('audio')
        elif (event.keyval == Clutter.KEY_Q):
            print("INFO: Bowing down gracefully")
            Clutter.main_quit()
    return Clutter.EVENT_STOP
コード例 #57
0
ファイル: elements.py プロジェクト: jojva/pitivi
 def _connectToEvents(self):
     self.dragAction = Clutter.DragAction()
     self.add_action(self.dragAction)
     self.dragAction.connect("drag-progress", self._dragProgressCb)
     self.dragAction.connect("drag-begin", self._dragBeginCb)
     self.dragAction.connect("drag-end", self._dragEndCb)
     self.bElement.selected.connect("selected-changed",
                                    self._selectedChangedCb)
     # We gotta go low-level cause Clutter.ClickAction["clicked"]
     # gets emitted after Clutter.DragAction["drag-begin"]
     self.connect("button-press-event", self._clickedCb)
コード例 #58
0
ファイル: polygons.py プロジェクト: ItzSwirlz/libshumate
def make_button(text):
	black = Clutter.Color.new(0x00, 0x00, 0x00, 0xff)
	white = Clutter.Color.new(0xff, 0xff, 0xff, 0xff)

	button = Clutter.Actor()
	
	button_bg = Clutter.Actor()
	button_bg.set_background_color(white)
	button_bg.set_opacity(0xcc)
	button.add_child(button_bg)
	
	button_text = Clutter.Text.new_full("Sans 10", text, black)
	button.add_child(button_text)
	
	(width, height) = button_text.get_size()
	button_bg.set_size(width + PADDING * 2, height + PADDING * 2)
	button_bg.set_position(0, 0)
	button_text.set_position(PADDING, PADDING)

	return button
コード例 #59
0
    def do_allocate(self, actor, box, flags):
        for i, row in enumerate(actor.get_children()):
            row_box = Clutter.ActorBox()
            row_height = box.get_height() / VISIBLE_ROWS

            row_box.x1 = box.x1
            row_box.x2 = box.x2
            row_box.y1 = row_height * i
            row_box.y2 = (row_height * i) + row_height

            row.allocate(row_box, flags)
コード例 #60
0
ファイル: PisakEduMistakeApp.py プロジェクト: karolaug/pisak
 def __init__(self, container):
     super(ResultInfoPanel, self).__init__()
     self.container = container
     self.word = container.word
     self.user_word = container.user_word
     self.result = container.result
     layout = Clutter.BinLayout()
     self.set_layout_manager(layout)
     self.set_y_expand(True)
     self.set_x_expand(True)
     self._init_result_info()