示例#1
0
文件: widgets.py 项目: karolaug/pisak
 def _generate_tiles(self):
     tiles = []
     for index in range(self.from_idx, self.to_idx):
         if index < self.data_length:
             item = self.symbols[index]
             tile = widgets.PhotoTile()
             tile.label.set_style_class("PisakSymbolerPhotoTileLabel")
             if item.text:
                 label = item.text
             else:
                 label = os.path.splitext(os.path.split(item.path)[-1])[0]
             tile.label_text = label
             tile.hilite_tool = widgets.Aperture()
             tile.connect("activate", lambda source, tile:
                          self.target.append_symbol(tile), tile)
             tile.set_background_color(colors.LIGHT_GREY)
             tile.ratio_width = self.tile_ratio_width
             tile.ratio_height = self.tile_ratio_height
             tile.ratio_spacing = self.tile_ratio_spacing
             tile.preview_ratio_width = self.tile_preview_ratio_width
             tile.preview_ratio_height = self.tile_preview_ratio_height
             tile.scale_mode = Mx.ImageScaleMode.FIT
             tile.preview_path = item.path
         else:
             tile = Clutter.Actor()
         tiles.append(tile)
     return tiles
示例#2
0
 def _createSnapIndicator(self):
     self._snap_indicator = Clutter.Actor()
     self._snap_indicator.set_background_color(Clutter.Color.new(50, 150, 200, 200))
     self._snap_indicator.props.visible = False
     self._snap_indicator.props.width = 3
     self._snap_indicator.props.y = 0
     self.add_child(self._snap_indicator)
示例#3
0
文件: widgets.py 项目: Sasza/pisak
    def __init__(self):
        self.index = 0
        self.new_slide_transition = Clutter.PropertyTransition.new("x")
        self.new_slide_transition.connect("stopped", self._clean_up)
        self.old_slide_transition = Clutter.PropertyTransition.new("x")
        self.set_clip_to_allocation(True)
        self.transition_duration = 1000
        self.idle_duration = 1000
        self.pending_slides = ()
        self.slideshow_on = False
        self.fullscreen_on = False
        self.slideshow_on_fullscreen = True
        self.old_slide = None
        self.slide = None
        self.album_length = None
        self.cached_slide_width = None
        self.cached_slide_height = None

        self._prev_content = None
        self._middleware = None
        self._exit_button = None

        self._cover = Clutter.Actor()
        self._cover.set_layout_manager(Clutter.BinLayout())
        self._cover.set_size(unit.w(1), unit.h(1))

        self.apply_props()
示例#4
0
文件: elements.py 项目: jojva/pitivi
 def _createMarquee(self):
     # TODO: difference between Actor.new() and Actor()?
     self.marquee = Clutter.Actor()
     self.marquee.bElement = self.bElement
     self.marquee.set_background_color(Clutter.Color.new(60, 60, 60, 100))
     self.marquee.props.visible = False
     self.add_child(self.marquee)
示例#5
0
 def _init_buttons(self):
     for i in [1, 2, 3, 5, 6, 7]:
         a = Clutter.Actor()
         self.layout.attach(a, 0, i, 1, 1)  #filling
     self.buttons = []
     self._init_number_buttons()
     self._init_action_buttons()
示例#6
0
    def __init__(self):
        super().__init__()

        self.set_title("TextApp")
        self.set_size(800, 600)

        self.text = TestText()
        self.cursor = Cursor_Canvas()
        layout = Clutter.BinLayout()
        self.container = Clutter.Actor()
        self.container.set_layout_manager(layout)
        self.container.add_child(self.text)
        self.container.add_child(self.cursor)

        self.pos = Clutter.Text()
        self.pos2 = Clutter.Text()
        self.pos.set_background_color(Clutter.Color.new(0, 0, 255, 255))

        cursor_pos = self.text.get_cursor_position()
        coords = self.text.position_to_coords(cursor_pos)

        self.pos.set_text(''.join(["Kursor na pozycji: ", str(cursor_pos)]))
        self.pos2.set_text(''.join(["Kursor na koordynatach: ", str(coords)]))

        self.layout = Clutter.BoxLayout()
        self.layout.set_orientation(Clutter.Orientation.VERTICAL)
        self.set_layout_manager(self.layout)
        self.add_child(self.pos)
        self.add_child(self.container)
        self.add_child(self.pos2)

        self.text.connect("cursor_changed", lambda _1: self.onKeyPress(_1))
    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
 def _init_bg(self):
     self.bg = Clutter.Actor()
     self.bg.set_background_color(Clutter.Color.new(0xcc, 0xcc, 0xcc, 0xFF))
     self.bg.set_x_expand(True)
     self.bg.set_y_expand(False)
     self.add_child(self.bg)
     self._init_bg_content()
示例#9
0
    def __init__(self, width=128, height=100):
        GtkClutter.Embed.__init__(self)

        self.set_size_request(width, height)

        self.stage = self.get_stage()
        self.stage.set_size(width, height)

        self.layout_manager = Clutter.BoxLayout()
        self.container = Clutter.Actor(layout_manager=self.layout_manager)
        self.stage.add_actor(self.container)

        self.video_texture = Clutter.Texture.new()
        self.video_texture.set_keep_aspect_ratio(True)
        self.video_texture.set_size(width, height)

        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(video_texture=self.video_texture,
                                        camera_device_node=None,
                                        x_resolution=640,
                                        y_resolution=480)

        try:
            self.camera.setup()
            self.camera_found = True
        except GLib.GError as error:
            logging.warning(error)
            self.camera_found = False
            return
示例#10
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)
示例#11
0
 def _createPlayhead(self):
     self.playhead = Clutter.Actor()
     self.playhead.set_background_color(Clutter.Color.new(200, 0, 0, 255))
     self.playhead.set_size(0, 0)
     self.playhead.set_position(0, 0)
     self.playhead.set_easing_duration(0)
     self.playhead.set_z_position(1)
     self.add_child(self.playhead)
示例#12
0
 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()
示例#13
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()
示例#14
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()
示例#15
0
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
示例#16
0
 def create(self):
     """
     Create the clutter object
     """
     if not self.width or not self.height:
         self.width = self.height = 1
     self.obj = clutter.Actor()
     self.content = clutter.Canvas()
     self.content.set_size(self.width, self.height)
     self.obj.set_content(self.content);
     self.content.connect('draw', self._draw_canvas)
     self.obj.show()
示例#17
0
    def _init_content(self):
        self.menu = widgets.ButtonsMenu(None)
        self.menu.set_background_color(colors.BUTTON_BG)
        self.layout.attach(self.menu, 0, 0, 1, 2)
        #self.menu.set_size(50, 50)

        self.header = Clutter.Actor()
        self.header.set_background_color(colors.HILITE_1)
        self.layout.attach(self.header, 1, 0, 1, 1)
        self.header.set_height(dims.MENU_BUTTON_H_PX)
        self.header.set_x_expand(True)

        self.scroll = Clutter.Actor()
        self.scroll.set_background_color(colors.TRANSPARENT)
        self.layout.attach(self.scroll, 1, 1, 1, 1)
        self.scroll.set_y_expand(True)

        self.bar = Clutter.Actor()
        self.bar.set_background_color(colors.HILITE_1)
        self.layout.attach(self.bar, 0, 2, 2, 1)
        self.bar.set_height(dims.MENU_BUTTON_H_PX)
        self.set_x_expand(True)
示例#18
0
def create_imagebutton(imageFile, posX, posY, sizeX, sizeY, iD="imagebutton"):
    btnImage = create_image(imageFile)
    imgBtn = Clutter.Actor()
    imgBtn.set_id(iD)
    imgBtn.set_content(btnImage)
    imgBtn.set_content_scaling_filters(Clutter.ScalingFilter.LINEAR,
                                       Clutter.ScalingFilter.LINEAR)
    imgBtn.set_content_gravity(Clutter.Gravity.CENTER)
    if (posX != IGNORE) and (posY != IGNORE):
        imgBtn.set_position(posX, posY)
    if (sizeX != IGNORE) and (sizeY != IGNORE):
        imgBtn.set_size(sizeX, sizeY)
    imgBtn.set_reactive(True)
    return imgBtn
示例#19
0
    def __init__(self):
        super().__init__()
        self._exit_button = None
        self._engine = None
        self._menu = None
        self._middleware = None
        self._exit_handler = 0
        self._prev_content = None

        self._cover = Clutter.Actor()
        self._cover.set_layout_manager(Clutter.BinLayout())
        self._cover.set_size(unit.w(1), unit.h(1))

        self.fullscreen = False
示例#20
0
    def __init__(self, box, coordinate, **kw):
        kw["reactive"] = True
        super(DraggableOrnament, self).__init__(**kw)

        self.draggable_box = box
        self.coordinate = coordinate

        self.hitbox = Clutter.Actor()
        self.hitbox.set_reactive(True)

        drag_action = Clutter.DragAction()
        drag_action.connect("drag-progress", self.drag_progress_handler)

        self.hitbox.add_action(drag_action)
        self.hitbox.connect("enter-event", self.mouse_enter_handler)
示例#21
0
文件: widgets.py 项目: karolaug/pisak
 def _generate_tiles(self):
     tiles = []
     for index in range(self.from_idx, self.to_idx):
         if index < self.data_length:
             tile = widgets.PhotoTile()
             tile.hilite_tool = widgets.Aperture()
             tile.connect("activate", self.tiles_handler, self.photos[index].id, self.album)
             tile.scale_mode = Mx.ImageScaleMode.FIT
             tile.ratio_width = self.tile_ratio_width
             tile.ratio_height = self.tile_ratio_height
             tile.preview_path = self.photos[index].path
         else:
             tile = Clutter.Actor()
         tiles.append(tile)
     return tiles
示例#22
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.embed = GtkClutter.Embed()
        self.mainActor = self.embed.get_stage()

        self.videoPlayback = ClutterGst.Playback()
        self.videoContent = ClutterGst.Content()
        self.videoPlayback.set_seek_flags(ClutterGst.SeekFlags.ACCURATE)

        self.videoContent.set_player(self.videoPlayback)
        self.videoPlayback.connect("notify::progress", rewind_progress)

        self.set_startup_id('Oboi')
        self.set_type_hint(Gdk.WindowTypeHint.DESKTOP)
        self.set_skip_pager_hint(True)
        self.set_skip_taskbar_hint(True)
        self.set_accept_focus(True)
        self.stick()
        self.set_resizable(False)
        self.set_keep_below(True)
        self.set_decorated(False)

        self.drag_dest_set(Gtk.DestDefaults.MOTION | Gtk.DestDefaults.DROP,
                           None, Gdk.DragAction.MOVE)

        self.add_events(Gdk.EventMask.ENTER_NOTIFY_MASK
                        | Gdk.EventMask.POINTER_MOTION_MASK
                        | Gdk.EventMask.SMOOTH_SCROLL_MASK)

        self.mainActor.set_background_color(
            Clutter.color_from_string("#000")[1])
        self.wallpaperActor = Clutter.Actor()

        self.videoPath = "file:///home/qwerty/Downloads/videoplayback.mp4"
        self.videoPlayback.set_uri(self.videoPath)
        print("Video path:", self.videoPlayback.get_uri())
        self.videoPlayback.set_playing(True)
        print("Is paying:", self.videoPlayback.get_playing())
        self.wallpaperActor.set_content(self.videoContent)
        # size = get_desktop_size()

        self.wallpaperActor.set_pivot_point(0.5, 0.5)
        self.wallpaperActor.scale_y = 1
        self.wallpaperActor.scale_x = 1

        self.mainActor.add_child(self.wallpaperActor)
        self.add(self.embed)
示例#23
0
 def custom_content(self):
     self.set_icon_visible(False)
     self.box = Box()
     original_box = self.get_children()[0]
     self.clutter_text = original_box.get_children()[1]
     self.clutter_text.set_property("ellipsize", 0)
     text_content = self.clutter_text.get_text()
     if text_content.strip() == '':
         original_box.set_layout_manager(Clutter.BinLayout())
         original_box.add_actor(self.box, 1)
     else:
         original_box.add_actor(self.box, 1)
         self.space = Clutter.Actor()
         self.box.add_child(self.space)
     self.image = Mx.Image()
     self.image.set_scale_mode(1)
     self.box.add_child(self.image)
示例#24
0
 def _generate_items_custom(self):
     if self._current_ods['ods'] is None:
         self._load_category_ods(self._current_ods)
     sheet = self._current_ods['sheets'][self._sheet_idx]
     self.target_spec["columns"] = sheet.ncols()  # custom number of columns
     self.target_spec["rows"] = sheet.nrows()  # custom number of rows
     items = []
     ods_type = self._current_ods['type']
     for row in sheet.rows():
         items_row = []
         for cell in row:
             value = cell.value
             if value:
                 item = self._item_producers[ods_type](value)
             else:
                 item = Clutter.Actor()
                 self._prepare_filler(item)
             self._prepare_item(item)
             items_row.append(item)
         items.append(items_row)
     return items
示例#25
0
    def __init__(self, *args):
        super(DraggableHandle, self).__init__(*args)
        self.dimension = MARGIN
        self.current_knob = None

        self.hitbox.set_height(self.dimension)
        self.hitbox.set_width(self.dimension)

        self.NORMAL_KNOB = util.load_clutter_image_from_resource(
            IMAGES_RESOURCE_PREFIX + "crop_knob_normal.png")
        self.LIGHT_KNOB = util.load_clutter_image_from_resource(
            IMAGES_RESOURCE_PREFIX + "crop_knob_hover.png")
        self.DARK_KNOB = util.load_clutter_image_from_resource(
            IMAGES_RESOURCE_PREFIX + "crop_knob_dark.png")

        dummy, knob_width, knob_height = self.NORMAL_KNOB.get_preferred_size()
        self.current_knob = Clutter.Actor(width=knob_width,
                                          height=knob_height,
                                          content=self.NORMAL_KNOB)
        self.add_child(self.current_knob)
        self.add_child(self.hitbox)
示例#26
0
    def __init__(self, app):
        Gtk.ApplicationWindow.__init__(self,
                                       title='ClutterBrowser',
                                       application=app)

        self.build_treeview()

        self.embed = GtkClutter.Embed()

        container = Clutter.Actor()
        self.embed.get_stage().add_child(container)

        self.actors = []

        for i in range(BROWSERS):
            actor = GtkClutter.Actor()
            #actor.set_x(i * 700)

            da = Gtk.DrawingArea()
            da.connect('draw', self.on_draw)

            actor.get_widget().add(da)
            container.add_child(actor)
            self.actors.append(actor)

        scw = Gtk.ScrolledWindow()
        scw.set_size_request(200, -1)
        scw.add(self._treeview)

        pane = Gtk.Paned()
        pane.add1(scw)
        pane.add2(self.embed)

        container.save_easing_state()
        container.set_easing_mode(Clutter.AnimationMode.EASE_IN_OUT_CUBIC)
        container.set_easing_duration(1500)

        self._container = container

        self.add(pane)
示例#27
0
    def make_wifi_tab(self, ap):
        logging.debug("make_wifi")
        actor = Clutter.Actor()
        actor.set_size(self.actor_width, 40)
        text = Mx.Label()
        text.set_position(120, 0)
        apName = ap["service"][1]["Name"]
        if ap["active"]:
            text.set_text("* " + apName)
        else:
            text.set_text(
                "  " + apName
            )  # the space is to keep the names aligned on the display
        text.set_style_class("wifi")
        actor.add_actor(text)
        tap = Clutter.TapAction()
        actor.add_action(tap)
        actor.ap = ap
        tap.connect("tap", self.ap_tap)
        actor.set_reactive(True)

        return actor
示例#28
0
文件: pager.py 项目: karolaug/pisak
 def _add_tiles(self, rows, columns, tiles, ratio_spacing):
     index = 0
     for _row in range(rows):
         group = scanning.Group()
         group.strategy = scanning.RowStrategy()
         group.selector = self.selector
         group.strategy.unwind_to = self
         group.strategy.max_cycle_count = self.strategy.max_cycle_count
         group.strategy.interval = self.strategy.interval
         group_box = layout.Box()
         group_box.ratio_spacing = ratio_spacing
         group.add_child(group_box)
         self.add_child(group)
         for _col in range(columns):
             if index < len(tiles):
                 actor = tiles[index]
                 group_box.add_child(actor)
             else:
                 actor = Clutter.Actor()
                 group_box.add_child(actor)
                 actor.set_x_expand(True)
                 actor.set_y_expand(True)
             index += 1
示例#29
0
 def _generate_items_normal(self):
     """
     Generate items and structure them into a nested list.
     """
     rows, cols = self.target_spec["rows"], self.target_spec["columns"]
     to = self.to_idx
     if self.from_idx + rows * cols >= self._length:
         to = self.from_idx + rows * cols
     items = []
     idx = 0
     for index in range(self.from_idx, to):
         if idx % cols == 0:
             row = []
             items.append(row)
         idx += 1
         if index < self._length and index < self.to_idx:
             item = self._produce_item(self.data[index])
         elif index > self._length or index >= self.to_idx:
             item = Clutter.Actor()
             self._prepare_filler(item)
         self._prepare_item(item)
         row.append(item)
     return items
    def get_texture(self, doc, pagenum, reqscale):

        texture = None
        textureinfo = None

        self.cachelock.acquire()
        c = self.cache[doc][pagenum]
        if len(c) > 0:
            previous = c[0]
            for cur in c:
                curscale, _, _ = cur
                if curscale < reqscale: break
                previous = cur
            _, texture, textureinfo = previous
        readtime = time()
        self.cachelock.release()

        if texture:
            image = Clutter.Image()
            image.set_data(
                texture.get_pixels(), Cogl.PixelFormat.RGBA_8888
                if texture.get_has_alpha() else Cogl.PixelFormat.RGB_888,
                texture.get_width(), texture.get_height(),
                texture.get_rowstride())
            actor = Clutter.Actor()
            actor.set_content(image)
            actor.set_size(texture.get_width(), texture.get_height())

            cloneinfo = CloneInfo(textureinfo.origscale, doc, pagenum,
                                  readtime)
            if FREEING_STRATEGY == "aggressive":
                self.cachelock.acquire()
                self.cacheUse[doc, pagenum, textureinfo.origscale] += 1
                self.cachelock.release()
            return (actor, cloneinfo)
        else:
            return None