diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-01 19:33:02 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-01 19:33:02 +0000 |
commit | 55750b57e30ecc9f3657d1ebd08853e232ba4e23 (patch) | |
tree | 503375ad11d746a859d5a62a71747ce0b11fa64a /chrome/browser/gtk/task_manager_gtk.cc | |
parent | 29eff6a5c9e140fb902ae80f200441b0ab4673fc (diff) | |
download | chromium_src-55750b57e30ecc9f3657d1ebd08853e232ba4e23.zip chromium_src-55750b57e30ecc9f3657d1ebd08853e232ba4e23.tar.gz chromium_src-55750b57e30ecc9f3657d1ebd08853e232ba4e23.tar.bz2 |
task manager gtk:
When sorting by a column that is shared by resources in a group (e.g. process id or CPU, but not network), make sure those rows are grouped.
Also get rid of the confusing grid lines. I think we want separators between groups, but getting them to draw properly without introducing huge complexity to the code is hard.
BUG=none
TEST=manual
Review URL: http://codereview.chromium.org/555177
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37727 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk/task_manager_gtk.cc')
-rw-r--r-- | chrome/browser/gtk/task_manager_gtk.cc | 69 |
1 files changed, 49 insertions, 20 deletions
diff --git a/chrome/browser/gtk/task_manager_gtk.cc b/chrome/browser/gtk/task_manager_gtk.cc index e3721e9..ab4a9a7 100644 --- a/chrome/browser/gtk/task_manager_gtk.cc +++ b/chrome/browser/gtk/task_manager_gtk.cc @@ -400,8 +400,6 @@ void TaskManagerGtk::Init() { CreateTaskManagerTreeview(); gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(treeview_), TRUE); - gtk_tree_view_set_grid_lines(GTK_TREE_VIEW(treeview_), - GTK_TREE_VIEW_GRID_LINES_HORIZONTAL); g_signal_connect(G_OBJECT(treeview_), "button-press-event", G_CALLBACK(OnButtonPressEvent), this); gtk_widget_add_events(treeview_, @@ -509,7 +507,8 @@ void TaskManagerGtk::CreateTaskManagerTreeview() { TreeViewInsertColumn(treeview_, IDS_TASK_MANAGER_CPU_COLUMN); TreeViewInsertColumn(treeview_, IDS_TASK_MANAGER_NET_COLUMN); TreeViewInsertColumn(treeview_, IDS_TASK_MANAGER_PROCESS_ID_COLUMN); - TreeViewInsertColumn(treeview_, IDS_TASK_MANAGER_JAVASCRIPT_MEMORY_ALLOCATED_COLUMN); + TreeViewInsertColumn(treeview_, + IDS_TASK_MANAGER_JAVASCRIPT_MEMORY_ALLOCATED_COLUMN); TreeViewInsertColumn(treeview_, IDS_TASK_MANAGER_WEBCORE_IMAGE_CACHE_COLUMN); TreeViewInsertColumn(treeview_, IDS_TASK_MANAGER_WEBCORE_SCRIPTS_CACHE_COLUMN); @@ -529,52 +528,55 @@ void TaskManagerGtk::CreateTaskManagerTreeview() { g_object_unref(process_list_sort_); } +bool IsSharedByGroup(int col_id) { + switch (col_id) { + case IDS_TASK_MANAGER_PRIVATE_MEM_COLUMN: + case IDS_TASK_MANAGER_SHARED_MEM_COLUMN: + case IDS_TASK_MANAGER_CPU_COLUMN: + case IDS_TASK_MANAGER_PROCESS_ID_COLUMN: + case IDS_TASK_MANAGER_JAVASCRIPT_MEMORY_ALLOCATED_COLUMN: + case IDS_TASK_MANAGER_WEBCORE_IMAGE_CACHE_COLUMN: + case IDS_TASK_MANAGER_WEBCORE_SCRIPTS_CACHE_COLUMN: + case IDS_TASK_MANAGER_WEBCORE_CSS_CACHE_COLUMN: + return true; + default: + return false; + } +} + std::string TaskManagerGtk::GetModelText(int row, int col_id) { + if (IsSharedByGroup(col_id) && !model_->IsResourceFirstInGroup(row)) + return std::string(); + switch (col_id) { case IDS_TASK_MANAGER_PAGE_COLUMN: // Process return WideToUTF8(model_->GetResourceTitle(row)); case IDS_TASK_MANAGER_PRIVATE_MEM_COLUMN: // Memory - if (!model_->IsResourceFirstInGroup(row)) - return std::string(); return WideToUTF8(model_->GetResourcePrivateMemory(row)); case IDS_TASK_MANAGER_SHARED_MEM_COLUMN: // Memory - if (!model_->IsResourceFirstInGroup(row)) - return std::string(); return WideToUTF8(model_->GetResourceSharedMemory(row)); case IDS_TASK_MANAGER_CPU_COLUMN: // CPU - if (!model_->IsResourceFirstInGroup(row)) - return std::string(); return WideToUTF8(model_->GetResourceCPUUsage(row)); case IDS_TASK_MANAGER_NET_COLUMN: // Net return WideToUTF8(model_->GetResourceNetworkUsage(row)); case IDS_TASK_MANAGER_PROCESS_ID_COLUMN: // Process ID - if (!model_->IsResourceFirstInGroup(row)) - return std::string(); return WideToUTF8(model_->GetResourceProcessId(row)); case IDS_TASK_MANAGER_JAVASCRIPT_MEMORY_ALLOCATED_COLUMN: - if (!model_->IsResourceFirstInGroup(row)) - return std::string(); return WideToUTF8(model_->GetResourceV8MemoryAllocatedSize(row)); case IDS_TASK_MANAGER_WEBCORE_IMAGE_CACHE_COLUMN: - if (!model_->IsResourceFirstInGroup(row)) - return std::string(); return WideToUTF8(model_->GetResourceWebCoreImageCacheSize(row)); case IDS_TASK_MANAGER_WEBCORE_SCRIPTS_CACHE_COLUMN: - if (!model_->IsResourceFirstInGroup(row)) - return std::string(); return WideToUTF8(model_->GetResourceWebCoreScriptsCacheSize(row)); case IDS_TASK_MANAGER_WEBCORE_CSS_CACHE_COLUMN: - if (!model_->IsResourceFirstInGroup(row)) - return std::string(); return WideToUTF8(model_->GetResourceWebCoreCSSCacheSize(row)); case IDS_TASK_MANAGER_GOATS_TELEPORTED_COLUMN: // Goats Teleported! @@ -697,7 +699,34 @@ gint TaskManagerGtk::CompareImpl(GtkTreeModel* model, GtkTreeIter* a, GtkTreeIter* b, int id) { int row1 = gtk_tree::GetRowNumForIter(model, a); int row2 = gtk_tree::GetRowNumForIter(model, b); - return model_->CompareValues(row1, row2, id); + + // When sorting by non-grouped attributes (e.g., Network), just do a normal + // sort. + if (!IsSharedByGroup(id)) + return model_->CompareValues(row1, row2, id); + + // Otherwise, make sure grouped resources are shown together. + std::pair<int, int> group_range1 = model_->GetGroupRangeForResource(row1); + std::pair<int, int> group_range2 = model_->GetGroupRangeForResource(row2); + + if (group_range1 == group_range2) { + // Sort within groups. + // We want the first-in-group row at the top, whether we are sorting up or + // down. + GtkSortType sort_type; + gtk_tree_sortable_get_sort_column_id(GTK_TREE_SORTABLE(process_list_sort_), + NULL, &sort_type); + if (row1 == group_range1.first) + return sort_type == GTK_SORT_ASCENDING ? -1 : 1; + if (row2 == group_range2.first) + return sort_type == GTK_SORT_ASCENDING ? 1 : -1; + + return model_->CompareValues(row1, row2, id); + } else { + // Sort between groups. + // Compare by the first-in-group rows so that the groups will stay together. + return model_->CompareValues(group_range1.first, group_range2.first, id); + } } // static |