added history wiew

This commit is contained in:
2025-09-17 11:45:04 +02:00
parent 5f3b4b7ddb
commit fa41eb1b02
2 changed files with 43 additions and 2 deletions

View File

@@ -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=(',', ': '))