OLD | NEW |
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/status_bubble_gtk.h" | 5 #include "chrome/browser/ui/gtk/status_bubble_gtk.h" |
6 | 6 |
7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 | 10 |
11 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 14 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
15 #include "chrome/browser/ui/gtk/gtk_util.h" | 15 #include "chrome/browser/ui/gtk/gtk_util.h" |
16 #include "chrome/browser/ui/gtk/rounded_window.h" | 16 #include "chrome/browser/ui/gtk/rounded_window.h" |
17 #include "chrome/browser/ui/gtk/slide_animator_gtk.h" | 17 #include "chrome/browser/ui/gtk/slide_animator_gtk.h" |
18 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
19 #include "content/common/notification_service.h" | 19 #include "content/common/notification_service.h" |
20 #include "ui/base/animation/slide_animation.h" | 20 #include "ui/base/animation/slide_animation.h" |
| 21 #include "ui/base/gtk/gtk_hig_constants.h" |
21 #include "ui/base/text/text_elider.h" | 22 #include "ui/base/text/text_elider.h" |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
25 // Inner padding between the border and the text label. | 26 // Inner padding between the border and the text label. |
26 const int kInternalTopBottomPadding = 1; | 27 const int kInternalTopBottomPadding = 1; |
27 const int kInternalLeftRightPadding = 2; | 28 const int kInternalLeftRightPadding = 2; |
28 | 29 |
29 // The radius of the edges of our bubble. | 30 // The radius of the edges of our bubble. |
30 const int kCornerSize = 3; | 31 const int kCornerSize = 3; |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 gtk_alignment_set_padding(GTK_ALIGNMENT(padding_), | 253 gtk_alignment_set_padding(GTK_ALIGNMENT(padding_), |
253 kInternalTopBottomPadding, kInternalTopBottomPadding, | 254 kInternalTopBottomPadding, kInternalTopBottomPadding, |
254 kInternalLeftRightPadding + (ltr ? 0 : kCornerSize), | 255 kInternalLeftRightPadding + (ltr ? 0 : kCornerSize), |
255 kInternalLeftRightPadding + (ltr ? kCornerSize : 0)); | 256 kInternalLeftRightPadding + (ltr ? kCornerSize : 0)); |
256 gtk_container_add(GTK_CONTAINER(padding_), label_.get()); | 257 gtk_container_add(GTK_CONTAINER(padding_), label_.get()); |
257 gtk_widget_show_all(padding_); | 258 gtk_widget_show_all(padding_); |
258 | 259 |
259 container_.Own(gtk_event_box_new()); | 260 container_.Own(gtk_event_box_new()); |
260 gtk_widget_set_no_show_all(container_.get(), TRUE); | 261 gtk_widget_set_no_show_all(container_.get(), TRUE); |
261 gtk_util::ActAsRoundedWindow( | 262 gtk_util::ActAsRoundedWindow( |
262 container_.get(), gtk_util::kGdkWhite, kCornerSize, | 263 container_.get(), ui::kGdkWhite, kCornerSize, |
263 gtk_util::ROUNDED_TOP_RIGHT, | 264 gtk_util::ROUNDED_TOP_RIGHT, |
264 gtk_util::BORDER_TOP | gtk_util::BORDER_RIGHT); | 265 gtk_util::BORDER_TOP | gtk_util::BORDER_RIGHT); |
265 gtk_widget_set_name(container_.get(), "status-bubble"); | 266 gtk_widget_set_name(container_.get(), "status-bubble"); |
266 gtk_container_add(GTK_CONTAINER(container_.get()), padding_); | 267 gtk_container_add(GTK_CONTAINER(container_.get()), padding_); |
267 | 268 |
268 // We need to listen for mouse motion events, since a fast-moving pointer may | 269 // We need to listen for mouse motion events, since a fast-moving pointer may |
269 // enter our window without us getting any motion events on the browser near | 270 // enter our window without us getting any motion events on the browser near |
270 // enough for us to run away. | 271 // enough for us to run away. |
271 gtk_widget_add_events(container_.get(), GDK_POINTER_MOTION_MASK | | 272 gtk_widget_add_events(container_.get(), GDK_POINTER_MOTION_MASK | |
272 GDK_ENTER_NOTIFY_MASK); | 273 GDK_ENTER_NOTIFY_MASK); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 return FALSE; | 359 return FALSE; |
359 } | 360 } |
360 | 361 |
361 void StatusBubbleGtk::AnimationEnded(const ui::Animation* animation) { | 362 void StatusBubbleGtk::AnimationEnded(const ui::Animation* animation) { |
362 UpdateLabelSizeRequest(); | 363 UpdateLabelSizeRequest(); |
363 } | 364 } |
364 | 365 |
365 void StatusBubbleGtk::AnimationProgressed(const ui::Animation* animation) { | 366 void StatusBubbleGtk::AnimationProgressed(const ui::Animation* animation) { |
366 UpdateLabelSizeRequest(); | 367 UpdateLabelSizeRequest(); |
367 } | 368 } |
OLD | NEW |