2021-02-03_13-44-09

This commit is contained in:
koraynilay 2021-02-03 13:44:09 +01:00
parent a0ad4799bb
commit d106a2d213

View file

@ -20,7 +20,7 @@ def installed_size(app_name):
return f"{g.install_size / (1024*1024*1024):.02f} GiB" return f"{g.install_size / (1024*1024*1024):.02f} GiB"
def update_avail(app_name): def update_avail(app_name):
print_version = False print_version = False # temporary, this will be in the config
g = core.get_installed_game(app_name) g = core.get_installed_game(app_name)
if g != None: if g != None:
try: try:
@ -42,7 +42,7 @@ def update_avail(app_name):
def log_gtk(msg): def log_gtk(msg):
dialog = Gtk.Dialog(title="Legendary Log") dialog = Gtk.Dialog(title="Legendary Log")
dialog.log = Gtk.Label(label=msg) dialog.log = Gtk.Label(label=msg)
dialog.log.set_selectable() dialog.log.set_selectable(True)
box = dialog.get_content_area() box = dialog.get_content_area()
box.add(dialog.log) box.add(dialog.log)
dialog.show_all() dialog.show_all()
@ -63,8 +63,14 @@ class main_window(Gtk.Window):
# Login button # Login button
if not core.login(): if not core.login():
self.button_login = Gtk.Button(label="Login") self.button_login = Gtk.Button(label="Login")
self.button_login.connect("clicked", self.onclick) self.button_login.connect("clicked", self.onclick_login)
self.login_vbox.pack_start(self.button_login, False, False, 10) self.login_vbox.pack_start(self.button_login, False, False, 10)
else:
self.username_label = Gtk.Label(label=core.lgd.userdata["displayName"])
self.button_logout = Gtk.Button(label="Logout")
self.button_logout.connect("clicked", self.onclick_logout)
self.login_vbox.pack_end(self.button_logout, False, False, 10)
self.login_vbox.pack_end(self.username_label, False, False, 0)
self.box.pack_start(self.login_vbox, False, False, 20) self.box.pack_start(self.login_vbox, False, False, 20)
@ -76,8 +82,7 @@ class main_window(Gtk.Window):
self.scroll.games = Gtk.ListStore(str, str, str, str) self.scroll.games = Gtk.ListStore(str, str, str, str)
gcols = ["Title","Installed","Size","Update Avaiable"] gcols = ["Title","Installed","Size","Update Avaiable"]
if not core.login(): if core.login():
log_gtk('Login failed, cannot continue!')
games, dlc_list = core.get_game_and_dlc_list() games, dlc_list = core.get_game_and_dlc_list()
games = sorted(games, key=lambda x: x.app_title.lower()) games = sorted(games, key=lambda x: x.app_title.lower())
for citem_id in dlc_list.keys(): for citem_id in dlc_list.keys():
@ -99,7 +104,8 @@ class main_window(Gtk.Window):
self.scroll.games.append(list(ls)) self.scroll.games.append(list(ls))
#print(f' + {dlc.app_title} (App name: {dlc.app_name} | Version: {dlc.app_version})') #print(f' + {dlc.app_title} (App name: {dlc.app_name} | Version: {dlc.app_version})')
self.scroll.gview = Gtk.TreeView(Gtk.TreeModelSort(model=self.scroll.games)) #self.scroll.gview = Gtk.TreeView(Gtk.TreeModelSort(model=self.scroll.games))
self.scroll.gview = Gtk.TreeView(model=self.scroll.games)
for i, c in enumerate(gcols): for i, c in enumerate(gcols):
cell = Gtk.CellRendererText() cell = Gtk.CellRendererText()
col = Gtk.TreeViewColumn(c, cell, text=i) col = Gtk.TreeViewColumn(c, cell, text=i)
@ -117,7 +123,7 @@ class main_window(Gtk.Window):
self.scroll.add(g) self.scroll.add(g)
def onclick(self, widget): def onclick_login(self, widget):
webbrowser.open('https://www.epicgames.com/id/login?redirectUrl=https%3A%2F%2Fwww.epicgames.com%2Fid%2Fapi%2Fredirect') webbrowser.open('https://www.epicgames.com/id/login?redirectUrl=https%3A%2F%2Fwww.epicgames.com%2Fid%2Fapi%2Fredirect')
exchange_token = '' exchange_token = ''
sid = ask_sid(self) sid = ask_sid(self)
@ -130,6 +136,10 @@ class main_window(Gtk.Window):
else: else:
log_gtk('Login attempt failed, please see log for details.') log_gtk('Login attempt failed, please see log for details.')
def onclick_logout(self, widget):
core.lgd.invalidate_userdata()
log_gtk("Successfully logged out")
def ask_sid(parent): def ask_sid(parent):
dialog = Gtk.MessageDialog(parent, Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.QUESTION, Gtk.ButtonsType.OK_CANCEL) dialog = Gtk.MessageDialog(parent, Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.QUESTION, Gtk.ButtonsType.OK_CANCEL)
dialog.set_title("Enter Sid") dialog.set_title("Enter Sid")