def switch_view(self, view_type): """Switch between grid view and list view.""" self.view.destroy() self.load_icon_type_from_settings(view_type) self.game_store.set_icon_type(self.icon_type) self.view = self.get_view(view_type) self.view.contextual_menu = ContextualMenu( self.game_actions.get_game_actions()) self._connect_signals() scrollwindow_children = self.games_scrollwindow.get_children() if scrollwindow_children: child = scrollwindow_children[0] child.destroy() self.games_scrollwindow.add(self.view) self.set_selected_filter(self.selected_runner, self.selected_platform, self.selected_category) self.set_show_installed_state(self.filter_installed) self.view.show_all() self.zoom_adjustment.props.value = list(IMAGE_SIZES.keys()).index( self.icon_type) self.set_viewtype_icon(view_type) settings.write_setting("view_type", view_type)
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, icon_name="lutris", application=application, **kwargs) self.application = application self.runtime_updater = RuntimeUpdater() self.threads_stoppers = [] self.selected_runner = None self.selected_platform = None self.icon_type = None # Load settings self.window_size = (width, height) self.maximized = settings.read_setting("maximized") == "True" view_type = self.get_view_type() self.load_icon_type_from_settings(view_type) # Window initialization self.game_actions = GameActions(application=application, window=self) self.search_terms = None self.search_timer_id = None self.search_mode = "local" self.game_store = self.get_store() self.view = self.get_view(view_type) GObject.add_emission_hook(Game, "game-updated", self.on_game_updated) GObject.add_emission_hook(Game, "game-removed", self.on_game_updated) GObject.add_emission_hook(Game, "game-installed", self.on_game_installed) GObject.add_emission_hook(GenericPanel, "running-game-selected", self.game_selection_changed) self.connect("delete-event", self.on_window_delete) if self.maximized: self.maximize() self.init_template() self._init_actions() self._bind_zoom_adjustment() # Load view self.games_scrollwindow.add(self.view) self._connect_signals() # Set theme to dark if set in the settings self.set_dark_theme() self.set_viewtype_icon(view_type) # Add additional widgets lutris_icon = Gtk.Image.new_from_icon_name("lutris", Gtk.IconSize.MENU) lutris_icon.set_margin_right(10) lutris_icon.set_margin_left(10) self.website_search_toggle.set_image(lutris_icon) self.website_search_toggle.set_tooltip_text("Search on Lutris.net") self.sidebar_listbox = SidebarListBox() self.sidebar_listbox.set_size_request(250, -1) self.sidebar_listbox.connect("selected-rows-changed", self.on_sidebar_changed) self.sidebar_scrolled.add(self.sidebar_listbox) self.game_panel = GenericPanel(application=self.application) self.game_scrolled = Gtk.ScrolledWindow(visible=True) self.game_scrolled.set_size_request(320, -1) self.game_scrolled.get_style_context().add_class("game-scrolled") self.game_scrolled.set_policy(Gtk.PolicyType.EXTERNAL, Gtk.PolicyType.EXTERNAL) self.game_scrolled.add(self.game_panel) self.panel_revealer = Gtk.Revealer(visible=True) self.panel_revealer.set_transition_duration(300) self.panel_revealer.set_transition_type( Gtk.RevealerTransitionType.SLIDE_LEFT) self.panel_revealer.set_reveal_child(True) self.panel_revealer.add(self.game_scrolled) self.main_box.pack_end(self.panel_revealer, False, False, 0) self.view.show() self.game_store.load() # Contextual menu self.view.contextual_menu = ContextualMenu( self.game_actions.get_game_actions()) # Sidebar self.sidebar_revealer.set_reveal_child(self.sidebar_visible) self.sidebar_revealer.set_transition_duration(300) self.update_runtime() # Connect account and/or sync credentials = api.read_api_key() if credentials: self.on_connect_success(None, credentials["username"]) else: self.toggle_connection(False) self.sync_library() self.sync_services()
def __init__(self, application, **kwargs): self.application = application self.runtime_updater = RuntimeUpdater() self.threads_stoppers = [] self.selected_runner = None self.selected_platform = None self.icon_type = None # Load settings width = int(settings.read_setting("width") or self.default_width) height = int(settings.read_setting("height") or self.default_height) self.window_size = (width, height) self.maximized = settings.read_setting("maximized") == "True" view_type = self.get_view_type() self.load_icon_type_from_settings(view_type) # Window initialization self.game_actions = GameActions(application=application, window=self) self.game_store = GameStore( self.icon_type, self.filter_installed, self.view_sorting, self.view_sorting_ascending, self.show_installed_first, ) self.view = self.get_view(view_type) self.game_store.connect("sorting-changed", self.on_game_store_sorting_changed) super().__init__(default_width=width, default_height=height, icon_name="lutris", application=application, **kwargs) if self.maximized: self.maximize() self.init_template() self._init_actions() self._bind_zoom_adjustment() # Load view self.games_scrollwindow.add(self.view) self._connect_signals() # Set theme to dark if set in the settings self.set_dark_theme() self.set_viewtype_icon(view_type) # Add additional widgets self.sidebar_listbox = SidebarListBox() self.sidebar_listbox.set_size_request(250, -1) self.sidebar_listbox.connect("selected-rows-changed", self.on_sidebar_changed) self.sidebar_scrolled.add(self.sidebar_listbox) self.game_scrolled = Gtk.ScrolledWindow(visible=True) self.game_scrolled.set_size_request(320, -1) self.game_scrolled.get_style_context().add_class("game-scrolled") self.game_scrolled.set_policy(Gtk.PolicyType.EXTERNAL, Gtk.PolicyType.EXTERNAL) self.game_panel = Gtk.Box() self.main_box.pack_end(self.game_scrolled, False, False, 0) self.view.show() # Contextual menu self.view.contextual_menu = ContextualMenu( self.game_actions.get_game_actions()) self.game_store.load() # Sidebar self.sidebar_revealer.set_reveal_child(self.sidebar_visible) self.update_runtime() # Connect account and/or sync credentials = api.read_api_key() if credentials: self.on_connect_success(None, credentials["username"]) else: self.toggle_connection(False) self.sync_library() self.sync_services()
def __init__(self, application, **kwargs): self.application = application self.runtime_updater = RuntimeUpdater() self.threads_stoppers = [] # Emulate double click to workaround GTK bug #484640 # https://bugzilla.gnome.org/show_bug.cgi?id=484640 self.game_launch_time = 0 self.selected_runner = None self.selected_platform = None self.icon_type = None # Load settings width = int(settings.read_setting("width") or 800) height = int(settings.read_setting("height") or 600) self.window_size = (width, height) self.maximized = settings.read_setting("maximized") == "True" view_type = self.get_view_type() self.load_icon_type_from_settings(view_type) self.filter_installed = settings.read_setting( "filter_installed") == "true" self.show_installed_first = ( settings.read_setting("show_installed_first") == "true") self.sidebar_visible = settings.read_setting("sidebar_visible") in [ "true", None, ] self.view_sorting = settings.read_setting("view_sorting") or "name" self.view_sorting_ascending = ( settings.read_setting("view_sorting_ascending") != "false") self.use_dark_theme = (settings.read_setting( "dark_theme", default="false").lower() == "true") self.show_tray_icon = (settings.read_setting( "show_tray_icon", default="false").lower() == "true") # Window initialization self.game_actions = GameActions(application=application, window=self) self.game_list = pga.get_games( show_installed_first=self.show_installed_first) self.game_store = GameStore( [], self.icon_type, self.filter_installed, self.view_sorting, self.view_sorting_ascending, self.show_installed_first, ) self.view = self.get_view(view_type) self.game_store.connect("sorting-changed", self.on_game_store_sorting_changed) super().__init__(default_width=width, default_height=height, icon_name="lutris", application=application, **kwargs) if self.maximized: self.maximize() self.init_template() self._init_actions() self._bind_zoom_adjustment() # Load view self.games_scrollwindow.add(self.view) self._connect_signals() # Set theme to dark if set in the settings self.set_dark_theme(self.use_dark_theme) self.set_viewtype_icon(view_type) # Add additional widgets self.sidebar_listbox = SidebarListBox() self.sidebar_listbox.set_size_request(250, -1) self.sidebar_listbox.connect("selected-rows-changed", self.on_sidebar_changed) self.sidebar_scrolled.add(self.sidebar_listbox) self.game_revealer = Gtk.Revealer() self.game_revealer.show() self.game_revealer.set_transition_duration(500) self.game_revealer.set_transition_type( Gtk.RevealerTransitionType.SLIDE_LEFT) self.game_scrolled = Gtk.ScrolledWindow() self.game_scrolled.set_size_request(320, -1) self.game_scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.NEVER) self.game_scrolled.show() self.game_revealer.add(self.game_scrolled) self.game_panel = Gtk.Box() self.main_box.pack_end(self.game_revealer, False, False, 0) self.view.show() # Contextual menu self.view.contextual_menu = ContextualMenu( self.game_actions.get_game_actions()) # Sidebar self.game_store.fill_store(self.game_list) self.switch_splash_screen() self.sidebar_revealer.set_reveal_child(self.sidebar_visible) self.update_runtime() # Connect account and/or sync credentials = api.read_api_key() if credentials: self.on_connect_success(None, credentials["username"]) else: self.toggle_connection(False) self.sync_library() self.sync_services()