Skip to content

Commit

Permalink
smart-panel and DesktopCube: work together
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiux committed Dec 1, 2024
1 parent 24bd5ef commit 2886fac
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 76 deletions.
3 changes: 3 additions & 0 deletions DesktopCube@yare/files/DesktopCube@yare/5.4/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const Settings = imports.ui.settings;
const Util = imports.misc.util; // Needed for spawnCommandLine()
const SignalManager = imports.misc.signalManager;

const UUID = "DesktopCube@yare";

let enabled;
let settings;
let signalManager;
Expand Down Expand Up @@ -64,6 +66,7 @@ Cube.prototype = {
this.destroy_requested = false;
this.transitions = []; // An array of Meta.MotionDirection values for each face transiation that is queued up
this.firstRotate = true;
settings = new CubeSettings(UUID);
this.pullaway = (100-settings.pullawayPercent)/100/2;

if (faces === undefined)
Expand Down
45 changes: 23 additions & 22 deletions DesktopCube@yare/files/DesktopCube@yare/metadata.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
{
"cinnamon-version": [
"2.0",
"2.1",
"2.2",
"2.4",
"2.6",
"2.8",
"3.0",
"3.2",
"3.4",
"3.8",
"4.0",
"4.2",
"4.4",
"4.6",
"5.4"
],
"version": "2.0.0",
"uuid": "DesktopCube@yare",
"name": "Desktop Cube",
"description": "Compiz Cube-like animation for workspace switching",
"url": "http://cinnamon-spices.linuxmint.com/"
"cinnamon-version": [
"2.0",
"2.1",
"2.2",
"2.4",
"2.6",
"2.8",
"3.0",
"3.2",
"3.4",
"3.8",
"4.0",
"4.2",
"4.4",
"4.6",
"5.4"
],
"version": "2.0.1",
"uuid": "DesktopCube@yare",
"name": "Desktop Cube",
"description": "Compiz Cube-like animation for workspace switching",
"url": "http://cinnamon-spices.linuxmint.com/extensions/view/68",
"author": "klangman"
}
88 changes: 55 additions & 33 deletions smart-panel@mohammad-sn/files/smart-panel@mohammad-sn/extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function SmartPanelExt(metadata, orientation, panel_height, instanceId) {

SmartPanelExt.prototype = {
_init: function(metadata, orientation, panel_height, instanceId) {

Settings.BindingDirection.BI = Settings.BindingDirection.BIDIRECTIONAL
this.settings = new Settings.ExtensionSettings(this, "smart-panel@mohammad-sn");
this.settings.bindProperty(Settings.BindingDirection.BI, "scroll-action" , "scrl_action", this._onScrollActionChanged, null);
Expand All @@ -66,7 +66,7 @@ SmartPanelExt.prototype = {
this.settings.bindProperty(Settings.BindingDirection.IN, "appswitcher-scope" , "switcher_scope", null, null);
this.settings.bindProperty(Settings.BindingDirection.IN, "scope-modified" , "switcher_modified", null, null);
this.settings.bindProperty(Settings.BindingDirection.IN, "appswitcher-modifier", "switcher_modifier", null, null);

this.cwm_settings = new Gio.Settings({ schema: "org.cinnamon.desktop.wm.preferences" });

// schema location has changed around 5.4, do a try catch for maximum compatibility
Expand All @@ -78,21 +78,21 @@ SmartPanelExt.prototype = {
this.mos_settings = new Gio.Settings({ schema: "org.cinnamon.desktop.peripherals.mouse" });
}
}

this.muf_settings = new Gio.Settings({ schema: "org.cinnamon.muffin" });

//this._panel = Main.panel._centerBox;
this._panel = Main.panel.actor;

this._lastScroll = Date.now();
this.dblb = false;
this.dblb_T = this.mos_settings.get_int('double-click');
},

_onScrollActionChanged : function() {
if (this.scrl_action != "none") this.sep_acts = false;
},

_onScrollSettingsChanged : function() {
if (this.sep_acts == true ) this.scrl_action = "none";
},
Expand Down Expand Up @@ -120,7 +120,7 @@ SmartPanelExt.prototype = {
return;
},

_onLeave : function(actor, event) {
_onLeave : function(actor, event) {
if (this.checkEventSource(actor, event)) return Clutter.EVENT_PROPAGATE;
if (this.p && this.use_gestures) {
let v = Math.abs(global.get_pointer()[0] - this.ppos[0]) < 33;
Expand Down Expand Up @@ -162,7 +162,7 @@ SmartPanelExt.prototype = {
this.p = false;
return;
},

_onScroll : function(actor, event) {
if (this.checkEventSource(actor, event)) return Clutter.EVENT_PROPAGATE;
let currentTime = Date.now();
Expand Down Expand Up @@ -191,10 +191,10 @@ SmartPanelExt.prototype = {
if (this.scrl_action == 'adjust_opacity') {
let min_opacity = this.cwm_settings.get_int("min-window-opacity") * 255 / 100;
let m = 50;
m = global.window_group.opacity + m * scrollDirection;
m = global.window_group.get_opacity() + m * scrollDirection;
if (m < min_opacity) m = min_opacity;
if (m > 255) m = 255;
global.window_group.opacity = m;
global.window_group.set_opacity(m);
}
else if (this.scrl_action == 'desktop') {
if (Main.panel.bottomPosition) scrollDirection = -scrollDirection;
Expand All @@ -208,14 +208,35 @@ SmartPanelExt.prototype = {
let limit = this._lastScroll + this.scroll_delay;
if (this.no_fast_scroll && currentTime < limit && currentTime >= this._lastScroll) { }
else if (this.scrl_action == 'switch_workspace') {
if(ExtensionSystem.runningExtensions['Flipper@connerdev']){
if (ExtensionSystem.runningExtensions.indexOf('DesktopCube@yare') > -1 ) {
//~ global.log("DesktopCube@yare DETECTED!!!");
if (this.DesktopCube) {}
else {
//~ global.log("ExtensionSystem.extensions['DesktopCube@yare']['5.4']['extension']: "+Object.keys(ExtensionSystem.extensions['DesktopCube@yare']['5.4']['extension']));
this.DesktopCube = ExtensionSystem.extensions['DesktopCube@yare']['5.4']['extension'];
}
let binding = [];
binding.get_mask = function(){ return 0x0; };
if (scrollDirection == 1) binding.get_name = function(){ return 'switch-to-workspace-left'; };
else if (scrollDirection == -1) binding.get_name = function(){ return 'switch-to-workspace-right'; };
let cube = new this.DesktopCube.Cube(null, null, binding);
if (cube.isAnimating) {
cube.destroy_requested = true;
} else {
cube.destroy_requested = true;
cube.onDestroy();
}
}
else
if (ExtensionSystem.runningExtensions.indexOf('Flipper@connerdev') > -1) {
//~ global.log("Flipper@connerdev DETECTED!!!");
if (this.Flipper){}
else { this.Flipper = ExtensionSystem.extensions['Flipper@connerdev']['extension']; }
else { this.Flipper = ExtensionSystem.extensions['Flipper@connerdev']['5.4']['extension']; }
let binding = [];
binding.get_mask = function(){ return 0x0; };
if (scrollDirection == 1) binding.get_name = function(){ return 'switch-to-workspace-left'; };
else if (scrollDirection == -1) binding.get_name = function(){ return 'switch-to-workspace-right'; };
flipper = new this.Flipper.Flipper(null, null, null, binding);
let flipper = new this.Flipper.Flipper(null, null, binding);
if (flipper.is_animating) {
flipper.destroy_requested = true;
} else {
Expand All @@ -232,7 +253,7 @@ SmartPanelExt.prototype = {
if (this.muf_settings.get_boolean("workspace-cycle")){
first = last;
flast = 0;
}
}
if (reqWsInex < 0) reqWsInex = first;
else if (reqWsInex > last) reqWsInex = flast;
let reqWs = global.screen.get_workspace_by_index(reqWsInex);
Expand Down Expand Up @@ -266,14 +287,14 @@ SmartPanelExt.prototype = {
this._lastScroll = currentTime;
return;
},

checkEventSource : function(actor, event) {
let source = event.get_source();
let clr = (source != Main.panel._centerBox || source != Main.panel._leftBox || source != Main.panel._rightBox);
let not_ours = (source != actor && clr);
return not_ours;
},

Do : function(action) {
let activeWs = 0, reqWs = 0;
switch (action) {
Expand Down Expand Up @@ -321,7 +342,7 @@ SmartPanelExt.prototype = {
break;
case 'appswitcher' :
this.get_name = Lang.bind(this, function(){
if (eval(this.switcher_modifier) & global.get_pointer()[2]) return this.switcher_modified;
if (eval(this.switcher_modifier) & global.get_pointer()[2]) return this.switcher_modified;
else return this.switcher_scope;
});
this.get_mask = function(){ return 0xFFFF; }
Expand All @@ -342,12 +363,12 @@ SmartPanelExt.prototype = {
else {
new myClassicSwitcher(this);
}

break;
}
if (reqWs) { reqWs.activate(global.get_current_time()); this.showWorkspaceOSD(); }
},

showWorkspaceOSD : function() {
this._hideWorkspaceOSD();
if (
Expand All @@ -364,7 +385,8 @@ SmartPanelExt.prototype = {
this._workspace_osd.set_text(
Main.getWorkspaceName(current_workspace_index)
);
this._workspace_osd.set_opacity = 0;
//this._workspace_osd.set_opacity = 0;
this._workspace_osd.set_opacity(0);
Main.layoutManager.addChrome(this._workspace_osd, {
visibleInFullscreen: false,
affectsInputRegion: false,
Expand Down Expand Up @@ -431,14 +453,14 @@ function myClassicSwitcher() {

myClassicSwitcher.prototype = {
__proto__: ClassicSwitcher.ClassicSwitcher.prototype,

_init: function() {
AppSwitcher.AppSwitcher.prototype._init.apply(this, arguments);

this.actor = new Cinnamon.GenericContainer({ name: 'altTabPopup',
reactive: true,
visible: false });

this._thumbnailTimeoutId = 0;
this.thumbnailsVisible = false;
this._displayPreviewTimeoutId = 0;
Expand All @@ -447,7 +469,7 @@ myClassicSwitcher.prototype = {

if (!this._setupModal())
return;

let styleSettings = this._binding.switcher_style;
if (styleSettings == 'default') styleSettings = global.settings.get_string("alttab-switcher-style");
let features = styleSettings.split('+');
Expand All @@ -459,13 +481,13 @@ myClassicSwitcher.prototype = {

this._showThumbnails = this._thumbnailsEnabled && !this._iconsEnabled;
this._showArrows = this._thumbnailsEnabled && this._iconsEnabled;

this._updateList(0);

this.actor.connect('get-preferred-width', Lang.bind(this, this._getPreferredWidth));
this.actor.connect('get-preferred-height', Lang.bind(this, this._getPreferredHeight));
this.actor.connect('allocate', Lang.bind(this, this._allocate));

// Need to force an allocation so we can figure out whether we
// need to scroll when selecting
this.actor.opacity = 0;
Expand All @@ -479,7 +501,7 @@ myClassicSwitcher.prototype = {
this._activateSelected();
else {
this._disableHover();

this.actor.connect('key-press-event', Lang.bind(this, this._keyPressEvent));
this.actor.connect('key-release-event', Lang.bind(this, this._keyReleaseEvent));
this.actor.connect('scroll-event', Lang.bind(this, this._scrollEvent));
Expand All @@ -499,7 +521,7 @@ myClassicSwitcher.prototype = {
this._activateSelected();
return true;
},

owndestroy: function() {
this._activateSelected();
},
Expand All @@ -511,7 +533,7 @@ function myTimelineSwitcher() {

myTimelineSwitcher.prototype = {
__proto__: TimelineSwitcher.TimelineSwitcher.prototype,

_init: function() {
TimelineSwitcher.TimelineSwitcher.prototype._init.apply(this, arguments);
},
Expand All @@ -522,7 +544,7 @@ myTimelineSwitcher.prototype = {
this._activateSelected();
else {
this._disableHover();

this.actor.connect('key-press-event', Lang.bind(this, this._keyPressEvent));
this.actor.connect('key-release-event', Lang.bind(this, this._keyReleaseEvent));
this.actor.connect('scroll-event', Lang.bind(this, this._scrollEvent));
Expand All @@ -542,7 +564,7 @@ myTimelineSwitcher.prototype = {
this._activateSelected();
return true;
},

owndestroy: function() {
this._activateSelected();
},
Expand All @@ -555,7 +577,7 @@ function myCoverflowSwitcher() {

myCoverflowSwitcher.prototype = {
__proto__: CoverflowSwitcher.CoverflowSwitcher.prototype,

_init: function() {
CoverflowSwitcher.CoverflowSwitcher.prototype._init.apply(this, arguments);
},
Expand All @@ -566,7 +588,7 @@ myCoverflowSwitcher.prototype = {
this._activateSelected();
else {
this._disableHover();

this.actor.connect('key-press-event', Lang.bind(this, this._keyPressEvent));
this.actor.connect('key-release-event', Lang.bind(this, this._keyReleaseEvent));
this.actor.connect('scroll-event', Lang.bind(this, this._scrollEvent));
Expand All @@ -586,7 +608,7 @@ myCoverflowSwitcher.prototype = {
this._activateSelected();
return true;
},

owndestroy: function() {
this._activateSelected();
},
Expand Down
Loading

0 comments on commit 2886fac

Please sign in to comment.