diff options
author | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-09 19:30:24 +0000 |
---|---|---|
committer | jhawkins@chromium.org <jhawkins@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-09 19:30:24 +0000 |
commit | f89570a7e67d69f066ffd8fdcc40ef48864c5359 (patch) | |
tree | e2397eebec0289dc1dbe3e664c520fac1321aa5b | |
parent | 0f605396ab522e1f2f48824c42bb784e9784d479 (diff) | |
download | chromium_src-f89570a7e67d69f066ffd8fdcc40ef48864c5359.zip chromium_src-f89570a7e67d69f066ffd8fdcc40ef48864c5359.tar.gz chromium_src-f89570a7e67d69f066ffd8fdcc40ef48864c5359.tar.bz2 |
Scroll-wheeling, whilst over the tab-strip, now switches tabs on GTK/Linux.
TEST=none
BUG=1316
Review URL: http://codereview.chromium.org/155053
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20297 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | chrome/browser/gtk/browser_titlebar.cc | 33 | ||||
-rw-r--r-- | chrome/browser/gtk/browser_titlebar.h | 4 |
2 files changed, 32 insertions, 5 deletions
diff --git a/chrome/browser/gtk/browser_titlebar.cc b/chrome/browser/gtk/browser_titlebar.cc index 2448cae..174179d 100644 --- a/chrome/browser/gtk/browser_titlebar.cc +++ b/chrome/browser/gtk/browser_titlebar.cc @@ -10,6 +10,7 @@ #include "app/resource_bundle.h" #include "app/l10n_util.h" +#include "base/gfx/gtk_util.h" #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/browser.h" #include "chrome/browser/gtk/browser_window_gtk.h" @@ -76,7 +77,8 @@ BrowserTitlebar::BrowserTitlebar(BrowserWindowGtk* browser_window, void BrowserTitlebar::Init() { // The widget hierarchy is shown below. // - // +- HBox (container_) -----------------------------------------------------+ + // +- EventBox (container_) -------------------------------------------------+ + // +- HBox (container_hbox) -------------------------------------------------+ // |+- Algn. -++- Alignment --------------++- VBox (titlebar_buttons_box_) -+| // ||+ Image +|| (titlebar_alignment_) ||+- HBox -----------------------+|| // |||spy_guy||| |||+- button -++- button -+ ||| @@ -85,7 +87,14 @@ void BrowserTitlebar::Init() { // ||+-------+||+------------------------+||+------------------------------+|| // |+---------++--------------------------++--------------------------------+| // +-------------------------------------------------------------------------+ - container_ = gtk_hbox_new(FALSE, 0); + GtkWidget* container_hbox = gtk_hbox_new(FALSE, 0); + + container_ = gtk_event_box_new(); + gtk_event_box_set_visible_window(GTK_EVENT_BOX(container_), FALSE); + gtk_container_add(GTK_CONTAINER(container_), container_hbox); + + g_signal_connect(G_OBJECT(container_), "scroll-event", + G_CALLBACK(OnScroll), this); g_signal_connect(window_, "window-state-event", G_CALLBACK(OnWindowStateChanged), this); @@ -100,12 +109,12 @@ void BrowserTitlebar::Init() { kOTRBottomSpacing, kOTRSideSpacing, kOTRSideSpacing); gtk_widget_set_size_request(spy_guy, -1, 0); gtk_container_add(GTK_CONTAINER(spy_frame), spy_guy); - gtk_box_pack_start(GTK_BOX(container_), spy_frame, FALSE, FALSE, 0); + gtk_box_pack_start(GTK_BOX(container_hbox), spy_frame, FALSE, FALSE, 0); } // We use an alignment to control the titlebar height. titlebar_alignment_ = gtk_alignment_new(0.0, 0.0, 1.0, 1.0); - gtk_box_pack_start(GTK_BOX(container_), titlebar_alignment_, TRUE, + gtk_box_pack_start(GTK_BOX(container_hbox), titlebar_alignment_, TRUE, TRUE, 0); // Put the tab strip in the titlebar. @@ -135,7 +144,7 @@ void BrowserTitlebar::Init() { gtk_widget_size_request(close_button_->widget(), &req); close_button_default_width_ = req.width; - gtk_box_pack_end(GTK_BOX(container_), titlebar_buttons_box_, FALSE, + gtk_box_pack_end(GTK_BOX(container_hbox), titlebar_buttons_box_, FALSE, FALSE, 0); gtk_widget_show_all(container_); @@ -196,6 +205,20 @@ gboolean BrowserTitlebar::OnWindowStateChanged(GtkWindow* window, } // static +gboolean BrowserTitlebar::OnScroll(GtkWidget* widget, GdkEventScroll* event, + BrowserTitlebar* titlebar) { + TabStripModel* tabstrip_model = + titlebar->browser_window_->browser()->tabstrip_model(); + if (event->direction == GDK_SCROLL_LEFT || + event->direction == GDK_SCROLL_UP) { + tabstrip_model->SelectPreviousTab(); + } else { + tabstrip_model->SelectNextTab(); + } + return TRUE; +} + +// static void BrowserTitlebar::OnButtonClicked(GtkWidget* button, BrowserTitlebar* titlebar) { if (titlebar->close_button_->widget() == button) { diff --git a/chrome/browser/gtk/browser_titlebar.h b/chrome/browser/gtk/browser_titlebar.h index 3a88f80..4eadcaf 100644 --- a/chrome/browser/gtk/browser_titlebar.h +++ b/chrome/browser/gtk/browser_titlebar.h @@ -59,6 +59,10 @@ class BrowserTitlebar : public MenuGtk::Delegate { GdkEventWindowState* event, BrowserTitlebar* titlebar); + // Callback for mousewheel events. + static gboolean OnScroll(GtkWidget* widget, GdkEventScroll* event, + BrowserTitlebar* titlebar); + // Callback for min/max/close buttons. static void OnButtonClicked(GtkWidget* button, BrowserTitlebar* window); |