added burger menu, About section and Preferences menu item, which is WIP
This commit is contained in:
@@ -81,6 +81,7 @@ modules:
|
||||
- install -Dm755 rdpconnect.sh /app/bin/rdpconnect
|
||||
- install -Dm755 main.py /app/
|
||||
- install com.angoosh.RDPConnect.ui /app/
|
||||
- install menu.ui /app/
|
||||
- install style-dark.css /app/
|
||||
- install style-light.css /app/
|
||||
- install -Dm644 com.angoosh.RDPConnect.svg /app/share/icons/hicolor/scalable/apps/
|
||||
@@ -104,4 +105,6 @@ modules:
|
||||
- type: file
|
||||
path: com.angoosh.RDPConnect.desktop
|
||||
- type: file
|
||||
path: com.angoosh.RDPConnect.metainfo.xml
|
||||
path: com.angoosh.RDPConnect.metainfo.xml
|
||||
- type: file
|
||||
path: menu.ui
|
||||
@@ -4,6 +4,10 @@
|
||||
Created on Mon Nov 18 12:04:53 2024
|
||||
|
||||
@author: angoosh
|
||||
|
||||
references:
|
||||
https://pygobject.gnome.org/tutorials/gtk4/introduction.html
|
||||
https://docs.gtk.org/gtk3/index.html#classes
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
@@ -18,6 +22,8 @@ from gi.repository import Gtk, Adw, Gdk, Gio
|
||||
APPID = "com.angoosh.RDPConnect"
|
||||
HOMEDIR = os.path.expanduser('~')
|
||||
|
||||
VERSION = "1.0.5rc1"
|
||||
|
||||
conn_info = {}
|
||||
settings = {}
|
||||
fernet = ""
|
||||
@@ -34,7 +40,7 @@ def load_keys():
|
||||
with open(HOMEDIR+"/.config/rdpconnect/.key", "w") as keyfile:
|
||||
keyfile.write(cryptoKey.decode("utf-8"))
|
||||
print("Encription key generated")
|
||||
|
||||
|
||||
fernet = Fernet(cryptoKey)
|
||||
|
||||
def load_config():
|
||||
@@ -44,23 +50,23 @@ def load_config():
|
||||
with open(HOMEDIR+"/.config/rdpconnect/connection.json", "r") as connection_file:
|
||||
for line in connection_file:
|
||||
loaded_json += line
|
||||
|
||||
|
||||
conn_info = json.loads(loaded_json)
|
||||
|
||||
|
||||
conn_info["passwd"] = fernet.decrypt(str.encode(conn_info["passwd"])).decode()
|
||||
except:
|
||||
print("[WARN] FILE: "+HOMEDIR+"/.config/rdpconnect/connection.json doesn't exist")
|
||||
|
||||
|
||||
loaded_json = ""
|
||||
try:
|
||||
with open(HOMEDIR+"/.config/rdpconnect/settings.json", "r") as settings_file:
|
||||
for line in settings_file:
|
||||
loaded_json += line
|
||||
|
||||
|
||||
settings = json.loads(loaded_json)
|
||||
except:
|
||||
print("[WARN] FILE: "+HOMEDIR+"/.config/rdpconnect/settings.json doesn't exist")
|
||||
|
||||
|
||||
|
||||
class MyApp(Adw.Application):
|
||||
def __init__(self, **kwargs):
|
||||
@@ -70,62 +76,98 @@ class MyApp(Adw.Application):
|
||||
def on_activate(self, app):
|
||||
builder = Gtk.Builder()
|
||||
builder.add_from_file("/app/"+APPID+".ui")
|
||||
|
||||
buildermenu = Gtk.Builder()
|
||||
buildermenu.add_from_file("/app/menu.ui")
|
||||
menu_model = buildermenu.get_object('app-menu')
|
||||
|
||||
css_provider = Gtk.CssProvider()
|
||||
if Adw.StyleManager().get_default().get_dark():
|
||||
css_provider.load_from_file(Gio.File.new_for_path("/app/style-dark.css"))
|
||||
else:
|
||||
css_provider.load_from_file(Gio.File.new_for_path("/app/style-light.css"))
|
||||
Gtk.StyleContext.add_provider_for_display(Gdk.Display.get_default(), css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION)
|
||||
|
||||
|
||||
connect = builder.get_object("connect")
|
||||
connect.connect("clicked", self.connectRDP)
|
||||
|
||||
|
||||
self.ip = builder.get_object("ip")
|
||||
self.user = builder.get_object("user")
|
||||
self.passwd = builder.get_object("pass")
|
||||
|
||||
|
||||
self.save_conf = builder.get_object("save_conf")
|
||||
|
||||
|
||||
try:
|
||||
if settings["save_conn"]:
|
||||
self.ip.get_buffer().set_text(str(conn_info["ip"]), len(conn_info["ip"]))
|
||||
self.user.get_buffer().set_text(str(conn_info["user"]), len(conn_info["user"]))
|
||||
self.passwd.get_buffer().set_text(str(conn_info["passwd"]), len(conn_info["passwd"]))
|
||||
|
||||
|
||||
self.save_conf.set_active(True)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
#menu config
|
||||
self.win = builder.get_object("main_window")
|
||||
header_bar = Gtk.HeaderBar()
|
||||
self.win.set_titlebar(header_bar)
|
||||
|
||||
menubutton = Gtk.MenuButton(menu_model=menu_model, icon_name='open-menu-symbolic')
|
||||
header_bar.pack_end(menubutton)
|
||||
|
||||
self.win.set_application(self)
|
||||
self.win.present()
|
||||
|
||||
|
||||
def do_startup(self):
|
||||
Gtk.Application.do_startup(self)
|
||||
|
||||
action = Gio.SimpleAction(name='preferences')
|
||||
action.connect('activate', self.on_preferences)
|
||||
self.add_action(action)
|
||||
|
||||
action = Gio.SimpleAction(name='about')
|
||||
action.connect('activate', self.on_about)
|
||||
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")
|
||||
about_dialog.set_program_name("RDP Connect")
|
||||
about_dialog.set_license_type(Gtk.License(16))
|
||||
about_dialog.set_logo_icon_name("com.angoosh.RDPConnect")
|
||||
about_dialog.set_version(VERSION)
|
||||
about_dialog.set_website("https://gitea.farmdash.org/angoosh/Flatpaks")
|
||||
about_dialog.present()
|
||||
|
||||
def on_preferences(self, action, param):
|
||||
pref_window = Gtk.Window(title="Preferences")
|
||||
pref_window.show()
|
||||
print("Preferences")
|
||||
|
||||
def saveConnConf(self):
|
||||
if settings["save_conn"]:
|
||||
password = conn_info["passwd"]
|
||||
conn_info["passwd"] = fernet.encrypt(password.encode()).decode("utf-8")
|
||||
|
||||
|
||||
print("Saving connection config to "+HOMEDIR+"/.config/rdpconnect/connection.json")
|
||||
with open(HOMEDIR+"/.config/rdpconnect/connection.json", "w") as connection_file:
|
||||
js = json.dumps(conn_info, sort_keys=True, indent=4, separators=(',', ': '))
|
||||
connection_file.write(js)
|
||||
|
||||
|
||||
conn_info["passwd"] = password
|
||||
else:
|
||||
with open(HOMEDIR+"/.config/rdpconnect/connection.json", "w") as connection_file:
|
||||
connection_file.write("")
|
||||
|
||||
|
||||
print("Saving settings config to "+HOMEDIR+"/.config/rdpconnect/settings.json")
|
||||
with open(HOMEDIR+"/.config/rdpconnect/settings.json", "w") as settings_file:
|
||||
js = json.dumps(settings, sort_keys=True, indent=4, separators=(',', ': '))
|
||||
settings_file.write(js)
|
||||
|
||||
|
||||
def connectRDP(self, button):
|
||||
conn_info["ip"] = self.ip.get_buffer().get_text()
|
||||
conn_info["user"] = self.user.get_buffer().get_text()
|
||||
conn_info["passwd"] = self.passwd.get_buffer().get_text()
|
||||
|
||||
|
||||
if self.save_conf.get_active():
|
||||
settings["save_conn"] = True
|
||||
else:
|
||||
@@ -134,15 +176,14 @@ class MyApp(Adw.Application):
|
||||
settings["extra_params"] = []
|
||||
if not "rdp_bin" in settings:
|
||||
settings["rdp_bin"] = "sdl-freerdp"
|
||||
|
||||
|
||||
self.saveConnConf()
|
||||
|
||||
|
||||
try:
|
||||
subprocess.Popen([settings["rdp_bin"], "/v:"+str(conn_info["ip"]), "/u:"+str(conn_info["user"]), "/p:"+str(conn_info["passwd"])]+settings["extra_params"])
|
||||
except:
|
||||
subprocess.Popen(["sdl-freerdp", "/v:"+str(conn_info["ip"]), "/u:"+str(conn_info["user"]), "/p:"+str(conn_info["passwd"])]+settings["extra_params"])
|
||||
#subprocess.run(["xfreerdp", "/v:"+str(ip), "/u:"+str(user), "/p:"+str(passwd)])
|
||||
|
||||
|
||||
if not os.path.isdir(HOMEDIR+"/.config/rdpconnect"):
|
||||
os.makedirs(HOMEDIR+"/.config/rdpconnect")
|
||||
|
||||
|
||||
16
com.angoosh.RDPConnect/menu.ui
Normal file
16
com.angoosh.RDPConnect/menu.ui
Normal file
@@ -0,0 +1,16 @@
|
||||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<interface>
|
||||
<menu id='app-menu'>
|
||||
<section>
|
||||
<item>
|
||||
<attribute name='label'>Preferences</attribute>
|
||||
<attribute name='action'>app.preferences</attribute>
|
||||
</item>
|
||||
<item>
|
||||
<attribute name='label'>About</attribute>
|
||||
<attribute name='action'>app.about</attribute>
|
||||
</item>
|
||||
</section>
|
||||
</menu>
|
||||
</interface>
|
||||
|
||||
@@ -1 +1 @@
|
||||
9428c06df79e34ced50b30da7348cc491dc8079b34898598a6c78424405839ce
|
||||
c85d2b15939555943d6b112b19ea5c08212f7fcaceb16f625d893379cf4b1099
|
||||
|
||||
@@ -1 +1 @@
|
||||
2fdcf76a694b1f6cebc310c5f85ce998aa678ffb6558a4f1bbd075cd1640feab
|
||||
f3ef1294b654475b4a5acda3a7d56f3013ac3ec6ddebf1c900717c45ccaa3781
|
||||
|
||||
@@ -1 +1 @@
|
||||
e0461f34512c2cb7a0dae63db3d82588f59df34419ddd191c279714512dd3789
|
||||
42cff0ba2f3cc77988cd5bb0542221818fc3937c4e7c8c8539b385d728e63b0d
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
repo/summary
BIN
repo/summary
Binary file not shown.
BIN
repo/summary.idx
BIN
repo/summary.idx
Binary file not shown.
Reference in New Issue
Block a user