Skip to content

Commit

Permalink
Merge pull request linuxmint#590 from Dreckr/master
Browse files Browse the repository at this point in the history
Close window area in expo
  • Loading branch information
clefebvre committed Apr 2, 2012
2 parents e9bd51b + 09dcbb6 commit 59dd612
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 3 deletions.
11 changes: 11 additions & 0 deletions data/theme/cinnamon.css
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,17 @@ StTooltip StLabel {
.window-close:rtl {
-st-background-image-shadow: 2px 2px 6px rgba(0,0,0,0.5);
}

.window-close-area {
background-image: url("trash-icon.png");
background-color: rgba(60, 60, 60, 0.8);
border: 4px solid rgba(128,128,128,0.8);
border-bottom-width: 0px;
border-radius: 20px 20px 0px 0px;
height: 120px;
width: 400px;
}

.icon-grid {
spacing: 36px;
-cinnamon-grid-item-size: 118px;
Expand Down
Binary file added data/theme/trash-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
52 changes: 51 additions & 1 deletion js/ui/expo.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const St = imports.gi.St;
const Cinnamon = imports.gi.Cinnamon;
const Gdk = imports.gi.Gdk;

const DND = imports.ui.dnd;
const Main = imports.ui.main;
const MessageTray = imports.ui.messageTray;
const Params = imports.misc.params;
Expand Down Expand Up @@ -118,7 +119,7 @@ Expo.prototype = {

this.visible = false; // animating to overview, in overview, animating out
this._shown = false; // show() and not hide()
this._shownTemporarily = false; // showTemporarily() and not hideTemporarily()
this._shownTemporarily = false; // showTemporarily() and not hilog("huasuhashusu");deTemporarily()
this._modal = false; // have a modal grab
this.animationInProgress = false;
this._hideInProgress = false;
Expand All @@ -139,12 +140,34 @@ Expo.prototype = {
this._group.add_actor(this._addWorkspaceButton);
this._addWorkspaceButton.connect('clicked', Lang.bind(this, function () { Main._addWorkspace();}));

this._windowCloseArea = new St.Button({style_class: 'window-close-area'});
this._windowCloseArea.handleDragOver = function(source, actor, x, y, time) {
return DND.DragMotionResult.MOVE_DROP;
};
this._windowCloseArea.acceptDrop = function(source, actor, x, y, time) {

if (source.realWindow) {
let win = source.realWindow;

let metaWindow = win.get_meta_window();

source._draggable._restoreOnSuccess = false;
metaWindow.delete(global.get_current_time());
return true;
}
return false;
};

this._windowCloseArea._delegate = this._windowCloseArea;
this._group.add_actor(this._windowCloseArea);

this._group.hide();
global.overlay_group.add_actor(this._group);

this._gradient.hide();
this._coverPane.hide();
this._addWorkspaceButton.hide();
this._windowCloseArea.hide();

this._windowSwitchTimeoutId = 0;
this._windowSwitchTimestamp = 0;
Expand Down Expand Up @@ -202,6 +225,8 @@ Expo.prototype = {
this._group.set_position(primary.x, primary.y);
this._group.set_size(primary.width, primary.height);

this._group.set_clip(primary.x, primary.y, primary.width, primary.height);

this._gradient.set_position(0, 0);
this._gradient.set_size(primary.width, primary.height);

Expand All @@ -217,6 +242,10 @@ Expo.prototype = {
let buttonWidth = node.get_length('width');
let buttonHeight = node.get_length('height');

node = this._windowCloseArea.get_theme_node();
this._windowCloseArea.height = node.get_length('height');
this._windowCloseArea.width = node.get_length('width');

this._expo.actor.set_position(0, 0);
this._expo.actor.set_size((primary.width - buttonWidth), primary.height);

Expand All @@ -226,6 +255,26 @@ Expo.prototype = {
this._addWorkspaceButton.set_size(buttonWidth, buttonHeight);
if (this._addWorkspaceButton.get_theme_node().get_background_image() == null)
this._addWorkspaceButton.set_style('background-image: url("/usr/share/cinnamon/theme/add-workspace.png");');

this._windowCloseArea.set_position((primary.width - this._windowCloseArea.width) / 2 , primary.height);
this._windowCloseArea.set_size(this._windowCloseArea.width, this._windowCloseArea.height);
this._windowCloseArea.raise_top();
},

showCloseArea : function() {
let primary = Main.layoutManager.primaryMonitor;
this._windowCloseArea.show();
Tweener.addTween(this._windowCloseArea, { y: primary.height - this._windowCloseArea.height,
time: ANIMATION_TIME,
transition: 'easeOutQuad'});
},

hideCloseArea : function() {
let primary = Main.layoutManager.primaryMonitor;
Tweener.addTween(this._windowCloseArea, { y: primary.height,
time: ANIMATION_TIME,
transition: 'easeOutQuad',
onComplete: this.hide});
},

//// Public methods ////
Expand Down Expand Up @@ -510,6 +559,7 @@ Expo.prototype = {

this._expo.hide();
this._addWorkspaceButton.hide();
this._windowCloseArea.hide();

this._background.hide();
this._group.hide();
Expand Down
8 changes: 6 additions & 2 deletions js/ui/expoThumbnail.js
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,13 @@ ExpoWindowClone.prototype = {
},

_onDragBegin : function (draggable, time) {
Main.expo.showCloseArea();
this.inDrag = true;
this.emit('drag-begin');
},

_onDragEnd : function (draggable, time, snapback) {
Main.expo.hideCloseArea();
this.inDrag = false;
// We may not have a parent if DnD completed successfully, in
// which case our clone will shortly be destroyed and replaced
Expand Down Expand Up @@ -201,6 +203,7 @@ ExpoWorkspaceThumbnail.prototype = {
let windows = global.get_window_actors().filter(this._isMyWindow, this);

// Create clones for windows that should be visible in the Expo
this.count = 0;
this._windows = [];
this._uninterestingWindows = new Clutter.Group();
this._uninterestingWindows.hide();
Expand Down Expand Up @@ -392,6 +395,7 @@ ExpoWorkspaceThumbnail.prototype = {
metaWin.disconnect(metaWin._minimizedChangedId);
delete metaWin._minimizedChangedId;
}
this._windows[i].destroy();
}

this._windows = [];
Expand Down Expand Up @@ -461,7 +465,7 @@ ExpoWorkspaceThumbnail.prototype = {

_addUninterestingWindowClone : function(win) {
let clone = new ExpoWindowClone(win);
this._uninterestingWindows.add_actor(clone.actor)
this._uninterestingWindows.add_actor(clone.actor);
return clone;
},

Expand Down Expand Up @@ -748,7 +752,7 @@ ExpoThumbnailsBox.prototype = {
thumbnail.connect('remove-event', Lang.bind(this, function () { this.button.hide(); if (thumbnail.metaWorkspace != global.screen.get_active_workspace()) thumbnail._shade(); thumbnail.hovered = false; thumbnail._overviewModeOff();}));

Main.expo.connect('hiding', Lang.bind(this, function() { this.button.hide();}));

if (start > 0) { // not the initial fill
thumbnail.state = ThumbnailState.NEW;
thumbnail.slidePosition = 1; // start slid out
Expand Down

0 comments on commit 59dd612

Please sign in to comment.