Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(7)

Side by Side Diff: chrome/browser/ui/gtk/tabs/tab_gtk.cc

Issue 6933037: Multi-tab selection for Linux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing context menu commands Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/gtk/tabs/tab_gtk.h ('k') | chrome/browser/ui/gtk/tabs/tab_renderer_gtk.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ui/gtk/tabs/tab_gtk.h" 5 #include "chrome/browser/ui/gtk/tabs/tab_gtk.h"
6 6
7 #include <gdk/gdkkeysyms.h> 7 #include <gdk/gdkkeysyms.h>
8 8
9 #include "base/memory/singleton.h" 9 #include "base/memory/singleton.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 18 matching lines...) Expand all
29 return font->GetStringWidth(title); 29 return font->GetStringWidth(title);
30 } 30 }
31 31
32 } // namespace 32 } // namespace
33 33
34 class TabGtk::ContextMenuController : public ui::SimpleMenuModel::Delegate, 34 class TabGtk::ContextMenuController : public ui::SimpleMenuModel::Delegate,
35 public MenuGtk::Delegate { 35 public MenuGtk::Delegate {
36 public: 36 public:
37 explicit ContextMenuController(TabGtk* tab) 37 explicit ContextMenuController(TabGtk* tab)
38 : tab_(tab), 38 : tab_(tab),
39 model_(this, tab->delegate()->IsTabPinned(tab)) { 39 model_(this, tab->delegate()->model(),
40 tab->delegate()->GetIndexOfTab(const_cast<const TabGtk*>(tab))) {
dpapad 2011/05/10 16:28:14 This is the hacky part. In order to invoke the des
40 menu_.reset(new MenuGtk(this, &model_)); 41 menu_.reset(new MenuGtk(this, &model_));
41 } 42 }
42 43
43 virtual ~ContextMenuController() {} 44 virtual ~ContextMenuController() {}
44 45
45 void RunMenu(const gfx::Point& point, guint32 event_time) { 46 void RunMenu(const gfx::Point& point, guint32 event_time) {
46 menu_->PopupAsContext(point, event_time); 47 menu_->PopupAsContext(point, event_time);
47 } 48 }
48 49
49 void Cancel() { 50 void Cancel() {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 } 170 }
170 } 171 }
171 172
172 gboolean TabGtk::OnButtonPressEvent(GtkWidget* widget, GdkEventButton* event) { 173 gboolean TabGtk::OnButtonPressEvent(GtkWidget* widget, GdkEventButton* event) {
173 // Every button press ensures either a button-release-event or a drag-fail 174 // Every button press ensures either a button-release-event or a drag-fail
174 // signal for |widget|. 175 // signal for |widget|.
175 if (event->button == 1 && event->type == GDK_BUTTON_PRESS) { 176 if (event->button == 1 && event->type == GDK_BUTTON_PRESS) {
176 // Store whether or not we were selected just now... we only want to be 177 // Store whether or not we were selected just now... we only want to be
177 // able to drag foreground tabs, so we don't start dragging the tab if 178 // able to drag foreground tabs, so we don't start dragging the tab if
178 // it was in the background. 179 // it was in the background.
179 bool just_selected = !IsSelected(); 180 if (!IsActive() && (event->state & 5) == 0) {
180 if (just_selected) { 181 delegate_->ActivateTab(this);
181 delegate_->SelectTab(this); 182 } else if (!IsActive() && (event->state & 4) == 4) {
183 // TODO(dpapad)
184 NOTIMPLEMENTED() << " Multi tab selection ctrl click under construction";
185 delegate_->ToggleTabSelection(this);
186 } else if (!IsActive() && (event->state & 1) == 1) {
187 NOTIMPLEMENTED() << " Multi tab selection shift click under construction";
188 delegate_->ExtendTabSelection(this);
182 } 189 }
183
184 // Hook into the message loop to handle dragging. 190 // Hook into the message loop to handle dragging.
185 observer_.reset(new TabGtkObserverHelper(this)); 191 observer_.reset(new TabGtkObserverHelper(this));
186 192
187 // Store the button press event, used to initiate a drag. 193 // Store the button press event, used to initiate a drag.
188 last_mouse_down_ = gdk_event_copy(reinterpret_cast<GdkEvent*>(event)); 194 last_mouse_down_ = gdk_event_copy(reinterpret_cast<GdkEvent*>(event));
189 } else if (event->button == 3) { 195 } else if (event->button == 3) {
190 // Only show the context menu if the left mouse button isn't down (i.e., 196 // Only show the context menu if the left mouse button isn't down (i.e.,
191 // the user might want to drag instead). 197 // the user might want to drag instead).
192 if (!last_mouse_down_) { 198 if (!last_mouse_down_) {
193 menu_controller_.reset(new ContextMenuController(this)); 199 menu_controller_.reset(new ContextMenuController(this));
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 static_cast<gint>(new_x), static_cast<gint>(new_y))) { 292 static_cast<gint>(new_x), static_cast<gint>(new_y))) {
287 StartDragging(gfx::Point( 293 StartDragging(gfx::Point(
288 static_cast<int>(last_mouse_down_->button.x), 294 static_cast<int>(last_mouse_down_->button.x),
289 static_cast<int>(last_mouse_down_->button.y))); 295 static_cast<int>(last_mouse_down_->button.y)));
290 } 296 }
291 } 297 }
292 298
293 /////////////////////////////////////////////////////////////////////////////// 299 ///////////////////////////////////////////////////////////////////////////////
294 // TabGtk, TabRendererGtk overrides: 300 // TabGtk, TabRendererGtk overrides:
295 301
302 bool TabGtk::IsActive() const {
303 return delegate_->IsTabActive(this);
304 }
305
296 bool TabGtk::IsSelected() const { 306 bool TabGtk::IsSelected() const {
297 return delegate_->IsTabSelected(this); 307 return delegate_->IsTabSelected(this);
298 } 308 }
299 309
300 bool TabGtk::IsVisible() const { 310 bool TabGtk::IsVisible() const {
301 return GTK_WIDGET_FLAGS(event_box_) & GTK_VISIBLE; 311 return GTK_WIDGET_FLAGS(event_box_) & GTK_VISIBLE;
302 } 312 }
303 313
304 void TabGtk::SetVisible(bool visible) const { 314 void TabGtk::SetVisible(bool visible) const {
305 if (visible) { 315 if (visible) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 gdk_event_free(last_mouse_down_); 397 gdk_event_free(last_mouse_down_);
388 last_mouse_down_ = NULL; 398 last_mouse_down_ = NULL;
389 } 399 }
390 400
391 // Notify the drag helper that we're done with any potential drag operations. 401 // Notify the drag helper that we're done with any potential drag operations.
392 // Clean up the drag helper, which is re-created on the next mouse press. 402 // Clean up the drag helper, which is re-created on the next mouse press.
393 delegate_->EndDrag(canceled); 403 delegate_->EndDrag(canceled);
394 404
395 observer_.reset(); 405 observer_.reset();
396 } 406 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/tabs/tab_gtk.h ('k') | chrome/browser/ui/gtk/tabs/tab_renderer_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698