Skip to content
This repository has been archived by the owner on Jun 19, 2023. It is now read-only.

Commit

Permalink
Add intellihide setting to reveal and hold panel
Browse files Browse the repository at this point in the history
  • Loading branch information
charlesg99 committed Oct 25, 2018
1 parent b67f8bf commit 5ad1893
Show file tree
Hide file tree
Showing 6 changed files with 118 additions and 14 deletions.
61 changes: 61 additions & 0 deletions Settings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -1813,6 +1813,66 @@
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow" id="listboxrow_intellihide_toggle">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<object class="GtkGrid" id="grid_intellihide_toggle">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">12</property>
<property name="margin_right">12</property>
<property name="margin_top">12</property>
<property name="margin_bottom">12</property>
<property name="column_spacing">32</property>
<child>
<object class="GtkEntry" id="intellihide_toggle_entry">
<property name="can_focus">True</property>
<property name="valign">center</property>
<property name="width_chars">12</property>
<property name="placeholder_text" translatable="yes">e.g. &lt;Super&gt;i</property>
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">0</property>
<property name="height">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="intellihide_toggle_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="hexpand">True</property>
<property name="label" translatable="yes">Keyboard shortcut to reveal and hold the panel</property>
<property name="xalign">0</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="intellihide_toggle_description">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Syntax: &lt;Shift&gt;, &lt;Ctrl&gt;, &lt;Alt&gt;, &lt;Super&gt;</property>
<property name="wrap">True</property>
<property name="max_width_chars">40</property>
<property name="xalign">0</property>
<style>
<class name="dim-label"/>
</style>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">1</property>
</packing>
</child>
</object>
</child>
</object>
</child>
<child>
<object class="GtkListBoxRow" id="listboxrow_intellihide_animation_time">
<property name="visible">True</property>
Expand Down Expand Up @@ -2781,6 +2841,7 @@
<property name="can_focus">True</property>
<property name="valign">center</property>
<property name="width_chars">12</property>
<property name="placeholder_text" translatable="yes">e.g. &lt;Super&gt;q</property>
</object>
<packing>
<property name="left_attach">1</property>
Expand Down
15 changes: 8 additions & 7 deletions intellihide.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,9 @@ var Intellihide = new Lang.Class({
},

disable: function(reset) {
this._proximityManager.removeWatch(this._proximityWatchId);
if (this._proximityWatchId) {
this._proximityManager.removeWatch(this._proximityWatchId);
}

this._setTrackPanel(reset, false);

Expand All @@ -116,6 +118,10 @@ var Intellihide = new Lang.Class({
this.disable();
},

toggle: function() {
this._currentlyHeld ? this.release() : this.revealAndHold()
},

revealAndHold: function() {
if (this._enabled) {
this._revealPanel();
Expand Down Expand Up @@ -310,13 +316,8 @@ var Intellihide = new Lang.Class({
return false;
},

_adjustDynamicTransparency: function() {
if (this._dtpPanel.panel.hasOwnProperty('_updateSolidStyle'))
this._invokeIfExists(this._dtpPanel.panel._updateSolidStyle);
},

_revealPanel: function(immediate) {
this._animatePanel(0, immediate, this._adjustDynamicTransparency);
this._animatePanel(0, immediate);
},

_hidePanel: function(immediate) {
Expand Down
26 changes: 26 additions & 0 deletions panelManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const Lang = imports.lang;
const St = imports.gi.St;
const Meta = imports.gi.Meta;
const Layout = imports.ui.layout;
const Shell = imports.gi.Shell;
const WorkspacesView = imports.ui.workspacesView;

var dtpPanelManager = new Lang.Class({
Expand Down Expand Up @@ -133,6 +134,11 @@ var dtpPanelManager = new Lang.Class({
],
() => this._reset()
],
[
this._dtpSettings,
'changed::intellihide-key-toggle-text',
() => this._setKeyBindings(true)
],
[
Utils.DisplayWrapper.getMonitorManager(),
'monitors-changed',
Expand All @@ -143,6 +149,8 @@ var dtpPanelManager = new Lang.Class({
['_leftBox', '_centerBox', '_rightBox'].forEach(c => this._signalsHandler.add(
[Main.panel[c], 'actor-added', (parent, child) => this._adjustBoxPointer(this._getPanelButtonBoxPointer(child), this.primaryPanel.monitor, Taskbar.getPosition())]
));

this._setKeyBindings(true);
},

disable: function(reset) {
Expand All @@ -162,6 +170,8 @@ var dtpPanelManager = new Lang.Class({

if (reset) return;

this._setKeyBindings(false);

this._signalsHandler.destroy();

Main.layoutManager._updateHotCorners = this._oldUpdateHotCorners;
Expand Down Expand Up @@ -249,6 +259,22 @@ var dtpPanelManager = new Lang.Class({
}
},

_setKeyBindings: function(enable) {
let keys = {
'intellihide-key-toggle': () => this.allPanels.forEach(p => p.intellihide.toggle())
};

Object.keys(keys).forEach(k => {
if (Main.wm._allowedKeybindings[k]) {
Main.wm.removeKeybinding(k);
}

if (enable) {
Main.wm.addKeybinding(k, this._dtpSettings, Meta.KeyBindingFlags.NONE, Shell.ActionMode.NORMAL, keys[k]);
}
});
},

_newOverviewRelayout: function() {
// To avoid updating the position and size of the workspaces
// we just hide the overview. The positions will be updated
Expand Down
18 changes: 13 additions & 5 deletions prefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ function cssHexString(css) {
return rrggbb;
}

function setShortcut(settings) {
let shortcut_text = settings.get_string('shortcut-text');
function setShortcut(settings, shortcutName) {
let shortcut_text = settings.get_string(shortcutName + '-text');
let [key, mods] = Gtk.accelerator_parse(shortcut_text);

if (Gtk.accelerator_valid(key, mods)) {
let shortcut = Gtk.accelerator_name(key, mods);
settings.set_strv('shortcut', [shortcut]);
settings.set_strv(shortcutName, [shortcut]);
}
else {
settings.set_strv('shortcut', []);
settings.set_strv(shortcutName, []);
}
}

Expand Down Expand Up @@ -693,6 +693,12 @@ const Settings = new Lang.Class({
this._settings.set_int('intellihide-pressure-time', widget.get_value());
}));

this._settings.bind('intellihide-key-toggle-text',
this._builder.get_object('intellihide_toggle_entry'),
'text',
Gio.SettingsBindFlags.DEFAULT);
this._settings.connect('changed::intellihide-key-toggle-text', () => setShortcut(this._settings, 'intellihide-key-toggle'));

this._builder.get_object('intellihide_animation_time_spinbutton').set_value(this._settings.get_int('intellihide-animation-time'));
this._builder.get_object('intellihide_animation_time_spinbutton').connect('value-changed', Lang.bind (this, function(widget) {
this._settings.set_int('intellihide-animation-time', widget.get_value());
Expand Down Expand Up @@ -730,6 +736,8 @@ const Settings = new Lang.Class({
this._settings.set_value('intellihide-pressure-time', this._settings.get_default_value('intellihide-pressure-time'));
this._builder.get_object('intellihide_pressure_time_spinbutton').set_value(this._settings.get_int('intellihide-pressure-time'));

this._settings.set_value('intellihide-key-toggle-text', this._settings.get_default_value('intellihide-key-toggle-text'));

this._settings.set_value('intellihide-animation-time', this._settings.get_default_value('intellihide-animation-time'));
this._builder.get_object('intellihide_animation_time_spinbutton').set_value(this._settings.get_int('intellihide-animation-time'));

Expand Down Expand Up @@ -1232,7 +1240,7 @@ const Settings = new Lang.Class({
this._builder.get_object('shortcut_entry'),
'text',
Gio.SettingsBindFlags.DEFAULT);
this._settings.connect('changed::shortcut-text', Lang.bind(this, function() {setShortcut(this._settings);}));
this._settings.connect('changed::shortcut-text', Lang.bind(this, function() {setShortcut(this._settings, 'shortcut');}));

dialog.connect('response', Lang.bind(this, function(dialog, id) {
if (id == 1) {
Expand Down
2 changes: 0 additions & 2 deletions proximity.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,8 +194,6 @@ var ProximityManager = new Lang.Class({

_checkIfHandledWindow: function(metaWindow) {
return metaWindow && !metaWindow.minimized &&
// metaWindow.get_workspace().index() == Utils.DisplayWrapper.getWorkspaceManager().get_active_workspace_index() &&
// metaWindow.get_monitor() == this._monitor.index &&
this._checkIfHandledWindowType(metaWindow);
},

Expand Down
10 changes: 10 additions & 0 deletions schemas/org.gnome.shell.extensions.dash-to-panel.gschema.xml
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,16 @@
<summary>Intellihide close delay</summary>
<description>The delay (ms) before hiding the panel</description>
</key>
<key type="s" name="intellihide-key-toggle-text">
<default>"&lt;Super&gt;i"</default>
<summary>Keybinding toggle intellihide</summary>
<description>Keybinding to reveal the panel while in intellihide mode</description>
</key>
<key type="as" name="intellihide-key-toggle">
<default><![CDATA[['<Super>i']]]></default>
<summary>Keybinding toggle intellihide</summary>
<description>Keybinding to reveal the panel while in intellihide mode</description>
</key>
<key type="b" name="show-show-apps-button">
<default>true</default>
<summary>Show applications button</summary>
Expand Down

0 comments on commit 5ad1893

Please sign in to comment.