summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-14 18:22:52 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-14 18:22:52 +0000
commit9ac7fcb5fdf8aa1c31e0c7665e567e59255235e8 (patch)
treea4ee969197fc84a3b92bd79dc41fd2df2d140f45 /chrome/browser
parent288bfcd3e84eb6747f697578e13b1ad4c81fd727 (diff)
downloadchromium_src-9ac7fcb5fdf8aa1c31e0c7665e567e59255235e8.zip
chromium_src-9ac7fcb5fdf8aa1c31e0c7665e567e59255235e8.tar.gz
chromium_src-9ac7fcb5fdf8aa1c31e0c7665e567e59255235e8.tar.bz2
Add keyboard shortcuts to reorder tabs left or right on Linux.
It's standard in GTK+ for tabbed interfaces to be reorderable using ctrl+shift+pgup and ctrl+shift+pgdn (e.g., in Terminal). The plumbing is included on all platforms, but the shortcut is only hooked up on Linux. BUG=21594 Review URL: http://codereview.chromium.org/194088 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26125 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/browser.cc14
-rw-r--r--chrome/browser/browser.h2
-rw-r--r--chrome/browser/gtk/browser_window_gtk.cc11
-rw-r--r--chrome/browser/tabs/tab_strip_model.cc10
-rw-r--r--chrome/browser/tabs/tab_strip_model.h4
5 files changed, 41 insertions, 0 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index e0b5336..981f8fd 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -877,6 +877,16 @@ void Browser::SelectPreviousTab() {
tabstrip_model_.SelectPreviousTab();
}
+void Browser::MoveTabNext() {
+ UserMetrics::RecordAction(L"MoveTabNext", profile_);
+ tabstrip_model_.MoveTabNext();
+}
+
+void Browser::MoveTabPrevious() {
+ UserMetrics::RecordAction(L"MoveTabPrevious", profile_);
+ tabstrip_model_.MoveTabPrevious();
+}
+
void Browser::SelectNumberedTab(int index) {
if (index < tab_count()) {
UserMetrics::RecordAction(L"SelectNumberedTab", profile_);
@@ -1365,6 +1375,8 @@ void Browser::ExecuteCommandWithDisposition(
case IDC_CLOSE_TAB: CloseTab(); break;
case IDC_SELECT_NEXT_TAB: SelectNextTab(); break;
case IDC_SELECT_PREVIOUS_TAB: SelectPreviousTab(); break;
+ case IDC_MOVE_TAB_NEXT: MoveTabNext(); break;
+ case IDC_MOVE_TAB_PREVIOUS: MoveTabPrevious(); break;
case IDC_SELECT_TAB_0:
case IDC_SELECT_TAB_1:
case IDC_SELECT_TAB_2:
@@ -2320,6 +2332,8 @@ void Browser::InitCommandState() {
command_updater_.UpdateCommandEnabled(IDC_SELECT_NEXT_TAB, normal_window);
command_updater_.UpdateCommandEnabled(IDC_SELECT_PREVIOUS_TAB,
normal_window);
+ command_updater_.UpdateCommandEnabled(IDC_MOVE_TAB_NEXT, normal_window);
+ command_updater_.UpdateCommandEnabled(IDC_MOVE_TAB_PREVIOUS, normal_window);
command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_0, normal_window);
command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_1, normal_window);
command_updater_.UpdateCommandEnabled(IDC_SELECT_TAB_2, normal_window);
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h
index fd2982f..5635c23 100644
--- a/chrome/browser/browser.h
+++ b/chrome/browser/browser.h
@@ -319,6 +319,8 @@ class Browser : public TabStripModelDelegate,
void CloseTab();
void SelectNextTab();
void SelectPreviousTab();
+ void MoveTabNext();
+ void MoveTabPrevious();
void SelectNumberedTab(int index);
void SelectLastTab();
void DuplicateTab();
diff --git a/chrome/browser/gtk/browser_window_gtk.cc b/chrome/browser/gtk/browser_window_gtk.cc
index 72e0123..a091294 100644
--- a/chrome/browser/gtk/browser_window_gtk.cc
+++ b/chrome/browser/gtk/browser_window_gtk.cc
@@ -198,6 +198,11 @@ const struct AcceleratorMapping {
// Tab/window controls.
{ GDK_Page_Down, IDC_SELECT_NEXT_TAB, GDK_CONTROL_MASK },
{ GDK_Page_Up, IDC_SELECT_PREVIOUS_TAB, GDK_CONTROL_MASK },
+ { GDK_Page_Down, IDC_MOVE_TAB_NEXT,
+ GdkModifierType(GDK_CONTROL_MASK | GDK_SHIFT_MASK) },
+ { GDK_Page_Up, IDC_MOVE_TAB_PREVIOUS,
+ GdkModifierType(GDK_CONTROL_MASK | GDK_SHIFT_MASK) },
+ { GDK_Page_Up, IDC_SELECT_PREVIOUS_TAB, GDK_CONTROL_MASK },
{ GDK_w, IDC_CLOSE_TAB, GDK_CONTROL_MASK },
{ GDK_t, IDC_RESTORE_TAB,
GdkModifierType(GDK_CONTROL_MASK | GDK_SHIFT_MASK) },
@@ -446,6 +451,9 @@ gboolean PreHandleAccelerator(guint keyval, GdkModifierType modifier,
if (GDK_CONTROL_MASK == modifier) {
browser->ExecuteCommand(IDC_SELECT_NEXT_TAB);
return TRUE;
+ } else if ((GDK_CONTROL_MASK | GDK_SHIFT_MASK) == modifier) {
+ browser->ExecuteCommand(IDC_MOVE_TAB_NEXT);
+ return TRUE;
}
break;
@@ -453,6 +461,9 @@ gboolean PreHandleAccelerator(guint keyval, GdkModifierType modifier,
if (GDK_CONTROL_MASK == modifier) {
browser->ExecuteCommand(IDC_SELECT_PREVIOUS_TAB);
return TRUE;
+ } else if ((GDK_CONTROL_MASK | GDK_SHIFT_MASK) == modifier) {
+ browser->ExecuteCommand(IDC_MOVE_TAB_PREVIOUS);
+ return TRUE;
}
break;
diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc
index a10c9fe..baca9b0 100644
--- a/chrome/browser/tabs/tab_strip_model.cc
+++ b/chrome/browser/tabs/tab_strip_model.cc
@@ -433,6 +433,16 @@ void TabStripModel::SelectLastTab() {
SelectTabContentsAt(count() - 1, true);
}
+void TabStripModel::MoveTabNext() {
+ int new_index = std::min(selected_index_ + 1, count() - 1);
+ MoveTabContentsAt(selected_index_, new_index, true);
+}
+
+void TabStripModel::MoveTabPrevious() {
+ int new_index = std::max(selected_index_ - 1, 0);
+ MoveTabContentsAt(selected_index_, new_index, true);
+}
+
Browser* TabStripModel::TearOffTabContents(TabContents* detached_contents,
const gfx::Rect& window_bounds,
const DockInfo& dock_info) {
diff --git a/chrome/browser/tabs/tab_strip_model.h b/chrome/browser/tabs/tab_strip_model.h
index 4f1d44b..b75a9f86 100644
--- a/chrome/browser/tabs/tab_strip_model.h
+++ b/chrome/browser/tabs/tab_strip_model.h
@@ -438,6 +438,10 @@ class TabStripModel : public NotificationObserver {
// Selects the last tab in the tab strip.
void SelectLastTab();
+ // Swap adjacent tabs.
+ void MoveTabNext();
+ void MoveTabPrevious();
+
// View API //////////////////////////////////////////////////////////////////
// The specified contents should be opened in a new tabstrip. Returns the