From fa41eb1b020d2ed849fbb7ae6ab822e46566fb40 Mon Sep 17 00:00:00 2001 From: Angoosh Date: Wed, 17 Sep 2025 11:45:04 +0200 Subject: [PATCH] added history wiew --- com.angoosh.RDPConnect/main.py | 43 ++++++++++++++++++++++++++- com.angoosh.RDPConnect/preferences.ui | 2 +- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/com.angoosh.RDPConnect/main.py b/com.angoosh.RDPConnect/main.py index af510b1..15badd5 100755 --- a/com.angoosh.RDPConnect/main.py +++ b/com.angoosh.RDPConnect/main.py @@ -82,6 +82,40 @@ def load_config(): except: print("[WARN] FILE: "+HOMEDIR+"/.config/rdpconnect/settings.json doesn't exist") +class HistoryWindow(Gtk.Window): + def __init__(self, **kargs): + super().__init__(**kargs, title='History') + + self.set_default_size(100, 300) + + self.scroll = Gtk.ScrolledWindow() + self.scroll.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC) + + self.grid = Gtk.Grid() + + self.scroll.set_child(self.grid) + + index = 0 + for i in hist_info: + self.addRow(hist_info[i], index) + index += 1 + + self.set_child(self.scroll) + + def addRow(self, entry, index): + runb = Gtk.Button(label=entry) + runb.connect("clicked", self.apply_contents) + + self.grid.attach(runb, 0, index, 1, 1) + + def apply_contents(self, button): + conn_info["user"] = button.get_label().split('@')[0] + conn_info["ip"] = button.get_label().split('@')[1] + try: + conn_info["passwd"] = keyring.get_password("com.angoosh.RDPConnect", button.get_label()) + except: + pass + class PreferencesWindow(Gtk.Window): global settings def __init__(self, **kwargs): @@ -259,6 +293,10 @@ class MyApp(Adw.Application): action.connect('activate', self.on_about) self.add_action(action) + action = Gio.SimpleAction(name='history') + action.connect('activate', self.on_history) + self.add_action(action) + def on_about(self, action, param): about_dialog = Gtk.AboutDialog(transient_for=self.win, modal=True) about_dialog.set_copyright("Antonin Kaplan") @@ -272,11 +310,14 @@ class MyApp(Adw.Application): def on_preferences(self, action, param): PreferencesWindow() + def on_history(self, action, param): + HistoryWindow() + def saveConnConf(self): if settings["save_conn"]: password = conn_info["passwd"] useratip = conn_info["user"] + "@" + conn_info["ip"] - with open(HOMEDIR+"/.config/rdpconnect/history.json", "a") as hist_file: + with open(HOMEDIR+"/.config/rdpconnect/history.json", "w") as hist_file: hist_id = str(int(max(hist_info, default=0)) + 1) hist_info[hist_id] = useratip js = json.dumps(hist_info, sort_keys=True, indent=4, separators=(',', ': ')) diff --git a/com.angoosh.RDPConnect/preferences.ui b/com.angoosh.RDPConnect/preferences.ui index 6725121..185ac08 100644 --- a/com.angoosh.RDPConnect/preferences.ui +++ b/com.angoosh.RDPConnect/preferences.ui @@ -1,4 +1,4 @@ - +.