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 "content/common/notification_service.h" | 19 #include "content/common/notification_service.h" |
19 #include "ui/base/animation/slide_animation.h" | 20 #include "ui/base/animation/slide_animation.h" |
20 #include "ui/base/text/text_elider.h" | 21 #include "ui/base/text/text_elider.h" |
21 | 22 |
22 namespace { | 23 namespace { |
23 | 24 |
24 // Inner padding between the border and the text label. | 25 // Inner padding between the border and the text label. |
25 const int kInternalTopBottomPadding = 1; | 26 const int kInternalTopBottomPadding = 1; |
26 const int kInternalLeftRightPadding = 2; | 27 const int kInternalLeftRightPadding = 2; |
27 | 28 |
(...skipping 14 matching lines...) Expand all Loading... |
42 padding_(NULL), | 43 padding_(NULL), |
43 flip_horizontally_(false), | 44 flip_horizontally_(false), |
44 y_offset_(0), | 45 y_offset_(0), |
45 download_shelf_is_visible_(false), | 46 download_shelf_is_visible_(false), |
46 last_mouse_location_(0, 0), | 47 last_mouse_location_(0, 0), |
47 last_mouse_left_content_(false), | 48 last_mouse_left_content_(false), |
48 ignore_next_left_content_(false) { | 49 ignore_next_left_content_(false) { |
49 InitWidgets(); | 50 InitWidgets(); |
50 | 51 |
51 theme_service_->InitThemesFor(this); | 52 theme_service_->InitThemesFor(this); |
52 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED, | 53 registrar_.Add(this, chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
53 Source<ThemeService>(theme_service_)); | 54 Source<ThemeService>(theme_service_)); |
54 } | 55 } |
55 | 56 |
56 StatusBubbleGtk::~StatusBubbleGtk() { | 57 StatusBubbleGtk::~StatusBubbleGtk() { |
57 label_.Destroy(); | 58 label_.Destroy(); |
58 container_.Destroy(); | 59 container_.Destroy(); |
59 } | 60 } |
60 | 61 |
61 void StatusBubbleGtk::SetStatus(const string16& status_text_wide) { | 62 void StatusBubbleGtk::SetStatus(const string16& status_text_wide) { |
62 std::string status_text = UTF16ToUTF8(status_text_wide); | 63 std::string status_text = UTF16ToUTF8(status_text_wide); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 } | 228 } |
228 | 229 |
229 if (y_offset_ != old_y_offset || flip_horizontally_ != old_flip_horizontally) | 230 if (y_offset_ != old_y_offset || flip_horizontally_ != old_flip_horizontally) |
230 gtk_widget_queue_resize_no_redraw(parent); | 231 gtk_widget_queue_resize_no_redraw(parent); |
231 } | 232 } |
232 | 233 |
233 void StatusBubbleGtk::UpdateDownloadShelfVisibility(bool visible) { | 234 void StatusBubbleGtk::UpdateDownloadShelfVisibility(bool visible) { |
234 download_shelf_is_visible_ = visible; | 235 download_shelf_is_visible_ = visible; |
235 } | 236 } |
236 | 237 |
237 void StatusBubbleGtk::Observe(NotificationType type, | 238 void StatusBubbleGtk::Observe(int type, |
238 const NotificationSource& source, | 239 const NotificationSource& source, |
239 const NotificationDetails& details) { | 240 const NotificationDetails& details) { |
240 if (type == NotificationType::BROWSER_THEME_CHANGED) { | 241 if (type == chrome::NOTIFICATION_BROWSER_THEME_CHANGED) { |
241 UserChangedTheme(); | 242 UserChangedTheme(); |
242 } | 243 } |
243 } | 244 } |
244 | 245 |
245 void StatusBubbleGtk::InitWidgets() { | 246 void StatusBubbleGtk::InitWidgets() { |
246 bool ltr = !base::i18n::IsRTL(); | 247 bool ltr = !base::i18n::IsRTL(); |
247 | 248 |
248 label_.Own(gtk_label_new(NULL)); | 249 label_.Own(gtk_label_new(NULL)); |
249 | 250 |
250 padding_ = gtk_alignment_new(0, 0, 1, 1); | 251 padding_ = gtk_alignment_new(0, 0, 1, 1); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 return FALSE; | 358 return FALSE; |
358 } | 359 } |
359 | 360 |
360 void StatusBubbleGtk::AnimationEnded(const ui::Animation* animation) { | 361 void StatusBubbleGtk::AnimationEnded(const ui::Animation* animation) { |
361 UpdateLabelSizeRequest(); | 362 UpdateLabelSizeRequest(); |
362 } | 363 } |
363 | 364 |
364 void StatusBubbleGtk::AnimationProgressed(const ui::Animation* animation) { | 365 void StatusBubbleGtk::AnimationProgressed(const ui::Animation* animation) { |
365 UpdateLabelSizeRequest(); | 366 UpdateLabelSizeRequest(); |
366 } | 367 } |
OLD | NEW |