def on_synchronize_manually(self, *args): """Callback when Synchronize Library is activated.""" sync = Sync() credentials = api.read_api_key() if credentials: # Is connected sync.sync_all(caller=self) else: sync.sync_steam_local(caller=self) self.sync_icons() dialogs.NoticeDialog('Library synchronized')
def on_synchronize_manually(self, *args): """Callback when Synchronize Library is activated.""" credentials = api.read_api_key() if credentials: # Is connected self.sync_library() else: sync = Sync() async_call( sync.sync_steam_local, lambda r, e: async_call(self.sync_icons, None), caller=self ) # Update Runtime async_call(runtime.update_runtime, None, self.set_status)
def get_library(self): """Return the remote library as a list of dicts.""" credentials = read_api_key() if not credentials: return [] url = settings.SITE_URL + "/api/games/library/%s" % urllib.parse.quote(credentials["username"]) request = http.Request(url, headers={"Authorization": "Token " + credentials["token"]}) try: response = request.get() except http.HTTPError as ex: logger.error("Unable to load library: %s", ex) return [] response_data = response.json if response_data: return response_data["games"] return []
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): ui_filename = os.path.join(datapath.get(), "ui", "LutrisWindow.ui") if not os.path.exists(ui_filename): raise IOError("File %s not found" % ui_filename) self.running_game = None self.threads_stoppers = [] # Emulate double click to workaround GTK bug #484640 # https://bugzilla.gnome.org/show_bug.cgi?id=484640 self.game_selection_time = 0 self.game_launch_time = 0 self.last_selected_game = None self.builder = Gtk.Builder() self.builder.add_from_file(ui_filename) # Load settings width = int(settings.read_setting("width") or 800) height = int(settings.read_setting("height") or 600) self.window_size = (width, height) view_type = self.get_view_type() self.icon_type = self.get_icon_type(view_type) filter_installed_setting = settings.read_setting("filter_installed") or "false" filter_installed = filter_installed_setting == "true" show_installed_games_menuitem = self.builder.get_object("filter_installed") show_installed_games_menuitem.set_active(filter_installed) # Load view logger.debug("Loading view") self.game_store = GameStore([], self.icon_type, filter_installed) self.view = load_view(view_type, self.game_store) logger.debug("Connecting signals") self.main_box = self.builder.get_object("main_box") self.splash_box = self.builder.get_object("splash_box") # View menu self.grid_view_menuitem = self.builder.get_object("gridview_menuitem") self.grid_view_menuitem.set_active(view_type == "grid") self.list_view_menuitem = self.builder.get_object("listview_menuitem") self.list_view_menuitem.set_active(view_type == "list") # View buttons self.grid_view_btn = self.builder.get_object("switch_grid_view_btn") self.grid_view_btn.set_active(view_type == "grid") self.list_view_btn = self.builder.get_object("switch_list_view_btn") self.list_view_btn.set_active(view_type == "list") # Icon type menu self.banner_small_menuitem = self.builder.get_object("banner_small_menuitem") self.banner_small_menuitem.set_active(self.icon_type == "banner_small") self.banner_menuitem = self.builder.get_object("banner_menuitem") self.banner_menuitem.set_active(self.icon_type == "banner") self.icon_menuitem = self.builder.get_object("icon_menuitem") self.icon_menuitem.set_active(self.icon_type == "icon") self.search_entry = self.builder.get_object("search_entry") self.search_entry.connect("icon-press", self.on_clear_search) # Scroll window self.games_scrollwindow = self.builder.get_object("games_scrollwindow") self.games_scrollwindow.add(self.view) # Status bar self.status_label = self.builder.get_object("status_label") self.joystick_icons = [] # Buttons self.stop_button = self.builder.get_object("stop_button") self.stop_button.set_sensitive(False) self.delete_button = self.builder.get_object("delete_button") self.delete_button.set_sensitive(False) self.play_button = self.builder.get_object("play_button") self.play_button.set_sensitive(False) # Contextual menu main_entries = [ ("play", "Play", self.on_game_run), ("install", "Install", self.on_install_clicked), ("add", "Add manually", self.add_manually), ("configure", "Configure", self.edit_game_configuration), ("browse", "Browse files", self.on_browse_files), ("desktop-shortcut", "Create desktop shortcut", self.create_desktop_shortcut), ("rm-desktop-shortcut", "Delete desktop shortcut", self.remove_desktop_shortcut), ("menu-shortcut", "Create application menu shortcut", self.create_menu_shortcut), ("rm-menu-shortcut", "Delete application menu shortcut", self.remove_menu_shortcut), ("remove", "Remove", self.on_remove_game), ] self.menu = ContextualMenu(main_entries) self.view.contextual_menu = self.menu # Sidebar sidebar_paned = self.builder.get_object("sidebar_paned") sidebar_paned.set_position(150) self.sidebar_treeview = SidebarTreeView() self.sidebar_treeview.connect("cursor-changed", self.on_sidebar_changed) self.sidebar_viewport = self.builder.get_object("sidebar_viewport") self.sidebar_viewport.add(self.sidebar_treeview) # Window initialization self.window = self.builder.get_object("window") self.window.resize_to_geometry(width, height) self.window.show_all() self.builder.connect_signals(self) self.connect_signals() # XXX Hide PGA config menu item until it actually gets implemented pga_menuitem = self.builder.get_object("pga_menuitem") pga_menuitem.hide() self.init_game_store() # Connect account and/or sync credentials = api.read_api_key() if credentials: self.on_connect_success(None, credentials) else: self.toggle_connection(False) self.sync_library() # Timers self.timer_ids = [GLib.timeout_add(300, self.refresh_status), GLib.timeout_add(10000, self.on_sync_timer)]
def __init__(self, application, **kwargs): self.application = application self.runtime_updater = RuntimeUpdater() self.running_game = None self.threads_stoppers = [] # Emulate double click to workaround GTK bug #484640 # https://bugzilla.gnome.org/show_bug.cgi?id=484640 self.game_selection_time = 0 self.game_launch_time = 0 self.last_selected_game = None 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.sidebar_width = int(settings.read_setting('sidebar_width') or 180) 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' # Sync local lutris library with current Steam games and desktop games for service in get_services_synced_at_startup(): service.sync_with_lutris() # Window initialization self.game_list = pga.get_games( show_installed_first=self.show_installed_first) self.game_store = GameStore([], self.icon_type, self.filter_installed, self.show_installed_first) self.view = self.get_view(view_type) 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() # Set theme to dark if set in the settings self.set_dark_theme(self.use_dark_theme) # Load view self.games_scrollwindow.add(self.view) self.connect_signals() self.view.show() # Contextual menu main_entries = [ ('play', "Play", self.on_game_run), ('install', "Install", self.on_install_clicked), ('add', "Add manually", self.on_add_manually), ('configure', "Configure", self.on_edit_game_configuration), ('execute-script', "Execute script", self.on_execute_script_clicked), ('browse', "Browse files", self.on_browse_files), ('desktop-shortcut', "Create desktop shortcut", self.create_desktop_shortcut), ('rm-desktop-shortcut', "Delete desktop shortcut", self.remove_desktop_shortcut), ('menu-shortcut', "Create application menu shortcut", self.create_menu_shortcut), ('rm-menu-shortcut', "Delete application menu shortcut", self.remove_menu_shortcut), ('install_more', "Install (add) another version", self.on_install_clicked), ('remove', "Remove", self.on_remove_game), ('view', "View on Lutris.net", self.on_view_game), ] self.menu = ContextualMenu(main_entries) self.view.contextual_menu = self.menu # Sidebar self.sidebar_treeview = SidebarTreeView() self.sidebar_treeview.connect('cursor-changed', self.on_sidebar_changed) self.sidebar_viewport.add(self.sidebar_treeview) self.sidebar_treeview.show() self.game_store.fill_store(self.game_list) self.switch_splash_screen() self.show_sidebar() self.update_runtime() # Connect account and/or sync credentials = api.read_api_key() if credentials: self.on_connect_success(None, credentials) else: self.toggle_connection(False) self.sync_library() # Timers self.timer_ids = [GLib.timeout_add(300, self.refresh_status)] steamapps_paths = steam.get_steamapps_paths(flat=True) self.steam_watcher = SteamWatcher(steamapps_paths, self.on_steam_game_changed) self.gui_needs_update = True self.config_menu_first_access = True
def __init__(self): ui_filename = os.path.join(datapath.get(), 'ui', 'LutrisWindow.ui') if not os.path.exists(ui_filename): raise IOError('File %s not found' % ui_filename) # Currently running game self.running_game = None # Emulate double click to workaround GTK bug #484640 # https://bugzilla.gnome.org/show_bug.cgi?id=484640 self.game_selection_time = 0 self.game_launch_time = 0 self.last_selected_game = None self.builder = Gtk.Builder() self.builder.add_from_file(ui_filename) # load config width = int(settings.read_setting('width') or 800) height = int(settings.read_setting('height') or 600) self.window_size = (width, height) view_type = self.get_view_type() self.icon_type = self.get_icon_type(view_type) filter_installed_setting = settings.read_setting( 'filter_installed') or 'false' self.filter_installed = filter_installed_setting == 'true' show_installed_games_menuitem = self.builder.get_object( 'filter_installed') show_installed_games_menuitem.set_active(self.filter_installed) logger.debug("Getting game list") game_list = get_game_list(self.filter_installed) logger.debug("Switching view") self.view = load_view(view_type, game_list, icon_type=self.icon_type) logger.debug("Connecting signals") self.main_box = self.builder.get_object('main_box') self.splash_box = self.builder.get_object('splash_box') # View menu self.grid_view_menuitem = self.builder.get_object("gridview_menuitem") self.grid_view_menuitem.set_active(view_type == 'grid') self.list_view_menuitem = self.builder.get_object("listview_menuitem") self.list_view_menuitem.set_active(view_type == 'list') # View buttons self.grid_view_btn = self.builder.get_object('switch_grid_view_btn') self.grid_view_btn.set_active(view_type == 'grid') self.list_view_btn = self.builder.get_object('switch_list_view_btn') self.list_view_btn.set_active(view_type == 'list') # Icon type menu self.banner_small_menuitem = \ self.builder.get_object('banner_small_menuitem') self.banner_small_menuitem.set_active(self.icon_type == 'banner_small') self.banner_menuitem = self.builder.get_object('banner_menuitem') self.banner_menuitem.set_active(self.icon_type == 'banner') self.icon_menuitem = self.builder.get_object('icon_menuitem') self.icon_menuitem.set_active(self.icon_type == 'grid') self.search_entry = self.builder.get_object('search_entry') # Scroll window self.games_scrollwindow = self.builder.get_object('games_scrollwindow') self.games_scrollwindow.add(self.view) # Status bar self.status_label = self.builder.get_object('status_label') self.joystick_icons = [] # Buttons self.stop_button = self.builder.get_object('stop_button') self.stop_button.set_sensitive(False) self.delete_button = self.builder.get_object('delete_button') self.delete_button.set_sensitive(False) self.play_button = self.builder.get_object('play_button') self.play_button.set_sensitive(False) # Contextual menu menu_callbacks = [ ('play', self.on_game_clicked), ('install', self.on_game_clicked), ('add', self.add_manually), ('configure', self.edit_game_configuration), ('browse', self.on_browse_files), ('desktop-shortcut', self.create_desktop_shortcut), ('menu-shortcut', self.create_menu_shortcut), ('remove', self.on_remove_game), ] self.menu = ContextualMenu(menu_callbacks) self.view.contextual_menu = self.menu # Timer self.timer_id = GLib.timeout_add(2000, self.refresh_status) sidebar_paned = self.builder.get_object('sidebar_paned') sidebar_paned.set_position(150) sidebar_treeview = SidebarTreeView() sidebar_treeview.connect('cursor-changed', self.on_sidebar_changed) self.sidebar_viewport = self.builder.get_object('sidebar_viewport') self.sidebar_viewport.add(sidebar_treeview) # Window initialization self.window = self.builder.get_object("window") self.window.resize_to_geometry(width, height) self.window.show_all() self.builder.connect_signals(self) self.connect_signals() # XXX Hide PGA config menu item until it actually gets implemented pga_menuitem = self.builder.get_object('pga_menuitem') pga_menuitem.hide() self.switch_splash_screen() credentials = api.read_api_key() if credentials: self.on_connect_success(None, credentials) else: self.toggle_connection(False) sync = Sync() async_call(sync.sync_steam_local, lambda r, e: async_call(self.sync_icons, None), caller=self) # Update Lutris Runtime async_call(runtime.update_runtime, None)
def __init__(self, service=None): Gtk.Application.__init__( self, application_id="net.lutris.main", flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE) ui_filename = os.path.join(datapath.get(), 'ui', 'lutris-window.ui') if not os.path.exists(ui_filename): raise IOError('File %s not found' % ui_filename) self.service = service self.runtime_updater = RuntimeUpdater() self.running_game = None self.threads_stoppers = [] # Emulate double click to workaround GTK bug #484640 # https://bugzilla.gnome.org/show_bug.cgi?id=484640 self.game_selection_time = 0 self.game_launch_time = 0 self.last_selected_game = None self.selected_runner = None self.builder = Gtk.Builder() self.builder.add_from_file(ui_filename) # Load settings width = int(settings.read_setting('width') or 800) height = int(settings.read_setting('height') or 600) self.window_size = (width, height) window = self.builder.get_object('window') window.resize(width, height) view_type = self.get_view_type() self.load_icon_type_from_settings(view_type) self.filter_installed = \ settings.read_setting('filter_installed') == 'true' self.sidebar_visible = \ settings.read_setting('sidebar_visible') in ['true', None] # Set theme to dark if set in the settings dark_theme_menuitem = self.builder.get_object('dark_theme_menuitem') use_dark_theme = settings.read_setting('dark_theme') == 'true' dark_theme_menuitem.set_active(use_dark_theme) self.set_dark_theme(use_dark_theme) self.game_list = pga.get_games() # Load view self.game_store = GameStore([], self.icon_type, self.filter_installed) self.view = self.get_view(view_type) self.main_box = self.builder.get_object('main_box') self.splash_box = self.builder.get_object('splash_box') self.connect_link = self.builder.get_object('connect_link') # View menu installed_games_only_menuitem =\ self.builder.get_object('filter_installed') installed_games_only_menuitem.set_active(self.filter_installed) self.grid_view_menuitem = self.builder.get_object("gridview_menuitem") self.grid_view_menuitem.set_active(view_type == 'grid') self.list_view_menuitem = self.builder.get_object("listview_menuitem") self.list_view_menuitem.set_active(view_type == 'list') sidebar_menuitem = self.builder.get_object('sidebar_menuitem') sidebar_menuitem.set_active(self.sidebar_visible) # View buttons self.grid_view_btn = self.builder.get_object('switch_grid_view_btn') self.grid_view_btn.set_active(view_type == 'grid') self.list_view_btn = self.builder.get_object('switch_list_view_btn') self.list_view_btn.set_active(view_type == 'list') # Icon type menu self.banner_small_menuitem = \ self.builder.get_object('banner_small_menuitem') self.banner_small_menuitem.set_active(self.icon_type == 'banner_small') self.banner_menuitem = self.builder.get_object('banner_menuitem') self.banner_menuitem.set_active(self.icon_type == 'banner') self.icon_menuitem = self.builder.get_object('icon_menuitem') self.icon_menuitem.set_active(self.icon_type == 'icon') self.search_entry = self.builder.get_object('search_entry') self.search_entry.connect('icon-press', self.on_clear_search) # Scroll window self.games_scrollwindow = self.builder.get_object('games_scrollwindow') self.games_scrollwindow.add(self.view) # Buttons self.stop_button = self.builder.get_object('stop_button') self.stop_button.set_sensitive(False) self.delete_button = self.builder.get_object('delete_button') self.delete_button.set_sensitive(False) self.play_button = self.builder.get_object('play_button') self.play_button.set_sensitive(False) # Contextual menu main_entries = [ ('play', "Play", self.on_game_run), ('install', "Install", self.on_install_clicked), ('add', "Add manually", self.on_add_manually), ('configure', "Configure", self.on_edit_game_configuration), ('browse', "Browse files", self.on_browse_files), ('desktop-shortcut', "Create desktop shortcut", self.create_desktop_shortcut), ('rm-desktop-shortcut', "Delete desktop shortcut", self.remove_desktop_shortcut), ('menu-shortcut', "Create application menu shortcut", self.create_menu_shortcut), ('rm-menu-shortcut', "Delete application menu shortcut", self.remove_menu_shortcut), ('install_more', "Install (add) another version", self.on_install_clicked), ('remove', "Remove", self.on_remove_game), ] self.menu = ContextualMenu(main_entries) self.view.contextual_menu = self.menu # Sidebar self.sidebar_paned = self.builder.get_object('sidebar_paned') self.sidebar_treeview = SidebarTreeView() self.sidebar_treeview.connect('cursor-changed', self.on_sidebar_changed) self.sidebar_viewport = self.builder.get_object('sidebar_viewport') self.sidebar_viewport.add(self.sidebar_treeview) # Window initialization self.window = self.builder.get_object("window") self.window.resize_to_geometry(width, height) self.window.set_default_icon_name('lutris') self.window.show_all() self.builder.connect_signals(self) self.connect_signals() self.statusbar = self.builder.get_object("statusbar") # XXX Hide PGA config menu item until it actually gets implemented pga_menuitem = self.builder.get_object('pga_menuitem') pga_menuitem.hide() # Sync local lutris library with current Steam games before setting up # view steam.sync_with_lutris() self.game_store.fill_store(self.game_list) self.switch_splash_screen() self.show_sidebar() self.update_runtime() # Connect account and/or sync credentials = api.read_api_key() if credentials: self.on_connect_success(None, credentials) else: self.toggle_connection(False) self.sync_library() # Timers self.timer_ids = [GLib.timeout_add(300, self.refresh_status)] steamapps_paths = steam.get_steamapps_paths(flat=True) self.steam_watcher = steam.SteamWatcher(steamapps_paths, self.on_steam_game_changed)
def __init__(self, service=None): Gtk.Application.__init__( self, application_id="net.lutris.main", flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE ) ui_filename = os.path.join( datapath.get(), 'ui', 'lutris-window.ui' ) if not os.path.exists(ui_filename): raise IOError('File %s not found' % ui_filename) self.service = service self.runtime_updater = RuntimeUpdater() self.running_game = None self.threads_stoppers = [] # Emulate double click to workaround GTK bug #484640 # https://bugzilla.gnome.org/show_bug.cgi?id=484640 self.game_selection_time = 0 self.game_launch_time = 0 self.last_selected_game = None self.selected_runner = None self.builder = Gtk.Builder() self.builder.add_from_file(ui_filename) # Load settings width = int(settings.read_setting('width') or 800) height = int(settings.read_setting('height') or 600) self.window_size = (width, height) window = self.builder.get_object('window') window.resize(width, height) view_type = self.get_view_type() self.load_icon_type_from_settings(view_type) self.filter_installed = \ settings.read_setting('filter_installed') == 'true' self.sidebar_visible = \ settings.read_setting('sidebar_visible') in ['true', None] # Set theme to dark if set in the settings dark_theme_menuitem = self.builder.get_object('dark_theme_menuitem') use_dark_theme = settings.read_setting('dark_theme') == 'true' dark_theme_menuitem.set_active(use_dark_theme) self.set_dark_theme(use_dark_theme) self.game_list = pga.get_games() # Load view self.game_store = GameStore([], self.icon_type, self.filter_installed) self.view = self.get_view(view_type) self.main_box = self.builder.get_object('main_box') self.splash_box = self.builder.get_object('splash_box') self.connect_link = self.builder.get_object('connect_link') # View menu installed_games_only_menuitem =\ self.builder.get_object('filter_installed') installed_games_only_menuitem.set_active(self.filter_installed) self.grid_view_menuitem = self.builder.get_object("gridview_menuitem") self.grid_view_menuitem.set_active(view_type == 'grid') self.list_view_menuitem = self.builder.get_object("listview_menuitem") self.list_view_menuitem.set_active(view_type == 'list') sidebar_menuitem = self.builder.get_object('sidebar_menuitem') sidebar_menuitem.set_active(self.sidebar_visible) # View buttons self.grid_view_btn = self.builder.get_object('switch_grid_view_btn') self.grid_view_btn.set_active(view_type == 'grid') self.list_view_btn = self.builder.get_object('switch_list_view_btn') self.list_view_btn.set_active(view_type == 'list') # Icon type menu self.banner_small_menuitem = \ self.builder.get_object('banner_small_menuitem') self.banner_small_menuitem.set_active(self.icon_type == 'banner_small') self.banner_menuitem = self.builder.get_object('banner_menuitem') self.banner_menuitem.set_active(self.icon_type == 'banner') self.icon_menuitem = self.builder.get_object('icon_menuitem') self.icon_menuitem.set_active(self.icon_type == 'icon') self.search_entry = self.builder.get_object('search_entry') self.search_entry.connect('icon-press', self.on_clear_search) # Scroll window self.games_scrollwindow = self.builder.get_object('games_scrollwindow') self.games_scrollwindow.add(self.view) # Buttons self.stop_button = self.builder.get_object('stop_button') self.stop_button.set_sensitive(False) self.delete_button = self.builder.get_object('delete_button') self.delete_button.set_sensitive(False) self.play_button = self.builder.get_object('play_button') self.play_button.set_sensitive(False) # Contextual menu main_entries = [ ('play', "Play", self.on_game_run), ('install', "Install", self.on_install_clicked), ('add', "Add manually", self.on_add_manually), ('configure', "Configure", self.on_edit_game_configuration), ('browse', "Browse files", self.on_browse_files), ('desktop-shortcut', "Create desktop shortcut", self.create_desktop_shortcut), ('rm-desktop-shortcut', "Delete desktop shortcut", self.remove_desktop_shortcut), ('menu-shortcut', "Create application menu shortcut", self.create_menu_shortcut), ('rm-menu-shortcut', "Delete application menu shortcut", self.remove_menu_shortcut), ('install_more', "Install (add) another version", self.on_install_clicked), ('remove', "Remove", self.on_remove_game), ] self.menu = ContextualMenu(main_entries) self.view.contextual_menu = self.menu # Sidebar self.sidebar_paned = self.builder.get_object('sidebar_paned') self.sidebar_treeview = SidebarTreeView() self.sidebar_treeview.connect('cursor-changed', self.on_sidebar_changed) self.sidebar_viewport = self.builder.get_object('sidebar_viewport') self.sidebar_viewport.add(self.sidebar_treeview) # Window initialization self.window = self.builder.get_object("window") self.window.resize_to_geometry(width, height) self.window.set_default_icon_name('lutris') self.window.show_all() self.builder.connect_signals(self) self.connect_signals() self.statusbar = self.builder.get_object("statusbar") # XXX Hide PGA config menu item until it actually gets implemented pga_menuitem = self.builder.get_object('pga_menuitem') pga_menuitem.hide() # Sync local lutris library with current Steam games before setting up # view steam.sync_with_lutris() self.game_store.fill_store(self.game_list) self.switch_splash_screen() self.show_sidebar() self.update_runtime() # Connect account and/or sync credentials = api.read_api_key() if credentials: self.on_connect_success(None, credentials) else: self.toggle_connection(False) self.sync_library() # Timers self.timer_ids = [GLib.timeout_add(300, self.refresh_status)] steamapps_paths = steam.get_steamapps_paths(flat=True) self.steam_watcher = steam.SteamWatcher(steamapps_paths, self.on_steam_game_changed)
def __init__(self): ui_filename = os.path.join( datapath.get(), 'ui', 'LutrisWindow.ui' ) if not os.path.exists(ui_filename): raise IOError('File %s not found' % ui_filename) self.builder = Gtk.Builder() self.builder.add_from_file(ui_filename) # load config width = int(settings.read_setting('width') or 800) height = int(settings.read_setting('height') or 600) self.window_size = (width, height) view_type = settings.read_setting('view_type') or 'icon' filter_installed_setting = settings.read_setting( 'filter_installed' ) or 'false' self.filter_installed = filter_installed_setting == 'true' show_installed_games_menuitem = self.builder.get_object( 'filter_installed' ) show_installed_games_menuitem.set_active(self.filter_installed) logger.debug("Getting game list") game_list = get_game_list(self.filter_installed) logger.debug("Switching view") self.view = switch_to_view(view_type, game_list) logger.debug("Connecting signals") self.icon_view_menuitem = self.builder.get_object("iconview_menuitem") self.icon_view_menuitem.set_active(view_type == 'icon') self.list_view_menuitem = self.builder.get_object("listview_menuitem") self.list_view_menuitem.set_active(view_type == 'list') self.icon_view_btn = self.builder.get_object('switch_grid_view_btn') self.icon_view_btn.set_active(view_type == 'icon') self.list_view_btn = self.builder.get_object('switch_list_view_btn') self.list_view_btn.set_active(view_type == 'list') # Scroll window self.games_scrollwindow = self.builder.get_object('games_scrollwindow') self.games_scrollwindow.add(self.view) #Status bar self.status_label = self.builder.get_object('status_label') self.joystick_icons = [] # Buttons self.stop_button = self.builder.get_object('stop_button') self.stop_button.set_sensitive(False) self.delete_button = self.builder.get_object('delete_button') self.delete_button.set_sensitive(False) self.play_button = self.builder.get_object('play_button') self.play_button.set_sensitive(False) #Contextual menu menu_callbacks = [ ('play', self.on_game_clicked), ('install', self.on_game_clicked), ('add', self.add_manually), ('configure', self.edit_game_configuration), ('desktop-shortcut', self.create_desktop_shortcut), ('menu-shortcut', self.create_menu_shortcut), ('uninstall', self.on_remove_game), ] self.menu = ContextualMenu(menu_callbacks) self.view.contextual_menu = self.menu #Timer self.timer_id = GLib.timeout_add(2000, self.refresh_status) self.window = self.builder.get_object("window") self.window.resize_to_geometry(width, height) self.window.show_all() self.builder.connect_signals(self) self.connect_signals() if api.read_api_key(): self.status_label.set_text("Connected to lutris.net") self.sync_library() else: async_call(self.sync_icons, None)
def __init__(self, application, **kwargs): self.runtime_updater = RuntimeUpdater() self.running_game = None self.threads_stoppers = [] # Emulate double click to workaround GTK bug #484640 # https://bugzilla.gnome.org/show_bug.cgi?id=484640 self.game_selection_time = 0 self.game_launch_time = 0 self.last_selected_game = None self.selected_runner = None self.selected_platform = 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.sidebar_visible = \ settings.read_setting('sidebar_visible') in ['true', None] self.use_dark_theme = settings.read_setting('dark_theme') == 'true' # Sync local lutris library with current Steam games and desktop games # before setting up game list and view steam.sync_with_lutris() desktopapps.sync_with_lutris() # Window initialization self.game_list = pga.get_games() self.game_store = GameStore([], self.icon_type, self.filter_installed) self.view = self.get_view(view_type) 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() # Set theme to dark if set in the settings self.set_dark_theme(self.use_dark_theme) # Load view self.games_scrollwindow.add(self.view) self.connect_signals() self.view.show() # Contextual menu main_entries = [ ('play', "Play", self.on_game_run), ('install', "Install", self.on_install_clicked), ('add', "Add manually", self.on_add_manually), ('configure', "Configure", self.on_edit_game_configuration), ('browse', "Browse files", self.on_browse_files), ('desktop-shortcut', "Create desktop shortcut", self.create_desktop_shortcut), ('rm-desktop-shortcut', "Delete desktop shortcut", self.remove_desktop_shortcut), ('menu-shortcut', "Create application menu shortcut", self.create_menu_shortcut), ('rm-menu-shortcut', "Delete application menu shortcut", self.remove_menu_shortcut), ('install_more', "Install (add) another version", self.on_install_clicked), ('remove', "Remove", self.on_remove_game), ('view', "View on Lutris.net", self.on_view_game), ] self.menu = ContextualMenu(main_entries) self.view.contextual_menu = self.menu # Sidebar self.sidebar_treeview = SidebarTreeView() self.sidebar_treeview.connect('cursor-changed', self.on_sidebar_changed) self.sidebar_viewport.add(self.sidebar_treeview) self.sidebar_treeview.show() self.game_store.fill_store(self.game_list) self.switch_splash_screen() self.show_sidebar() self.update_runtime() # Connect account and/or sync credentials = api.read_api_key() if credentials: self.on_connect_success(None, credentials) else: self.toggle_connection(False) self.sync_library() # Timers self.timer_ids = [GLib.timeout_add(300, self.refresh_status)] steamapps_paths = steam.get_steamapps_paths(flat=True) self.steam_watcher = steam.SteamWatcher(steamapps_paths, self.on_steam_game_changed)
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): ui_filename = os.path.join( datapath.get(), 'ui', 'LutrisWindow.ui' ) if not os.path.exists(ui_filename): raise IOError('File %s not found' % ui_filename) # Currently running game self.running_game = None # Emulate double click to workaround GTK bug #484640 # https://bugzilla.gnome.org/show_bug.cgi?id=484640 self.game_selection_time = 0 self.game_launch_time = 0 self.last_selected_game = None self.builder = Gtk.Builder() self.builder.add_from_file(ui_filename) # load config width = int(settings.read_setting('width') or 800) height = int(settings.read_setting('height') or 600) self.window_size = (width, height) view_type = self.get_view_type() self.icon_type = self.get_icon_type(view_type) filter_installed_setting = settings.read_setting( 'filter_installed' ) or 'false' self.filter_installed = filter_installed_setting == 'true' show_installed_games_menuitem = self.builder.get_object( 'filter_installed' ) show_installed_games_menuitem.set_active(self.filter_installed) logger.debug("Getting game list") game_list = get_game_list(self.filter_installed) logger.debug("Switching view") self.view = load_view(view_type, game_list, icon_type=self.icon_type) logger.debug("Connecting signals") self.main_box = self.builder.get_object('main_box') self.splash_box = self.builder.get_object('splash_box') # View menu self.grid_view_menuitem = self.builder.get_object("gridview_menuitem") self.grid_view_menuitem.set_active(view_type == 'grid') self.list_view_menuitem = self.builder.get_object("listview_menuitem") self.list_view_menuitem.set_active(view_type == 'list') # View buttons self.grid_view_btn = self.builder.get_object('switch_grid_view_btn') self.grid_view_btn.set_active(view_type == 'grid') self.list_view_btn = self.builder.get_object('switch_list_view_btn') self.list_view_btn.set_active(view_type == 'list') # Icon type menu self.banner_small_menuitem = \ self.builder.get_object('banner_small_menuitem') self.banner_small_menuitem.set_active(self.icon_type == 'banner_small') self.banner_menuitem = self.builder.get_object('banner_menuitem') self.banner_menuitem.set_active(self.icon_type == 'banner') self.icon_menuitem = self.builder.get_object('icon_menuitem') self.icon_menuitem.set_active(self.icon_type == 'grid') self.search_entry = self.builder.get_object('search_entry') # Scroll window self.games_scrollwindow = self.builder.get_object('games_scrollwindow') self.games_scrollwindow.add(self.view) # Status bar self.status_label = self.builder.get_object('status_label') self.joystick_icons = [] # Buttons self.stop_button = self.builder.get_object('stop_button') self.stop_button.set_sensitive(False) self.delete_button = self.builder.get_object('delete_button') self.delete_button.set_sensitive(False) self.play_button = self.builder.get_object('play_button') self.play_button.set_sensitive(False) # Contextual menu menu_callbacks = [ ('play', self.on_game_clicked), ('install', self.on_game_clicked), ('add', self.add_manually), ('configure', self.edit_game_configuration), ('browse', self.on_browse_files), ('desktop-shortcut', self.create_desktop_shortcut), ('menu-shortcut', self.create_menu_shortcut), ('remove', self.on_remove_game), ] self.menu = ContextualMenu(menu_callbacks) self.view.contextual_menu = self.menu # Timer self.timer_id = GLib.timeout_add(2000, self.refresh_status) # Window initialization self.window = self.builder.get_object("window") self.window.resize_to_geometry(width, height) self.window.show_all() self.builder.connect_signals(self) self.connect_signals() # XXX Hide PGA config menu item until it actually gets implemented pga_menuitem = self.builder.get_object('pga_menuitem') pga_menuitem.hide() self.switch_splash_screen() credentials = api.read_api_key() if credentials: self.on_connect_success(None, credentials) else: self.toggle_connection(False) sync = Sync() async_call( sync.sync_steam_local, lambda r, e: async_call(self.sync_icons, None), caller=self ) # Update Lutris Runtime async_call(runtime.update_runtime, None)
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()
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(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(3) self.website_search_toggle.set_image(lutris_icon) self.website_search_toggle.set_label("Search Lutris.net") self.website_search_toggle.set_tooltip_text("Search 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()