summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-08 23:31:43 +0000
committerjhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-08 23:31:43 +0000
commit8929b5f10a41c0d586c0a27dcabb1d714dde88e4 (patch)
treee8aa3916549f202b72b3aa94e9c112850d358e4f /chrome
parentb96bc1f3abfd902ba112a95d07318ea34d7f817b (diff)
downloadchromium_src-8929b5f10a41c0d586c0a27dcabb1d714dde88e4.zip
chromium_src-8929b5f10a41c0d586c0a27dcabb1d714dde88e4.tar.gz
chromium_src-8929b5f10a41c0d586c0a27dcabb1d714dde88e4.tar.bz2
Connect the ctrl-w accelerator to the task manager dialog, and close the window when this accelerator is activated.
BUG=11392 TEST=Open the task manager in Linux Chrome. Press ctrl-w. The task manager should close. Review URL: http://codereview.chromium.org/149363 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20207 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/gtk/task_manager_gtk.cc34
-rw-r--r--chrome/browser/gtk/task_manager_gtk.h10
2 files changed, 44 insertions, 0 deletions
diff --git a/chrome/browser/gtk/task_manager_gtk.cc b/chrome/browser/gtk/task_manager_gtk.cc
index 45cf3f3..5f64c45 100644
--- a/chrome/browser/gtk/task_manager_gtk.cc
+++ b/chrome/browser/gtk/task_manager_gtk.cc
@@ -4,6 +4,8 @@
#include "chrome/browser/gtk/task_manager_gtk.h"
+#include <gdk/gdkkeysyms.h>
+
#include <vector>
#include "app/l10n_util.h"
@@ -312,6 +314,8 @@ void TaskManagerGtk::Init() {
kTaskManagerResponseKill,
NULL);
+ ConnectAccelerators();
+
gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(dialog_)->vbox),
gtk_util::kContentAreaSpacing);
@@ -362,6 +366,19 @@ void TaskManagerGtk::Init() {
model_->SetObserver(this);
}
+void TaskManagerGtk::ConnectAccelerators() {
+ GtkAccelGroup* accel_group = gtk_accel_group_new();
+ gtk_window_add_accel_group(GTK_WINDOW(dialog_), accel_group);
+
+ // Drop the initial ref on |accel_group| so |dialog_| will own it.
+ g_object_unref(accel_group);
+
+ gtk_accel_group_connect(accel_group,
+ GDK_w, GDK_CONTROL_MASK, GtkAccelFlags(0),
+ g_cclosure_new(G_CALLBACK(OnGtkAccelerator),
+ this, NULL));
+}
+
void TaskManagerGtk::CreateTaskManagerTreeview() {
treeview_ = gtk_tree_view_new();
@@ -544,3 +561,20 @@ gboolean TaskManagerGtk::OnButtonReleaseEvent(GtkWidget* widget,
return FALSE;
}
+
+// static
+gboolean TaskManagerGtk::OnGtkAccelerator(GtkAccelGroup* accel_group,
+ GObject* acceleratable,
+ guint keyval,
+ GdkModifierType modifier,
+ TaskManagerGtk* task_manager) {
+ if (keyval == GDK_w && modifier == GDK_CONTROL_MASK) {
+ // The GTK_RESPONSE_DELETE_EVENT response must be sent before the widget
+ // is destroyed. The deleted object will receive gtk signals otherwise.
+ gtk_dialog_response(GTK_DIALOG(task_manager->dialog_),
+ GTK_RESPONSE_DELETE_EVENT);
+ gtk_widget_destroy(task_manager->dialog_);
+ }
+
+ return TRUE;
+}
diff --git a/chrome/browser/gtk/task_manager_gtk.h b/chrome/browser/gtk/task_manager_gtk.h
index e90ed18..6d4c366 100644
--- a/chrome/browser/gtk/task_manager_gtk.h
+++ b/chrome/browser/gtk/task_manager_gtk.h
@@ -33,6 +33,9 @@ class TaskManagerGtk : public TaskManagerModelObserver {
// Initializes the task manager dialog.
void Init();
+ // Connects the ctrl-w accelerator to the dialog.
+ void ConnectAccelerators();
+
// Sets up the treeview widget.
void CreateTaskManagerTreeview();
@@ -71,6 +74,13 @@ class TaskManagerGtk : public TaskManagerModelObserver {
static gboolean OnButtonReleaseEvent(GtkWidget* widget, GdkEventButton* event,
TaskManagerGtk* task_manager);
+ // Handles an accelerator being pressed.
+ static gboolean OnGtkAccelerator(GtkAccelGroup* accel_group,
+ GObject* acceleratable,
+ guint keyval,
+ GdkModifierType modifier,
+ TaskManagerGtk* task_manager);
+
// The task manager.
TaskManager* task_manager_;