OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/gtk/task_manager_gtk.h" | 5 #include "chrome/browser/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 <vector> | 10 #include <vector> |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
627 g_object_unref(icon); | 627 g_object_unref(icon); |
628 } | 628 } |
629 | 629 |
630 void TaskManagerGtk::KillSelectedProcesses() { | 630 void TaskManagerGtk::KillSelectedProcesses() { |
631 GtkTreeSelection* selection = gtk_tree_view_get_selection( | 631 GtkTreeSelection* selection = gtk_tree_view_get_selection( |
632 GTK_TREE_VIEW(treeview_)); | 632 GTK_TREE_VIEW(treeview_)); |
633 | 633 |
634 GtkTreeModel* model; | 634 GtkTreeModel* model; |
635 GList* paths = gtk_tree_selection_get_selected_rows(selection, &model); | 635 GList* paths = gtk_tree_selection_get_selected_rows(selection, &model); |
636 for (GList* item = paths; item; item = item->next) { | 636 for (GList* item = paths; item; item = item->next) { |
637 int row = gtk_tree::GetRowNumForPath( | 637 GtkTreePath* path = gtk_tree_model_sort_convert_path_to_child_path( |
| 638 GTK_TREE_MODEL_SORT(process_list_sort_), |
638 reinterpret_cast<GtkTreePath*>(item->data)); | 639 reinterpret_cast<GtkTreePath*>(item->data)); |
| 640 int row = gtk_tree::GetRowNumForPath(path); |
| 641 gtk_tree_path_free(path); |
639 task_manager_->KillProcess(row); | 642 task_manager_->KillProcess(row); |
640 } | 643 } |
| 644 g_list_foreach(paths, reinterpret_cast<GFunc>(gtk_tree_path_free), NULL); |
641 g_list_free(paths); | 645 g_list_free(paths); |
642 } | 646 } |
643 | 647 |
644 void TaskManagerGtk::ShowContextMenu() { | 648 void TaskManagerGtk::ShowContextMenu() { |
645 if (!menu_controller_.get()) | 649 if (!menu_controller_.get()) |
646 menu_controller_.reset(new ContextMenuController(this)); | 650 menu_controller_.reset(new ContextMenuController(this)); |
647 | 651 |
648 menu_controller_->RunMenu(); | 652 menu_controller_->RunMenu(); |
649 } | 653 } |
650 | 654 |
651 void TaskManagerGtk::ActivateFocusedTab() { | 655 void TaskManagerGtk::ActivateFocusedTab() { |
652 GtkTreeSelection* selection = gtk_tree_view_get_selection( | 656 GtkTreeSelection* selection = gtk_tree_view_get_selection( |
653 GTK_TREE_VIEW(treeview_)); | 657 GTK_TREE_VIEW(treeview_)); |
654 | 658 |
655 // If the user has just double clicked, only one item is selected. | 659 // If the user has just double clicked, only one item is selected. |
656 GtkTreeModel* model; | 660 GtkTreeModel* model; |
657 GList* selected = gtk_tree_selection_get_selected_rows(selection, &model); | 661 GList* selected = gtk_tree_selection_get_selected_rows(selection, &model); |
658 if (selected) { | 662 if (selected) { |
659 int row = gtk_tree::GetRowNumForPath( | 663 GtkTreePath* path = gtk_tree_model_sort_convert_path_to_child_path( |
| 664 GTK_TREE_MODEL_SORT(process_list_sort_), |
660 reinterpret_cast<GtkTreePath*>(selected->data)); | 665 reinterpret_cast<GtkTreePath*>(selected->data)); |
| 666 int row = gtk_tree::GetRowNumForPath(path); |
| 667 gtk_tree_path_free(path); |
661 task_manager_->ActivateProcess(row); | 668 task_manager_->ActivateProcess(row); |
662 } | 669 } |
| 670 g_list_foreach(selected, reinterpret_cast<GFunc>(gtk_tree_path_free), NULL); |
| 671 g_list_free(selected); |
663 } | 672 } |
664 | 673 |
665 void TaskManagerGtk::OnLinkActivated() { | 674 void TaskManagerGtk::OnLinkActivated() { |
666 task_manager_->OpenAboutMemory(); | 675 task_manager_->OpenAboutMemory(); |
667 } | 676 } |
668 | 677 |
669 gint TaskManagerGtk::CompareImpl(GtkTreeModel* model, GtkTreeIter* a, | 678 gint TaskManagerGtk::CompareImpl(GtkTreeModel* model, GtkTreeIter* a, |
670 GtkTreeIter* b, int id) { | 679 GtkTreeIter* b, int id) { |
671 int row1 = gtk_tree::GetRowNumForIter(model, a); | 680 int row1 = gtk_tree::GetRowNumForIter(model, a); |
672 int row2 = gtk_tree::GetRowNumForIter(model, b); | 681 int row2 = gtk_tree::GetRowNumForIter(model, b); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
743 } | 752 } |
744 | 753 |
745 // static | 754 // static |
746 void TaskManagerGtk::OnSelectionChanged(GtkTreeSelection* selection, | 755 void TaskManagerGtk::OnSelectionChanged(GtkTreeSelection* selection, |
747 TaskManagerGtk* task_manager) { | 756 TaskManagerGtk* task_manager) { |
748 bool selection_contains_browser_process = false; | 757 bool selection_contains_browser_process = false; |
749 | 758 |
750 GtkTreeModel* model; | 759 GtkTreeModel* model; |
751 GList* paths = gtk_tree_selection_get_selected_rows(selection, &model); | 760 GList* paths = gtk_tree_selection_get_selected_rows(selection, &model); |
752 for (GList* item = paths; item; item = item->next) { | 761 for (GList* item = paths; item; item = item->next) { |
753 int row = gtk_tree::GetRowNumForPath( | 762 GtkTreePath* path = gtk_tree_model_sort_convert_path_to_child_path( |
| 763 GTK_TREE_MODEL_SORT(task_manager->process_list_sort_), |
754 reinterpret_cast<GtkTreePath*>(item->data)); | 764 reinterpret_cast<GtkTreePath*>(item->data)); |
| 765 int row = gtk_tree::GetRowNumForPath(path); |
| 766 gtk_tree_path_free(path); |
755 if (task_manager->task_manager_->IsBrowserProcess(row)) { | 767 if (task_manager->task_manager_->IsBrowserProcess(row)) { |
756 selection_contains_browser_process = true; | 768 selection_contains_browser_process = true; |
757 break; | 769 break; |
758 } | 770 } |
759 } | 771 } |
| 772 g_list_foreach(paths, reinterpret_cast<GFunc>(gtk_tree_path_free), NULL); |
760 g_list_free(paths); | 773 g_list_free(paths); |
761 | 774 |
762 bool sensitive = (paths != NULL) && !selection_contains_browser_process; | 775 bool sensitive = (paths != NULL) && !selection_contains_browser_process; |
763 gtk_dialog_set_response_sensitive(GTK_DIALOG(task_manager->dialog_), | 776 gtk_dialog_set_response_sensitive(GTK_DIALOG(task_manager->dialog_), |
764 kTaskManagerResponseKill, sensitive); | 777 kTaskManagerResponseKill, sensitive); |
765 } | 778 } |
766 | 779 |
767 // static | 780 // static |
768 gboolean TaskManagerGtk::OnButtonPressEvent(GtkWidget* widget, | 781 gboolean TaskManagerGtk::OnButtonPressEvent(GtkWidget* widget, |
769 GdkEventButton* event, | 782 GdkEventButton* event, |
(...skipping 22 matching lines...) Expand all Loading... |
792 TaskManagerGtk* task_manager) { | 805 TaskManagerGtk* task_manager) { |
793 if (keyval == GDK_w && modifier == GDK_CONTROL_MASK) { | 806 if (keyval == GDK_w && modifier == GDK_CONTROL_MASK) { |
794 // The GTK_RESPONSE_DELETE_EVENT response must be sent before the widget | 807 // The GTK_RESPONSE_DELETE_EVENT response must be sent before the widget |
795 // is destroyed. The deleted object will receive gtk signals otherwise. | 808 // is destroyed. The deleted object will receive gtk signals otherwise. |
796 gtk_dialog_response(GTK_DIALOG(task_manager->dialog_), | 809 gtk_dialog_response(GTK_DIALOG(task_manager->dialog_), |
797 GTK_RESPONSE_DELETE_EVENT); | 810 GTK_RESPONSE_DELETE_EVENT); |
798 } | 811 } |
799 | 812 |
800 return TRUE; | 813 return TRUE; |
801 } | 814 } |
OLD | NEW |