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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 void StatusBubbleGtk::SetStatusTextToURL() { | 92 void StatusBubbleGtk::SetStatusTextToURL() { |
93 GtkWidget* parent = gtk_widget_get_parent(container_.get()); | 93 GtkWidget* parent = gtk_widget_get_parent(container_.get()); |
94 | 94 |
95 // It appears that parent can be NULL (probably only during shutdown). | 95 // It appears that parent can be NULL (probably only during shutdown). |
96 if (!parent || !GTK_WIDGET_REALIZED(parent)) | 96 if (!parent || !GTK_WIDGET_REALIZED(parent)) |
97 return; | 97 return; |
98 | 98 |
99 int desired_width = parent->allocation.width; | 99 int desired_width = parent->allocation.width; |
100 if (!expanded()) { | 100 if (!expanded()) { |
101 expand_timer_.Stop(); | 101 expand_timer_.Stop(); |
102 expand_timer_.Start(base::TimeDelta::FromMilliseconds(kExpandHoverDelay), | 102 expand_timer_.Start(FROM_HERE, |
| 103 base::TimeDelta::FromMilliseconds(kExpandHoverDelay), |
103 this, &StatusBubbleGtk::ExpandURL); | 104 this, &StatusBubbleGtk::ExpandURL); |
104 // When not expanded, we limit the size to one third the browser's | 105 // When not expanded, we limit the size to one third the browser's |
105 // width. | 106 // width. |
106 desired_width /= 3; | 107 desired_width /= 3; |
107 } | 108 } |
108 | 109 |
109 // TODO(tc): We don't actually use gfx::Font as the font in the status | 110 // TODO(tc): We don't actually use gfx::Font as the font in the status |
110 // bubble. We should extend ui::ElideUrl to take some sort of pango font. | 111 // bubble. We should extend ui::ElideUrl to take some sort of pango font. |
111 url_text_ = UTF16ToUTF8( | 112 url_text_ = UTF16ToUTF8( |
112 ui::ElideUrl(url_, gfx::Font(), desired_width, languages_)); | 113 ui::ElideUrl(url_, gfx::Font(), desired_width, languages_)); |
(...skipping 13 matching lines...) Expand all Loading... |
126 // If we were going to expand the bubble, stop. | 127 // If we were going to expand the bubble, stop. |
127 expand_timer_.Stop(); | 128 expand_timer_.Stop(); |
128 expand_animation_.reset(); | 129 expand_animation_.reset(); |
129 | 130 |
130 gtk_widget_hide(container_.get()); | 131 gtk_widget_hide(container_.get()); |
131 } | 132 } |
132 | 133 |
133 void StatusBubbleGtk::SetStatusTextTo(const std::string& status_utf8) { | 134 void StatusBubbleGtk::SetStatusTextTo(const std::string& status_utf8) { |
134 if (status_utf8.empty()) { | 135 if (status_utf8.empty()) { |
135 hide_timer_.Stop(); | 136 hide_timer_.Stop(); |
136 hide_timer_.Start(base::TimeDelta::FromMilliseconds(kHideDelay), | 137 hide_timer_.Start(FROM_HERE, base::TimeDelta::FromMilliseconds(kHideDelay), |
137 this, &StatusBubbleGtk::Hide); | 138 this, &StatusBubbleGtk::Hide); |
138 } else { | 139 } else { |
139 gtk_label_set_text(GTK_LABEL(label_.get()), status_utf8.c_str()); | 140 gtk_label_set_text(GTK_LABEL(label_.get()), status_utf8.c_str()); |
140 GtkRequisition req; | 141 GtkRequisition req; |
141 gtk_widget_size_request(label_.get(), &req); | 142 gtk_widget_size_request(label_.get(), &req); |
142 desired_width_ = req.width; | 143 desired_width_ = req.width; |
143 | 144 |
144 UpdateLabelSizeRequest(); | 145 UpdateLabelSizeRequest(); |
145 | 146 |
146 if (!last_mouse_left_content_) { | 147 if (!last_mouse_left_content_) { |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
359 return FALSE; | 360 return FALSE; |
360 } | 361 } |
361 | 362 |
362 void StatusBubbleGtk::AnimationEnded(const ui::Animation* animation) { | 363 void StatusBubbleGtk::AnimationEnded(const ui::Animation* animation) { |
363 UpdateLabelSizeRequest(); | 364 UpdateLabelSizeRequest(); |
364 } | 365 } |
365 | 366 |
366 void StatusBubbleGtk::AnimationProgressed(const ui::Animation* animation) { | 367 void StatusBubbleGtk::AnimationProgressed(const ui::Animation* animation) { |
367 UpdateLabelSizeRequest(); | 368 UpdateLabelSizeRequest(); |
368 } | 369 } |
OLD | NEW |