diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-16 21:27:37 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-16 21:27:37 +0000 |
commit | 87639f3ca70b43063316af530971bfdabbc86bec (patch) | |
tree | 171b04d8211c663d4154a3e933aff0a27df7362d | |
parent | 6009dc01772c79b4e964fbdf07dada473c821555 (diff) | |
download | chromium_src-87639f3ca70b43063316af530971bfdabbc86bec.zip chromium_src-87639f3ca70b43063316af530971bfdabbc86bec.tar.gz chromium_src-87639f3ca70b43063316af530971bfdabbc86bec.tar.bz2 |
gtk - Activate the correct tab when users double click on a row in the task manager.
BUG=64966
TEST=manual
Review URL: http://codereview.chromium.org/5860007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69467 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/gtk/task_manager_gtk.cc | 39 | ||||
-rw-r--r-- | chrome/browser/gtk/task_manager_gtk.h | 10 |
2 files changed, 14 insertions, 35 deletions
diff --git a/chrome/browser/gtk/task_manager_gtk.cc b/chrome/browser/gtk/task_manager_gtk.cc index fcb9817..ccc5f73 100644 --- a/chrome/browser/gtk/task_manager_gtk.cc +++ b/chrome/browser/gtk/task_manager_gtk.cc @@ -476,10 +476,8 @@ void TaskManagerGtk::Init() { CreateTaskManagerTreeview(); gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(treeview_), TRUE); - g_signal_connect(treeview_, "button-press-event", - G_CALLBACK(OnButtonPressEventThunk), this); - gtk_widget_add_events(treeview_, - GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); + g_signal_connect(treeview_, "row-activated", + G_CALLBACK(OnRowActivatedThunk), this); // |selection| is owned by |treeview_|. GtkTreeSelection* selection = gtk_tree_view_get_selection( @@ -780,25 +778,6 @@ void TaskManagerGtk::ShowContextMenu() { } #endif -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); - if (selected) { - GtkTreePath* path = gtk_tree_model_sort_convert_path_to_child_path( - GTK_TREE_MODEL_SORT(process_list_sort_), - reinterpret_cast<GtkTreePath*>(selected->data)); - int row = gtk_tree::GetRowNumForPath(path); - gtk_tree_path_free(path); - task_manager_->ActivateProcess(row); - } - g_list_foreach(selected, reinterpret_cast<GFunc>(gtk_tree_path_free), NULL); - g_list_free(selected); -} - void TaskManagerGtk::OnLinkActivated() { task_manager_->OpenAboutMemory(); } @@ -942,12 +921,14 @@ void TaskManagerGtk::OnSelectionChanged(GtkTreeSelection* selection) { kTaskManagerResponseKill, sensitive); } -gboolean TaskManagerGtk::OnButtonPressEvent(GtkWidget* widget, - GdkEventButton* event) { - if (event->type == GDK_2BUTTON_PRESS) - ActivateFocusedTab(); - - return FALSE; +void TaskManagerGtk::OnRowActivated(GtkWidget* widget, + GtkTreePath* path, + GtkTreeViewColumn* column) { + GtkTreePath* child_path = gtk_tree_model_sort_convert_path_to_child_path( + GTK_TREE_MODEL_SORT(process_list_sort_), path); + int row = gtk_tree::GetRowNumForPath(child_path); + gtk_tree_path_free(child_path); + task_manager_->ActivateProcess(row); } gboolean TaskManagerGtk::OnButtonReleaseEvent(GtkWidget* widget, diff --git a/chrome/browser/gtk/task_manager_gtk.h b/chrome/browser/gtk/task_manager_gtk.h index 75982e1..5aa5907 100644 --- a/chrome/browser/gtk/task_manager_gtk.h +++ b/chrome/browser/gtk/task_manager_gtk.h @@ -72,9 +72,6 @@ class TaskManagerGtk : public TaskManagerModelObserver { void ShowContextMenu(); #endif - // Activates the tab associated with the focused row. - void ActivateFocusedTab(); - // Opens about:memory in a new foreground tab. void OnLinkActivated(); @@ -95,9 +92,10 @@ class TaskManagerGtk : public TaskManagerModelObserver { CHROMEG_CALLBACK_0(TaskManagerGtk, void, OnSelectionChanged, GtkTreeSelection*); - // button-press-event handler that activates a process on double-click. - CHROMEGTK_CALLBACK_1(TaskManagerGtk, gboolean, OnButtonPressEvent, - GdkEventButton*); + // row-activated handler that foregrounds a process on activation (e.g., + // double-click). + CHROMEGTK_CALLBACK_2(TaskManagerGtk, void, OnRowActivated, + GtkTreePath*, GtkTreeViewColumn*); // button-release-event handler that opens the right-click context menu. CHROMEGTK_CALLBACK_1(TaskManagerGtk, gboolean, OnButtonReleaseEvent, |