| 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/first_run_bubble.h" | 5 #include "chrome/browser/ui/gtk/first_run_bubble.h" |
| 6 | 6 |
| 7 #include <gtk/gtk.h> | 7 #include <gtk/gtk.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
| 11 #include "base/utf_string_conversions.h" | 11 #include "base/utf_string_conversions.h" |
| 12 #include "chrome/browser/search_engines/util.h" | 12 #include "chrome/browser/search_engines/util.h" |
| 13 #include "chrome/browser/ui/browser.h" | 13 #include "chrome/browser/ui/browser.h" |
| 14 #include "chrome/browser/ui/browser_list.h" | 14 #include "chrome/browser/ui/browser_list.h" |
| 15 #include "chrome/browser/ui/gtk/gtk_theme_service.h" | 15 #include "chrome/browser/ui/gtk/gtk_theme_service.h" |
| 16 #include "chrome/browser/ui/gtk/gtk_util.h" | 16 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 17 #include "grit/chromium_strings.h" | 17 #include "grit/chromium_strings.h" |
| 18 #include "grit/generated_resources.h" | 18 #include "grit/generated_resources.h" |
| 19 #include "grit/locale_settings.h" | 19 #include "grit/locale_settings.h" |
| 20 #include "ui/base/gtk/gtk_hig_constants.h" |
| 20 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/l10n/l10n_util.h" |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 // Markup for the text of the Omnibox search label | 24 // Markup for the text of the Omnibox search label |
| 24 const char kSearchLabelMarkup[] = "<big><b>%s</b></big>"; | 25 const char kSearchLabelMarkup[] = "<big><b>%s</b></big>"; |
| 25 | 26 |
| 26 // Padding for the buttons on first run bubble. | 27 // Padding for the buttons on first run bubble. |
| 27 const int kButtonPadding = 4; | 28 const int kButtonPadding = 4; |
| 28 | 29 |
| 29 // Padding between content and edge of bubble. | 30 // Padding between content and edge of bubble. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 NOTREACHED(); | 95 NOTREACHED(); |
| 95 return; | 96 return; |
| 96 } | 97 } |
| 97 } | 98 } |
| 98 | 99 |
| 99 FirstRunBubble::~FirstRunBubble() { | 100 FirstRunBubble::~FirstRunBubble() { |
| 100 } | 101 } |
| 101 | 102 |
| 102 void FirstRunBubble::InitializeContentForLarge( | 103 void FirstRunBubble::InitializeContentForLarge( |
| 103 std::vector<GtkWidget*>* labels) { | 104 std::vector<GtkWidget*>* labels) { |
| 104 GtkWidget* label1 = theme_service_->BuildLabel("", gtk_util::kGdkBlack); | 105 GtkWidget* label1 = theme_service_->BuildLabel("", ui::kGdkBlack); |
| 105 labels->push_back(label1); | 106 labels->push_back(label1); |
| 106 char* markup = g_markup_printf_escaped(kSearchLabelMarkup, | 107 char* markup = g_markup_printf_escaped(kSearchLabelMarkup, |
| 107 l10n_util::GetStringUTF8(IDS_FR_BUBBLE_TITLE).c_str()); | 108 l10n_util::GetStringUTF8(IDS_FR_BUBBLE_TITLE).c_str()); |
| 108 gtk_label_set_markup(GTK_LABEL(label1), markup); | 109 gtk_label_set_markup(GTK_LABEL(label1), markup); |
| 109 g_free(markup); | 110 g_free(markup); |
| 110 | 111 |
| 111 GtkWidget* label2 = theme_service_->BuildLabel( | 112 GtkWidget* label2 = theme_service_->BuildLabel( |
| 112 l10n_util::GetStringUTF8(IDS_FR_BUBBLE_SUBTEXT), gtk_util::kGdkBlack); | 113 l10n_util::GetStringUTF8(IDS_FR_BUBBLE_SUBTEXT), ui::kGdkBlack); |
| 113 labels->push_back(label2); | 114 labels->push_back(label2); |
| 114 | 115 |
| 115 string16 search_engine = GetDefaultSearchEngineName(profile_); | 116 string16 search_engine = GetDefaultSearchEngineName(profile_); |
| 116 GtkWidget* label3 = theme_service_->BuildLabel( | 117 GtkWidget* label3 = theme_service_->BuildLabel( |
| 117 l10n_util::GetStringFUTF8(IDS_FR_BUBBLE_QUESTION, search_engine), | 118 l10n_util::GetStringFUTF8(IDS_FR_BUBBLE_QUESTION, search_engine), |
| 118 gtk_util::kGdkBlack); | 119 ui::kGdkBlack); |
| 119 labels->push_back(label3); | 120 labels->push_back(label3); |
| 120 | 121 |
| 121 GtkWidget* keep_button = gtk_button_new_with_label( | 122 GtkWidget* keep_button = gtk_button_new_with_label( |
| 122 l10n_util::GetStringFUTF8(IDS_FR_BUBBLE_OK, search_engine).c_str()); | 123 l10n_util::GetStringFUTF8(IDS_FR_BUBBLE_OK, search_engine).c_str()); |
| 123 GtkWidget* change_button = gtk_button_new_with_label( | 124 GtkWidget* change_button = gtk_button_new_with_label( |
| 124 l10n_util::GetStringUTF8(IDS_FR_BUBBLE_CHANGE).c_str()); | 125 l10n_util::GetStringUTF8(IDS_FR_BUBBLE_CHANGE).c_str()); |
| 125 | 126 |
| 126 gtk_box_pack_start(GTK_BOX(content_), label1, FALSE, FALSE, 0); | 127 gtk_box_pack_start(GTK_BOX(content_), label1, FALSE, FALSE, 0); |
| 127 gtk_box_pack_start(GTK_BOX(content_), label2, FALSE, FALSE, 0); | 128 gtk_box_pack_start(GTK_BOX(content_), label2, FALSE, FALSE, 0); |
| 128 // Leave an empty line. | 129 // Leave an empty line. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 147 G_CALLBACK(&HandleChangeButtonThunk), this); | 148 G_CALLBACK(&HandleChangeButtonThunk), this); |
| 148 } | 149 } |
| 149 | 150 |
| 150 void FirstRunBubble::InitializeContentForOEM(std::vector<GtkWidget*>* labels) { | 151 void FirstRunBubble::InitializeContentForOEM(std::vector<GtkWidget*>* labels) { |
| 151 NOTIMPLEMENTED() << "Falling back to minimal bubble"; | 152 NOTIMPLEMENTED() << "Falling back to minimal bubble"; |
| 152 InitializeContentForMinimal(labels); | 153 InitializeContentForMinimal(labels); |
| 153 } | 154 } |
| 154 | 155 |
| 155 void FirstRunBubble::InitializeContentForMinimal( | 156 void FirstRunBubble::InitializeContentForMinimal( |
| 156 std::vector<GtkWidget*>* labels) { | 157 std::vector<GtkWidget*>* labels) { |
| 157 GtkWidget* label1 = theme_service_->BuildLabel("", gtk_util::kGdkBlack); | 158 GtkWidget* label1 = theme_service_->BuildLabel("", ui::kGdkBlack); |
| 158 labels->push_back(label1); | 159 labels->push_back(label1); |
| 159 char* markup = g_markup_printf_escaped(kSearchLabelMarkup, | 160 char* markup = g_markup_printf_escaped(kSearchLabelMarkup, |
| 160 l10n_util::GetStringFUTF8( | 161 l10n_util::GetStringFUTF8( |
| 161 IDS_FR_SE_BUBBLE_TITLE, | 162 IDS_FR_SE_BUBBLE_TITLE, |
| 162 GetDefaultSearchEngineName(profile_)).c_str()); | 163 GetDefaultSearchEngineName(profile_)).c_str()); |
| 163 gtk_label_set_markup(GTK_LABEL(label1), markup); | 164 gtk_label_set_markup(GTK_LABEL(label1), markup); |
| 164 g_free(markup); | 165 g_free(markup); |
| 165 | 166 |
| 166 GtkWidget* label2 = theme_service_->BuildLabel( | 167 GtkWidget* label2 = theme_service_->BuildLabel( |
| 167 l10n_util::GetStringUTF8(IDS_FR_BUBBLE_SUBTEXT), gtk_util::kGdkBlack); | 168 l10n_util::GetStringUTF8(IDS_FR_BUBBLE_SUBTEXT), ui::kGdkBlack); |
| 168 labels->push_back(label2); | 169 labels->push_back(label2); |
| 169 | 170 |
| 170 gtk_box_pack_start(GTK_BOX(content_), label1, FALSE, FALSE, 0); | 171 gtk_box_pack_start(GTK_BOX(content_), label1, FALSE, FALSE, 0); |
| 171 gtk_box_pack_start(GTK_BOX(content_), label2, FALSE, FALSE, 0); | 172 gtk_box_pack_start(GTK_BOX(content_), label2, FALSE, FALSE, 0); |
| 172 } | 173 } |
| 173 | 174 |
| 174 void FirstRunBubble::InitializeLabels(int width_resource, | 175 void FirstRunBubble::InitializeLabels(int width_resource, |
| 175 std::vector<GtkWidget*>* labels) { | 176 std::vector<GtkWidget*>* labels) { |
| 176 int width = -1; | 177 int width = -1; |
| 177 | 178 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 194 void FirstRunBubble::HandleKeepButton(GtkWidget* sender) { | 195 void FirstRunBubble::HandleKeepButton(GtkWidget* sender) { |
| 195 bubble_->Close(); | 196 bubble_->Close(); |
| 196 } | 197 } |
| 197 | 198 |
| 198 void FirstRunBubble::HandleChangeButton(GtkWidget* sender) { | 199 void FirstRunBubble::HandleChangeButton(GtkWidget* sender) { |
| 199 bubble_->Close(); | 200 bubble_->Close(); |
| 200 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); | 201 Browser* browser = BrowserList::GetLastActiveWithProfile(profile_); |
| 201 DCHECK(browser); | 202 DCHECK(browser); |
| 202 browser->OpenSearchEngineOptionsDialog(); | 203 browser->OpenSearchEngineOptionsDialog(); |
| 203 } | 204 } |
| OLD | NEW |