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

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

Issue 160025: GTK Themes: Theme the bookmark bubble. (And first run bubble). (Closed)
Patch Set: Remove text_color for estade 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
« no previous file with comments | « chrome/browser/gtk/first_run_bubble.h ('k') | chrome/browser/gtk/info_bubble_gtk.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/first_run_bubble.h" 5 #include "chrome/browser/gtk/first_run_bubble.h"
6 6
7 #include <gtk/gtk.h> 7 #include <gtk/gtk.h>
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "base/gfx/gtk_util.h" 10 #include "base/gfx/gtk_util.h"
11 #include "chrome/browser/gtk/gtk_theme_provider.h"
11 #include "chrome/browser/options_window.h" 12 #include "chrome/browser/options_window.h"
12 #include "chrome/browser/search_engines/template_url_model.h" 13 #include "chrome/browser/search_engines/template_url_model.h"
13 #include "chrome/common/gtk_util.h" 14 #include "chrome/common/gtk_util.h"
15 #include "chrome/common/notification_service.h"
14 #include "grit/chromium_strings.h" 16 #include "grit/chromium_strings.h"
15 #include "grit/locale_settings.h" 17 #include "grit/locale_settings.h"
16 #include "grit/generated_resources.h" 18 #include "grit/generated_resources.h"
17 #include "grit/google_chrome_strings.h" 19 #include "grit/google_chrome_strings.h"
18 20
19 namespace { 21 namespace {
20 // Markup for the text of the Omnibox search label 22 // Markup for the text of the Omnibox search label
21 const char kSearchLabelMarkup[] = "<big><b>%s</b></big>"; 23 const char kSearchLabelMarkup[] = "<big><b>%s</b></big>";
22 24
23 // Padding for the buttons on first run bubble. 25 // Padding for the buttons on first run bubble.
(...skipping 19 matching lines...) Expand all
43 const gfx::Rect& rect, 45 const gfx::Rect& rect,
44 bool use_OEM_bubble) { 46 bool use_OEM_bubble) {
45 new FirstRunBubble(profile, parent, rect); 47 new FirstRunBubble(profile, parent, rect);
46 } 48 }
47 49
48 void FirstRunBubble::InfoBubbleClosing(InfoBubbleGtk* info_bubble, 50 void FirstRunBubble::InfoBubbleClosing(InfoBubbleGtk* info_bubble,
49 bool closed_by_escape) { 51 bool closed_by_escape) {
50 // TODO(port): Enable parent window 52 // TODO(port): Enable parent window
51 } 53 }
52 54
55 void FirstRunBubble::Observe(NotificationType type,
56 const NotificationSource& source,
57 const NotificationDetails& details) {
58 DCHECK(type == NotificationType::BROWSER_THEME_CHANGED);
59
60 if (theme_provider_->UseGtkTheme()) {
61 for (std::vector<GtkWidget*>::iterator it = labels_.begin();
62 it != labels_.end(); ++it) {
63 gtk_widget_modify_fg(*it, GTK_STATE_NORMAL, NULL);
64 }
65 } else {
66 for (std::vector<GtkWidget*>::iterator it = labels_.begin();
67 it != labels_.end(); ++it) {
68 gtk_widget_modify_fg(*it, GTK_STATE_NORMAL, &gfx::kGdkBlack);
69 }
70 }
71 }
72
53 FirstRunBubble::FirstRunBubble(Profile* profile, 73 FirstRunBubble::FirstRunBubble(Profile* profile,
54 GtkWindow* parent, 74 GtkWindow* parent,
55 const gfx::Rect& rect) 75 const gfx::Rect& rect)
56 : profile_(profile), 76 : profile_(profile),
77 theme_provider_(GtkThemeProvider::GetFrom(profile_)),
57 parent_(parent), 78 parent_(parent),
58 content_(NULL), 79 content_(NULL),
59 bubble_(NULL) { 80 bubble_(NULL) {
60 GtkWidget* label1 = gtk_label_new(NULL); 81 GtkWidget* label1 = gtk_label_new(NULL);
82 labels_.push_back(label1);
61 char* markup = g_markup_printf_escaped(kSearchLabelMarkup, 83 char* markup = g_markup_printf_escaped(kSearchLabelMarkup,
62 l10n_util::GetStringUTF8(IDS_FR_BUBBLE_TITLE).c_str()); 84 l10n_util::GetStringUTF8(IDS_FR_BUBBLE_TITLE).c_str());
63 gtk_label_set_markup(GTK_LABEL(label1), markup); 85 gtk_label_set_markup(GTK_LABEL(label1), markup);
64 g_free(markup); 86 g_free(markup);
65 gtk_misc_set_alignment(GTK_MISC(label1), 0, .5); 87 gtk_misc_set_alignment(GTK_MISC(label1), 0, .5);
88 // TODO(erg): Theme these colors.
66 gtk_widget_modify_fg(label1, GTK_STATE_NORMAL, &gfx::kGdkBlack); 89 gtk_widget_modify_fg(label1, GTK_STATE_NORMAL, &gfx::kGdkBlack);
67 90
68 GtkWidget* label2 = gtk_label_new( 91 GtkWidget* label2 = gtk_label_new(
69 l10n_util::GetStringUTF8(IDS_FR_BUBBLE_SUBTEXT).c_str()); 92 l10n_util::GetStringUTF8(IDS_FR_BUBBLE_SUBTEXT).c_str());
93 labels_.push_back(label2);
70 gtk_misc_set_alignment(GTK_MISC(label2), 0, .5); 94 gtk_misc_set_alignment(GTK_MISC(label2), 0, .5);
71 gtk_label_set_line_wrap(GTK_LABEL(label2), TRUE); 95 gtk_label_set_line_wrap(GTK_LABEL(label2), TRUE);
72 gtk_widget_modify_fg(label2, GTK_STATE_NORMAL, &gfx::kGdkBlack); 96 gtk_widget_modify_fg(label2, GTK_STATE_NORMAL, &gfx::kGdkBlack);
73 97
74 string16 search_engine = GetDefaultSearchEngineName(profile_); 98 string16 search_engine = GetDefaultSearchEngineName(profile_);
75 GtkWidget* label3 = gtk_label_new( 99 GtkWidget* label3 = gtk_label_new(
76 l10n_util::GetStringFUTF8(IDS_FR_BUBBLE_QUESTION, search_engine).c_str()); 100 l10n_util::GetStringFUTF8(IDS_FR_BUBBLE_QUESTION, search_engine).c_str());
101 labels_.push_back(label3);
77 gtk_misc_set_alignment(GTK_MISC(label3), 0, .5); 102 gtk_misc_set_alignment(GTK_MISC(label3), 0, .5);
78 gtk_label_set_line_wrap(GTK_LABEL(label3), TRUE); 103 gtk_label_set_line_wrap(GTK_LABEL(label3), TRUE);
79 gtk_widget_modify_fg(label3, GTK_STATE_NORMAL, &gfx::kGdkBlack); 104 gtk_widget_modify_fg(label3, GTK_STATE_NORMAL, &gfx::kGdkBlack);
80 105
81 GtkWidget* keep_button = gtk_button_new_with_label( 106 GtkWidget* keep_button = gtk_button_new_with_label(
82 l10n_util::GetStringFUTF8(IDS_FR_BUBBLE_OK, search_engine).c_str()); 107 l10n_util::GetStringFUTF8(IDS_FR_BUBBLE_OK, search_engine).c_str());
83 GtkWidget* change_button = gtk_button_new_with_label( 108 GtkWidget* change_button = gtk_button_new_with_label(
84 l10n_util::GetStringUTF8(IDS_FR_BUBBLE_CHANGE).c_str()); 109 l10n_util::GetStringUTF8(IDS_FR_BUBBLE_CHANGE).c_str());
85 110
86 content_ = gtk_vbox_new(FALSE, 5); 111 content_ = gtk_vbox_new(FALSE, 5);
(...skipping 20 matching lines...) Expand all
107 // all of the extra space on the left. 132 // all of the extra space on the left.
108 gtk_box_pack_start(GTK_BOX(bottom), gtk_label_new(NULL), TRUE, TRUE, 0); 133 gtk_box_pack_start(GTK_BOX(bottom), gtk_label_new(NULL), TRUE, TRUE, 0);
109 gtk_box_pack_start(GTK_BOX(bottom), keep_button, FALSE, FALSE, 134 gtk_box_pack_start(GTK_BOX(bottom), keep_button, FALSE, FALSE,
110 kButtonPadding); 135 kButtonPadding);
111 gtk_box_pack_start(GTK_BOX(bottom), change_button, FALSE, FALSE, 0); 136 gtk_box_pack_start(GTK_BOX(bottom), change_button, FALSE, FALSE, 0);
112 137
113 gtk_box_pack_start(GTK_BOX(content_), bottom, FALSE, FALSE, 0); 138 gtk_box_pack_start(GTK_BOX(content_), bottom, FALSE, FALSE, 0);
114 // We want the focus to start on the keep entry, not on the change button. 139 // We want the focus to start on the keep entry, not on the change button.
115 gtk_container_set_focus_child(GTK_CONTAINER(content_), keep_button); 140 gtk_container_set_focus_child(GTK_CONTAINER(content_), keep_button);
116 141
117 bubble_ = InfoBubbleGtk::Show(parent_, rect, content_, this); 142 bubble_ = InfoBubbleGtk::Show(parent_, rect, content_, theme_provider_, this);
118 if (!bubble_) { 143 if (!bubble_) {
119 NOTREACHED(); 144 NOTREACHED();
120 return; 145 return;
121 } 146 }
122 147
123 g_signal_connect(content_, "destroy", 148 g_signal_connect(content_, "destroy",
124 G_CALLBACK(&HandleDestroyThunk), this); 149 G_CALLBACK(&HandleDestroyThunk), this);
125 g_signal_connect(keep_button, "clicked", 150 g_signal_connect(keep_button, "clicked",
126 G_CALLBACK(&HandleKeepButtonThunk), this); 151 G_CALLBACK(&HandleKeepButtonThunk), this);
127 g_signal_connect(change_button, "clicked", 152 g_signal_connect(change_button, "clicked",
128 G_CALLBACK(&HandleChangeButtonThunk), this); 153 G_CALLBACK(&HandleChangeButtonThunk), this);
154
155 registrar_.Add(this, NotificationType::BROWSER_THEME_CHANGED,
156 NotificationService::AllSources());
157 theme_provider_->InitThemesFor(this);
129 } 158 }
130 159
131 void FirstRunBubble::HandleChangeButton() { 160 void FirstRunBubble::HandleChangeButton() {
132 bubble_->Close(); 161 bubble_->Close();
133 ShowOptionsWindow(OPTIONS_PAGE_GENERAL, OPTIONS_GROUP_DEFAULT_SEARCH, 162 ShowOptionsWindow(OPTIONS_PAGE_GENERAL, OPTIONS_GROUP_DEFAULT_SEARCH,
134 profile_); 163 profile_);
135 } 164 }
136 165
137 void FirstRunBubble::HandleDestroy() { 166 void FirstRunBubble::HandleDestroy() {
138 content_ = NULL; 167 content_ = NULL;
139 delete this; 168 delete this;
140 } 169 }
141 170
142 void FirstRunBubble::HandleKeepButton() { 171 void FirstRunBubble::HandleKeepButton() {
143 bubble_->Close(); 172 bubble_->Close();
144 } 173 }
OLDNEW
« no previous file with comments | « chrome/browser/gtk/first_run_bubble.h ('k') | chrome/browser/gtk/info_bubble_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698