当前位置: 首页>>代码示例>>Python>>正文


Python ViewContainer.get_visible_child方法代码示例

本文整理汇总了Python中lollypop.view_container.ViewContainer.get_visible_child方法的典型用法代码示例。如果您正苦于以下问题:Python ViewContainer.get_visible_child方法的具体用法?Python ViewContainer.get_visible_child怎么用?Python ViewContainer.get_visible_child使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lollypop.view_container.ViewContainer的用法示例。


在下文中一共展示了ViewContainer.get_visible_child方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: AlbumsPopover

# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import get_visible_child [as 别名]
class AlbumsPopover(Gtk.Popover):
    """
        Init Popover ui with a text entry and a scrolled treeview
    """
    def __init__(self):
        Gtk.Popover.__init__(self)
        self._stack = ViewContainer(1000)
        self._stack.show()

        self._on_screen_id = None
        self.add(self._stack)

        Lp.player.connect("current-changed", self._update_content)

    """
        Run _populate in a thread
    """
    def populate(self):
        if Lp.player.current_track.aartist_id == Type.COMPILATIONS:
            new_id = Lp.player.current_track.album_id
        else:
            new_id = Lp.player.current_track.aartist_id
        if self._on_screen_id != new_id:
            self._on_screen_id = new_id
            view = PopArtistView(Lp.player.current_track.aartist_id)
            view.show()
            start_new_thread(view.populate, ())
            self._stack.add(view)
            self._stack.set_visible_child(view)
            self._stack.clean_old_views(view)

    """
        Resize popover
    """
    def do_show(self):
        size_setting = Lp.settings.get_value('window-size')
        if isinstance(size_setting[0], int) and\
           isinstance(size_setting[1], int):
            self.set_size_request(size_setting[0]*0.65, size_setting[1]*0.8)
        else:
            self.set_size_request(600, 600)
        Gtk.Popover.do_show(self)

    """
        Remove view
    """
    def do_hide(self):
        Gtk.Popover.do_hide(self)
        child = self._stack.get_visible_child()
        if child is not None:
            child.stop()
        self._on_screen_id = None
        self._stack.clean_old_views(None)

#######################
# PRIVATE             #
#######################
    """
        Update the content view
        @param player as Player
        @param track id as int
    """
    def _update_content(self, player):
        if self.is_visible():
            self.populate()
开发者ID:yoseforb,项目名称:lollypop,代码行数:67,代码来源:pop_albums.py

示例2: __init__

# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import get_visible_child [as 别名]

#.........这里部分代码省略.........

    def show_playlist_editor(self, playlist_id):
        """
            Show playlist editor for playlist
            Current view stay present in ViewContainer
            @param playlist id as int
            @param playlist name as str
        """
        view = PlaylistEditView(playlist_id)
        view.show()
        self._stack.add(view)
        self._stack.set_visible_child(view)
        self._stack.clean_old_views(view)
        view.populate()

    def main_widget(self):
        """
            Get main widget
            @return Gtk.HPaned
        """
        return self._paned_main_list

    def get_view_width(self):
        """
            Return view width
            @return width as int
        """
        return self._stack.get_allocation().width

    def stop_all(self):
        """
            Stop current view from processing
        """
        view = self._stack.get_visible_child()
        if view is not None:
            self._stack.clean_old_views(None)

    def show_genres(self, show):
        """
            Show/Hide genres
            @param bool
        """
        self._show_genres = show
        self._list_one.clear()
        self._update_list_one(None)

    def destroy_current_view(self):
        """
            Destroy current view
        """
        view = self._stack.get_visible_child()
        for child in self._stack.get_children():
            if child != view:
                self._stack.set_visible_child(child)
                self._stack.clean_old_views(child)
                break

    def disable_overlays(self):
        """
            Disable overlays
        """
        view = self._stack.get_visible_child()
        if view:
            view.disable_overlays()

    def update_view(self):
开发者ID:ktkr3d,项目名称:lollypop,代码行数:70,代码来源:container.py

示例3: __init__

# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import get_visible_child [as 别名]

#.........这里部分代码省略.........
    """
    def show_playlist_manager(self, object_id, genre_id, is_album):
        view = PlaylistsManageView(object_id, genre_id, is_album,
                                   self._stack.get_allocated_width()/2)
        view.show()
        self._stack.add(view)
        self._stack.set_visible_child(view)
        start_new_thread(view.populate, ())

    """
        Show playlist editor for playlist
        Current view stay present in ViewContainer
        @param playlist name as str
    """
    def show_playlist_editor(self, playlist_name):
        view = PlaylistEditView(playlist_name,
                                self._stack.get_allocated_width()/2)
        view.show()
        self._stack.add(view)
        self._stack.set_visible_child(view)
        start_new_thread(view.populate, ())

    """
        Get main widget
        @return Gtk.HPaned
    """
    def main_widget(self):
        return self._paned_main_list

    """
        Stop current view from processing
    """
    def stop_all(self):
        view = self._stack.get_visible_child()
        if view is not None:
            self._stack.clean_old_views(None)

    """
        Show/Hide genres
        @param bool
    """
    def show_genres(self, show):
        self._show_genres = show
        self._list_one.clear()
        self._update_list_one(None)

    """
        Destroy current view
    """
    def destroy_current_view(self):
        view = self._stack.get_visible_child()
        for child in self._stack.get_children():
            if child != view:
                self._stack.set_visible_child(child)
                self._stack.clean_old_views(child)
                break

    """
        Update current view
    """
    def update_view(self):
        view = self._stack.get_visible_child()
        if view:
            start_new_thread(view.update_covers, ())

    """
开发者ID:yoseforb,项目名称:lollypop,代码行数:70,代码来源:container.py

示例4: AlbumsPopover

# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import get_visible_child [as 别名]
class AlbumsPopover(Gtk.Popover):
    """
        Popover => CurrentArtistView
    """

    def __init__(self):
        """
            Init popover
        """
        Gtk.Popover.__init__(self)
        self._stack = ViewContainer(1000)
        self._stack.show()

        self._on_screen_id = None
        self.add(self._stack)

        Lp.player.connect("current-changed", self._update_content)

    def populate(self):
        """
            Load content of the popover
        """
        if Lp.player.current_track.album_artist_id == Type.COMPILATIONS:
            new_id = Lp.player.current_track.album_id
        else:
            new_id = Lp.player.current_track.album_artist_id
        if self._on_screen_id != new_id:
            self._on_screen_id = new_id
            view = CurrentArtistView(Lp.player.current_track.album_artist_id)
            albums = self._get_albums(Lp.player.current_track.album_artist_id)
            view.populate(albums)
            view.show()
            self._stack.add(view)
            self._stack.set_visible_child(view)
            self._stack.clean_old_views(view)

    def do_show(self):
        """
            Resize popover
        """
        size_setting = Lp.settings.get_value('window-size')
        if isinstance(size_setting[0], int) and\
           isinstance(size_setting[1], int):
            self.set_size_request(size_setting[0]*0.65, size_setting[1]*0.8)
        else:
            self.set_size_request(600, 600)
        Gtk.Popover.do_show(self)

    def do_hide(self):
        """
            Remove view
        """
        Gtk.Popover.do_hide(self)
        child = self._stack.get_visible_child()
        if child is not None:
            child.stop()
        self._on_screen_id = None
        self._stack.clean_old_views(None)

#######################
# PRIVATE             #
#######################
    def _get_albums(self, artist_id):
        """
            Get albums
            @return album ids as [int]
        """
        sql = Lp.db.get_cursor()
        if artist_id == Type.COMPILATIONS:
            albums = [Lp.player.current_track.album_id]
        else:
            albums = Lp.artists.get_albums(artist_id, sql)
        sql.close()
        return albums

    def _update_content(self, player):
        """
            Update the content view
            @param player as Player
            @param track id as int
        """
        if self.is_visible():
            self.populate()

    def do_get_preferred_width(self):
        """
            Set 0 to force popover to not expand
        """
        return (0, 0)
开发者ID:ktosiu,项目名称:lollypop,代码行数:91,代码来源:pop_albums.py

示例5: __init__

# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import get_visible_child [as 别名]

#.........这里部分代码省略.........
    def update_lists(self, updater=None):
        self._update_list_one(updater)
        self._update_list_two(updater)

    """
        Load external files
        @param files as [Gio.Files]
    """
    def load_external(self, files):
        self._need_to_update_db = False
        # We wait as selection list is threaded,
        # we don't want to insert item before populated
        # Same for locked db
        if self._list_one.is_populating() or\
           self._list_one.is_populating() or\
           self._scanner.is_locked():
            self._scanner.stop()
            GLib.timeout_add(250, self.load_external, files)
        else:
            self._scanner.add(files)

    """
        Get main widget
        @return Gtk.HPaned
    """
    def main_widget(self):
        return self._paned_main_list

    """
        Stop current view from processing
    """
    def stop_all(self):
        self._scanner.stop()
        view = self._stack.get_visible_child()
        if view is not None:
            self._stack.clean_old_views(None)

    """
        Show/Hide genres
        @param bool
    """
    def show_genres(self, show):
        self._show_genres = show
        self._update_list_one(None)

    """
        Destroy current view
    """
    def destroy_current_view(self):
        view = self._stack.get_visible_child()
        for child in self._stack.get_children():
            if child != view:
                self._stack.set_visible_child(child)
                self._stack.clean_old_views(child)
                break

    """
        Update current view
    """
    def update_view(self):
        view = self._stack.get_visible_child()
        if view:
            start_new_thread(view.update_covers, ())

############
# Private  #
开发者ID:horst3180,项目名称:lollypop,代码行数:70,代码来源:container.py

示例6: __init__

# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import get_visible_child [as 别名]
class Container:
    """
        Container for main view
    """
    def __init__(self):
        """
            Init container
        """
        self.__pulse_timeout = None
        # Index will start at -VOLUMES
        self.__devices = {}
        self.__devices_index = Type.DEVICES
        self.__show_genres = Lp().settings.get_value('show-genres')
        self.__stack = ViewContainer(500)
        self.__stack.show()

        self.__setup_view()
        self.__setup_scanner()

        (list_one_ids, list_two_ids) = self.__get_saved_view_state()
        if list_one_ids and list_one_ids[0] != Type.NONE:
            self.__list_one.select_ids(list_one_ids)
        if list_two_ids and list_two_ids[0] != Type.NONE:
            self.__list_two.select_ids(list_two_ids)

        # Volume manager
        self.__vm = Gio.VolumeMonitor.get()
        self.__vm.connect('mount-added', self.__on_mount_added)
        self.__vm.connect('mount-removed', self.__on_mount_removed)
        for mount in self.__vm.get_mounts():
            self.__add_device(mount, False)

        Lp().playlists.connect('playlists-changed',
                               self.__update_playlists)

    def update_db(self):
        """
            Update db at startup only if needed
        """
        # Stop previous scan
        if Lp().scanner.is_locked():
            Lp().scanner.stop()
            GLib.timeout_add(250, self.update_db)
        else:
            Lp().scanner.update()

    def get_genre_id(self):
        """
            Return current selected genre
            @return genre id as int
        """
        if self.__show_genres:
            return self.__list_one.get_selected_id()
        else:
            return None

    def init_list_one(self):
        """
            Init list one
        """
        self.__update_list_one(None)

    def save_view_state(self):
        """
            Save view state
        """
        Lp().settings.set_value(
                            "list-one-ids",
                            GLib.Variant('ai',
                                         self.__list_one.selected_ids))
        Lp().settings.set_value(
                            "list-two-ids",
                            GLib.Variant('ai',
                                         self.__list_two.selected_ids))

    def show_playlist_manager(self, object_id, genre_ids,
                              artist_ids, is_album):
        """
            Show playlist manager for object_id
            Current view stay present in ViewContainer
            @param object id as int
            @param genre ids as [int]
            @param artist ids as [int]
            @param is_album as bool
        """
        from lollypop.view_playlists import PlaylistsManageView
        current = self.__stack.get_visible_child()
        view = PlaylistsManageView(object_id, genre_ids, artist_ids, is_album)
        view.populate()
        view.show()
        self.__stack.add(view)
        self.__stack.set_visible_child(view)
        current.disable_overlay()

    def show_playlist_editor(self, playlist_id):
        """
            Show playlist editor for playlist
            Current view stay present in ViewContainer
            @param playlist id as int
            @param playlist name as str
#.........这里部分代码省略.........
开发者ID:TainakaDrums,项目名称:lollypop,代码行数:103,代码来源:container.py

示例7: __init__

# 需要导入模块: from lollypop.view_container import ViewContainer [as 别名]
# 或者: from lollypop.view_container.ViewContainer import get_visible_child [as 别名]

#.........这里部分代码省略.........
            @param object id as int
            @param genre id as int
            @param is_album as bool
        """
        view = PlaylistsManageView(object_id, genre_id, is_album)
        view.populate()
        view.show()
        self._stack.add(view)
        self._stack.set_visible_child(view)

    def show_playlist_editor(self, playlist_name):
        """
            Show playlist editor for playlist
            Current view stay present in ViewContainer
            @param playlist name as str
        """
        view = PlaylistEditView(playlist_name)
        view.show()
        self._stack.add(view)
        self._stack.set_visible_child(view)
        view.populate()

    def main_widget(self):
        """
            Get main widget
            @return Gtk.HPaned
        """
        return self._paned_main_list

    def stop_all(self):
        """
            Stop current view from processing
        """
        view = self._stack.get_visible_child()
        if view is not None:
            self._stack.clean_old_views(None)

    def show_genres(self, show):
        """
            Show/Hide genres
            @param bool
        """
        self._show_genres = show
        self._list_one.clear()
        self._update_list_one(None)

    def destroy_current_view(self):
        """
            Destroy current view
        """
        view = self._stack.get_visible_child()
        for child in self._stack.get_children():
            if child != view:
                self._stack.set_visible_child(child)
                self._stack.clean_old_views(child)
                break

    def update_view(self):
        """
            Update current view
        """
        view = self._stack.get_visible_child()
        if view:
            view.update_covers()

    def on_scan_finished(self, scanner):
开发者ID:kenden,项目名称:lollypop,代码行数:70,代码来源:container.py


注:本文中的lollypop.view_container.ViewContainer.get_visible_child方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。