<commit_before>const Me = imports.misc.extensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;
const DeskChangerPopupMenu = Me.imports.ui.popupMenu;
const DeskChangerControl = Me.imports.ui.control;

const Gio = imports.gi.Gio;
const GObject = imports.gi.GObject;
const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu;
const St = imports.gi.St;
const Util = imports.misc.util;

var Button = GObject.registerClass(
class DeskChangerPanelMenuButton extends PanelMenu.Button {
    _init(daemon) {
        super._init(0.0, 'DeskChanger');
        this._daemon = daemon;

        this._icon = new Icon(daemon);
        this.add_child(this._icon);
        this.menu.addMenuItem(new DeskChangerPopupMenu.ProfileDesktopMenuItem());
        this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
        this.menu.addMenuItem(new DeskChangerPopupMenu.SwitchMenuItem(_('Notifications'), 'notifications'));
        this.menu.addMenuItem(new DeskChangerPopupMenu.SwitchMenuItem(_('Remember profile state'), 'remember_profile_state'));
        this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
        this.menu.addMenuItem(new DeskChangerPopupMenu.PreviewMenuItem(daemon));
        this.menu.addMenuItem(new DeskChangerPopupMenu.ControlsMenuItem(daemon));
        this.menu.addMenuItem(new DeskChangerPopupMenu.OpenCurrentMenuItem());
        this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
        this.menu.addMenuItem(new DeskChangerPopupMenu.RotationMenuItem());
        this.menu.addMenuItem(new DeskChangerPopupMenu.DaemonMenuItem(daemon));

        let menu_item = new PopupMenu.PopupMenuItem(_('DeskChanger Settings'));
        menu_item.connect('activate', function () {
            Util.spawn(['gnome-shell-extension-prefs', Me.metadata.uuid]);
        });
        this.menu.addMenuItem(menu_item);
    }

    destroy() {
        this._icon.destroy();
        super.destroy();
    }
}
);

let Icon = GObject.registerClass(
class DeskChangerPanelMenuIcon extends St.Bin {
    _init(daemon) {
        this._daemon = daemon;
        this._gicon = Gio.icon_new_for_string(Me.path + '/resources/icons/wallpaper-icon.png');
        super._init({
            style_class: 'panel-status-menu-box',
        });
        this._icon = null;
        this._preview = null;
        this.update_child();

        this._preview_id = deskchanger.settings.connect('changed::icon-preview', (settings, key) => {
            this.update_child(this._daemon.Preview);
        });

        this._daemon.connectSignal('Preview', (proxy, name, [uri]) => {
            if (this._preview) {
                this.update_child(uri);
            }
        });
    }

    destroy() {
        if (this._preview_id) {
            deskchanger.settings.disconnect(this._preview_id);
        }

        this._destroy_icon();
        this._destroy_preview();
        super.destroy();
    }

    update_child(file) {
        if (deskchanger.settings.icon_preview && this._create_preview(file)) {
            this.set_child(this._preview);
            this._destroy_icon();
        } else if (!(this._icon)) {
            this._icon = new St.Icon({
                gicon: this._gicon,
                style_class: 'system-status-icon',
            });<commit_msg>Updating the way prefs are opened<commit_after>const Me = imports.misc.extensionUtils.getCurrentExtension();
const Convenience = Me.imports.convenience;
const DeskChangerPopupMenu = Me.imports.ui.popupMenu;
const DeskChangerControl = Me.imports.ui.control;

const Gio = imports.gi.Gio;
const GObject = imports.gi.GObject;
const PanelMenu = imports.ui.panelMenu;
const PopupMenu = imports.ui.popupMenu;
const St = imports.gi.St;
const Util = imports.misc.util;

var Button = GObject.registerClass(
class DeskChangerPanelMenuButton extends PanelMenu.Button {
    _init(daemon) {
        super._init(0.0, 'DeskChanger');
        this._daemon = daemon;

        this._icon = new Icon(daemon);
        this.add_child(this._icon);
        this.menu.addMenuItem(new DeskChangerPopupMenu.ProfileDesktopMenuItem());
        this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
        this.menu.addMenuItem(new DeskChangerPopupMenu.SwitchMenuItem(_('Notifications'), 'notifications'));
        this.menu.addMenuItem(new DeskChangerPopupMenu.SwitchMenuItem(_('Remember profile state'), 'remember_profile_state'));
        this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
        this.menu.addMenuItem(new DeskChangerPopupMenu.PreviewMenuItem(daemon));
        this.menu.addMenuItem(new DeskChangerPopupMenu.ControlsMenuItem(daemon));
        this.menu.addMenuItem(new DeskChangerPopupMenu.OpenCurrentMenuItem());
        this.menu.addMenuItem(new PopupMenu.PopupSeparatorMenuItem());
        this.menu.addMenuItem(new DeskChangerPopupMenu.RotationMenuItem());
        this.menu.addMenuItem(new DeskChangerPopupMenu.DaemonMenuItem(daemon));

        let menu_item = new PopupMenu.PopupMenuItem(_('DeskChanger Settings'));
        menu_item.connect('activate', function () {
            if ('openPrefs' in imports.misc.extensionUtils) {
                imports.misc.extensionUtils.openPrefs();
            } else {
                Util.spawn(['gnome-shell-extension-prefs', Me.metadata.uuid]);
            }
        });
        this.menu.addMenuItem(menu_item);
    }

    destroy() {
        this._icon.destroy();
        super.destroy();
    }
}
);

let Icon = GObject.registerClass(
class DeskChangerPanelMenuIcon extends St.Bin {
    _init(daemon) {
        this._daemon = daemon;
        this._gicon = Gio.icon_new_for_string(Me.path + '/resources/icons/wallpaper-icon.png');
        super._init({
            style_class: 'panel-status-menu-box',
        });
        this._icon = null;
        this._preview = null;
        this.update_child();

        this._preview_id = deskchanger.settings.connect('changed::icon-preview', (settings, key) => {
            this.update_child(this._daemon.Preview);
        });
    }

    destroy() {
        if (this._preview_id) {
            deskchanger.settings.disconnect(this._preview_id);
        }

        this._destroy_icon();
        this._destroy_preview();
        super.destroy();
    }

    update_child(file) {
        if (deskchanger.settings.icon_preview && this._create_preview(file)) {
            this.set_child(this._preview);
            this._destroy_icon();
        } else if (!(this._icon)) {
            this._icon = new St.Icon({
                gicon: this._gicon,
                style_class: 'system-status-icon',
            });
{'fraction_non_alphanumeric': 0.12280966767371601, 'fraction_numerical': 0.0006042296072507553, 'mean_word_length': 2.9038915094339623, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4145796', 'n_tokens_mistral': 1955, 'n_tokens_neox': 1955, 'n_words': 286}