| 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 "chrome/common/chrome_notification_types.h" |
| 12 #include "content/common/notification_service.h" | 12 #include "content/common/notification_service.h" |
| 13 #include "grit/generated_resources.h" | 13 #include "grit/generated_resources.h" |
| 14 #include "ui/base/gtk/gtk_hig_constants.h" | |
| 15 #include "ui/base/l10n/l10n_util.h" | 14 #include "ui/base/l10n/l10n_util.h" |
| 16 | 15 |
| 17 // Roundedness of bubble. | 16 // Roundedness of bubble. |
| 18 static const int kBubbleCornerRadius = 4; | 17 static const int kBubbleCornerRadius = 4; |
| 19 | 18 |
| 20 // Padding between border of bubble and text. | 19 // Padding between border of bubble and text. |
| 21 static const int kTextPadding = 8; | 20 static const int kTextPadding = 8; |
| 22 | 21 |
| 23 // The bubble is partially transparent. | 22 // The bubble is partially transparent. |
| 24 static const double kBubbleOpacity = static_cast<double>(0xcc) / 0xff; | 23 static const double kBubbleOpacity = static_cast<double>(0xcc) / 0xff; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 widget_ = gtk_window_new(GTK_WINDOW_POPUP); | 90 widget_ = gtk_window_new(GTK_WINDOW_POPUP); |
| 92 gtk_container_set_border_width(GTK_CONTAINER(widget_), kTextPadding); | 91 gtk_container_set_border_width(GTK_CONTAINER(widget_), kTextPadding); |
| 93 GtkWidget* label = gtk_label_new(NULL); | 92 GtkWidget* label = gtk_label_new(NULL); |
| 94 | 93 |
| 95 gchar* markup = g_markup_printf_escaped( | 94 gchar* markup = g_markup_printf_escaped( |
| 96 "<span size='xx-large'>%s</span>", | 95 "<span size='xx-large'>%s</span>", |
| 97 l10n_util::GetStringUTF8(IDS_THEME_LOADING_TITLE).c_str()); | 96 l10n_util::GetStringUTF8(IDS_THEME_LOADING_TITLE).c_str()); |
| 98 gtk_label_set_markup(GTK_LABEL(label), markup); | 97 gtk_label_set_markup(GTK_LABEL(label), markup); |
| 99 g_free(markup); | 98 g_free(markup); |
| 100 | 99 |
| 101 gtk_widget_modify_fg(label, GTK_STATE_NORMAL, &ui::kGdkWhite); | 100 gtk_widget_modify_fg(label, GTK_STATE_NORMAL, >k_util::kGdkWhite); |
| 102 gtk_container_add(GTK_CONTAINER(widget_), label); | 101 gtk_container_add(GTK_CONTAINER(widget_), label); |
| 103 | 102 |
| 104 // We need to show the label so we'll know the widget's actual size when we | 103 // We need to show the label so we'll know the widget's actual size when we |
| 105 // call MoveWindow(). | 104 // call MoveWindow(). |
| 106 gtk_widget_show_all(label); | 105 gtk_widget_show_all(label); |
| 107 | 106 |
| 108 bool composited = false; | 107 bool composited = false; |
| 109 if (gtk_util::IsScreenComposited()) { | 108 if (gtk_util::IsScreenComposited()) { |
| 110 composited = true; | 109 composited = true; |
| 111 GdkScreen* screen = gtk_widget_get_screen(widget_); | 110 GdkScreen* screen = gtk_widget_get_screen(widget_); |
| 112 GdkColormap* colormap = gdk_screen_get_rgba_colormap(screen); | 111 GdkColormap* colormap = gdk_screen_get_rgba_colormap(screen); |
| 113 | 112 |
| 114 if (colormap) | 113 if (colormap) |
| 115 gtk_widget_set_colormap(widget_, colormap); | 114 gtk_widget_set_colormap(widget_, colormap); |
| 116 else | 115 else |
| 117 composited = false; | 116 composited = false; |
| 118 } | 117 } |
| 119 | 118 |
| 120 if (composited) { | 119 if (composited) { |
| 121 gtk_widget_set_app_paintable(widget_, TRUE); | 120 gtk_widget_set_app_paintable(widget_, TRUE); |
| 122 g_signal_connect(widget_, "expose-event", | 121 g_signal_connect(widget_, "expose-event", |
| 123 G_CALLBACK(OnExposeThunk), this); | 122 G_CALLBACK(OnExposeThunk), this); |
| 124 gtk_widget_realize(widget_); | 123 gtk_widget_realize(widget_); |
| 125 } else { | 124 } else { |
| 126 gtk_widget_modify_bg(widget_, GTK_STATE_NORMAL, &ui::kGdkBlack); | 125 gtk_widget_modify_bg(widget_, GTK_STATE_NORMAL, >k_util::kGdkBlack); |
| 127 GdkColor color; | 126 GdkColor color; |
| 128 gtk_util::ActAsRoundedWindow(widget_, color, kBubbleCornerRadius, | 127 gtk_util::ActAsRoundedWindow(widget_, color, kBubbleCornerRadius, |
| 129 gtk_util::ROUNDED_ALL, gtk_util::BORDER_NONE); | 128 gtk_util::ROUNDED_ALL, gtk_util::BORDER_NONE); |
| 130 } | 129 } |
| 131 | 130 |
| 132 MoveWindow(); | 131 MoveWindow(); |
| 133 | 132 |
| 134 g_signal_connect(widget_, "unmap-event", | 133 g_signal_connect(widget_, "unmap-event", |
| 135 G_CALLBACK(OnUnmapEventThunk), this); | 134 G_CALLBACK(OnUnmapEventThunk), this); |
| 136 | 135 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 0, M_PI_2); | 180 0, M_PI_2); |
| 182 cairo_arc(cr, inner_rect.x(), inner_rect.bottom(), inset, | 181 cairo_arc(cr, inner_rect.x(), inner_rect.bottom(), inset, |
| 183 M_PI_2, M_PI); | 182 M_PI_2, M_PI); |
| 184 | 183 |
| 185 cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, kBubbleOpacity); | 184 cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, kBubbleOpacity); |
| 186 cairo_fill(cr); | 185 cairo_fill(cr); |
| 187 cairo_destroy(cr); | 186 cairo_destroy(cr); |
| 188 | 187 |
| 189 return FALSE; | 188 return FALSE; |
| 190 } | 189 } |
| OLD | NEW |