diff --git a/legendary/gui/simple.py b/legendary/gui/simple.py index dc3d1a0..08b0e81 100755 --- a/legendary/gui/simple.py +++ b/legendary/gui/simple.py @@ -1,20 +1,44 @@ #!/usr/bin/env python3 import gi +import webbrowser gi.require_version('Gtk', '3.0') from gi.repository import Gtk +from legendary.cli import LegendaryCLI -win = Gtk.Window() -grid = Gtk.Grid() -win.add(grid) -quit = Gtk.Button(label="Quit") -quit.set_size_request(80,30) -quit.connect("clicked", Gtk.main_quit) +class MyWindow(Gtk.Window): + def __init__(self): + Gtk.Window.__init__(self,title="Legendary") + self.button = Gtk.Button(label="Login") + self.button.connect("clicked", self.onclick) + self.add(self.button) + def onclick(self, widget): +# webbrowser.open('https://www.epicgames.com/id/login?redirectUrl=https%3A%2F%2Fwww.epicgames.com%2Fid%2Fapi%2Fredirect') + sid = AskSid(self) + print(f'LegendaryCLI.auth(f"--sid {sid}")') -grid.attach(quit,0,0,1,1) -win.set_border_width(10) -win.set_title("Legendary") -win.set_wmclass("Legendary","Legendary") +def AskSid(parent): + dialog = Gtk.MessageDialog(parent, Gtk.DialogFlags.DESTROY_WITH_PARENT, Gtk.MessageType.QUESTION, Gtk.ButtonsType.OK_CANCEL) + dialog.set_title("Enter Sid") + #dialog.set_default_size(200, 200) + + label = Gtk.Label() + label.set_markup("Please login via the epic web login, if web page did not open automatically, please manually open the following URL:\nhttps://www.epicgames.com/id/login?redirectUrl=https://www.epicgames.com/id/api/redirect") + entry = Gtk.Entry() + box = dialog.get_content_area() + box.pack_start(label, False, False, 0) + box.add(entry) + + dialog.show_all() + response = dialog.run() + sid = entry.get_text() + dialog.destroy() + if response == Gtk.ResponseType.OK: + return sid + else: + return 1 + +win = MyWindow() win.connect("destroy", Gtk.main_quit) -win.show() +win.show_all() Gtk.main()