示例#1
0
    def __init__(self, application):
        super().__init__()
        self.application = application
        self.get_style_context().add_class("sidebar")
        self.installed_runners = []
        self.active_platforms = pga.get_used_platforms()
        self.runners = sorted(runners.__all__)
        self.platforms = sorted(platforms.__all__)
        self.categories = pga.get_categories()

        GObject.add_emission_hook(RunnersDialog, "runner-installed",
                                  self.update)
        GObject.add_emission_hook(RunnersDialog, "runner-removed", self.update)
        GObject.add_emission_hook(Game, "game-updated", self.update)
        GObject.add_emission_hook(Game, "game-removed", self.update)

        load_icon_theme()

        icon = Gtk.Image.new_from_icon_name("favorite-symbolic",
                                            Gtk.IconSize.MENU)
        self.add(SidebarRow("favorite", "category", _("Favorites"), icon))

        all_row = SidebarRow(None, "runner", _("All"), None)
        self.add(all_row)
        self.select_row(all_row)
        for runner_name in self.runners:
            icon_name = runner_name.lower().replace(" ", "") + "-symbolic"
            icon = Gtk.Image.new_from_icon_name(icon_name, Gtk.IconSize.MENU)
            runner = runners.import_runner(runner_name)()
            self.add(
                SidebarRow(runner_name,
                           "runner",
                           runner.human_name,
                           icon,
                           application=self.application))

        self.add(SidebarRow(None, "platform", _("All"), None))
        for platform in self.platforms:
            icon_name = (platform.lower().replace(" ", "").replace("/", "_") +
                         "-symbolic")
            icon = Gtk.Image.new_from_icon_name(icon_name, Gtk.IconSize.MENU)
            self.add(SidebarRow(platform, "platform", platform, icon))

        self.set_filter_func(self._filter_func)
        self.set_header_func(self._header_func)
        self.update()
        self.show_all()
示例#2
0
    def __init__(self, application, **kwargs):
        width = int(settings.read_setting("width") or self.default_width)
        height = int(settings.read_setting("height") or self.default_height)
        super().__init__(default_width=width,
                         default_height=height,
                         window_position=Gtk.WindowPosition.NONE,
                         name="lutris",
                         icon_name="lutris",
                         application=application,
                         **kwargs)
        update_desktop_icons()
        load_icon_theme()
        self.application = application
        self.window_x = settings.read_setting("window_x")
        self.window_y = settings.read_setting("window_y")
        if self.window_x and self.window_y:
            self.move(int(self.window_x), int(self.window_y))
        self.threads_stoppers = []
        self.window_size = (width, height)
        self.maximized = settings.read_setting("maximized") == "True"
        self.service = None
        self.game_actions = GameActions(application=application, window=self)
        self.search_timer_id = None
        self.selected_category = settings.read_setting("selected_category",
                                                       default="runner:all")
        self.filters = self.load_filters()
        self.set_service(self.filters.get("service"))
        self.icon_type = self.load_icon_type()
        self.game_store = GameStore(self.service, self.service_media)
        self.view = Gtk.Box()

        self.connect("delete-event", self.on_window_delete)
        self.connect("configure-event", self.on_window_configure)
        self.connect("realize", self.on_load)
        if self.maximized:
            self.maximize()

        self.init_template()
        self._init_actions()

        self.set_dark_theme()

        self.set_viewtype_icon(self.view_type)

        lutris_icon = Gtk.Image.new_from_icon_name("lutris", Gtk.IconSize.MENU)
        lutris_icon.set_margin_right(3)

        self.sidebar = LutrisSidebar(self.application,
                                     selected=self.selected_category)
        self.sidebar.connect("selected-rows-changed", self.on_sidebar_changed)
        self.sidebar_scrolled.add(self.sidebar)

        self.sidebar_revealer.set_reveal_child(self.side_panel_visible)
        self.sidebar_revealer.set_transition_duration(300)
        self.tabs_box.hide()

        self.game_bar = None
        self.revealer_box = Gtk.HBox(visible=True)
        self.game_revealer.add(self.revealer_box)

        self.connect("view-updated", self.update_store)
        GObject.add_emission_hook(BaseService, "service-login",
                                  self.on_service_login)
        GObject.add_emission_hook(BaseService, "service-logout",
                                  self.on_service_logout)
        GObject.add_emission_hook(BaseService, "service-games-load",
                                  self.on_service_games_updating)
        GObject.add_emission_hook(BaseService, "service-games-loaded",
                                  self.on_service_games_updated)
        GObject.add_emission_hook(Game, "game-updated",
                                  self.on_game_collection_changed)
        GObject.add_emission_hook(Game, "game-removed",
                                  self.on_game_collection_changed)
示例#3
0
    def __init__(self, application, selected=None):
        super().__init__()
        self.application = application
        self.get_style_context().add_class("sidebar")
        self.installed_runners = []
        self.active_platforms = games_db.get_used_platforms()
        self.runners = sorted(runners.__all__)
        self.platforms = sorted(platforms.__all__)
        self.categories = categories_db.get_categories()
        if selected:
            row_type, row_id = selected.split(":")
        else:
            row_type, row_id = ("runner", "all")

        GObject.add_emission_hook(RunnersDialog, "runner-installed",
                                  self.update)
        GObject.add_emission_hook(RunnersDialog, "runner-removed", self.update)
        GObject.add_emission_hook(Game, "game-updated", self.update)
        GObject.add_emission_hook(Game, "game-removed", self.update)

        load_icon_theme()

        self.add(
            SidebarRow(
                "running", "dynamic_category", _("Running"),
                Gtk.Image.new_from_icon_name("media-playback-start-symbolic",
                                             Gtk.IconSize.MENU)))

        self.add(
            SidebarRow(
                "installed", "dynamic_category", _("Installed"),
                Gtk.Image.new_from_icon_name("drive-harddisk-symbolic",
                                             Gtk.IconSize.MENU)))

        self.add(
            SidebarRow(
                "favorite", "category", _("Favorites"),
                Gtk.Image.new_from_icon_name("favorite-symbolic",
                                             Gtk.IconSize.MENU)))

        service_classes = services.get_services()
        for service_name in service_classes:
            service = service_classes[service_name]()
            self.add(
                SidebarRow(
                    service.id, "service", service.name,
                    Gtk.Image.new_from_icon_name(service.icon,
                                                 Gtk.IconSize.MENU)))

        all_row = RunnerSidebarRow(None, "runner", _("All"), None)
        self.add(all_row)
        for runner_name in self.runners:
            icon_name = runner_name.lower().replace(" ", "") + "-symbolic"
            icon = Gtk.Image.new_from_icon_name(icon_name, Gtk.IconSize.MENU)
            runner = runners.import_runner(runner_name)()
            self.add(
                RunnerSidebarRow(runner_name,
                                 "runner",
                                 runner.human_name,
                                 icon,
                                 application=self.application))

        self.add(SidebarRow(None, "platform", _("All"), None))
        for platform in self.platforms:
            icon_name = (platform.lower().replace(" ", "").replace("/", "_") +
                         "-symbolic")
            icon = Gtk.Image.new_from_icon_name(icon_name, Gtk.IconSize.MENU)
            self.add(SidebarRow(platform, "platform", platform, icon))

        self.set_filter_func(self._filter_func)
        self.set_header_func(self._header_func)
        self.update()
        for row in self.get_children():
            if row.type == row_type and row.id == row_id:
                self.select_row(row)
                break
        self.show_all()