[appDisplay] Unify Inactive/RunningWellItem, split into AppIcon, AppWellIcon
The distinction between the inactive and running was silly; just have one class which can handle both running states. However for a future search patch, we do want a separation between an icon which just has icon + name + glow, and a well icon which does the menu integration. https://bugzilla.gnome.org/show_bug.cgi?id=603523
This commit is contained in:
parent
14df7cd62c
commit
f5f92b2e79
@ -221,19 +221,20 @@ AppDisplay.prototype = {
|
|||||||
Signals.addSignalMethods(AppDisplay.prototype);
|
Signals.addSignalMethods(AppDisplay.prototype);
|
||||||
|
|
||||||
|
|
||||||
function BaseWellItem(app, isFavorite) {
|
function AppIcon(app) {
|
||||||
this._init(app, isFavorite);
|
this._init(app);
|
||||||
}
|
}
|
||||||
|
|
||||||
BaseWellItem.prototype = {
|
AppIcon.prototype = {
|
||||||
_init : function(app, isFavorite) {
|
_init : function(app) {
|
||||||
this.app = app;
|
this.app = app;
|
||||||
|
|
||||||
this._glowExtendVertical = 0;
|
this._glowExtendVertical = 0;
|
||||||
this._glowShrinkHorizontal = 0;
|
this._glowShrinkHorizontal = 0;
|
||||||
|
|
||||||
this.actor = new St.Clickable({ style_class: 'app-well-app',
|
this.actor = new St.Bin({ style_class: 'app-icon',
|
||||||
reactive: true });
|
x_fill: true,
|
||||||
|
y_fill: true });
|
||||||
this.actor._delegate = this;
|
this.actor._delegate = this;
|
||||||
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
|
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
|
||||||
this._workId = Main.initializeDeferredWork(this.actor, Lang.bind(this, this._rerenderGlow));
|
this._workId = Main.initializeDeferredWork(this.actor, Lang.bind(this, this._rerenderGlow));
|
||||||
@ -241,10 +242,6 @@ BaseWellItem.prototype = {
|
|||||||
let box = new St.BoxLayout({ vertical: true });
|
let box = new St.BoxLayout({ vertical: true });
|
||||||
this.actor.set_child(box);
|
this.actor.set_child(box);
|
||||||
|
|
||||||
this.actor.connect('clicked', Lang.bind(this, this._onClicked));
|
|
||||||
|
|
||||||
this._menu = null;
|
|
||||||
|
|
||||||
this.icon = this.app.create_icon_texture(APPICON_SIZE);
|
this.icon = this.app.create_icon_texture(APPICON_SIZE);
|
||||||
|
|
||||||
box.add(this.icon, { expand: true, x_fill: false, y_fill: false });
|
box.add(this.icon, { expand: true, x_fill: false, y_fill: false });
|
||||||
@ -265,13 +262,6 @@ BaseWellItem.prototype = {
|
|||||||
this._appWindowChangedId = this.app.connect('windows-changed', Lang.bind(this, this._queueRerenderGlow));
|
this._appWindowChangedId = this.app.connect('windows-changed', Lang.bind(this, this._queueRerenderGlow));
|
||||||
|
|
||||||
box.add(nameBox);
|
box.add(nameBox);
|
||||||
|
|
||||||
this._draggable = DND.makeDraggable(this.actor, true);
|
|
||||||
this._dragStartX = null;
|
|
||||||
this._dragStartY = null;
|
|
||||||
|
|
||||||
this.actor.connect('button-press-event', Lang.bind(this, this._onButtonPress));
|
|
||||||
this.actor.connect('notify::hover', Lang.bind(this, this._onHoverChange));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_nameBoxGetPreferredWidth: function (nameBox, forHeight, alloc) {
|
_nameBoxGetPreferredWidth: function (nameBox, forHeight, alloc) {
|
||||||
@ -322,6 +312,19 @@ BaseWellItem.prototype = {
|
|||||||
Main.queueDeferredWork(this._workId);
|
Main.queueDeferredWork(this._workId);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_onStyleChanged: function() {
|
||||||
|
let themeNode = this._glowBox.get_theme_node();
|
||||||
|
|
||||||
|
let success, len;
|
||||||
|
[success, len] = themeNode.get_length('-shell-glow-extend-vertical', false);
|
||||||
|
if (success)
|
||||||
|
this._glowExtendVertical = len;
|
||||||
|
[success, len] = themeNode.get_length('-shell-glow-shrink-horizontal', false);
|
||||||
|
if (success)
|
||||||
|
this._glowShrinkHorizontal = len;
|
||||||
|
this.actor.queue_relayout();
|
||||||
|
},
|
||||||
|
|
||||||
_rerenderGlow: function() {
|
_rerenderGlow: function() {
|
||||||
this._glowBox.destroy_children();
|
this._glowBox.destroy_children();
|
||||||
let glowPath = GLib.filename_to_uri(global.imagedir + 'app-well-glow.png', '');
|
let glowPath = GLib.filename_to_uri(global.imagedir + 'app-well-glow.png', '');
|
||||||
@ -332,6 +335,34 @@ BaseWellItem.prototype = {
|
|||||||
glow.keep_aspect_ratio = false;
|
glow.keep_aspect_ratio = false;
|
||||||
this._glowBox.add(glow);
|
this._glowBox.add(glow);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function AppWellIcon(app) {
|
||||||
|
this._init(app);
|
||||||
|
}
|
||||||
|
|
||||||
|
AppWellIcon.prototype = {
|
||||||
|
_init : function(app) {
|
||||||
|
this.app = app;
|
||||||
|
this.actor = new St.Clickable({ style_class: 'app-well-app',
|
||||||
|
reactive: true,
|
||||||
|
x_fill: true,
|
||||||
|
y_fill: true });
|
||||||
|
this.actor._delegate = this;
|
||||||
|
|
||||||
|
this._icon = new AppIcon(app);
|
||||||
|
this.actor.set_child(this._icon.actor);
|
||||||
|
|
||||||
|
this.actor.connect('clicked', Lang.bind(this, this._onClicked));
|
||||||
|
this._menu = null;
|
||||||
|
|
||||||
|
this._draggable = DND.makeDraggable(this.actor, true);
|
||||||
|
this._dragStartX = null;
|
||||||
|
this._dragStartY = null;
|
||||||
|
|
||||||
|
this.actor.connect('button-press-event', Lang.bind(this, this._onButtonPress));
|
||||||
|
this.actor.connect('notify::hover', Lang.bind(this, this._onHoverChange));
|
||||||
},
|
},
|
||||||
|
|
||||||
_onButtonPress: function(actor, event) {
|
_onButtonPress: function(actor, event) {
|
||||||
@ -366,19 +397,6 @@ BaseWellItem.prototype = {
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
_onStyleChanged: function() {
|
|
||||||
let themeNode = this._glowBox.get_theme_node();
|
|
||||||
|
|
||||||
let success, len;
|
|
||||||
[success, len] = themeNode.get_length('-shell-glow-extend-vertical', false);
|
|
||||||
if (success)
|
|
||||||
this._glowExtendVertical = len;
|
|
||||||
[success, len] = themeNode.get_length('-shell-glow-shrink-horizontal', false);
|
|
||||||
if (success)
|
|
||||||
this._glowShrinkHorizontal = len;
|
|
||||||
this.actor.queue_relayout();
|
|
||||||
},
|
|
||||||
|
|
||||||
popupMenu: function(activatingButton) {
|
popupMenu: function(activatingButton) {
|
||||||
if (!this._menu) {
|
if (!this._menu) {
|
||||||
this._menu = new AppIconMenu(this);
|
this._menu = new AppIconMenu(this);
|
||||||
@ -402,13 +420,60 @@ BaseWellItem.prototype = {
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
// Default implementations; AppDisplay.RunningWellItem overrides these
|
activateMostRecentWindow: function () {
|
||||||
highlightWindow: function(window) {
|
let mostRecentWindow = this.app.get_windows()[0];
|
||||||
this.emit('highlight-window', window);
|
Main.overview.activateWindow(mostRecentWindow, Main.currentTime());
|
||||||
},
|
},
|
||||||
|
|
||||||
activateWindow: function(window) {
|
highlightWindow: function(metaWindow) {
|
||||||
this.emit('activate-window', window);
|
if (!this._getRunning())
|
||||||
|
return;
|
||||||
|
Main.overview.getWorkspacesForWindow(metaWindow).setHighlightWindow(metaWindow);
|
||||||
|
},
|
||||||
|
|
||||||
|
activateWindow: function(metaWindow) {
|
||||||
|
if (metaWindow) {
|
||||||
|
this._didActivateWindow = true;
|
||||||
|
Main.overview.activateWindow(metaWindow, Main.currentTime());
|
||||||
|
} else
|
||||||
|
Main.overview.hide();
|
||||||
|
},
|
||||||
|
|
||||||
|
_onMenuPoppedUp: function() {
|
||||||
|
if (this._getRunning()) {
|
||||||
|
Main.overview.getWorkspacesForWindow(null).setApplicationWindowSelection(this.app.get_id());
|
||||||
|
this._setWindowSelection = true;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
_onMenuPoppedDown: function() {
|
||||||
|
if (this._didActivateWindow)
|
||||||
|
return;
|
||||||
|
if (!this._setWindowSelection)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Main.overview.getWorkspacesForWindow(null).setApplicationWindowSelection(null);
|
||||||
|
this._setWindowSelection = false;
|
||||||
|
},
|
||||||
|
|
||||||
|
_getRunning: function() {
|
||||||
|
return this.app.get_windows().length > 0;
|
||||||
|
},
|
||||||
|
|
||||||
|
_onActivate: function (event) {
|
||||||
|
let running = this._getRunning();
|
||||||
|
|
||||||
|
if (!running) {
|
||||||
|
this.app.launch();
|
||||||
|
} else {
|
||||||
|
let modifiers = Shell.get_event_state(event);
|
||||||
|
|
||||||
|
if (modifiers & Clutter.ModifierType.CONTROL_MASK) {
|
||||||
|
this.app.launch();
|
||||||
|
} else {
|
||||||
|
this.activateMostRecentWindow();
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
shellWorkspaceLaunch : function() {
|
shellWorkspaceLaunch : function() {
|
||||||
@ -433,7 +498,7 @@ BaseWellItem.prototype = {
|
|||||||
return this.actor;
|
return this.actor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Signals.addSignalMethods(BaseWellItem.prototype);
|
Signals.addSignalMethods(AppWellIcon.prototype);
|
||||||
|
|
||||||
function AppIconMenu(source) {
|
function AppIconMenu(source) {
|
||||||
this._init(source);
|
this._init(source);
|
||||||
@ -733,80 +798,6 @@ AppIconMenu.prototype = {
|
|||||||
};
|
};
|
||||||
Signals.addSignalMethods(AppIconMenu.prototype);
|
Signals.addSignalMethods(AppIconMenu.prototype);
|
||||||
|
|
||||||
function RunningWellItem(app, isFavorite) {
|
|
||||||
this._init(app, isFavorite);
|
|
||||||
}
|
|
||||||
|
|
||||||
RunningWellItem.prototype = {
|
|
||||||
__proto__: BaseWellItem.prototype,
|
|
||||||
|
|
||||||
_init: function(app, isFavorite) {
|
|
||||||
BaseWellItem.prototype._init.call(this, app, isFavorite);
|
|
||||||
},
|
|
||||||
|
|
||||||
_onActivate: function (event) {
|
|
||||||
let modifiers = Shell.get_event_state(event);
|
|
||||||
|
|
||||||
if (modifiers & Clutter.ModifierType.CONTROL_MASK) {
|
|
||||||
this.app.launch();
|
|
||||||
} else {
|
|
||||||
this.activateMostRecentWindow();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
activateMostRecentWindow: function () {
|
|
||||||
let mostRecentWindow = this.app.get_windows()[0];
|
|
||||||
Main.overview.activateWindow(mostRecentWindow, global.get_current_time());
|
|
||||||
},
|
|
||||||
|
|
||||||
highlightWindow: function(metaWindow) {
|
|
||||||
Main.overview.getWorkspacesForWindow(metaWindow).setHighlightWindow(metaWindow);
|
|
||||||
},
|
|
||||||
|
|
||||||
activateWindow: function(metaWindow) {
|
|
||||||
if (metaWindow) {
|
|
||||||
this._didActivateWindow = true;
|
|
||||||
Main.overview.activateWindow(metaWindow, global.get_current_time());
|
|
||||||
} else
|
|
||||||
Main.overview.hide();
|
|
||||||
},
|
|
||||||
|
|
||||||
_onMenuPoppedUp: function() {
|
|
||||||
Main.overview.getWorkspacesForWindow(null).setApplicationWindowSelection(this.app.get_id());
|
|
||||||
},
|
|
||||||
|
|
||||||
_onMenuPoppedDown: function() {
|
|
||||||
if (this._didActivateWindow)
|
|
||||||
return;
|
|
||||||
|
|
||||||
Main.overview.getWorkspacesForWindow(null).setApplicationWindowSelection(null);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
function InactiveWellItem(app, isFavorite) {
|
|
||||||
this._init(app, isFavorite);
|
|
||||||
}
|
|
||||||
|
|
||||||
InactiveWellItem.prototype = {
|
|
||||||
__proto__: BaseWellItem.prototype,
|
|
||||||
|
|
||||||
_init : function(app, isFavorite) {
|
|
||||||
BaseWellItem.prototype._init.call(this, app, isFavorite);
|
|
||||||
},
|
|
||||||
|
|
||||||
_onActivate: function(event) {
|
|
||||||
this.app.launch();
|
|
||||||
Main.overview.hide();
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
|
|
||||||
_onMenuPoppedUp: function() {
|
|
||||||
},
|
|
||||||
|
|
||||||
_onMenuPoppedDown: function() {
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
function WellGrid() {
|
function WellGrid() {
|
||||||
this._init();
|
this._init();
|
||||||
}
|
}
|
||||||
@ -986,12 +977,7 @@ AppWell.prototype = {
|
|||||||
let nFavorites = 0;
|
let nFavorites = 0;
|
||||||
for (let id in favorites) {
|
for (let id in favorites) {
|
||||||
let app = favorites[id];
|
let app = favorites[id];
|
||||||
let display;
|
let display = new AppWellIcon(app);
|
||||||
if (app.get_windows().length > 0) {
|
|
||||||
display = new RunningWellItem(app, true);
|
|
||||||
} else {
|
|
||||||
display = new InactiveWellItem(app, true);
|
|
||||||
}
|
|
||||||
this._grid.addItem(display.actor);
|
this._grid.addItem(display.actor);
|
||||||
nFavorites++;
|
nFavorites++;
|
||||||
}
|
}
|
||||||
@ -1000,7 +986,7 @@ AppWell.prototype = {
|
|||||||
let app = running[i];
|
let app = running[i];
|
||||||
if (app.get_id() in favorites)
|
if (app.get_id() in favorites)
|
||||||
continue;
|
continue;
|
||||||
let display = new RunningWellItem(app, false);
|
let display = new AppWellIcon(app);
|
||||||
this._grid.addItem(display.actor);
|
this._grid.addItem(display.actor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -248,7 +248,7 @@ Overview.prototype = {
|
|||||||
// This allows the user to place the item on any workspace.
|
// This allows the user to place the item on any workspace.
|
||||||
handleDragOver : function(source, actor, x, y, time) {
|
handleDragOver : function(source, actor, x, y, time) {
|
||||||
if (source instanceof GenericDisplay.GenericDisplayItem
|
if (source instanceof GenericDisplay.GenericDisplayItem
|
||||||
|| source instanceof AppDisplay.BaseWellItem) {
|
|| source instanceof AppDisplay.AppIcon) {
|
||||||
if (this._activeDisplayPane != null)
|
if (this._activeDisplayPane != null)
|
||||||
this._activeDisplayPane.close();
|
this._activeDisplayPane.close();
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user