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 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 | 66 |
67 status_text_ = status_text; | 67 status_text_ = status_text; |
68 if (!status_text_.empty()) | 68 if (!status_text_.empty()) |
69 SetStatusTextTo(status_text_); | 69 SetStatusTextTo(status_text_); |
70 else if (!url_text_.empty()) | 70 else if (!url_text_.empty()) |
71 SetStatusTextTo(url_text_); | 71 SetStatusTextTo(url_text_); |
72 else | 72 else |
73 SetStatusTextTo(std::string()); | 73 SetStatusTextTo(std::string()); |
74 } | 74 } |
75 | 75 |
76 void StatusBubbleGtk::SetURL(const GURL& url, const string16& languages) { | 76 void StatusBubbleGtk::SetURL(const GURL& url, const std::string& languages) { |
77 url_ = url; | 77 url_ = url; |
78 languages_ = languages; | 78 languages_ = languages; |
79 | 79 |
80 // If we want to clear a displayed URL but there is a status still to | 80 // If we want to clear a displayed URL but there is a status still to |
81 // display, display that status instead. | 81 // display, display that status instead. |
82 if (url.is_empty() && !status_text_.empty()) { | 82 if (url.is_empty() && !status_text_.empty()) { |
83 url_text_ = std::string(); | 83 url_text_ = std::string(); |
84 SetStatusTextTo(status_text_); | 84 SetStatusTextTo(status_text_); |
85 return; | 85 return; |
86 } | 86 } |
(...skipping 13 matching lines...) Expand all Loading... |
100 expand_timer_.Stop(); | 100 expand_timer_.Stop(); |
101 expand_timer_.Start(base::TimeDelta::FromMilliseconds(kExpandHoverDelay), | 101 expand_timer_.Start(base::TimeDelta::FromMilliseconds(kExpandHoverDelay), |
102 this, &StatusBubbleGtk::ExpandURL); | 102 this, &StatusBubbleGtk::ExpandURL); |
103 // When not expanded, we limit the size to one third the browser's | 103 // When not expanded, we limit the size to one third the browser's |
104 // width. | 104 // width. |
105 desired_width /= 3; | 105 desired_width /= 3; |
106 } | 106 } |
107 | 107 |
108 // TODO(tc): We don't actually use gfx::Font as the font in the status | 108 // TODO(tc): We don't actually use gfx::Font as the font in the status |
109 // bubble. We should extend ui::ElideUrl to take some sort of pango font. | 109 // bubble. We should extend ui::ElideUrl to take some sort of pango font. |
110 url_text_ = UTF16ToUTF8(ui::ElideUrl(url_, gfx::Font(), desired_width, | 110 url_text_ = UTF16ToUTF8( |
111 UTF16ToUTF8(languages_))); | 111 ui::ElideUrl(url_, gfx::Font(), desired_width, languages_)); |
112 SetStatusTextTo(url_text_); | 112 SetStatusTextTo(url_text_); |
113 } | 113 } |
114 | 114 |
115 void StatusBubbleGtk::Show() { | 115 void StatusBubbleGtk::Show() { |
116 // If we were going to hide, stop. | 116 // If we were going to hide, stop. |
117 hide_timer_.Stop(); | 117 hide_timer_.Stop(); |
118 | 118 |
119 gtk_widget_show(container_.get()); | 119 gtk_widget_show(container_.get()); |
120 if (container_->window) | 120 if (container_->window) |
121 gdk_window_raise(container_->window); | 121 gdk_window_raise(container_->window); |
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 return FALSE; | 358 return FALSE; |
359 } | 359 } |
360 | 360 |
361 void StatusBubbleGtk::AnimationEnded(const ui::Animation* animation) { | 361 void StatusBubbleGtk::AnimationEnded(const ui::Animation* animation) { |
362 UpdateLabelSizeRequest(); | 362 UpdateLabelSizeRequest(); |
363 } | 363 } |
364 | 364 |
365 void StatusBubbleGtk::AnimationProgressed(const ui::Animation* animation) { | 365 void StatusBubbleGtk::AnimationProgressed(const ui::Animation* animation) { |
366 UpdateLabelSizeRequest(); | 366 UpdateLabelSizeRequest(); |
367 } | 367 } |
OLD | NEW |