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 <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 GTK_POLICY_NEVER, GTK_POLICY_NEVER); | 334 GTK_POLICY_NEVER, GTK_POLICY_NEVER); |
335 | 335 |
336 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog_)->vbox), scrolled); | 336 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(dialog_)->vbox), scrolled); |
337 | 337 |
338 CreateTaskManagerTreeview(); | 338 CreateTaskManagerTreeview(); |
339 gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(treeview_), TRUE); | 339 gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(treeview_), TRUE); |
340 gtk_tree_view_set_grid_lines(GTK_TREE_VIEW(treeview_), | 340 gtk_tree_view_set_grid_lines(GTK_TREE_VIEW(treeview_), |
341 GTK_TREE_VIEW_GRID_LINES_HORIZONTAL); | 341 GTK_TREE_VIEW_GRID_LINES_HORIZONTAL); |
342 g_signal_connect(G_OBJECT(treeview_), "button-press-event", | 342 g_signal_connect(G_OBJECT(treeview_), "button-press-event", |
343 G_CALLBACK(OnButtonPressEvent), this); | 343 G_CALLBACK(OnButtonPressEvent), this); |
344 g_signal_connect(G_OBJECT(treeview_), "button-release-event", | |
345 G_CALLBACK(OnButtonReleaseEvent), this); | |
346 gtk_widget_add_events(treeview_, | 344 gtk_widget_add_events(treeview_, |
347 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); | 345 GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK); |
348 | 346 |
349 // Hide some columns by default | 347 // Hide some columns by default |
350 TreeViewColumnSetVisible(treeview_, kTaskManagerSharedMem, false); | 348 TreeViewColumnSetVisible(treeview_, kTaskManagerSharedMem, false); |
351 TreeViewColumnSetVisible(treeview_, kTaskManagerPrivateMem, false); | 349 TreeViewColumnSetVisible(treeview_, kTaskManagerPrivateMem, false); |
352 TreeViewColumnSetVisible(treeview_, kTaskManagerProcessID, false); | 350 TreeViewColumnSetVisible(treeview_, kTaskManagerProcessID, false); |
353 TreeViewColumnSetVisible(treeview_, kTaskManagerGoatsTeleported, false); | 351 TreeViewColumnSetVisible(treeview_, kTaskManagerGoatsTeleported, false); |
354 | 352 |
355 // |selection| is owned by |treeview_|. | 353 // |selection| is owned by |treeview_|. |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
546 if (event->type == GDK_2BUTTON_PRESS) | 544 if (event->type == GDK_2BUTTON_PRESS) |
547 task_manager->ActivateFocusedTab(); | 545 task_manager->ActivateFocusedTab(); |
548 | 546 |
549 return FALSE; | 547 return FALSE; |
550 } | 548 } |
551 | 549 |
552 // static | 550 // static |
553 gboolean TaskManagerGtk::OnButtonReleaseEvent(GtkWidget* widget, | 551 gboolean TaskManagerGtk::OnButtonReleaseEvent(GtkWidget* widget, |
554 GdkEventButton* event, | 552 GdkEventButton* event, |
555 TaskManagerGtk* task_manager) { | 553 TaskManagerGtk* task_manager) { |
556 // We don't want to open the context menu in the treeview. | 554 if (gtk_util::WidgetContainsCursor(task_manager->treeview_)) |
557 if (widget == task_manager->treeview_) | 555 return FALSE; |
558 return TRUE; | |
559 | 556 |
560 if (event->button == 3) | 557 if (event->button == 3) |
561 task_manager->ShowContextMenu(); | 558 task_manager->ShowContextMenu(); |
562 | 559 |
563 return FALSE; | 560 return FALSE; |
564 } | 561 } |
565 | 562 |
566 // static | 563 // static |
567 gboolean TaskManagerGtk::OnGtkAccelerator(GtkAccelGroup* accel_group, | 564 gboolean TaskManagerGtk::OnGtkAccelerator(GtkAccelGroup* accel_group, |
568 GObject* acceleratable, | 565 GObject* acceleratable, |
569 guint keyval, | 566 guint keyval, |
570 GdkModifierType modifier, | 567 GdkModifierType modifier, |
571 TaskManagerGtk* task_manager) { | 568 TaskManagerGtk* task_manager) { |
572 if (keyval == GDK_w && modifier == GDK_CONTROL_MASK) { | 569 if (keyval == GDK_w && modifier == GDK_CONTROL_MASK) { |
573 // The GTK_RESPONSE_DELETE_EVENT response must be sent before the widget | 570 // The GTK_RESPONSE_DELETE_EVENT response must be sent before the widget |
574 // is destroyed. The deleted object will receive gtk signals otherwise. | 571 // is destroyed. The deleted object will receive gtk signals otherwise. |
575 gtk_dialog_response(GTK_DIALOG(task_manager->dialog_), | 572 gtk_dialog_response(GTK_DIALOG(task_manager->dialog_), |
576 GTK_RESPONSE_DELETE_EVENT); | 573 GTK_RESPONSE_DELETE_EVENT); |
577 gtk_widget_destroy(task_manager->dialog_); | 574 gtk_widget_destroy(task_manager->dialog_); |
578 } | 575 } |
579 | 576 |
580 return TRUE; | 577 return TRUE; |
581 } | 578 } |
OLD | NEW |