Skip to content

Commit

Permalink
Merge branch 'home-sweet-gnome:master' into system-wide-install-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
rathann authored Apr 5, 2024
2 parents d0cab28 + 1267526 commit 0f58b84
Show file tree
Hide file tree
Showing 37 changed files with 2,924 additions and 3,390 deletions.
5 changes: 2 additions & 3 deletions .github/stale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ staleLabel: stale
# Comment to post when marking as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
recent activity. Thank you for your contributions.
# Comment to post when removing the stale label.
# unmarkComment: >
Expand All @@ -58,4 +57,4 @@ only: issues

# issues:
# exemptLabels:
# - confirmed
# - confirmed
372 changes: 193 additions & 179 deletions appIcons.js

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions desktopIconsIntegration.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,16 @@
*
*******************************************************************************/

const GLib = imports.gi.GLib;
const Main = imports.ui.main;
import GLib from 'gi://GLib';
import * as Main from 'resource:///org/gnome/shell/ui/main.js';

const ExtensionUtils = imports.misc.extensionUtils;
const Me = ExtensionUtils.getCurrentExtension();
import {EXTENSION_UUID} from './extension.js';

import * as ExtensionUtils from 'resource:///org/gnome/shell/misc/extensionUtils.js';

const IDENTIFIER_UUID = "130cbc66-235c-4bd6-8571-98d2d8bba5e2";

var DesktopIconsUsableAreaClass = class {
export const DesktopIconsUsableAreaClass = class {
constructor() {
this._extensionManager = Main.extensionManager;
this._timedMarginsID = 0;
Expand Down Expand Up @@ -154,6 +155,6 @@ var DesktopIconsUsableAreaClass = class {

const usableArea = extension?.stateObj?.DesktopIconsUsableArea;
if (usableArea?.uuid === IDENTIFIER_UUID)
usableArea.setMarginsForExtension(Me.uuid, this._margins);
usableArea.setMarginsForExtension(EXTENSION_UUID, this._margins);
}
}
175 changes: 84 additions & 91 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,59 +18,93 @@
*/


const Main = imports.ui.main;
const Meta = imports.gi.Meta;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Shell = imports.gi.Shell;
const St = imports.gi.St;
const WindowManager = imports.ui.windowManager;
const ExtensionUtils = imports.misc.extensionUtils;
const Mainloop = imports.mainloop;
const Signals = imports.signals;

const Me = ExtensionUtils.getCurrentExtension();
const { PanelManager } = Me.imports.panelManager;
const Utils = Me.imports.utils;
const AppIcons = Me.imports.appIcons;
import Gio from 'gi://Gio';

import * as Main from 'resource:///org/gnome/shell/ui/main.js';
import {EventEmitter} from 'resource:///org/gnome/shell/misc/signals.js';
import {Extension, gettext as _} from 'resource:///org/gnome/shell/extensions/extension.js';

import * as PanelManager from './panelManager.js';
import * as Utils from './utils.js';
import * as AppIcons from './appIcons.js';


const UBUNTU_DOCK_UUID = '[email protected]';

let panelManager;
let extensionChangedHandler;
let startupCompleteHandler;
let disabledUbuntuDock;
let extensionSystem = (Main.extensionManager || imports.ui.extensionSystem);
let extensionSystem = Main.extensionManager;

export let DTP_EXTENSION = null;
export let SETTINGS = null;
export let DESKTOPSETTINGS = null;
export let TERMINALSETTINGS = null;
export let PERSISTENTSTORAGE = null;
export let EXTENSION_UUID = null;
export let EXTENSION_PATH = null;

export default class DashToPanelExtension extends Extension {
constructor(metadata) {
super(metadata);

this._realHasOverview = Main.sessionMode.hasOverview;

//create an object that persists until gnome-shell is restarted, even if the extension is disabled
PERSISTENTSTORAGE = {};
}

function init() {
this._realHasOverview = Main.sessionMode.hasOverview;
enable() {
DTP_EXTENSION = this;

ExtensionUtils.initTranslations(Utils.TRANSLATION_DOMAIN);

//create an object that persists until gnome-shell is restarted, even if the extension is disabled
Me.persistentStorage = {};
}
// The Ubuntu Dock extension might get enabled after this extension
extensionChangedHandler = extensionSystem.connect('extension-state-changed', (data, extension) => {
if (extension.uuid === UBUNTU_DOCK_UUID && extension.state === 1) {
_enable(this);
}
});

//create a global object that can emit signals and conveniently expose functionalities to other extensions
global.dashToPanel = new EventEmitter();

_enable(this);
}

disable(reset = false) {
panelManager.disable();

DTP_EXTENSION = null;
SETTINGS = null;
DESKTOPSETTINGS = null;
TERMINALSETTINGS = null;
panelManager = null;

if (!reset) {
extensionSystem.disconnect(extensionChangedHandler);
delete global.dashToPanel;

function enable() {
// The Ubuntu Dock extension might get enabled after this extension
extensionChangedHandler = extensionSystem.connect('extension-state-changed', (data, extension) => {
if (extension.uuid === UBUNTU_DOCK_UUID && extension.state === 1) {
_enable();
// Re-enable Ubuntu Dock if it was disabled by dash to panel
if (disabledUbuntuDock && Main.sessionMode.allowExtensions) {
(extensionSystem._callExtensionEnable || extensionSystem.enableExtension).call(extensionSystem, UBUNTU_DOCK_UUID);
}

AppIcons.resetRecentlyClickedApp();
}

if (startupCompleteHandler) {
Main.layoutManager.disconnect(startupCompleteHandler);
startupCompleteHandler = null;
}
});

//create a global object that can emit signals and conveniently expose functionalities to other extensions
global.dashToPanel = {};
Signals.addSignalMethods(global.dashToPanel);

_enable();
Main.sessionMode.hasOverview = this._realHasOverview;
}
}

function _enable() {
let ubuntuDock = Main.extensionManager ?
Main.extensionManager.lookup(UBUNTU_DOCK_UUID) : //gnome-shell >= 3.33.4
ExtensionUtils.extensions[UBUNTU_DOCK_UUID];
function _enable(extension) {
let ubuntuDock = extensionSystem.lookup(UBUNTU_DOCK_UUID);

if (ubuntuDock && ubuntuDock.stateObj && ubuntuDock.stateObj.dockManager) {
if (ubuntuDock && ubuntuDock.stateObj) {
// Disable Ubuntu Dock
let extensionOrder = (extensionSystem.extensionOrder || extensionSystem._extensionOrder);

Expand All @@ -82,69 +116,28 @@ function _enable() {

//reset to prevent conflicts with the ubuntu-dock
if (panelManager) {
disable(true);
extension.disable(true);
}
}

if (panelManager) return; //already initialized

Me.settings = ExtensionUtils.getSettings('org.gnome.shell.extensions.dash-to-panel');
Me.desktopSettings = ExtensionUtils.getSettings('org.gnome.desktop.interface');
SETTINGS = extension.getSettings('org.gnome.shell.extensions.dash-to-panel');
DESKTOPSETTINGS = new Gio.Settings({schema_id: 'org.gnome.desktop.interface'});
TERMINALSETTINGS = new Gio.Settings({schema_id: 'org.gnome.desktop.default-applications.terminal'})
EXTENSION_UUID = extension.uuid
EXTENSION_PATH = extension.path

Main.layoutManager.startInOverview = !Me.settings.get_boolean('hide-overview-on-startup');
Main.layoutManager.startInOverview = !SETTINGS.get_boolean('hide-overview-on-startup');

if (Me.settings.get_boolean('hide-overview-on-startup') && Main.layoutManager._startingUp) {
if (SETTINGS.get_boolean('hide-overview-on-startup') && Main.layoutManager._startingUp) {
Main.sessionMode.hasOverview = false;
Main.layoutManager.connect('startup-complete', () => {
Main.sessionMode.hasOverview = this._realHasOverview
startupCompleteHandler = Main.layoutManager.connect('startup-complete', () => {
Main.sessionMode.hasOverview = extension._realHasOverview
});
}

panelManager = new PanelManager();
panelManager = new PanelManager.PanelManager();

panelManager.enable();

Utils.removeKeybinding('open-application-menu');
Utils.addKeybinding(
'open-application-menu',
new Gio.Settings({ schema_id: WindowManager.SHELL_KEYBINDINGS_SCHEMA }),
() => {
if(Me.settings.get_boolean('show-appmenu'))
Main.wm._toggleAppMenu();
else
panelManager.primaryPanel.taskbar.popupFocusedAppSecondaryMenu();
},
Shell.ActionMode.NORMAL | Shell.ActionMode.POPUP
);
}

function disable(reset) {
panelManager.disable();
Me.settings.run_dispose();
Me.desktopSettings.run_dispose();

delete Me.settings;
panelManager = null;

Utils.removeKeybinding('open-application-menu');
Utils.addKeybinding(
'open-application-menu',
new Gio.Settings({ schema_id: WindowManager.SHELL_KEYBINDINGS_SCHEMA }),
Main.wm._toggleAppMenu.bind(Main.wm),
Shell.ActionMode.NORMAL | Shell.ActionMode.POPUP
);

if (!reset) {
extensionSystem.disconnect(extensionChangedHandler);
delete global.dashToPanel;

// Re-enable Ubuntu Dock if it was disabled by dash to panel
if (disabledUbuntuDock && Main.sessionMode.allowExtensions) {
(extensionSystem._callExtensionEnable || extensionSystem.enableExtension).call(extensionSystem, UBUNTU_DOCK_UUID);
}

AppIcons.resetRecentlyClickedApp();
}

Main.sessionMode.hasOverview = this._realHasOverview;
}
Loading

0 comments on commit 0f58b84

Please sign in to comment.