Skip to content

Commit

Permalink
Improve Expo workspace name editing.
Browse files Browse the repository at this point in the history
  • Loading branch information
autarkper committed Jul 18, 2012
1 parent c6ff643 commit a3a9ef0
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions js/ui/expoThumbnail.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,18 @@ ExpoWorkspaceThumbnail.prototype = {
this.title._spacing = 0;
this.titleText = this.title.clutter_text;
this.titleText.connect('key-press-event', Lang.bind(this, this._onTitleKeyPressEvent));
this.titleText.connect('key-focus-in', Lang.bind(this, function() {
this._origTitle = Main.getWorkspaceName(this.metaWorkspace.index());
}));
this.titleText.connect('key-focus-out', Lang.bind(this, function() {
if (!this._undoTitleEdit) {
let newName = this.title.get_text().trim();
Main.setWorkspaceName(this.metaWorkspace.index(), newName);
}
this.title.set_text(Main.getWorkspaceName(this.metaWorkspace.index()));
}));

let workspace_index = this.metaWorkspace.index();
if (workspace_index < Main.workspace_names.length) {
this.title.set_text(Main.workspace_names[workspace_index]);
}
this.title.set_text(Main.getWorkspaceName(this.metaWorkspace.index()));

this._background = Meta.BackgroundActor.new_for_screen(global.screen);
this._contents.add_actor(this._background);
Expand Down Expand Up @@ -272,13 +279,12 @@ ExpoWorkspaceThumbnail.prototype = {
},

_onTitleKeyPressEvent: function(actor, event) {

if (this.metaWorkspace.index() < Main.workspace_names.length && this.title.get_text() != Main.workspace_names[this.metaWorkspace.index()]) {
Main.workspace_names[this.metaWorkspace.index()] = this.title.get_text();
}

this._undoTitleEdit = false;
let symbol = event.get_key_symbol();
if (symbol === Clutter.Return || symbol === Clutter.Escape) {
if (symbol === Clutter.Escape) {
this._undoTitleEdit = true;
}
global.stage.set_key_focus(this.actor);
return true;
}
Expand Down

0 comments on commit a3a9ef0

Please sign in to comment.