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

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

Issue 14307023: chrome: Use base::MessageLoop. (Part 2) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 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_strip_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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/bind.h" 9 #include "base/bind.h"
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
(...skipping 24 matching lines...) Expand all
35 35
36 return font->GetStringWidth(title); 36 return font->GetStringWidth(title);
37 } 37 }
38 38
39 } // namespace 39 } // namespace
40 40
41 class TabGtk::TabGtkObserverHelper { 41 class TabGtk::TabGtkObserverHelper {
42 public: 42 public:
43 explicit TabGtkObserverHelper(TabGtk* tab) 43 explicit TabGtkObserverHelper(TabGtk* tab)
44 : tab_(tab) { 44 : tab_(tab) {
45 MessageLoopForUI::current()->AddObserver(tab_); 45 base::MessageLoopForUI::current()->AddObserver(tab_);
46 } 46 }
47 47
48 ~TabGtkObserverHelper() { 48 ~TabGtkObserverHelper() {
49 MessageLoopForUI::current()->RemoveObserver(tab_); 49 base::MessageLoopForUI::current()->RemoveObserver(tab_);
50 } 50 }
51 51
52 private: 52 private:
53 TabGtk* tab_; 53 TabGtk* tab_;
54 54
55 DISALLOW_COPY_AND_ASSIGN(TabGtkObserverHelper); 55 DISALLOW_COPY_AND_ASSIGN(TabGtkObserverHelper);
56 }; 56 };
57 57
58 /////////////////////////////////////////////////////////////////////////////// 58 ///////////////////////////////////////////////////////////////////////////////
59 // TabGtk, public: 59 // TabGtk, public:
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 return TRUE; 190 return TRUE;
191 } 191 }
192 192
193 gboolean TabGtk::OnDragButtonReleased(GtkWidget* widget, 193 gboolean TabGtk::OnDragButtonReleased(GtkWidget* widget,
194 GdkEventButton* button) { 194 GdkEventButton* button) {
195 // We always get this event when gtk is releasing the grab and ending the 195 // We always get this event when gtk is releasing the grab and ending the
196 // drag. However, if the user ended the drag with space or enter, we don't 196 // drag. However, if the user ended the drag with space or enter, we don't
197 // get a follow up event to tell us the drag has finished (either a 197 // get a follow up event to tell us the drag has finished (either a
198 // drag-failed or a drag-end). So we post a task to manually end the drag. 198 // drag-failed or a drag-end). So we post a task to manually end the drag.
199 // If GTK+ does send the drag-failed or drag-end event, we cancel the task. 199 // If GTK+ does send the drag-failed or drag-end event, we cancel the task.
200 MessageLoop::current()->PostTask( 200 base::MessageLoop::current()->PostTask(
201 FROM_HERE, 201 FROM_HERE,
202 base::Bind(&TabGtk::EndDrag, drag_end_factory_.GetWeakPtr(), false)); 202 base::Bind(&TabGtk::EndDrag, drag_end_factory_.GetWeakPtr(), false));
203 return TRUE; 203 return TRUE;
204 } 204 }
205 205
206 void TabGtk::OnDragBegin(GtkWidget* widget, GdkDragContext* context) { 206 void TabGtk::OnDragBegin(GtkWidget* widget, GdkDragContext* context) {
207 GdkPixbuf* pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 1, 1); 207 GdkPixbuf* pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, 1, 1);
208 gdk_pixbuf_fill(pixbuf, 0); 208 gdk_pixbuf_fill(pixbuf, 0);
209 gtk_drag_set_icon_pixbuf(context, pixbuf, 0, 0); 209 gtk_drag_set_icon_pixbuf(context, pixbuf, 0, 0);
210 g_object_unref(pixbuf); 210 g_object_unref(pixbuf);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 } 342 }
343 343
344 void TabGtk::EndDrag(bool canceled) { 344 void TabGtk::EndDrag(bool canceled) {
345 // Make sure we only run EndDrag once by canceling any tasks that want 345 // Make sure we only run EndDrag once by canceling any tasks that want
346 // to call EndDrag. 346 // to call EndDrag.
347 drag_end_factory_.InvalidateWeakPtrs(); 347 drag_end_factory_.InvalidateWeakPtrs();
348 348
349 // We must let gtk clean up after we handle the drag operation, otherwise 349 // We must let gtk clean up after we handle the drag operation, otherwise
350 // there will be outstanding references to the drag widget when we try to 350 // there will be outstanding references to the drag widget when we try to
351 // destroy it. 351 // destroy it.
352 MessageLoop::current()->PostTask( 352 base::MessageLoop::current()->PostTask(
353 FROM_HERE, 353 FROM_HERE,
354 base::Bind(&TabGtk::DestroyDragWidget, destroy_factory_.GetWeakPtr())); 354 base::Bind(&TabGtk::DestroyDragWidget, destroy_factory_.GetWeakPtr()));
355 355
356 if (last_mouse_down_) { 356 if (last_mouse_down_) {
357 gdk_event_free(last_mouse_down_); 357 gdk_event_free(last_mouse_down_);
358 last_mouse_down_ = NULL; 358 last_mouse_down_ = NULL;
359 } 359 }
360 360
361 // Notify the drag helper that we're done with any potential drag operations. 361 // Notify the drag helper that we're done with any potential drag operations.
362 // Clean up the drag helper, which is re-created on the next mouse press. 362 // Clean up the drag helper, which is re-created on the next mouse press.
363 delegate_->EndDrag(canceled); 363 delegate_->EndDrag(canceled);
364 364
365 observer_.reset(); 365 observer_.reset();
366 } 366 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/tabs/tab_gtk.h ('k') | chrome/browser/ui/gtk/tabs/tab_strip_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698