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