OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/ui/gtk/task_manager_gtk.h" | 5 #include "chrome/browser/ui/gtk/task_manager_gtk.h" |
6 | 6 |
7 #include <gdk/gdkkeysyms.h> | 7 #include <gdk/gdkkeysyms.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <set> | 10 #include <set> |
(...skipping 848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
859 GtkTreeIter* b, int id) { | 859 GtkTreeIter* b, int id) { |
860 int row1 = gtk_tree::GetRowNumForIter(model, b); | 860 int row1 = gtk_tree::GetRowNumForIter(model, b); |
861 int row2 = gtk_tree::GetRowNumForIter(model, a); | 861 int row2 = gtk_tree::GetRowNumForIter(model, a); |
862 | 862 |
863 // When sorting by non-grouped attributes (e.g., Network), just do a normal | 863 // When sorting by non-grouped attributes (e.g., Network), just do a normal |
864 // sort. | 864 // sort. |
865 if (!IsSharedByGroup(id)) | 865 if (!IsSharedByGroup(id)) |
866 return model_->CompareValues(row1, row2, id); | 866 return model_->CompareValues(row1, row2, id); |
867 | 867 |
868 // Otherwise, make sure grouped resources are shown together. | 868 // Otherwise, make sure grouped resources are shown together. |
869 std::pair<int, int> group_range1 = model_->GetGroupRangeForResource(row1); | 869 TaskManagerModel::GroupRange group_range1 = |
870 std::pair<int, int> group_range2 = model_->GetGroupRangeForResource(row2); | 870 model_->GetGroupRangeForResource(row1); |
| 871 TaskManagerModel::GroupRange group_range2 = |
| 872 model_->GetGroupRangeForResource(row2); |
871 | 873 |
872 if (group_range1 == group_range2) { | 874 if (group_range1 == group_range2) { |
873 // Sort within groups. | 875 // Sort within groups. |
874 // We want the first-in-group row at the top, whether we are sorting up or | 876 // We want the first-in-group row at the top, whether we are sorting up or |
875 // down. | 877 // down. |
876 GtkSortType sort_type; | 878 GtkSortType sort_type; |
877 gtk_tree_sortable_get_sort_column_id(GTK_TREE_SORTABLE(process_list_sort_), | 879 gtk_tree_sortable_get_sort_column_id(GTK_TREE_SORTABLE(process_list_sort_), |
878 NULL, &sort_type); | 880 NULL, &sort_type); |
879 if (row1 == group_range1.first) | 881 if (row1 == group_range1.first) |
880 return sort_type == GTK_SORT_ASCENDING ? -1 : 1; | 882 return sort_type == GTK_SORT_ASCENDING ? -1 : 1; |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
922 MemoryPurger::PurgeAll(); | 924 MemoryPurger::PurgeAll(); |
923 } | 925 } |
924 } | 926 } |
925 | 927 |
926 void TaskManagerGtk::OnSelectionChanged(GtkTreeSelection* selection) { | 928 void TaskManagerGtk::OnSelectionChanged(GtkTreeSelection* selection) { |
927 if (ignore_selection_changed_) | 929 if (ignore_selection_changed_) |
928 return; | 930 return; |
929 AutoReset<bool> autoreset(&ignore_selection_changed_, true); | 931 AutoReset<bool> autoreset(&ignore_selection_changed_, true); |
930 | 932 |
931 // The set of groups that should be selected. | 933 // The set of groups that should be selected. |
932 std::set<std::pair<int, int> > ranges; | 934 std::set<TaskManagerModel::GroupRange> ranges; |
933 bool selection_contains_browser_process = false; | 935 bool selection_contains_browser_process = false; |
934 | 936 |
935 GtkTreeModel* model; | 937 GtkTreeModel* model; |
936 GList* paths = gtk_tree_selection_get_selected_rows(selection, &model); | 938 GList* paths = gtk_tree_selection_get_selected_rows(selection, &model); |
937 for (GList* item = paths; item; item = item->next) { | 939 for (GList* item = paths; item; item = item->next) { |
938 GtkTreePath* path = gtk_tree_model_sort_convert_path_to_child_path( | 940 GtkTreePath* path = gtk_tree_model_sort_convert_path_to_child_path( |
939 GTK_TREE_MODEL_SORT(process_list_sort_), | 941 GTK_TREE_MODEL_SORT(process_list_sort_), |
940 reinterpret_cast<GtkTreePath*>(item->data)); | 942 reinterpret_cast<GtkTreePath*>(item->data)); |
941 int row = gtk_tree::GetRowNumForPath(path); | 943 int row = gtk_tree::GetRowNumForPath(path); |
942 gtk_tree_path_free(path); | 944 gtk_tree_path_free(path); |
943 if (task_manager_->IsBrowserProcess(row)) | 945 if (task_manager_->IsBrowserProcess(row)) |
944 selection_contains_browser_process = true; | 946 selection_contains_browser_process = true; |
945 ranges.insert(model_->GetGroupRangeForResource(row)); | 947 ranges.insert(model_->GetGroupRangeForResource(row)); |
946 } | 948 } |
947 g_list_foreach(paths, reinterpret_cast<GFunc>(gtk_tree_path_free), NULL); | 949 g_list_foreach(paths, reinterpret_cast<GFunc>(gtk_tree_path_free), NULL); |
948 g_list_free(paths); | 950 g_list_free(paths); |
949 | 951 |
950 for (std::set<std::pair<int, int> >::iterator iter = ranges.begin(); | 952 for (std::set<TaskManagerModel::GroupRange>::iterator iter = ranges.begin(); |
951 iter != ranges.end(); ++iter) { | 953 iter != ranges.end(); ++iter) { |
952 for (int i = 0; i < iter->second; ++i) { | 954 for (int i = 0; i < iter->second; ++i) { |
953 GtkTreePath* child_path = gtk_tree_path_new_from_indices(iter->first + i, | 955 GtkTreePath* child_path = gtk_tree_path_new_from_indices(iter->first + i, |
954 -1); | 956 -1); |
955 GtkTreePath* sort_path = gtk_tree_model_sort_convert_child_path_to_path( | 957 GtkTreePath* sort_path = gtk_tree_model_sort_convert_child_path_to_path( |
956 GTK_TREE_MODEL_SORT(process_list_sort_), child_path); | 958 GTK_TREE_MODEL_SORT(process_list_sort_), child_path); |
957 gtk_tree_selection_select_path(selection, sort_path); | 959 gtk_tree_selection_select_path(selection, sort_path); |
958 gtk_tree_path_free(child_path); | 960 gtk_tree_path_free(child_path); |
959 gtk_tree_path_free(sort_path); | 961 gtk_tree_path_free(sort_path); |
960 } | 962 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 guint keyval, | 995 guint keyval, |
994 GdkModifierType modifier) { | 996 GdkModifierType modifier) { |
995 if (keyval == GDK_w && modifier == GDK_CONTROL_MASK) { | 997 if (keyval == GDK_w && modifier == GDK_CONTROL_MASK) { |
996 // The GTK_RESPONSE_DELETE_EVENT response must be sent before the widget | 998 // The GTK_RESPONSE_DELETE_EVENT response must be sent before the widget |
997 // is destroyed. The deleted object will receive gtk signals otherwise. | 999 // is destroyed. The deleted object will receive gtk signals otherwise. |
998 gtk_dialog_response(GTK_DIALOG(dialog_), GTK_RESPONSE_DELETE_EVENT); | 1000 gtk_dialog_response(GTK_DIALOG(dialog_), GTK_RESPONSE_DELETE_EVENT); |
999 } | 1001 } |
1000 | 1002 |
1001 return TRUE; | 1003 return TRUE; |
1002 } | 1004 } |
OLD | NEW |