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

Side by Side Diff: chrome/browser/ui/gtk/page_info_bubble_gtk.cc

Issue 7748026: content: Reapply "Start splitting up chrome/browser/ui/gtk/gtk_util.h" (r98287) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase on Monday. Created 9 years, 3 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 | Annotate | Revision Log
OLDNEW
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 <gtk/gtk.h> 5 #include <gtk/gtk.h>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/i18n/rtl.h" 9 #include "base/i18n/rtl.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/certificate_viewer.h" 11 #include "chrome/browser/certificate_viewer.h"
12 #include "chrome/browser/google/google_util.h" 12 #include "chrome/browser/google/google_util.h"
13 #include "chrome/browser/page_info_model.h" 13 #include "chrome/browser/page_info_model.h"
14 #include "chrome/browser/page_info_model_observer.h" 14 #include "chrome/browser/page_info_model_observer.h"
15 #include "chrome/browser/page_info_window.h" 15 #include "chrome/browser/page_info_window.h"
16 #include "chrome/browser/ui/browser_list.h" 16 #include "chrome/browser/ui/browser_list.h"
17 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h" 17 #include "chrome/browser/ui/gtk/browser_toolbar_gtk.h"
18 #include "chrome/browser/ui/gtk/browser_window_gtk.h" 18 #include "chrome/browser/ui/gtk/browser_window_gtk.h"
19 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h" 19 #include "chrome/browser/ui/gtk/bubble/bubble_gtk.h"
20 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h" 20 #include "chrome/browser/ui/gtk/gtk_chrome_link_button.h"
21 #include "chrome/browser/ui/gtk/gtk_theme_service.h" 21 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
22 #include "chrome/browser/ui/gtk/gtk_util.h" 22 #include "chrome/browser/ui/gtk/gtk_util.h"
23 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h" 23 #include "chrome/browser/ui/gtk/location_bar_view_gtk.h"
24 #include "chrome/common/url_constants.h" 24 #include "chrome/common/url_constants.h"
25 #include "googleurl/src/gurl.h" 25 #include "googleurl/src/gurl.h"
26 #include "grit/generated_resources.h" 26 #include "grit/generated_resources.h"
27 #include "grit/locale_settings.h" 27 #include "grit/locale_settings.h"
28 #include "ui/base/gtk/gtk_hig_constants.h"
28 #include "ui/base/l10n/l10n_util.h" 29 #include "ui/base/l10n/l10n_util.h"
29 30
30 class Profile; 31 class Profile;
31 32
32 namespace { 33 namespace {
33 34
34 class PageInfoBubbleGtk : public PageInfoModelObserver, 35 class PageInfoBubbleGtk : public PageInfoModelObserver,
35 public BubbleDelegateGtk { 36 public BubbleDelegateGtk {
36 public: 37 public:
37 PageInfoBubbleGtk(gfx::NativeWindow parent, 38 PageInfoBubbleGtk(gfx::NativeWindow parent,
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 InitContents(); 132 InitContents();
132 } 133 }
133 134
134 void PageInfoBubbleGtk::BubbleClosing(BubbleGtk* bubble, 135 void PageInfoBubbleGtk::BubbleClosing(BubbleGtk* bubble,
135 bool closed_by_escape) { 136 bool closed_by_escape) {
136 delete this; 137 delete this;
137 } 138 }
138 139
139 void PageInfoBubbleGtk::InitContents() { 140 void PageInfoBubbleGtk::InitContents() {
140 if (!contents_) { 141 if (!contents_) {
141 contents_ = gtk_vbox_new(FALSE, gtk_util::kContentAreaSpacing); 142 contents_ = gtk_vbox_new(FALSE, ui::kContentAreaSpacing);
142 gtk_container_set_border_width(GTK_CONTAINER(contents_), 143 gtk_container_set_border_width(GTK_CONTAINER(contents_),
143 gtk_util::kContentAreaBorder); 144 ui::kContentAreaBorder);
144 } else { 145 } else {
145 gtk_util::RemoveAllChildren(contents_); 146 gtk_util::RemoveAllChildren(contents_);
146 } 147 }
147 148
148 for (int i = 0; i < model_.GetSectionCount(); i++) { 149 for (int i = 0; i < model_.GetSectionCount(); i++) {
149 gtk_box_pack_start(GTK_BOX(contents_), 150 gtk_box_pack_start(GTK_BOX(contents_),
150 CreateSection(model_.GetSectionInfo(i)), 151 CreateSection(model_.GetSectionInfo(i)),
151 FALSE, FALSE, 0); 152 FALSE, FALSE, 0);
152 gtk_box_pack_start(GTK_BOX(contents_), 153 gtk_box_pack_start(GTK_BOX(contents_),
153 gtk_hseparator_new(), 154 gtk_hseparator_new(),
154 FALSE, FALSE, 0); 155 FALSE, FALSE, 0);
155 } 156 }
156 157
157 GtkWidget* help_link = theme_service_->BuildChromeLinkButton( 158 GtkWidget* help_link = theme_service_->BuildChromeLinkButton(
158 l10n_util::GetStringUTF8(IDS_PAGE_INFO_HELP_CENTER_LINK)); 159 l10n_util::GetStringUTF8(IDS_PAGE_INFO_HELP_CENTER_LINK));
159 GtkWidget* help_link_hbox = gtk_hbox_new(FALSE, 0); 160 GtkWidget* help_link_hbox = gtk_hbox_new(FALSE, 0);
160 // Stick it in an hbox so it doesn't expand to the whole width. 161 // Stick it in an hbox so it doesn't expand to the whole width.
161 gtk_box_pack_start(GTK_BOX(help_link_hbox), help_link, FALSE, FALSE, 0); 162 gtk_box_pack_start(GTK_BOX(help_link_hbox), help_link, FALSE, FALSE, 0);
162 gtk_box_pack_start(GTK_BOX(contents_), help_link_hbox, FALSE, FALSE, 0); 163 gtk_box_pack_start(GTK_BOX(contents_), help_link_hbox, FALSE, FALSE, 0);
163 g_signal_connect(help_link, "clicked", 164 g_signal_connect(help_link, "clicked",
164 G_CALLBACK(OnHelpLinkClickedThunk), this); 165 G_CALLBACK(OnHelpLinkClickedThunk), this);
165 166
166 gtk_widget_show_all(contents_); 167 gtk_widget_show_all(contents_);
167 } 168 }
168 169
169 GtkWidget* PageInfoBubbleGtk::CreateSection( 170 GtkWidget* PageInfoBubbleGtk::CreateSection(
170 const PageInfoModel::SectionInfo& section) { 171 const PageInfoModel::SectionInfo& section) {
171 GtkWidget* section_box = gtk_hbox_new(FALSE, gtk_util::kControlSpacing); 172 GtkWidget* section_box = gtk_hbox_new(FALSE, ui::kControlSpacing);
172 173
173 GdkPixbuf* pixbuf = *model_.GetIconImage(section.icon_id); 174 GdkPixbuf* pixbuf = *model_.GetIconImage(section.icon_id);
174 if (pixbuf) { 175 if (pixbuf) {
175 GtkWidget* image = gtk_image_new_from_pixbuf(pixbuf); 176 GtkWidget* image = gtk_image_new_from_pixbuf(pixbuf);
176 gtk_box_pack_start(GTK_BOX(section_box), image, FALSE, FALSE, 0); 177 gtk_box_pack_start(GTK_BOX(section_box), image, FALSE, FALSE, 0);
177 gtk_misc_set_alignment(GTK_MISC(image), 0, 0); 178 gtk_misc_set_alignment(GTK_MISC(image), 0, 0);
178 } 179 }
179 180
180 GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); 181 GtkWidget* vbox = gtk_vbox_new(FALSE, ui::kControlSpacing);
181 gtk_box_pack_start(GTK_BOX(section_box), vbox, TRUE, TRUE, 0); 182 gtk_box_pack_start(GTK_BOX(section_box), vbox, TRUE, TRUE, 0);
182 183
183 if (!section.headline.empty()) { 184 if (!section.headline.empty()) {
184 GtkWidget* label = theme_service_->BuildLabel( 185 GtkWidget* label = theme_service_->BuildLabel(
185 UTF16ToUTF8(section.headline), gtk_util::kGdkBlack); 186 UTF16ToUTF8(section.headline), ui::kGdkBlack);
186 gtk_label_set_selectable(GTK_LABEL(label), TRUE); 187 gtk_label_set_selectable(GTK_LABEL(label), TRUE);
187 PangoAttrList* attributes = pango_attr_list_new(); 188 PangoAttrList* attributes = pango_attr_list_new();
188 pango_attr_list_insert(attributes, 189 pango_attr_list_insert(attributes,
189 pango_attr_weight_new(PANGO_WEIGHT_BOLD)); 190 pango_attr_weight_new(PANGO_WEIGHT_BOLD));
190 gtk_label_set_attributes(GTK_LABEL(label), attributes); 191 gtk_label_set_attributes(GTK_LABEL(label), attributes);
191 pango_attr_list_unref(attributes); 192 pango_attr_list_unref(attributes);
192 gtk_util::SetLabelWidth(label, 400); 193 gtk_util::SetLabelWidth(label, 400);
193 // Allow linebreaking in the middle of words if necessary, so that extremely 194 // Allow linebreaking in the middle of words if necessary, so that extremely
194 // long hostnames (longer than one line) will still be completely shown. 195 // long hostnames (longer than one line) will still be completely shown.
195 gtk_label_set_line_wrap_mode(GTK_LABEL(label), PANGO_WRAP_WORD_CHAR); 196 gtk_label_set_line_wrap_mode(GTK_LABEL(label), PANGO_WRAP_WORD_CHAR);
196 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); 197 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
197 } 198 }
198 GtkWidget* label = theme_service_->BuildLabel( 199 GtkWidget* label = theme_service_->BuildLabel(
199 UTF16ToUTF8(section.description), gtk_util::kGdkBlack); 200 UTF16ToUTF8(section.description), ui::kGdkBlack);
200 gtk_label_set_selectable(GTK_LABEL(label), TRUE); 201 gtk_label_set_selectable(GTK_LABEL(label), TRUE);
201 gtk_util::SetLabelWidth(label, 400); 202 gtk_util::SetLabelWidth(label, 400);
202 // Allow linebreaking in the middle of words if necessary, so that extremely 203 // Allow linebreaking in the middle of words if necessary, so that extremely
203 // long hostnames (longer than one line) will still be completely shown. 204 // long hostnames (longer than one line) will still be completely shown.
204 gtk_label_set_line_wrap_mode(GTK_LABEL(label), PANGO_WRAP_WORD_CHAR); 205 gtk_label_set_line_wrap_mode(GTK_LABEL(label), PANGO_WRAP_WORD_CHAR);
205 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); 206 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
206 207
207 if (section.type == PageInfoModel::SECTION_INFO_IDENTITY && cert_id_ > 0) { 208 if (section.type == PageInfoModel::SECTION_INFO_IDENTITY && cert_id_ > 0) {
208 GtkWidget* view_cert_link = theme_service_->BuildChromeLinkButton( 209 GtkWidget* view_cert_link = theme_service_->BuildChromeLinkButton(
209 l10n_util::GetStringUTF8(IDS_PAGEINFO_CERT_INFO_BUTTON)); 210 l10n_util::GetStringUTF8(IDS_PAGEINFO_CERT_INFO_BUTTON));
(...skipping 28 matching lines...) Expand all
238 239
239 void ShowPageInfoBubble(gfx::NativeWindow parent, 240 void ShowPageInfoBubble(gfx::NativeWindow parent,
240 Profile* profile, 241 Profile* profile,
241 const GURL& url, 242 const GURL& url,
242 const NavigationEntry::SSLStatus& ssl, 243 const NavigationEntry::SSLStatus& ssl,
243 bool show_history) { 244 bool show_history) {
244 new PageInfoBubbleGtk(parent, profile, url, ssl, show_history); 245 new PageInfoBubbleGtk(parent, profile, url, ssl, show_history);
245 } 246 }
246 247
247 } // namespace browser 248 } // namespace browser
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/omnibox/omnibox_view_gtk.cc ('k') | chrome/browser/ui/gtk/repost_form_warning_gtk.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698