Files
dash-to-panel/extension.js
Philipp a4224f4acc Update to Gnome 40 (#1303)
* 1

* renamed ui.viewSelector to ui.searchController

* add arrowIcon null check

* add object null check

* add _showAppsButton null check

* fixed _workspacesDisplay

* removed shadow-type properties

* removed packing from ui

* renamed margin_left/right to margin_start/end

* renamed GtkRadioButton to GtkToggleButton, removed draw_indicator and image_position

* removed xalign from buttons, stock -> icon_name, GtkFileChooserButton -> BtkButton (todo connect a GtkFileChooserNative), removed format-value (todo connect GtkScaleFormatValueFunc callback)

* removed events, relief

* comment arrowIcon.set_icon_name and _hbox.get_last_child out

* called gtk4-builder-tool simplify --3to4 on Settings.ui

* fix _workspaceDisplay

* revert Settings.ui back to old gtk3 version

* removed _builder.connect_signals_full and added a BuilderScope instead, use class specific add functions, removed show_all for widgets, updated margins* for GtkGrid

* add try catch aroung object.connect

* fixed _searchEntry path

* disabled _newUpdateWorkspacesViews temporarily, because it is very buggy right now

* fixed _searchEntry path (this time for real?)

* dialog.show_all() -> dialog.show(), widget.get_toplevel() -> widget.get_root(), fixed adjustScrollableHeight (no longer crashes, still does not work correctly)

* updated GtkGrid.attach calls

* added Gtk.FileChooserNative for show_applications_icon_file_filebutton

* added packing again to ui (commented) and also added layout row/column/width/height in exchange for top_attach/left_attach/colspan/rowspan

* renamed colspan/rowspan to column-span/row-span

* removed all packaing left_attach/top_attach

* updated adjustScrollableHeight so the dialog will have a reasonable size again

* limit shell-version to 40 since it is not backwards compatible right now

* called _updateBackgrounds in layoutManager ,fixed overview <-> _overview typo?

* pass Settings instead of Settings._settings to BuilderScope

* workaround for showAppsIcon (_showAppsButton seems to be no longer be available)

* replaced newlines in the ui file with the newline unicode symbol, so code block collapsing works peroperly

* moved the scrolled window directly into each notebook tab, so the tab headers are always visible

* fixed taskbarListBox children loops

* commented non working elements out (panel on left/right, import/export settings, update)

* renamed Settings to Preferences to avoid confusion with dconf settings object

* updated this.widget to this.notebook

* fixed dialogs size and expand

* fixed window preview options having too many columns

* removed all packing with expand/fill/position (already uncommented)

* removed menu arrows since they are no longer recommended for gnome40

* removed adjustScrollableHeight, default sizes are acceptable

* updated ui required version to gtk 4.0

* updated path to dash.showAppsButton

* fixes for showAppsButton

* fixed clickToExit

* fixed import/export settings

* added disable show overview on startup option

* removed old show apps animation

* fixed panel on left/right side

* fixed scroll on volume icon

no longer will scrolling on the volume icon switch workspaces as well

* commented some setFocusedMonitor support out, caused issues on Xorg

* removed oldDash

* updated hide overview on startup, no longer closes overview after suspend etc

* removed _newOverviewRelayout

* removed _newUpdateWorkspacesViews

* commented setFocusedMonitor out completly, because show overview on non primary monitor does not work properly for now

* fixed typo

* fixed merging error

* check if func is valid in hookVfunc

* updated ui to gtk4, fixed merging error

* fixed layout for apply changes to all monitors

* fix behaviour tab and app icon margin/padding grid

* fix animate launching new windows grid row

* fixed about tab

Co-authored-by: Cole Gerdemann <corvettecole@gmail.com>
2021-05-08 09:07:25 -04:00

147 lines
5.1 KiB
JavaScript

/*
* Dash-To-Panel extension for Gnome 3
* Copyright 2016 Jason DeRose (jderose9) and Charles Gagnon (charlesg99)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
const Main = imports.ui.main;
const Meta = imports.gi.Meta;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Lang = imports.lang;
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 Convenience = Me.imports.convenience;
const PanelManager = Me.imports.panelManager;
const Utils = Me.imports.utils;
const UBUNTU_DOCK_UUID = 'ubuntu-dock@ubuntu.com';
let panelManager;
let extensionChangedHandler;
let disabledUbuntuDock;
let extensionSystem = (Main.extensionManager || imports.ui.extensionSystem);
function init() {
this._realHasOverview = Main.sessionMode.hasOverview;
Convenience.initTranslations(Utils.TRANSLATION_DOMAIN);
//create an object that persists until gnome-shell is restarted, even if the extension is disabled
Me.persistentStorage = {};
}
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();
}
});
//create a global object that can emit signals and conveniently expose functionalities to other extensions
global.dashToPanel = {};
Signals.addSignalMethods(global.dashToPanel);
_enable();
}
function _enable() {
let ubuntuDock = Main.extensionManager ?
Main.extensionManager.lookup(UBUNTU_DOCK_UUID) : //gnome-shell >= 3.33.4
ExtensionUtils.extensions[UBUNTU_DOCK_UUID];
if (ubuntuDock && ubuntuDock.stateObj && ubuntuDock.stateObj.dockManager) {
// Disable Ubuntu Dock
let extensionOrder = (extensionSystem.extensionOrder || extensionSystem._extensionOrder);
Utils.getStageTheme().get_theme().unload_stylesheet(ubuntuDock.stylesheet);
ubuntuDock.stateObj.disable();
disabledUbuntuDock = true;
ubuntuDock.state = 2; //ExtensionState.DISABLED
extensionOrder.splice(extensionOrder.indexOf(UBUNTU_DOCK_UUID), 1);
//reset to prevent conflicts with the ubuntu-dock
if (panelManager) {
disable(true);
}
}
if (panelManager) return; //already initialized
Me.settings = Convenience.getSettings('org.gnome.shell.extensions.dash-to-panel');
Me.desktopSettings = Convenience.getSettings('org.gnome.desktop.interface');
if (Me.settings.get_boolean('hide-overview-on-startup') && Main.layoutManager._startingUp) {
Main.sessionMode.hasOverview = false;
Main.layoutManager.connect('startup-complete', () => {
Main.sessionMode.hasOverview = this._realHasOverview
});
}
panelManager = new PanelManager.dtpPanelManager();
panelManager.enable();
Utils.removeKeybinding('open-application-menu');
Utils.addKeybinding(
'open-application-menu',
new Gio.Settings({ schema_id: WindowManager.SHELL_KEYBINDINGS_SCHEMA }),
Lang.bind(this, function() {
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 }),
Lang.bind(Main.wm, Main.wm._toggleAppMenu),
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);
}
}
Main.sessionMode.hasOverview = this._realHasOverview;
}