summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-06 20:24:01 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-06 20:24:01 +0000
commit8d140942adb41a0eaf0d1e815300d0d4a83d5ef3 (patch)
tree0025db4a2d72d8d654a561e06005f7fc1113f217 /chrome
parent5fcd543266ddd69074d102cc3fe7a1958a2854d5 (diff)
downloadchromium_src-8d140942adb41a0eaf0d1e815300d0d4a83d5ef3.zip
chromium_src-8d140942adb41a0eaf0d1e815300d0d4a83d5ef3.tar.gz
chromium_src-8d140942adb41a0eaf0d1e815300d0d4a83d5ef3.tar.bz2
Activate the currently selected process when the user double clicks the task manager treeview.
BUG=11392 TEST=Open the task manager and double click different processes. Those tabs should be activated. Review URL: http://codereview.chromium.org/155098 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19980 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/gtk/task_manager_gtk.cc24
-rw-r--r--chrome/browser/gtk/task_manager_gtk.h7
2 files changed, 30 insertions, 1 deletions
diff --git a/chrome/browser/gtk/task_manager_gtk.cc b/chrome/browser/gtk/task_manager_gtk.cc
index 1a93934..37ec95e 100644
--- a/chrome/browser/gtk/task_manager_gtk.cc
+++ b/chrome/browser/gtk/task_manager_gtk.cc
@@ -59,7 +59,6 @@ TaskManagerColumn TaskManagerResourceIDToColumnID(int id) {
}
int TaskManagerColumnIDToResourceID(int id) {
- printf("id: %d\n", id);
switch (id) {
case kTaskManagerPage:
return IDS_TASK_MANAGER_PAGE_COLUMN;
@@ -326,6 +325,8 @@ void TaskManagerGtk::Init() {
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);
g_signal_connect(G_OBJECT(treeview_), "button-release-event",
G_CALLBACK(OnButtonReleaseEvent), this);
gtk_widget_add_events(treeview_,
@@ -468,6 +469,17 @@ void TaskManagerGtk::ShowContextMenu() {
menu_controller_->RunMenu();
}
+void TaskManagerGtk::ActivateFocusedTab() {
+ GtkTreeSelection* selection = gtk_tree_view_get_selection(
+ GTK_TREE_VIEW(treeview_));
+
+ // If the user has just double clicked, only one item is selected.
+ GtkTreeModel* model;
+ GList* selected = gtk_tree_selection_get_selected_rows(selection, &model);
+ int row = GetRowNumForPath(reinterpret_cast<GtkTreePath*>(selected->data));
+ task_manager_->ActivateProcess(row);
+}
+
// static
void TaskManagerGtk::OnResponse(GtkDialog* dialog, gint response_id,
TaskManagerGtk* task_manager) {
@@ -501,6 +513,16 @@ void TaskManagerGtk::OnSelectionChanged(GtkTreeSelection* selection,
}
// static
+gboolean TaskManagerGtk::OnButtonPressEvent(GtkWidget* widget,
+ GdkEventButton* event,
+ TaskManagerGtk* task_manager) {
+ if (event->type == GDK_2BUTTON_PRESS)
+ task_manager->ActivateFocusedTab();
+
+ return FALSE;
+}
+
+// static
gboolean TaskManagerGtk::OnButtonReleaseEvent(GtkWidget* widget,
GdkEventButton* event,
TaskManagerGtk* task_manager) {
diff --git a/chrome/browser/gtk/task_manager_gtk.h b/chrome/browser/gtk/task_manager_gtk.h
index 7336522..e90ed18 100644
--- a/chrome/browser/gtk/task_manager_gtk.h
+++ b/chrome/browser/gtk/task_manager_gtk.h
@@ -52,6 +52,9 @@ class TaskManagerGtk : public TaskManagerModelObserver {
// Opens the context menu used to select the task manager columns.
void ShowContextMenu();
+ // Activates the tab associated with the focused row.
+ void ActivateFocusedTab();
+
// response signal handler that notifies us of dialog responses.
static void OnResponse(GtkDialog* dialog, gint response_id,
TaskManagerGtk* task_manager);
@@ -60,6 +63,10 @@ class TaskManagerGtk : public TaskManagerModelObserver {
static void OnSelectionChanged(GtkTreeSelection* selection,
TaskManagerGtk* task_manager);
+ // button-press-event handler that activates a process on double-click.
+ static gboolean OnButtonPressEvent(GtkWidget* widget, GdkEventButton* event,
+ TaskManagerGtk* task_manager);
+
// button-release-event handler that opens the right-click context menu.
static gboolean OnButtonReleaseEvent(GtkWidget* widget, GdkEventButton* event,
TaskManagerGtk* task_manager);