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

Side by Side Diff: chrome/browser/ui/gtk/notifications/balloon_view_gtk.cc

Issue 6273010: [linux] When the user has the notification options menu, delay system-initiat... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 11 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/notifications/balloon_view_gtk.h ('k') | no next file » | 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/notifications/balloon_view_gtk.h" 5 #include "chrome/browser/ui/gtk/notifications/balloon_view_gtk.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 const char* kLabelMarkup = "<span size=\"small\" color=\"%s\">%s</span>"; 95 const char* kLabelMarkup = "<span size=\"small\" color=\"%s\">%s</span>";
96 96
97 } // namespace 97 } // namespace
98 98
99 BalloonViewImpl::BalloonViewImpl(BalloonCollection* collection) 99 BalloonViewImpl::BalloonViewImpl(BalloonCollection* collection)
100 : balloon_(NULL), 100 : balloon_(NULL),
101 frame_container_(NULL), 101 frame_container_(NULL),
102 html_container_(NULL), 102 html_container_(NULL),
103 method_factory_(this), 103 method_factory_(this),
104 close_button_(NULL), 104 close_button_(NULL),
105 animation_(NULL) { 105 animation_(NULL),
106 menu_showing_(false),
107 pending_close_(false) {
106 } 108 }
107 109
108 BalloonViewImpl::~BalloonViewImpl() { 110 BalloonViewImpl::~BalloonViewImpl() {
109 } 111 }
110 112
111 void BalloonViewImpl::Close(bool by_user) { 113 void BalloonViewImpl::Close(bool by_user) {
112 MessageLoop::current()->PostTask(FROM_HERE, 114 // Delay a system-initiated close if the menu is showing.
113 method_factory_.NewRunnableMethod( 115 if (!by_user && menu_showing_) {
114 &BalloonViewImpl::DelayedClose, by_user)); 116 pending_close_ = true;
117 } else {
118 MessageLoop::current()->PostTask(
119 FROM_HERE,
120 method_factory_.NewRunnableMethod(
121 &BalloonViewImpl::DelayedClose, by_user));
122 }
115 } 123 }
116 124
117 gfx::Size BalloonViewImpl::GetSize() const { 125 gfx::Size BalloonViewImpl::GetSize() const {
118 // BalloonView has no size if it hasn't been shown yet (which is when 126 // BalloonView has no size if it hasn't been shown yet (which is when
119 // balloon_ is set). 127 // balloon_ is set).
120 if (!balloon_) 128 if (!balloon_)
121 return gfx::Size(); 129 return gfx::Size();
122 130
123 // Although this may not be the instantaneous size of the balloon if 131 // Although this may not be the instantaneous size of the balloon if
124 // called in the middle of an animation, it is the effective size that 132 // called in the middle of an animation, it is the effective size that
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 cairo_set_source_rgb(cr, kDividerLineColorR, 418 cairo_set_source_rgb(cr, kDividerLineColorR,
411 kDividerLineColorG, kDividerLineColorB); 419 kDividerLineColorG, kDividerLineColorB);
412 cairo_stroke(cr); 420 cairo_stroke(cr);
413 421
414 cairo_destroy(cr); 422 cairo_destroy(cr);
415 423
416 return FALSE; 424 return FALSE;
417 } 425 }
418 426
419 void BalloonViewImpl::OnOptionsMenuButton(GtkWidget* widget) { 427 void BalloonViewImpl::OnOptionsMenuButton(GtkWidget* widget) {
428 menu_showing_ = true;
420 options_menu_->PopupAsContext(gtk_get_current_event_time()); 429 options_menu_->PopupAsContext(gtk_get_current_event_time());
421 } 430 }
422 431
432 // Called when the menu stops showing.
433 void BalloonViewImpl::StoppedShowing() {
434 if (pending_close_)
435 DelayedClose(false);
436 menu_showing_ = false;
437 }
438
423 gboolean BalloonViewImpl::OnDestroy(GtkWidget* widget) { 439 gboolean BalloonViewImpl::OnDestroy(GtkWidget* widget) {
424 frame_container_ = NULL; 440 frame_container_ = NULL;
425 Close(false); 441 Close(false);
426 return FALSE; // Propagate. 442 return FALSE; // Propagate.
427 } 443 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/notifications/balloon_view_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698