diff --git a/resources/po/ar.po b/resources/po/ar.po index 9be8f014..60cfd2ae 100644 --- a/resources/po/ar.po +++ b/resources/po/ar.po @@ -43,10 +43,18 @@ msgstr "اكتب نصًا للبحث عنه" msgid "Clears the clipboard database and cache" msgstr "يمحو قاعدة بيانات الحافظة وذاكرتها المؤقتة" -#: src/prefs/dangerZone/index.ts:10 +#: src/prefs/dangerZone/index.ts:11 msgid "Danger Zone" msgstr "" +#: src/prefs/dangerZone/sessionOnlyMode.ts:13 +msgid "Session Only Mode" +msgstr "" + +#: src/prefs/dangerZone/sessionOnlyMode.ts:14 +msgid "When enabled, Pano will clear all history on logout/restart/shutdown." +msgstr "" + #: src/prefs/general/dbLocation.ts:22 msgid "Database Location" msgstr "موقع قاعدة البيانات" diff --git a/resources/po/en.po b/resources/po/en.po index aed079b3..07a9838b 100644 --- a/resources/po/en.po +++ b/resources/po/en.po @@ -43,10 +43,18 @@ msgstr "Type to search" msgid "Clears the clipboard database and cache" msgstr "Clears the clipboard database and cache" -#: src/prefs/dangerZone/index.ts:10 +#: src/prefs/dangerZone/index.ts:11 msgid "Danger Zone" msgstr "Danger Zone" +#: src/prefs/dangerZone/sessionOnlyMode.ts:13 +msgid "Session Only Mode" +msgstr "Session Only Mode" + +#: src/prefs/dangerZone/sessionOnlyMode.ts:14 +msgid "When enabled, Pano will clear all history on logout/restart/shutdown." +msgstr "When enabled, Pano will clear all history on logout/restart/shutdown." + #: src/prefs/general/dbLocation.ts:22 msgid "Database Location" msgstr "Database Location" diff --git a/resources/po/fr.po b/resources/po/fr.po index 6408a930..7acef667 100644 --- a/resources/po/fr.po +++ b/resources/po/fr.po @@ -43,10 +43,18 @@ msgstr "Tapez pour rechercher" msgid "Clears the clipboard database and cache" msgstr "Vider la base de données du presse-papiers et le cache" -#: src/prefs/dangerZone/index.ts:10 +#: src/prefs/dangerZone/index.ts:11 msgid "Danger Zone" msgstr "" +#: src/prefs/dangerZone/sessionOnlyMode.ts:13 +msgid "Session Only Mode" +msgstr "" + +#: src/prefs/dangerZone/sessionOnlyMode.ts:14 +msgid "When enabled, Pano will clear all history on logout/restart/shutdown." +msgstr "" + #: src/prefs/general/dbLocation.ts:22 msgid "Database Location" msgstr "Emplacement de la base de données" diff --git a/resources/po/hr.po b/resources/po/hr.po index 47a40a93..2d3c4b3b 100644 --- a/resources/po/hr.po +++ b/resources/po/hr.po @@ -43,10 +43,18 @@ msgstr "Upišite za pretragu" msgid "Clears the clipboard database and cache" msgstr "Briše bazu podataka međuspremnika i predmemoriju" -#: src/prefs/dangerZone/index.ts:10 +#: src/prefs/dangerZone/index.ts:11 msgid "Danger Zone" msgstr "" +#: src/prefs/dangerZone/sessionOnlyMode.ts:13 +msgid "Session Only Mode" +msgstr "" + +#: src/prefs/dangerZone/sessionOnlyMode.ts:14 +msgid "When enabled, Pano will clear all history on logout/restart/shutdown." +msgstr "" + #: src/prefs/general/dbLocation.ts:22 msgid "Database Location" msgstr "Lokacija baze podataka" diff --git a/resources/po/oc.po b/resources/po/oc.po index dafdc97d..ea56f63c 100644 --- a/resources/po/oc.po +++ b/resources/po/oc.po @@ -43,10 +43,18 @@ msgstr "Picatz per recercar" msgid "Clears the clipboard database and cache" msgstr "Escafa la basa de donadas del quichapapièrs e lo cache" -#: src/prefs/dangerZone/index.ts:10 +#: src/prefs/dangerZone/index.ts:11 msgid "Danger Zone" msgstr "" +#: src/prefs/dangerZone/sessionOnlyMode.ts:13 +msgid "Session Only Mode" +msgstr "" + +#: src/prefs/dangerZone/sessionOnlyMode.ts:14 +msgid "When enabled, Pano will clear all history on logout/restart/shutdown." +msgstr "" + #: src/prefs/general/dbLocation.ts:22 msgid "Database Location" msgstr "Emplaçament de la basa de donadas" diff --git a/resources/po/pano@elhan.io.pot b/resources/po/pano@elhan.io.pot index d59ceb40..4a4da2a9 100644 --- a/resources/po/pano@elhan.io.pot +++ b/resources/po/pano@elhan.io.pot @@ -46,7 +46,7 @@ msgstr "" msgid "Clears the clipboard database and cache" msgstr "" -#: src/prefs/dangerZone/index.ts:10 +#: src/prefs/dangerZone/index.ts:11 msgid "Danger Zone" msgstr "" @@ -116,6 +116,10 @@ msgstr "" msgid "Select a shortcut" msgstr "" +#: src/prefs/dangerZone/sessionOnlyMode.ts:13 +msgid "Session Only Mode" +msgstr "" + #: src/components/indicator/settingsMenu.ts:74 msgid "Settings" msgstr "" @@ -140,6 +144,10 @@ msgstr "" msgid "Watch Exclusions" msgstr "" +#: src/prefs/dangerZone/sessionOnlyMode.ts:14 +msgid "When enabled, Pano will clear all history on logout/restart/shutdown." +msgstr "" + #: src/prefs/general/watchExclusions.ts:14 msgid "When enabled, Pano will not track clipboard from excluded apps" msgstr "" diff --git a/resources/po/tr.po b/resources/po/tr.po index d4034df8..e2df3bf3 100644 --- a/resources/po/tr.po +++ b/resources/po/tr.po @@ -43,10 +43,20 @@ msgstr "Aramak için yazın" msgid "Clears the clipboard database and cache" msgstr "Pano veritabanını ve önbelleği temizler" -#: src/prefs/dangerZone/index.ts:10 +#: src/prefs/dangerZone/index.ts:11 msgid "Danger Zone" msgstr "Tehlikeli bölge" +#: src/prefs/dangerZone/sessionOnlyMode.ts:13 +msgid "Session Only Mode" +msgstr "Şu anki Oturum Modu" + +#: src/prefs/dangerZone/sessionOnlyMode.ts:14 +msgid "When enabled, Pano will clear all history on logout/restart/shutdown." +msgstr "" +"Etkinleştirildiğinde, Pano oturum kapatma/yeniden başlatma/kapatma sırasında " +"tüm geçmişi temizleyecektir." + #: src/prefs/general/dbLocation.ts:22 msgid "Database Location" msgstr "Veritabanı Konumu" diff --git a/resources/schemas/org.gnome.shell.extensions.pano.gschema.xml b/resources/schemas/org.gnome.shell.extensions.pano.gschema.xml index 8870a6f7..d16cb912 100644 --- a/resources/schemas/org.gnome.shell.extensions.pano.gschema.xml +++ b/resources/schemas/org.gnome.shell.extensions.pano.gschema.xml @@ -52,6 +52,11 @@ Offline mode When enabled, Pano will not try to connect to internet. + + false + Session only mode + When enabled, Pano will clear all history on logout/restart/shutdown. + true Watch exclusion list diff --git a/src/extension.ts b/src/extension.ts index fdd9ff71..e83baa69 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,8 +1,9 @@ -import { DBus, DBusExportedObject, Settings } from '@gi-types/gio2'; +import { DBus, DBusExportedObject, DBusSignalFlags, Settings } from '@gi-types/gio2'; import { PRIORITY_DEFAULT, Source, SOURCE_REMOVE, timeout_add } from '@gi-types/glib2'; import { Global } from '@gi-types/shell0'; +import { SettingsMenu } from '@pano/components/indicator/settingsMenu'; import { PanoWindow } from '@pano/containers/panoWindow'; -import { clipboardManager } from '@pano/utils/clipboardManager'; +import { ClipboardContent, clipboardManager, ContentType } from '@pano/utils/clipboardManager'; import { db } from '@pano/utils/db'; import { KeyManager } from '@pano/utils/keyManager'; import { @@ -17,7 +18,6 @@ import { setupAppDirs, } from '@pano/utils/shell'; import { addTopChrome, addToStatusArea, removeChrome, removeVirtualKeyboard } from '@pano/utils/ui'; -import { SettingsMenu } from '@pano/components/indicator/settingsMenu'; import './styles/stylesheet.css'; const debug = logger('extension'); @@ -31,6 +31,10 @@ class PanoExtension { private windowTrackerId: number | null; private timeoutId: number | null; private settingsMenu: SettingsMenu | null; + private shutdownSignalId: number | null; + private logoutSignalId: number | null; + private rebootSignalId: number | null; + private systemdSignalId: number | null; constructor() { setupAppDirs(); @@ -68,6 +72,23 @@ class PanoExtension { }); } + async clearSessionHistory() { + if (this.settings.get_boolean('session-only-mode')) { + debug('clearing session history'); + db.shutdown(); + clipboardManager.stopTracking(); + await deleteAppDirs(); + debug('deleted session cache and db'); + clipboardManager.setContent( + new ClipboardContent({ + type: ContentType.TEXT, + value: '', + }), + ); + debug('cleared last clipboard content'); + } + } + createIndicator() { if (this.settings.get_boolean('show-indicator')) { this.settingsMenu = new SettingsMenu(this.clearHistory.bind(this), () => this.panoWindow.toggle()); @@ -85,6 +106,44 @@ class PanoExtension { setupAppDirs(); this.createIndicator(); db.start(); + this.logoutSignalId = DBus.session.signal_subscribe( + null, + 'org.gnome.SessionManager.EndSessionDialog', + 'ConfirmedLogout', + '/org/gnome/SessionManager/EndSessionDialog', + null, + DBusSignalFlags.NONE, + this.clearSessionHistory.bind(this), + ); + + this.rebootSignalId = DBus.session.signal_subscribe( + null, + 'org.gnome.SessionManager.EndSessionDialog', + 'ConfirmedReboot', + '/org/gnome/SessionManager/EndSessionDialog', + null, + DBusSignalFlags.NONE, + this.clearSessionHistory.bind(this), + ); + + this.shutdownSignalId = DBus.session.signal_subscribe( + null, + 'org.gnome.SessionManager.EndSessionDialog', + 'ConfirmedShutdown', + '/org/gnome/SessionManager/EndSessionDialog', + null, + DBusSignalFlags.NONE, + this.clearSessionHistory.bind(this), + ); + this.systemdSignalId = DBus.system.signal_subscribe( + null, + 'org.freedesktop.login1.Manager', + 'PrepareForShutdown', + '/org/freedesktop/login1', + null, + DBusSignalFlags.NONE, + this.clearSessionHistory.bind(this), + ); addTopChrome(this.panoWindow); this.keyManager.listenFor('shortcut', () => this.panoWindow.toggle()); this.keyManager.listenFor('incognito-shortcut', () => { @@ -137,6 +196,22 @@ class PanoExtension { removeChrome(this.panoWindow); debug('extension is disabled'); db.shutdown(); + if (this.logoutSignalId) { + DBus.session.signal_unsubscribe(this.logoutSignalId); + this.logoutSignalId = null; + } + if (this.shutdownSignalId) { + DBus.session.signal_unsubscribe(this.shutdownSignalId); + this.shutdownSignalId = null; + } + if (this.rebootSignalId) { + DBus.session.signal_unsubscribe(this.rebootSignalId); + this.rebootSignalId = null; + } + if (this.systemdSignalId) { + DBus.system.signal_unsubscribe(this.systemdSignalId); + this.systemdSignalId = null; + } } async clearHistory() { diff --git a/src/prefs/dangerZone/index.ts b/src/prefs/dangerZone/index.ts index 0d81a72e..a76275c8 100644 --- a/src/prefs/dangerZone/index.ts +++ b/src/prefs/dangerZone/index.ts @@ -1,7 +1,8 @@ import { PreferencesGroup, PreferencesPage } from '@gi-types/adw1'; +import { ClearHistoryRow } from '@pano/prefs/dangerZone/clearHistory'; +import { SessionOnlyModeRow } from '@pano/prefs/dangerZone/sessionOnlyMode'; import { registerGObjectClass } from '@pano/utils/gjs'; import { _ } from '@pano/utils/shell'; -import { ClearHistoryRow } from './clearHistory'; @registerGObjectClass export class DangerZonePage extends PreferencesPage { @@ -12,6 +13,7 @@ export class DangerZonePage extends PreferencesPage { }); const dangerZoneGroup = new PreferencesGroup(); + dangerZoneGroup.add(new SessionOnlyModeRow()); dangerZoneGroup.add(new ClearHistoryRow()); this.add(dangerZoneGroup); diff --git a/src/prefs/dangerZone/sessionOnlyMode.ts b/src/prefs/dangerZone/sessionOnlyMode.ts new file mode 100644 index 00000000..33755259 --- /dev/null +++ b/src/prefs/dangerZone/sessionOnlyMode.ts @@ -0,0 +1,30 @@ +import { ActionRow } from '@gi-types/adw1'; +import { Settings, SettingsBindFlags } from '@gi-types/gio2'; +import { Align, Switch } from '@gi-types/gtk4'; +import { registerGObjectClass } from '@pano/utils/gjs'; +import { getCurrentExtensionSettings, _ } from '@pano/utils/shell'; + +@registerGObjectClass +export class SessionOnlyModeRow extends ActionRow { + private settings: Settings; + + constructor() { + super({ + title: _('Session Only Mode'), + subtitle: _('When enabled, Pano will clear all history on logout/restart/shutdown.'), + }); + + this.settings = getCurrentExtensionSettings(); + + const sessionOnlySwitch = new Switch({ + active: this.settings.get_boolean('session-only-mode'), + valign: Align.CENTER, + halign: Align.CENTER, + }); + + this.settings.bind('session-only-mode', sessionOnlySwitch, 'active', SettingsBindFlags.DEFAULT); + + this.add_suffix(sessionOnlySwitch); + this.set_activatable_widget(sessionOnlySwitch); + } +}