| 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 #ifndef CHROME_BROWSER_GTK_TASK_MANAGER_GTK_H_ | 5 #ifndef CHROME_BROWSER_GTK_TASK_MANAGER_GTK_H_ |
| 6 #define CHROME_BROWSER_GTK_TASK_MANAGER_GTK_H_ | 6 #define CHROME_BROWSER_GTK_TASK_MANAGER_GTK_H_ |
| 7 | 7 |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 #include "chrome/browser/task_manager.h" | 12 #include "chrome/browser/task_manager.h" |
| 13 | 13 |
| 14 class TaskManagerGtk : public TaskManagerModelObserver { | 14 class TaskManagerGtk : public TaskManagerModelObserver { |
| 15 public: | 15 public: |
| 16 TaskManagerGtk(); | 16 TaskManagerGtk(); |
| 17 virtual ~TaskManagerGtk(); | 17 virtual ~TaskManagerGtk(); |
| 18 | 18 |
| 19 // TaskManagerModelObserver | 19 // TaskManagerModelObserver |
| 20 virtual void OnModelChanged(); | 20 virtual void OnModelChanged(); |
| 21 virtual void OnItemsChanged(int start, int length); | 21 virtual void OnItemsChanged(int start, int length); |
| 22 virtual void OnItemsAdded(int start, int length); | 22 virtual void OnItemsAdded(int start, int length); |
| 23 virtual void OnItemsRemoved(int start, int length); | 23 virtual void OnItemsRemoved(int start, int length); |
| 24 | 24 |
| 25 // Creates the task manager if it doesn't exist; otherwise, it activates the | 25 // Creates the task manager if it doesn't exist; otherwise, it activates the |
| 26 // existing task manager window. | 26 // existing task manager window. |
| 27 static void Show(); | 27 static void Show(); |
| 28 | 28 |
| 29 private: | 29 private: |
| 30 class ContextMenuController; |
| 31 friend class ContextMenuController; |
| 32 |
| 30 // Initializes the task manager dialog. | 33 // Initializes the task manager dialog. |
| 31 void Init(); | 34 void Init(); |
| 32 | 35 |
| 33 // Sets up the treeview widget. | 36 // Sets up the treeview widget. |
| 34 void CreateTaskManagerTreeview(); | 37 void CreateTaskManagerTreeview(); |
| 35 | 38 |
| 36 // Returns the model data for a given |row| and |col_id|. | 39 // Returns the model data for a given |row| and |col_id|. |
| 37 std::string GetModelText(int row, int col_id); | 40 std::string GetModelText(int row, int col_id); |
| 38 | 41 |
| 39 // Retrieves the resource icon from the model for |row|. | 42 // Retrieves the resource icon from the model for |row|. |
| 40 GdkPixbuf* GetModelIcon(int row); | 43 GdkPixbuf* GetModelIcon(int row); |
| 41 | 44 |
| 42 // Sets the treeview row data. |row| is an index into the model and |iter| | 45 // Sets the treeview row data. |row| is an index into the model and |iter| |
| 43 // is the current position in the treeview. | 46 // is the current position in the treeview. |
| 44 void SetRowDataFromModel(int row, GtkTreeIter* iter); | 47 void SetRowDataFromModel(int row, GtkTreeIter* iter); |
| 45 | 48 |
| 46 // Queries the treeview for the selected rows, and kills those processes. | 49 // Queries the treeview for the selected rows, and kills those processes. |
| 47 void KillSelectedProcesses(); | 50 void KillSelectedProcesses(); |
| 48 | 51 |
| 52 // Opens the context menu used to select the task manager columns. |
| 53 void ShowContextMenu(); |
| 54 |
| 49 // response signal handler that notifies us of dialog responses. | 55 // response signal handler that notifies us of dialog responses. |
| 50 static void OnResponse(GtkDialog* dialog, gint response_id, | 56 static void OnResponse(GtkDialog* dialog, gint response_id, |
| 51 TaskManagerGtk* task_manager); | 57 TaskManagerGtk* task_manager); |
| 52 | 58 |
| 53 // changed signal handler that is sent when the treeview selection changes. | 59 // changed signal handler that is sent when the treeview selection changes. |
| 54 static void OnSelectionChanged(GtkTreeSelection* selection, | 60 static void OnSelectionChanged(GtkTreeSelection* selection, |
| 55 TaskManagerGtk* task_manager); | 61 TaskManagerGtk* task_manager); |
| 56 | 62 |
| 63 // button-release-event handler that opens the right-click context menu. |
| 64 static gboolean OnButtonReleaseEvent(GtkWidget* widget, GdkEventButton* event, |
| 65 TaskManagerGtk* task_manager); |
| 66 |
| 57 // The task manager. | 67 // The task manager. |
| 58 TaskManager* task_manager_; | 68 TaskManager* task_manager_; |
| 59 | 69 |
| 60 // Our model. | 70 // Our model. |
| 61 TaskManagerModel* model_; | 71 TaskManagerModel* model_; |
| 62 | 72 |
| 63 // The task manager dialog window. | 73 // The task manager dialog window. |
| 64 GtkWidget* dialog_; | 74 GtkWidget* dialog_; |
| 65 | 75 |
| 66 // The treeview that contains the process list. | 76 // The treeview that contains the process list. |
| 67 GtkWidget* treeview_; | 77 GtkWidget* treeview_; |
| 68 | 78 |
| 69 // The list of processes. | 79 // The list of processes. |
| 70 GtkListStore* process_list_; | 80 GtkListStore* process_list_; |
| 71 | 81 |
| 72 // The number of processes in |process_list_|. | 82 // The number of processes in |process_list_|. |
| 73 int process_count_; | 83 int process_count_; |
| 74 | 84 |
| 85 // The context menu controller. |
| 86 scoped_ptr<ContextMenuController> menu_controller_; |
| 87 |
| 75 // An open task manager window. There can only be one open at a time. This | 88 // An open task manager window. There can only be one open at a time. This |
| 76 // is reset to NULL when the window is closed. | 89 // is reset to NULL when the window is closed. |
| 77 static TaskManagerGtk* instance_; | 90 static TaskManagerGtk* instance_; |
| 78 | 91 |
| 79 DISALLOW_COPY_AND_ASSIGN(TaskManagerGtk); | 92 DISALLOW_COPY_AND_ASSIGN(TaskManagerGtk); |
| 80 }; | 93 }; |
| 81 | 94 |
| 82 #endif // CHROME_BROWSER_GTK_TASK_MANAGER_GTK_H_ | 95 #endif // CHROME_BROWSER_GTK_TASK_MANAGER_GTK_H_ |
| OLD | NEW |