Skip to content

Commit d2910be

Browse files
committed
feat/fix: mega aggiornamento UI, riscrittura tunnel manager e bugfix vari
- Crypto Manager: implementata l'interfaccia grafica mancante (CryptoManagerDialog) per l'impostazione e la gestione della master password globale. - Tunnel Manager: riscrittura completa di tunnel_manager.py. Aggiunto il supporto a sshpass per le password, il campo "Utente", l'esecuzione non bloccante di SSH in background e un terminale di log in tempo reale. - Sidebar: ottimizzato pesantemente il layout in session_panel.py (rimossi i ritorni a capo, testo su riga singola, padding verticale ridotto) per massimizzare lo spazio con liste di sessioni molto lunghe. - Variabili Globali: creato il modulo variables_dialog.py che mancava, ripristinando il corretto funzionamento del menu. - Traduzioni: aggiunte le chiavi mancanti in translations.py per la finestra di cifratura e per la voce "Terminale interno" (sd.open_int_terminal). - Fix vari: corretta la licenza in EUPL v1.2 nella schermata About, risolto un SyntaxError (parametro errato) nella funzione della guida in PCM.py e sistemata l'indentazione in session_panel.py.
1 parent 3b1b86b commit d2910be

8 files changed

Lines changed: 2951 additions & 67 deletions

File tree

gtk3/PCM.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -797,7 +797,8 @@ def _on_about(self):
797797
dlg.set_version("2.0 (GTK3)")
798798
dlg.set_comments("Python Connection Manager\nGestore connessioni remote multi-protocollo")
799799
dlg.set_authors(["Andres Zanzani <azanzani@gmail.com>"])
800-
dlg.set_license_type(Gtk.License.AGPL_3_0)
800+
dlg.set_license_type(Gtk.License.CUSTOM)
801+
dlg.set_license("Licensed under the European Union Public Licence (EUPL) v1.2")
801802
dlg.set_website("https://github.com/buzzqw/Python_Connection_Manager")
802803
dlg.set_website_label("GitHub")
803804
dlg.run()

gtk3/crypto_manager.py

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,3 +312,95 @@ def decrypt_profile(profilo: dict) -> dict:
312312
if campo in result:
313313
result[campo] = decrypt_field(str(result[campo]))
314314
return result
315+
316+
317+
318+
# ---------------------------------------------------------------------------
319+
# Interfaccia Grafica (Dialog)
320+
# ---------------------------------------------------------------------------
321+
import gi
322+
gi.require_version("Gtk", "3.0")
323+
from gi.repository import Gtk
324+
325+
# Questa è la funzione che "pesca" le traduzioni dal file translations.py
326+
from translations import t
327+
328+
class CryptoManagerDialog(Gtk.Dialog):
329+
def __init__(self, parent=None):
330+
super().__init__(
331+
title=t("crypto.custom.title"),
332+
transient_for=parent,
333+
modal=True,
334+
destroy_with_parent=True
335+
)
336+
self.set_default_size(400, 0)
337+
self._init_ui()
338+
self.show_all()
339+
340+
def _init_ui(self):
341+
area = self.get_content_area()
342+
area.set_spacing(10)
343+
area.set_margin_start(16)
344+
area.set_margin_end(16)
345+
area.set_margin_top(16)
346+
area.set_margin_bottom(16)
347+
348+
self.attiva = is_enabled()
349+
350+
lbl = Gtk.Label()
351+
lbl.set_xalign(0.0)
352+
area.pack_start(lbl, False, False, 0)
353+
354+
self.entry_pwd1 = Gtk.Entry()
355+
self.entry_pwd1.set_visibility(False)
356+
area.pack_start(self.entry_pwd1, False, False, 0)
357+
358+
self.entry_pwd2 = Gtk.Entry()
359+
self.entry_pwd2.set_visibility(False)
360+
361+
if not self.attiva:
362+
lbl.set_markup(f"<b>{t('crypto.custom.disabled_title')}</b>\n{t('crypto.custom.disabled_desc')}")
363+
self.entry_pwd1.set_placeholder_text(t("crypto.custom.new_pwd_ph"))
364+
else:
365+
lbl.set_markup(f"<b>{t('crypto.custom.active_title')}</b>\n{t('crypto.custom.active_desc')}")
366+
self.entry_pwd1.set_placeholder_text(t("crypto.custom.old_pwd_ph"))
367+
self.entry_pwd2.set_placeholder_text(t("crypto.custom.new_pwd_opt_ph"))
368+
area.pack_start(self.entry_pwd2, False, False, 0)
369+
370+
# "sd.cancel" esiste già in translations.py!
371+
self.add_button(t("sd.cancel"), Gtk.ResponseType.CANCEL)
372+
btn_ok = self.add_button(t("crypto.custom.btn_apply"), Gtk.ResponseType.OK)
373+
btn_ok.get_style_context().add_class("suggested-action")
374+
375+
def run(self):
376+
resp = super().run()
377+
if resp == Gtk.ResponseType.OK:
378+
p1 = self.entry_pwd1.get_text()
379+
p2 = self.entry_pwd2.get_text() if self.attiva else ""
380+
381+
if not self.attiva:
382+
if p1:
383+
setup(p1)
384+
self._mostra_msg(t("crypto.custom.success"), t("crypto.custom.msg_enabled"))
385+
else:
386+
if p1 and p2:
387+
if change_password(p1, p2):
388+
self._mostra_msg(t("crypto.custom.success"), t("crypto.custom.msg_changed"))
389+
else:
390+
self._mostra_msg(t("crypto.custom.error"), t("crypto.custom.msg_wrong_old"))
391+
elif p1 and not p2:
392+
if disable(p1):
393+
self._mostra_msg(t("crypto.custom.success"), t("crypto.custom.msg_disabled"))
394+
else:
395+
self._mostra_msg(t("crypto.custom.error"), t("crypto.custom.msg_wrong"))
396+
return resp
397+
398+
def _mostra_msg(self, titolo, testo):
399+
m_type = Gtk.MessageType.INFO if titolo == t("crypto.custom.success") else Gtk.MessageType.ERROR
400+
dlg = Gtk.MessageDialog(
401+
transient_for=self, modal=True, message_type=m_type,
402+
buttons=Gtk.ButtonsType.OK, text=titolo
403+
)
404+
dlg.format_secondary_text(testo)
405+
dlg.run()
406+
dlg.destroy()

0 commit comments

Comments
 (0)