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 "app/text_elider.h" | |
12 #include "base/i18n/rtl.h" | 11 #include "base/i18n/rtl.h" |
13 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
14 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
15 #include "chrome/browser/ui/gtk/gtk_theme_provider.h" | 14 #include "chrome/browser/ui/gtk/gtk_theme_provider.h" |
16 #include "chrome/browser/ui/gtk/gtk_util.h" | 15 #include "chrome/browser/ui/gtk/gtk_util.h" |
17 #include "chrome/browser/ui/gtk/rounded_window.h" | 16 #include "chrome/browser/ui/gtk/rounded_window.h" |
18 #include "chrome/browser/ui/gtk/slide_animator_gtk.h" | 17 #include "chrome/browser/ui/gtk/slide_animator_gtk.h" |
19 #include "chrome/common/notification_service.h" | 18 #include "chrome/common/notification_service.h" |
20 #include "ui/base/animation/slide_animation.h" | 19 #include "ui/base/animation/slide_animation.h" |
| 20 #include "ui/base/text/text_elider.h" |
21 | 21 |
22 namespace { | 22 namespace { |
23 | 23 |
24 // Inner padding between the border and the text label. | 24 // Inner padding between the border and the text label. |
25 const int kInternalTopBottomPadding = 1; | 25 const int kInternalTopBottomPadding = 1; |
26 const int kInternalLeftRightPadding = 2; | 26 const int kInternalLeftRightPadding = 2; |
27 | 27 |
28 // The radius of the edges of our bubble. | 28 // The radius of the edges of our bubble. |
29 const int kCornerSize = 3; | 29 const int kCornerSize = 3; |
30 | 30 |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 if (!expanded()) { | 98 if (!expanded()) { |
99 expand_timer_.Stop(); | 99 expand_timer_.Stop(); |
100 expand_timer_.Start(base::TimeDelta::FromMilliseconds(kExpandHoverDelay), | 100 expand_timer_.Start(base::TimeDelta::FromMilliseconds(kExpandHoverDelay), |
101 this, &StatusBubbleGtk::ExpandURL); | 101 this, &StatusBubbleGtk::ExpandURL); |
102 // When not expanded, we limit the size to one third the browser's | 102 // When not expanded, we limit the size to one third the browser's |
103 // width. | 103 // width. |
104 desired_width /= 3; | 104 desired_width /= 3; |
105 } | 105 } |
106 | 106 |
107 // TODO(tc): We don't actually use gfx::Font as the font in the status | 107 // TODO(tc): We don't actually use gfx::Font as the font in the status |
108 // bubble. We should extend gfx::ElideUrl to take some sort of pango font. | 108 // bubble. We should extend ui::ElideUrl to take some sort of pango font. |
109 url_text_ = UTF16ToUTF8(gfx::ElideUrl(url_, gfx::Font(), desired_width, | 109 url_text_ = UTF16ToUTF8(ui::ElideUrl(url_, gfx::Font(), desired_width, |
110 UTF16ToWideHack(languages_))); | 110 UTF16ToWideHack(languages_))); |
111 SetStatusTextTo(url_text_); | 111 SetStatusTextTo(url_text_); |
112 } | 112 } |
113 | 113 |
114 void StatusBubbleGtk::Show() { | 114 void StatusBubbleGtk::Show() { |
115 // If we were going to hide, stop. | 115 // If we were going to hide, stop. |
116 hide_timer_.Stop(); | 116 hide_timer_.Stop(); |
117 | 117 |
118 gtk_widget_show_all(container_.get()); | 118 gtk_widget_show_all(container_.get()); |
119 if (container_->window) | 119 if (container_->window) |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
355 return FALSE; | 355 return FALSE; |
356 } | 356 } |
357 | 357 |
358 void StatusBubbleGtk::AnimationEnded(const ui::Animation* animation) { | 358 void StatusBubbleGtk::AnimationEnded(const ui::Animation* animation) { |
359 UpdateLabelSizeRequest(); | 359 UpdateLabelSizeRequest(); |
360 } | 360 } |
361 | 361 |
362 void StatusBubbleGtk::AnimationProgressed(const ui::Animation* animation) { | 362 void StatusBubbleGtk::AnimationProgressed(const ui::Animation* animation) { |
363 UpdateLabelSizeRequest(); | 363 UpdateLabelSizeRequest(); |
364 } | 364 } |
OLD | NEW |