Bug 591246 - Move towards shell-black02 mockup

Remove the last use of passing width into Dash by having the
Pane with the previews scaling dynamically and relying on
Clutter scaling.

If we only have one workspace, don't display a selection frame
for it.

Rework Dash into a searchArea and sectionArea, which get
explicitly sized by overlay.js.  We use the workspaces size
to choose the size of those dash areas.

Switch dash colors/boxes etc. to ones from shell-black02.

Add a gradient to the panel.

Add a magnifier.svg for use in search.
This commit is contained in:
Colin Walters
2009-08-09 19:48:54 -04:00
parent 25a5da074c
commit f00500d3d5
10 changed files with 301 additions and 246 deletions

View File

@ -5,6 +5,7 @@ const Clutter = imports.gi.Clutter;
const Gio = imports.gi.Gio;
const Gtk = imports.gi.Gtk;
const Mainloop = imports.mainloop;
const Pango = imports.gi.Pango;
const Shell = imports.gi.Shell;
const Signals = imports.signals;
const Lang = imports.lang;
@ -18,14 +19,35 @@ const Main = imports.ui.main;
const DEFAULT_PADDING = 4;
const DASH_SECTION_PADDING = 6;
const DASH_SECTION_SPACING = 12;
const DASH_SECTION_SPACING = 40;
const DASH_CORNER_RADIUS = 5;
const DASH_SEARCH_BG_COLOR = new Clutter.Color();
DASH_SEARCH_BG_COLOR.from_pixel(0xffffffff);
const DASH_SECTION_COLOR = new Clutter.Color();
DASH_SECTION_COLOR.from_pixel(0x846c3dff);
const DASH_TEXT_COLOR = new Clutter.Color();
DASH_TEXT_COLOR.from_pixel(0xffffffff);
const BACKGROUND_COLOR = new Clutter.Color();
BACKGROUND_COLOR.from_pixel(0x000000c0);
const DASH_PADDING_SIDE = 14;
const SEARCH_BORDER_BOTTOM_COLOR = new Clutter.Color();
SEARCH_BORDER_BOTTOM_COLOR.from_pixel(0x191919ff);
const SECTION_BORDER_COLOR = new Clutter.Color();
SECTION_BORDER_COLOR.from_pixel(0x262626ff);
const SECTION_BORDER = 1;
const SECTION_INNER_BORDER_COLOR = new Clutter.Color();
SECTION_INNER_BORDER_COLOR.from_pixel(0x000000ff);
const SECTION_BACKGROUND_TOP_COLOR = new Clutter.Color();
SECTION_BACKGROUND_TOP_COLOR.from_pixel(0x161616ff);
const SECTION_BACKGROUND_BOTTOM_COLOR = new Clutter.Color();
SECTION_BACKGROUND_BOTTOM_COLOR.from_pixel(0x000000ff);
const SECTION_INNER_SPACING = 8;
const BROWSE_ACTIVATED_BG = new Clutter.Color();
BROWSE_ACTIVATED_BG.from_pixel(0x303030f0);
const TEXT_COLOR = new Clutter.Color();
TEXT_COLOR.from_pixel(0x5f5f5fff);
const BRIGHT_TEXT_COLOR = new Clutter.Color();
BRIGHT_TEXT_COLOR.from_pixel(0xffffffff);
const PANE_BORDER_COLOR = new Clutter.Color();
PANE_BORDER_COLOR.from_pixel(0x101d3cfa);
@ -144,7 +166,7 @@ ResultArea.prototype = {
// Utility function shared between ResultPane and the DocDisplay in the main dash.
// Connects to the detail signal of the display, and on-demand creates a new
// pane.
function createPaneForDetails(dash, display, detailsWidth) {
function createPaneForDetails(dash, display) {
let detailPane = null;
display.connect('show-details', Lang.bind(this, function(display, index) {
if (detailPane == null) {
@ -160,7 +182,7 @@ function createPaneForDetails(dash, display, detailsWidth) {
if (index >= 0) {
detailPane.destroyContent();
let details = display.createDetailsForIndex(index, detailsWidth, -1);
let details = display.createDetailsForIndex(index, -1);
detailPane.content.append(details, Big.BoxPackFlags.EXPAND);
detailPane.open();
} else {
@ -170,17 +192,16 @@ function createPaneForDetails(dash, display, detailsWidth) {
return null;
}
function ResultPane(dash, detailsWidth) {
this._init(dash, detailsWidth);
function ResultPane(dash) {
this._init(dash);
}
ResultPane.prototype = {
__proto__: Pane.prototype,
_init: function(dash, detailsWidth) {
_init: function(dash) {
Pane.prototype._init.call(this);
this._dash = dash;
this._detailsWidth = detailsWidth;
},
// Create an instance of displayClass and pack it into this pane's
@ -188,7 +209,7 @@ ResultPane.prototype = {
packResults: function(displayClass, enableNavigation) {
let resultArea = new ResultArea(displayClass, enableNavigation);
createPaneForDetails(this._dash, resultArea.display, this._detailsWidth);
createPaneForDetails(this._dash, resultArea.display);
this.content.append(resultArea.actor, Big.BoxPackFlags.EXPAND);
this.connect('open-state-changed', Lang.bind(this, function(pane, isOpen) {
@ -206,31 +227,89 @@ SearchEntry.prototype = {
_init : function() {
this.actor = new Big.Box({ orientation: Big.BoxOrientation.HORIZONTAL,
y_align: Big.BoxAlignment.CENTER,
background_color: DASH_SEARCH_BG_COLOR,
corner_radius: 4,
spacing: DEFAULT_PADDING,
padding: DEFAULT_PADDING
});
let icon = new Gio.ThemedIcon({ name: 'gtk-find' });
let searchIconTexture = Shell.TextureCache.get_default().load_gicon(icon, 16);
this.actor.append(searchIconTexture, Big.BoxPackFlags.NONE);
border_bottom: SECTION_BORDER,
border_color: SEARCH_BORDER_BOTTOM_COLOR });
this.pane = null;
this._defaultText = "Find apps or documents";
let textProperties = { font_name: "Sans 12" };
let entryProperties = { editable: true,
activatable: true,
single_line_mode: true,
color: BRIGHT_TEXT_COLOR,
cursor_color: BRIGHT_TEXT_COLOR,
text: '' };
Lang.copyProperties(textProperties, entryProperties);
// We need to initialize the text for the entry to have the cursor displayed
// in it. See http://bugzilla.openedhand.com/show_bug.cgi?id=1365
this.entry = new Clutter.Text({ font_name: "Sans 14px",
editable: true,
activatable: true,
singleLineMode: true,
text: ""
});
this.entry = new Clutter.Text(entryProperties);
this.entry.connect('notify::text', Lang.bind(this, function () {
this._resetTextState();
}));
this.actor.append(this.entry, Big.BoxPackFlags.EXPAND);
// Mark as editable just to get a cursor
let defaultTextProperties = { ellipsize: Pango.EllipsizeMode.END,
text: "Find apps or documents",
editable: true,
color: TEXT_COLOR,
cursor_visible: false,
single_line_mode: true };
Lang.copyProperties(textProperties, defaultTextProperties);
this._defaultText = new Clutter.Text(defaultTextProperties);
this.actor.add_actor(this._defaultText);
this.entry.connect('notify::allocation', Lang.bind(this, function () {
this._repositionDefaultText();
}));
this._iconBox = new Big.Box({ x_align: Big.BoxAlignment.CENTER,
y_align: Big.BoxAlignment.CENTER });
this.actor.append(this._iconBox, Big.BoxPackFlags.END);
let global = Shell.Global.get();
let magnifierUri = "file://" + global.imagedir + "magnifier.svg";
this._magnifierIcon = Shell.TextureCache.get_default().load_uri_sync(Shell.TextureCachePolicy.FOREVER,
magnifierUri, 29, 18);
let closeUri = "file://" + global.imagedir + "close.svg";
this._closeIcon = Shell.TextureCache.get_default().load_uri_sync(Shell.TextureCachePolicy.FOREVER,
closeUri, 18, 18);
this._closeIcon.reactive = true;
this._closeIcon.connect('button-press-event', Lang.bind(this, function () {
this.entry.text = '';
}));
this._repositionDefaultText();
this._resetTextState();
},
setPane: function (pane) {
this._pane = pane;
},
reset: function () {
this.entry.text = '';
},
getText: function () {
return this.entry.text;
},
_resetTextState: function () {
let text = this.getText();
this._iconBox.remove_all();
if (text != '') {
this._defaultText.hide();
this._iconBox.append(this._closeIcon, Big.BoxPackFlags.NONE);
} else {
this._defaultText.show();
this._iconBox.append(this._magnifierIcon, Big.BoxPackFlags.NONE);
}
},
_repositionDefaultText: function () {
// Offset a little to show the cursor
this._defaultText.set_position(this.entry.x + 4, this.entry.y);
this._defaultText.set_size(this.entry.width, this.entry.height);
}
};
Signals.addSignalMethods(SearchEntry.prototype);
@ -242,22 +321,21 @@ function MoreLink() {
MoreLink.prototype = {
_init : function () {
this.actor = new Big.Box({ orientation: Big.BoxOrientation.HORIZONTAL,
padding_right: DEFAULT_PADDING,
padding_left: DEFAULT_PADDING,
padding_right: DEFAULT_PADDING });
let global = Shell.Global.get();
let inactiveUri = "file://" + global.imagedir + "view-more.svg";
let activeUri = "file://" + global.imagedir + "view-more-activated.svg";
this._inactiveIcon = Shell.TextureCache.get_default().load_uri_sync(Shell.TextureCachePolicy.FOREVER,
inactiveUri, 29, 18);
this._activeIcon = Shell.TextureCache.get_default().load_uri_sync(Shell.TextureCachePolicy.FOREVER,
activeUri, 29, 18);
this._iconBox = new Big.Box({ reactive: true });
this._iconBox.append(this._inactiveIcon, Big.BoxPackFlags.NONE);
this.actor.append(this._iconBox, Big.BoxPackFlags.END);
reactive: true,
x_align: Big.BoxAlignment.CENTER,
y_align: Big.BoxAlignment.CENTER,
border_left: SECTION_BORDER,
border_color: SECTION_BORDER_COLOR });
this.pane = null;
this._iconBox.connect('button-press-event', Lang.bind(this, function (b, e) {
let text = new Clutter.Text({ font_name: "Sans 12px",
color: BRIGHT_TEXT_COLOR,
text: "Browse" });
this.actor.append(text, Big.BoxPackFlags.NONE);
this.actor.connect('button-press-event', Lang.bind(this, function (b, e) {
if (this.pane == null) {
// Ensure the pane is created; the activated handler will call setPane
this.emit('activated');
@ -270,41 +348,66 @@ MoreLink.prototype = {
setPane: function (pane) {
this._pane = pane;
this._pane.connect('open-state-changed', Lang.bind(this, function(pane, isOpen) {
this._iconBox.remove_all();
this._iconBox.append(isOpen ? this._activeIcon : this._inactiveIcon,
Big.BoxPackFlags.NONE);
}));
}
}
Signals.addSignalMethods(MoreLink.prototype);
function SectionHeader(title) {
this._init(title);
function SectionHeader(title, suppressBrowse) {
this._init(title, suppressBrowse);
}
SectionHeader.prototype = {
_init : function (title) {
this.actor = new Big.Box({ orientation: Big.BoxOrientation.HORIZONTAL });
let text = new Clutter.Text({ color: DASH_SECTION_COLOR,
font_name: "Sans Bold 10px",
_init : function (title, suppressBrowse) {
this.actor = new Big.Box({ border: SECTION_BORDER,
border_color: SECTION_BORDER_COLOR });
this._innerBox = new Big.Box({ border: SECTION_BORDER,
border_color: SECTION_INNER_BORDER_COLOR,
padding_left: DEFAULT_PADDING,
orientation: Big.BoxOrientation.HORIZONTAL });
this.actor.append(this._innerBox, Big.BoxPackFlags.EXPAND);
let backgroundGradient = Shell.create_vertical_gradient(SECTION_BACKGROUND_TOP_COLOR,
SECTION_BACKGROUND_BOTTOM_COLOR);
this._innerBox.add_actor(backgroundGradient);
this._innerBox.connect('notify::allocation', Lang.bind(this, function (actor) {
let [width, height] = actor.get_size();
backgroundGradient.set_size(width, height);
}));
let textBox = new Big.Box({ padding_top: DEFAULT_PADDING,
padding_bottom: DEFAULT_PADDING });
let text = new Clutter.Text({ color: TEXT_COLOR,
font_name: "Sans Bold 12px",
text: title });
this.moreLink = new MoreLink();
this.actor.append(text, Big.BoxPackFlags.EXPAND);
this.actor.append(this.moreLink.actor, Big.BoxPackFlags.END);
textBox.append(text, Big.BoxPackFlags.NONE);
this._innerBox.append(textBox, Big.BoxPackFlags.EXPAND);
if (!suppressBrowse) {
this.moreLink = new MoreLink();
this._innerBox.append(this.moreLink.actor, Big.BoxPackFlags.END);
}
}
}
function Dash(displayGridColumnWidth) {
this._init(displayGridColumnWidth);
function Section(titleString, suppressBrowse) {
this._init(titleString, suppressBrowse);
}
Section.prototype = {
_init: function(titleString, suppressBrowse) {
this.actor = new Big.Box({ spacing: SECTION_INNER_SPACING });
this.header = new SectionHeader(titleString, suppressBrowse);
this.actor.append(this.header.actor, Big.BoxPackFlags.NONE);
this.content = new Big.Box();
this.actor.append(this.content, Big.BoxPackFlags.EXPAND);
}
}
function Dash() {
this._init();
}
Dash.prototype = {
_init : function(displayGridColumnWidth) {
this._width = displayGridColumnWidth;
this._detailsWidth = displayGridColumnWidth * 2;
_init : function() {
let global = Shell.Global.get();
// dash and the popup panes need to be reactive so that the clicks in unoccupied places on them
@ -316,14 +419,21 @@ Dash.prototype = {
// of the Group actor ends up including the width of its hidden children, so we were getting a reactive object as
// wide as the details pane that was blocking the clicks to the workspaces underneath it even when the details pane
// was actually hidden.
this.actor = new Big.Box({ orientation: Big.BoxOrientation.HORIZONTAL,
width: this._width,
padding: DEFAULT_PADDING,
this.actor = new Big.Box({ orientation: Big.BoxOrientation.VERTICAL,
background_color: BACKGROUND_COLOR,
corner_radius: DASH_CORNER_RADIUS,
padding_left: DASH_PADDING_SIDE,
padding_right: DASH_PADDING_SIDE,
reactive: true });
this.dashContainer = new Big.Box({ orientation: Big.BoxOrientation.VERTICAL,
spacing: DASH_SECTION_SPACING });
this.actor.append(this.dashContainer, Big.BoxPackFlags.EXPAND);
// Size for this one explicitly set from overlay.js
this.searchArea = new Big.Box({ y_align: Big.BoxAlignment.CENTER });
this.sectionArea = new Big.Box({ orientation: Big.BoxOrientation.VERTICAL,
spacing: DASH_SECTION_SPACING });
this.actor.append(this.searchArea, Big.BoxPackFlags.NONE);
this.actor.append(this.sectionArea, Big.BoxPackFlags.NONE);
// The currently active popup display
this._activePane = null;
@ -333,24 +443,25 @@ Dash.prototype = {
this._searchPane = null;
this._searchActive = false;
this._searchEntry = new SearchEntry();
this.dashContainer.append(this._searchEntry.actor, Big.BoxPackFlags.NONE);
this.searchArea.append(this._searchEntry.actor, Big.BoxPackFlags.EXPAND);
this._searchAreaApps = null;
this._searchAreaDocs = null;
this._searchQueued = false;
this._searchEntry.entry.connect('text-changed', Lang.bind(this, function (se, prop) {
this._searchActive = this._searchEntry.text != '';
let text = this._searchEntry.getText();
this._searchActive = text != '';
if (this._searchQueued)
return;
if (this._searchPane == null) {
this._searchPane = new ResultPane(this, this._detailsWidth);
this._searchPane.content.append(new Clutter.Text({ color: DASH_SECTION_COLOR,
this._searchPane = new ResultPane(this);
this._searchPane.content.append(new Clutter.Text({ color: TEXT_COLOR,
font_name: 'Sans Bold 10px',
text: "APPLICATIONS" }),
Big.BoxPackFlags.NONE);
this._searchAreaApps = this._searchPane.packResults(AppDisplay.AppDisplay, false);
this._searchPane.content.append(new Clutter.Text({ color: DASH_SECTION_COLOR,
this._searchPane.content.append(new Clutter.Text({ color: TEXT_COLOR,
font_name: 'Sans Bold 10px',
text: "RECENT DOCUMENTS" }),
Big.BoxPackFlags.NONE);
@ -360,8 +471,9 @@ Dash.prototype = {
}
this._searchQueued = true;
Mainloop.timeout_add(250, Lang.bind(this, function() {
let text = this._searchEntry.getText();
// Strip leading and trailing whitespace
let text = this._searchEntry.entry.text.replace(/^\s+/g, "").replace(/\s+$/g, "");
text = text.replace(/^\s+/g, "").replace(/\s+$/g, "");
this._searchQueued = false;
this._searchAreaApps.setSearch(text);
this._searchAreaDocs.setSearch(text);
@ -380,12 +492,13 @@ Dash.prototype = {
return true;
}));
this._searchEntry.entry.connect('key-press-event', Lang.bind(this, function (se, e) {
let text = this._searchEntry.getText();
let symbol = Shell.get_event_key_symbol(e);
if (symbol == Clutter.Escape) {
// Escape will keep clearing things back to the desktop. First, if
// we have active text, we remove it.
if (this._searchEntry.entry.text != '')
this._searchEntry.entry.text = '';
if (text != '')
this._searchEntry.reset();
// Next, if we're in one of the "more" modes or showing the details pane, close them
else if (this._activePane != null)
this._activePane.close();
@ -423,64 +536,49 @@ Dash.prototype = {
/***** Applications *****/
let appsHeader = new SectionHeader("APPLICATIONS");
this._appsSection = new Big.Box({ spacing: DEFAULT_PADDING });
this._appsSection.append(appsHeader.actor, Big.BoxPackFlags.NONE);
this._appsContent = new Big.Box({ orientation: Big.BoxOrientation.HORIZONTAL });
this._appsSection.append(this._appsContent, Big.BoxPackFlags.EXPAND);
this._appWell = new AppDisplay.AppWell();
this._appsContent.append(this._appWell.actor, Big.BoxPackFlags.EXPAND);
let appsSection = new Section("APPLICATIONS");
let appWell = new AppDisplay.AppWell();
appsSection.content.append(appWell.actor, Big.BoxPackFlags.EXPAND);
this._moreAppsPane = null;
appsHeader.moreLink.connect('activated', Lang.bind(this, function (link) {
appsSection.header.moreLink.connect('activated', Lang.bind(this, function (link) {
if (this._moreAppsPane == null) {
this._moreAppsPane = new ResultPane(this, this._detailsWidth);
this._moreAppsPane = new ResultPane(this);
this._moreAppsPane.packResults(AppDisplay.AppDisplay, true);
this._addPane(this._moreAppsPane);
link.setPane(this._moreAppsPane);
}
}));
this.dashContainer.append(this._appsSection, Big.BoxPackFlags.NONE);
this.sectionArea.append(appsSection.actor, Big.BoxPackFlags.NONE);
/***** Places *****/
let placesSection = new Big.Box({ orientation: Big.BoxOrientation.VERTICAL,
spacing: DEFAULT_PADDING });
let placesHeader = new SectionHeader("PLACES");
placesSection.append(placesHeader.actor, Big.BoxPackFlags.NONE);
let placesSection = new Section("PLACES", true);
let placesDisplay = new Places.Places();
placesSection.append(placesDisplay.actor, Big.BoxPackFlags.EXPAND);
this.dashContainer.append(placesSection, Big.BoxPackFlags.NONE);
placesSection.content.append(placesDisplay.actor, Big.BoxPackFlags.EXPAND);
this.sectionArea.append(placesSection.actor, Big.BoxPackFlags.NONE);
/***** Documents *****/
this._docsSection = new Big.Box({ orientation: Big.BoxOrientation.VERTICAL,
spacing: DEFAULT_PADDING });
let docsSection = new Section("RECENT DOCUMENTS");
let docDisplay = new DocDisplay.DocDisplay();
docDisplay.load();
docsSection.content.append(docDisplay.actor, Big.BoxPackFlags.EXPAND);
createPaneForDetails(this, docDisplay);
this._moreDocsPane = null;
let docsHeader = new SectionHeader("RECENT DOCUMENTS");
this._docsSection.append(docsHeader.actor, Big.BoxPackFlags.NONE);
this._docDisplay = new DocDisplay.DocDisplay();
this._docDisplay.load();
this._docsSection.append(this._docDisplay.actor, Big.BoxPackFlags.EXPAND);
createPaneForDetails(this, this._docDisplay, this._detailsWidth);
docsHeader.moreLink.connect('activated', Lang.bind(this, function (link) {
docsSection.header.moreLink.connect('activated', Lang.bind(this, function (link) {
if (this._moreDocsPane == null) {
this._moreDocsPane = new ResultPane(this, this._detailsWidth);
this._moreDocsPane = new ResultPane(this);
this._moreDocsPane.packResults(DocDisplay.DocDisplay, true);
this._addPane(this._moreDocsPane);
link.setPane(this._moreDocsPane);
}
}));
this.dashContainer.append(this._docsSection, Big.BoxPackFlags.EXPAND);
this.sectionArea.append(docsSection.actor, Big.BoxPackFlags.EXPAND);
},
show: function() {
@ -489,9 +587,8 @@ Dash.prototype = {
},
hide: function() {
this._firstSelectAfterOverviewShow = true;
if (this._searchEntry.entry.text != '')
this._searchEntry.entry.text = '';
this._firstSelectAfterOverlayShow = true;
this._searchEntry.reset();
if (this._activePane != null)
this._activePane.close();
},