Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(142)

Side by Side Diff: chrome/browser/gtk/status_bubble_gtk.cc

Issue 149259: GTK Themes: Status bubble obeys GTK colors now. (Closed)
Patch Set: Created 11 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/gtk/status_bubble_gtk.h" 5 #include "chrome/browser/gtk/status_bubble_gtk.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include "base/gfx/gtk_util.h" 9 #include "base/gfx/gtk_util.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "chrome/browser/gtk/gtk_theme_provider.h"
12 #include "chrome/browser/gtk/slide_animator_gtk.h" 13 #include "chrome/browser/gtk/slide_animator_gtk.h"
13 #include "chrome/common/gtk_util.h" 14 #include "chrome/common/gtk_util.h"
14 #include "googleurl/src/gurl.h" 15 #include "googleurl/src/gurl.h"
15 16
16 namespace { 17 namespace {
17 18
18 const GdkColor kTextColor = GDK_COLOR_RGB(100, 100, 100); 19 const GdkColor kTextColor = GDK_COLOR_RGB(100, 100, 100);
19 const GdkColor kBackgroundColor = GDK_COLOR_RGB(0xe6, 0xed, 0xf4); 20 const GdkColor kBackgroundColor = GDK_COLOR_RGB(0xe6, 0xed, 0xf4);
20 const GdkColor kFrameBorderColor = GDK_COLOR_RGB(0xbe, 0xc8, 0xd4); 21 const GdkColor kFrameBorderColor = GDK_COLOR_RGB(0xbe, 0xc8, 0xd4);
21 22
22 // Inner padding between the border and the text label. 23 // Inner padding between the border and the text label.
23 const int kInternalTopBottomPadding = 1; 24 const int kInternalTopBottomPadding = 1;
24 const int kInternalLeftRightPadding = 2; 25 const int kInternalLeftRightPadding = 2;
25 26
26 // Border of color kFrameBorderColor around the status bubble. 27 // Border of color kFrameBorderColor around the status bubble.
27 const int kBorderPadding = 1; 28 const int kBorderPadding = 1;
28 29
29 // Milliseconds before we hide the status bubble widget when you mouseout. 30 // Milliseconds before we hide the status bubble widget when you mouseout.
30 static const int kHideDelay = 250; 31 static const int kHideDelay = 250;
31 32
32 } // namespace 33 } // namespace
33 34
34 StatusBubbleGtk::StatusBubbleGtk() 35 StatusBubbleGtk::StatusBubbleGtk(Profile* profile)
35 : timer_factory_(this) { 36 : timer_factory_(this) {
36 InitWidgets(); 37 InitWidgets();
38
39 GtkThemeProperties properties(profile);
40 UserChangedTheme(&properties);
37 } 41 }
38 42
39 StatusBubbleGtk::~StatusBubbleGtk() { 43 StatusBubbleGtk::~StatusBubbleGtk() {
40 container_.Destroy(); 44 container_.Destroy();
41 } 45 }
42 46
43 void StatusBubbleGtk::SetStatus(const std::wstring& status_text_wide) { 47 void StatusBubbleGtk::SetStatus(const std::wstring& status_text_wide) {
44 std::string status_text = WideToUTF8(status_text_wide); 48 std::string status_text = WideToUTF8(status_text_wide);
45 if (status_text_ == status_text) 49 if (status_text_ == status_text)
46 return; 50 return;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 // We can't do that fancy sliding behaviour where the status bubble slides 110 // We can't do that fancy sliding behaviour where the status bubble slides
107 // out of the window because the window manager gets in the way. So totally 111 // out of the window because the window manager gets in the way. So totally
108 // ignore this message for now. 112 // ignore this message for now.
109 // 113 //
110 // TODO(erg): At least get some sliding behaviour so that it slides out of 114 // TODO(erg): At least get some sliding behaviour so that it slides out of
111 // the way to hide the status bubble on mouseover. 115 // the way to hide the status bubble on mouseover.
112 } 116 }
113 117
114 void StatusBubbleGtk::InitWidgets() { 118 void StatusBubbleGtk::InitWidgets() {
115 label_ = gtk_label_new(NULL); 119 label_ = gtk_label_new(NULL);
116 gtk_widget_modify_fg(label_, GTK_STATE_NORMAL, &kTextColor);
117 120
118 GtkWidget* padding = gtk_alignment_new(0, 0, 1, 1); 121 GtkWidget* padding = gtk_alignment_new(0, 0, 1, 1);
119 gtk_alignment_set_padding(GTK_ALIGNMENT(padding), 122 gtk_alignment_set_padding(GTK_ALIGNMENT(padding),
120 kInternalTopBottomPadding, kInternalTopBottomPadding, 123 kInternalTopBottomPadding, kInternalTopBottomPadding,
121 kInternalLeftRightPadding, kInternalLeftRightPadding); 124 kInternalLeftRightPadding, kInternalLeftRightPadding);
122 gtk_container_add(GTK_CONTAINER(padding), label_); 125 gtk_container_add(GTK_CONTAINER(padding), label_);
123 126
124 GtkWidget* bg_box = gtk_event_box_new(); 127 bg_box_ = gtk_event_box_new();
125 gtk_container_add(GTK_CONTAINER(bg_box), padding); 128 gtk_container_add(GTK_CONTAINER(bg_box_), padding);
126 gtk_widget_modify_bg(bg_box, GTK_STATE_NORMAL, &kBackgroundColor);
127 129
128 container_.Own(gtk_util::CreateGtkBorderBin(bg_box, &kFrameBorderColor, 130 container_.Own(gtk_util::CreateGtkBorderBin(bg_box_, &kFrameBorderColor,
129 kBorderPadding, kBorderPadding, kBorderPadding, kBorderPadding)); 131 kBorderPadding, kBorderPadding, kBorderPadding, kBorderPadding));
130 gtk_widget_set_name(container_.get(), "status-bubble"); 132 gtk_widget_set_name(container_.get(), "status-bubble");
131 gtk_widget_set_app_paintable(container_.get(), TRUE); 133 gtk_widget_set_app_paintable(container_.get(), TRUE);
132 } 134 }
135
136 void StatusBubbleGtk::UserChangedTheme(GtkThemeProperties* properties) {
137 if (properties->use_gtk_rendering) {
138 gtk_widget_modify_fg(label_, GTK_STATE_NORMAL, NULL);
139 gtk_widget_modify_bg(bg_box_, GTK_STATE_NORMAL, NULL);
140 } else {
141 // TODO(erg): This is the closest to "text that will look good on a
142 // toolbar" that I can find. Maybe in later iterations of the theme system,
143 // there will be a better color to pick.
144 GdkColor bookmark_text =
145 properties->GetGdkColor(BrowserThemeProvider::COLOR_BOOKMARK_TEXT);
146 gtk_widget_modify_fg(label_, GTK_STATE_NORMAL, &bookmark_text);
147
148 GdkColor toolbar_color =
149 properties->GetGdkColor(BrowserThemeProvider::COLOR_TOOLBAR);
150 gtk_widget_modify_bg(bg_box_, GTK_STATE_NORMAL, &toolbar_color);
151 }
152
153 // TODO(erg): I don't know what to do with the status bubble border
154 // (|container_|). There needs to be a border in GTK mode, and I'm not sure
155 // which BrowserThemeProvider::COLOR I'm supposed to use here since the Views
156 // implementation still uses constants in the equivalent, and it's used for
157 // alpha blending instead of drawing a real border.
158 //
159 // This doesn't really matter because this part of the UI needs to be
160 // rewritten per the UI review anyway; we should be matching windows with a
161 // semi-transparent, rounded border instead of our constantly
162 // CreateGtkBorderBin() usage.
163 }
OLDNEW
« chrome/browser/gtk/status_bubble_gtk.h ('K') | « chrome/browser/gtk/status_bubble_gtk.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698