summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/app/nibs/TaskManager.xib17
-rw-r--r--chrome/browser/cocoa/task_manager_mac.mm59
2 files changed, 65 insertions, 11 deletions
diff --git a/chrome/app/nibs/TaskManager.xib b/chrome/app/nibs/TaskManager.xib
index ceed983..3f72abc 100644
--- a/chrome/app/nibs/TaskManager.xib
+++ b/chrome/app/nibs/TaskManager.xib
@@ -43,6 +43,7 @@
<string key="NSWindowClass">NSWindow</string>
<nil key="NSViewClass"/>
<string key="NSWindowContentMaxSize">{3.40282e+38, 3.40282e+38}</string>
+ <string key="NSWindowContentMinSize">{300, 200}</string>
<object class="NSView" key="NSWindowView" id="1006">
<reference key="NSNextResponder"/>
<int key="NSvFlags">256</int>
@@ -154,8 +155,8 @@
</object>
</object>
<double key="NSRowHeight">1.600000e+01</double>
- <int key="NSTvFlags">1522532352</int>
- <int key="NSColumnAutoresizingStyle">4</int>
+ <int key="NSTvFlags">1522565120</int>
+ <int key="NSColumnAutoresizingStyle">1</int>
<int key="NSDraggingSourceMaskForLocal">15</int>
<int key="NSDraggingSourceMaskForNonLocal">0</int>
<bool key="NSAllowsTypeSelect">YES</bool>
@@ -286,6 +287,7 @@
<reference key="NSSuperview"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1680, 1028}}</string>
+ <string key="NSMinSize">{300, 222}</string>
<string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
</object>
<object class="NSCustomObject" id="680042460">
@@ -549,6 +551,8 @@
<string>1.NSWindowTemplate.visibleAtLaunch</string>
<string>1.WindowOrigin</string>
<string>1.editorWindowContentRectSynchronizationRect</string>
+ <string>1.windowTemplate.hasMinSize</string>
+ <string>1.windowTemplate.minSize</string>
<string>11.IBPluginDependency</string>
<string>12.IBPluginDependency</string>
<string>13.IBPluginDependency</string>
@@ -576,6 +580,8 @@
<boolean value="NO"/>
<string>{196, 240}</string>
<string>{{357, 418}, {480, 270}}</string>
+ <boolean value="YES"/>
+ <string>{300, 200}</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -715,13 +721,6 @@
</object>
</object>
<object class="IBPartialClassDescription">
- <string key="className">NSWindow</string>
- <object class="IBClassDescriptionSource" key="sourceIdentifier">
- <string key="majorKey">IBProjectSource</string>
- <string key="minorKey">browser/cocoa/nswindow_local_state.h</string>
- </object>
- </object>
- <object class="IBPartialClassDescription">
<string key="className">TaskManagerWindowController</string>
<string key="superclassName">NSWindowController</string>
<object class="NSMutableDictionary" key="actions">
diff --git a/chrome/browser/cocoa/task_manager_mac.mm b/chrome/browser/cocoa/task_manager_mac.mm
index 593d9a1..caf5c59 100644
--- a/chrome/browser/cocoa/task_manager_mac.mm
+++ b/chrome/browser/cocoa/task_manager_mac.mm
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -15,11 +15,45 @@
#include "chrome/common/pref_names.h"
#include "grit/generated_resources.h"
-// TODO(thakis): Better resizing behavior (and think about storing column sizes)
// TODO(thakis): Column sort comparator
// TODO(thakis): Clicking column header doesn't sort
// TODO(thakis): Default sort column
+// Width of "a" and most other letters/digits in "small" table views.
+static const int kCharWidth = 6;
+
+// Some of the strings below have spaces at the end or are missing letters, to
+// make the columns look nicer, and to take potentially longer localized strings
+// into account.
+static const struct ColumnWidth {
+ int columnId;
+ int minWidth;
+ int maxWidth; // If this is -1, 1.5*minColumWidth is used as max width.
+} columnWidths[] = {
+ // Note that arraysize includes the trailing \0. That's intended.
+ { IDS_TASK_MANAGER_PAGE_COLUMN, 120, 600 },
+ { IDS_TASK_MANAGER_PHYSICAL_MEM_COLUMN,
+ arraysize("800 MiB") * kCharWidth, -1 },
+ { IDS_TASK_MANAGER_SHARED_MEM_COLUMN,
+ arraysize("800 MiB") * kCharWidth, -1 },
+ { IDS_TASK_MANAGER_PRIVATE_MEM_COLUMN,
+ arraysize("800 MiB") * kCharWidth, -1 },
+ { IDS_TASK_MANAGER_CPU_COLUMN,
+ arraysize("99.9") * kCharWidth, -1 },
+ { IDS_TASK_MANAGER_NET_COLUMN,
+ arraysize("150 kiB/s") * kCharWidth, -1 },
+ { IDS_TASK_MANAGER_PROCESS_ID_COLUMN,
+ arraysize("73099 ") * kCharWidth, -1 },
+ { IDS_TASK_MANAGER_WEBCORE_IMAGE_CACHE_COLUMN,
+ arraysize("2000.0K (2000.0 live)") * kCharWidth, -1 },
+ { IDS_TASK_MANAGER_WEBCORE_SCRIPTS_CACHE_COLUMN,
+ arraysize("2000.0K (2000.0 live)") * kCharWidth, -1 },
+ { IDS_TASK_MANAGER_WEBCORE_CSS_CACHE_COLUMN,
+ arraysize("2000.0K (2000.0 live)") * kCharWidth, -1 },
+ { IDS_TASK_MANAGER_GOATS_TELEPORTED_COLUMN,
+ arraysize("15 ") * kCharWidth, -1 },
+};
+
@interface TaskManagerWindowController (Private)
- (NSTableColumn*)addColumnWithId:(int)columnId visible:(BOOL)isVisible;
- (void)setUpTableColumns;
@@ -106,6 +140,27 @@
[column.get() setHidden:!isVisible];
[column.get() setEditable:NO];
+
+ // Default values, only used in release builds if nobody notices the DCHECK
+ // during development when adding new columns.
+ int minWidth = 200, maxWidth = 400;
+
+ size_t i;
+ for (i = 0; i < arraysize(columnWidths); ++i) {
+ if (columnWidths[i].columnId == columnId) {
+ minWidth = columnWidths[i].minWidth;
+ maxWidth = columnWidths[i].maxWidth;
+ if (maxWidth < 0)
+ maxWidth = 3 * minWidth / 2; // *1.5 for ints.
+ break;
+ }
+ }
+ DCHECK(i < arraysize(columnWidths)) << "Could not find " << columnId;
+ [column.get() setMinWidth:minWidth];
+ [column.get() setMaxWidth:maxWidth];
+ [column.get() setResizingMask:NSTableColumnAutoresizingMask |
+ NSTableColumnUserResizingMask];
+
[tableView_ addTableColumn:column.get()];
return column.get(); // Now retained by |tableView_|.
}