Skip to content

Commit

Permalink
Add utils function to clear inner GIO.Settings
Browse files Browse the repository at this point in the history
  • Loading branch information
yilozt committed Nov 12, 2023
1 parent c514c33 commit d51fa4e
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 16 deletions.
4 changes: 2 additions & 2 deletions po/rounded-window-corners@yilozt.pot
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Report-Msgid-Bugs-To: yilozt@outlook.com\n"
"Project-Id-Version: 11\n"
"Project-Id-Version: 12\n"

#: src/preferences/pages/general.ui:284
msgid "Add Settings Entry in right-click menu of Background"
Expand Down Expand Up @@ -183,7 +183,7 @@ msgid "Right"
msgstr ""

#: src/utils/ui.ts:103
#: src/utils/ui.ts:131
#: src/utils/ui.ts:132
msgid "Rounded Corners Settings..."
msgstr ""

Expand Down
13 changes: 0 additions & 13 deletions src/preferences/pages/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { settings } from '../../utils/settings.js'
import { SchemasKeys } from '../../utils/settings.js'
import { connections } from '../../utils/connections.js'
import { list_children } from '../../utils/prefs.js'
import { _log } from '../../utils/log.js'
import { RoundedCornersItem } from '../widgets/rounded_corners_item.js'
import { EditShadowWindow } from '../widgets/edit_shadow_window.js'
import { ResetDialog } from '../widgets/reset_dialog.js'
Expand Down Expand Up @@ -157,18 +156,6 @@ export const General = GObject.registerClass (
})
}

vfunc_root (): void {
super.vfunc_root ()
const win = this.root as Gtk.Window

// Disconnect all signal when close prefs
win.connect ('close-request', () => {
_log ('Disconnect Signals')
connections.get ().disconnect_all ()
connections.del ()
})
}

private build_ui () {
list_children (this.config_items).forEach ((i) => {
this.config_items.remove (i)
Expand Down
12 changes: 11 additions & 1 deletion src/prefs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ import * as Gtk from 'gi://Gtk'
import * as Gdk from 'gi://Gdk'
import * as Adw from 'gi://Adw'

import { init_settings } from './utils/settings.js'
import { connections } from './utils/connections.js'
import { init_settings, uninit_settings } from './utils/settings.js'
import { pages } from './preferences/index.js'
import { _log } from './utils/log.js'
import * as Utils from './utils/io.js'
import { ExtensionPreferences } from 'resource:///org/gnome/Shell/Extensions/js/extensions/prefs.js'

Expand Down Expand Up @@ -40,6 +42,14 @@ export default class RoundedWindowCornresPrefs extends ExtensionPreferences {
win.add (pref_page)
}

// Disconnect all signal when close prefs
win.connect ('close-request', () => {
_log ('Disconnect Signals')
connections.get ().disconnect_all ()
connections.del ()
uninit_settings ()
})

this._load_css ()
}
}
Expand Down
9 changes: 9 additions & 0 deletions src/utils/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,10 @@ export class Settings {

log (`[RoundedWindowCorners] Update Settings to v${VERSION}`)
}

_disable () {
(this.g_settings as Gio.Settings | null) = null
}
}

/** A singleton instance of Settings */
Expand All @@ -212,6 +216,11 @@ export const init_settings = (g_settings: Gio.Settings) => {
_settings = new Settings (g_settings)
}

export const uninit_settings = () => {
_settings?._disable ()
;(_settings as Settings | null) = null
}

/** Access _settings by this method */
export const settings = () => {
return _settings
Expand Down

0 comments on commit d51fa4e

Please sign in to comment.