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