mirror of
https://github.com/lutris/lutris
synced 2024-07-05 16:38:42 +00:00
Hide and show the notification bar on service login/logout, and hook up the Login button
This commit is contained in:
parent
507561d1d3
commit
bed49c83e4
|
@ -11,6 +11,7 @@ from urllib.parse import unquote, urlparse
|
|||
from gi.repository import Gdk, Gio, GLib, GObject, Gtk
|
||||
|
||||
from lutris import services, settings
|
||||
from lutris.api import read_user_info
|
||||
from lutris.api import LUTRIS_ACCOUNT_CONNECTED
|
||||
from lutris.database import categories as categories_db
|
||||
from lutris.database import games as games_db
|
||||
|
@ -45,7 +46,8 @@ from lutris.util.system import update_desktop_icons
|
|||
|
||||
|
||||
@GtkTemplate(ui=os.path.join(datapath.get(), "ui", "lutris-window.ui"))
|
||||
class LutrisWindow(Gtk.ApplicationWindow, DialogLaunchUIDelegate, DialogInstallUIDelegate): # pylint: disable=too-many-public-methods
|
||||
class LutrisWindow(Gtk.ApplicationWindow, DialogLaunchUIDelegate,
|
||||
DialogInstallUIDelegate): # pylint: disable=too-many-public-methods
|
||||
"""Handler class for main window signals."""
|
||||
|
||||
default_view_type = "grid"
|
||||
|
@ -63,6 +65,7 @@ class LutrisWindow(Gtk.ApplicationWindow, DialogLaunchUIDelegate, DialogInstallU
|
|||
viewtype_icon = GtkTemplate.Child()
|
||||
download_revealer: Gtk.Revealer = GtkTemplate.Child()
|
||||
game_view_spinner: Gtk.Spinner = GtkTemplate.Child()
|
||||
notification_revealer: Gtk.Revealer = GtkTemplate.Child()
|
||||
|
||||
def __init__(self, application, **kwargs):
|
||||
width = int(settings.read_setting("width") or self.default_width)
|
||||
|
@ -136,6 +139,7 @@ class LutrisWindow(Gtk.ApplicationWindow, DialogLaunchUIDelegate, DialogInstallU
|
|||
self.game_revealer.add(self.revealer_box)
|
||||
|
||||
self.update_action_state()
|
||||
self.update_notification()
|
||||
|
||||
GObject.add_emission_hook(BaseService, "service-login", self.on_service_login)
|
||||
GObject.add_emission_hook(BaseService, "service-logout", self.on_service_logout)
|
||||
|
@ -229,7 +233,6 @@ class LutrisWindow(Gtk.ApplicationWindow, DialogLaunchUIDelegate, DialogInstallU
|
|||
action.connect("change-state", value.callback)
|
||||
self.actions[name] = action
|
||||
if value.enabled:
|
||||
|
||||
def updater(action=action, value=value):
|
||||
action.props.enabled = value.enabled()
|
||||
|
||||
|
@ -820,6 +823,15 @@ class LutrisWindow(Gtk.ApplicationWindow, DialogLaunchUIDelegate, DialogInstallU
|
|||
settings.write_setting("filter_installed", bool(filter_installed))
|
||||
self.filters["installed"] = filter_installed
|
||||
|
||||
def update_notification(self):
|
||||
logged_in = bool(read_user_info())
|
||||
self.notification_revealer.set_reveal_child(not logged_in)
|
||||
|
||||
@GtkTemplate.Callback
|
||||
def on_lutris_log_in_button_clicked(self, _button):
|
||||
service = LutrisService()
|
||||
service.login(parent=self)
|
||||
|
||||
def on_service_games_updated(self, service):
|
||||
"""Request a view update when service games are loaded"""
|
||||
if self.service and service.id == self.service.id:
|
||||
|
@ -845,6 +857,7 @@ class LutrisWindow(Gtk.ApplicationWindow, DialogLaunchUIDelegate, DialogInstallU
|
|||
self.move(int(self.window_x), int(self.window_y))
|
||||
|
||||
def on_service_login(self, service):
|
||||
self.update_notification()
|
||||
service.start_reload(self._service_reloaded_cb)
|
||||
return True
|
||||
|
||||
|
@ -853,6 +866,7 @@ class LutrisWindow(Gtk.ApplicationWindow, DialogLaunchUIDelegate, DialogInstallU
|
|||
dialogs.ErrorDialog(error, parent=self)
|
||||
|
||||
def on_service_logout(self, service):
|
||||
self.update_notification()
|
||||
if self.service and service.id == self.service.id:
|
||||
self.update_store()
|
||||
return True
|
||||
|
|
|
@ -125,6 +125,7 @@
|
|||
<property name="visible">True</property>
|
||||
<property name="can-focus">True</property>
|
||||
<property name="receives-default">True</property>
|
||||
<signal name="clicked" handler="on_lutris_log_in_button_clicked" swapped="no"/>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="expand">False</property>
|
||||
|
|
Loading…
Reference in New Issue
Block a user