| 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/theme_install_bubble_view_gtk.h" | 5 #include "chrome/browser/ui/gtk/theme_install_bubble_view_gtk.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include "chrome/browser/ui/gtk/gtk_util.h" | 9 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 10 #include "chrome/browser/ui/gtk/rounded_window.h" | 10 #include "chrome/browser/ui/gtk/rounded_window.h" |
| 11 #include "chrome/common/chrome_notification_types.h" |
| 11 #include "content/common/notification_service.h" | 12 #include "content/common/notification_service.h" |
| 12 #include "content/common/notification_type.h" | |
| 13 #include "grit/generated_resources.h" | 13 #include "grit/generated_resources.h" |
| 14 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
| 15 | 15 |
| 16 // Roundedness of bubble. | 16 // Roundedness of bubble. |
| 17 static const int kBubbleCornerRadius = 4; | 17 static const int kBubbleCornerRadius = 4; |
| 18 | 18 |
| 19 // Padding between border of bubble and text. | 19 // Padding between border of bubble and text. |
| 20 static const int kTextPadding = 8; | 20 static const int kTextPadding = 8; |
| 21 | 21 |
| 22 // The bubble is partially transparent. | 22 // The bubble is partially transparent. |
| 23 static const double kBubbleOpacity = static_cast<double>(0xcc) / 0xff; | 23 static const double kBubbleOpacity = static_cast<double>(0xcc) / 0xff; |
| 24 | 24 |
| 25 ThemeInstallBubbleViewGtk* ThemeInstallBubbleViewGtk::instance_ = NULL; | 25 ThemeInstallBubbleViewGtk* ThemeInstallBubbleViewGtk::instance_ = NULL; |
| 26 | 26 |
| 27 // ThemeInstallBubbleViewGtk, public ------------------------------------------- | 27 // ThemeInstallBubbleViewGtk, public ------------------------------------------- |
| 28 | 28 |
| 29 // static | 29 // static |
| 30 void ThemeInstallBubbleViewGtk::Show(GtkWindow* parent) { | 30 void ThemeInstallBubbleViewGtk::Show(GtkWindow* parent) { |
| 31 if (instance_) | 31 if (instance_) |
| 32 instance_->increment_num_loading(); | 32 instance_->increment_num_loading(); |
| 33 else | 33 else |
| 34 instance_ = new ThemeInstallBubbleViewGtk(GTK_WIDGET(parent)); | 34 instance_ = new ThemeInstallBubbleViewGtk(GTK_WIDGET(parent)); |
| 35 } | 35 } |
| 36 | 36 |
| 37 void ThemeInstallBubbleViewGtk::Observe(NotificationType type, | 37 void ThemeInstallBubbleViewGtk::Observe(int type, |
| 38 const NotificationSource& source, | 38 const NotificationSource& source, |
| 39 const NotificationDetails& details) { | 39 const NotificationDetails& details) { |
| 40 if (--num_loads_extant_ == 0) | 40 if (--num_loads_extant_ == 0) |
| 41 delete this; | 41 delete this; |
| 42 } | 42 } |
| 43 | 43 |
| 44 // ThemeInstallBubbleViewGtk, private ------------------------------------------ | 44 // ThemeInstallBubbleViewGtk, private ------------------------------------------ |
| 45 | 45 |
| 46 ThemeInstallBubbleViewGtk::ThemeInstallBubbleViewGtk(GtkWidget* parent) | 46 ThemeInstallBubbleViewGtk::ThemeInstallBubbleViewGtk(GtkWidget* parent) |
| 47 : widget_(NULL), | 47 : widget_(NULL), |
| 48 parent_(parent), | 48 parent_(parent), |
| 49 num_loads_extant_(1) { | 49 num_loads_extant_(1) { |
| 50 InitWidgets(); | 50 InitWidgets(); |
| 51 | 51 |
| 52 // Close when theme has been installed. | 52 // Close when theme has been installed. |
| 53 registrar_.Add( | 53 registrar_.Add( |
| 54 this, | 54 this, |
| 55 NotificationType::BROWSER_THEME_CHANGED, | 55 chrome::NOTIFICATION_BROWSER_THEME_CHANGED, |
| 56 NotificationService::AllSources()); | 56 NotificationService::AllSources()); |
| 57 | 57 |
| 58 // Close when we are installing an extension, not a theme. | 58 // Close when we are installing an extension, not a theme. |
| 59 registrar_.Add( | 59 registrar_.Add( |
| 60 this, | 60 this, |
| 61 NotificationType::NO_THEME_DETECTED, | 61 chrome::NOTIFICATION_NO_THEME_DETECTED, |
| 62 NotificationService::AllSources()); | 62 NotificationService::AllSources()); |
| 63 registrar_.Add( | 63 registrar_.Add( |
| 64 this, | 64 this, |
| 65 NotificationType::EXTENSION_INSTALLED, | 65 chrome::NOTIFICATION_EXTENSION_INSTALLED, |
| 66 NotificationService::AllSources()); | 66 NotificationService::AllSources()); |
| 67 registrar_.Add( | 67 registrar_.Add( |
| 68 this, | 68 this, |
| 69 NotificationType::EXTENSION_INSTALL_ERROR, | 69 chrome::NOTIFICATION_EXTENSION_INSTALL_ERROR, |
| 70 NotificationService::AllSources()); | 70 NotificationService::AllSources()); |
| 71 | 71 |
| 72 // Don't let the bubble overlap the confirm dialog. | 72 // Don't let the bubble overlap the confirm dialog. |
| 73 registrar_.Add( | 73 registrar_.Add( |
| 74 this, | 74 this, |
| 75 NotificationType::EXTENSION_WILL_SHOW_CONFIRM_DIALOG, | 75 chrome::NOTIFICATION_EXTENSION_WILL_SHOW_CONFIRM_DIALOG, |
| 76 NotificationService::AllSources()); | 76 NotificationService::AllSources()); |
| 77 } | 77 } |
| 78 | 78 |
| 79 ThemeInstallBubbleViewGtk::~ThemeInstallBubbleViewGtk() { | 79 ThemeInstallBubbleViewGtk::~ThemeInstallBubbleViewGtk() { |
| 80 gtk_widget_destroy(widget_); | 80 gtk_widget_destroy(widget_); |
| 81 instance_ = NULL; | 81 instance_ = NULL; |
| 82 } | 82 } |
| 83 | 83 |
| 84 void ThemeInstallBubbleViewGtk::InitWidgets() { | 84 void ThemeInstallBubbleViewGtk::InitWidgets() { |
| 85 // Widgematically, the bubble is just a label in a popup window. | 85 // Widgematically, the bubble is just a label in a popup window. |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 0, M_PI_2); | 176 0, M_PI_2); |
| 177 cairo_arc(cr, inner_rect.x(), inner_rect.bottom(), inset, | 177 cairo_arc(cr, inner_rect.x(), inner_rect.bottom(), inset, |
| 178 M_PI_2, M_PI); | 178 M_PI_2, M_PI); |
| 179 | 179 |
| 180 cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, kBubbleOpacity); | 180 cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, kBubbleOpacity); |
| 181 cairo_fill(cr); | 181 cairo_fill(cr); |
| 182 cairo_destroy(cr); | 182 cairo_destroy(cr); |
| 183 | 183 |
| 184 return FALSE; | 184 return FALSE; |
| 185 } | 185 } |
| OLD | NEW |