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

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

Issue 3560004: Refactor the code for loading icons into the PageInfoModel. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: cleanup Created 10 years, 2 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/page_info_bubble_gtk.cc ('k') | chrome/browser/page_info_model.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 <gtk/gtk.h> 5 #include <gtk/gtk.h>
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include "app/l10n_util.h" 9 #include "app/l10n_util.h"
10 #include "app/resource_bundle.h"
11 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
12 #include "base/utf_string_conversions.h" 11 #include "base/utf_string_conversions.h"
13 #include "chrome/browser/certificate_viewer.h" 12 #include "chrome/browser/certificate_viewer.h"
14 #include "chrome/browser/gtk/gtk_util.h" 13 #include "chrome/browser/gtk/gtk_util.h"
15 #include "chrome/browser/page_info_model.h" 14 #include "chrome/browser/page_info_model.h"
16 #include "chrome/browser/page_info_window.h" 15 #include "chrome/browser/page_info_window.h"
17 #include "grit/generated_resources.h" 16 #include "grit/generated_resources.h"
18 #include "grit/locale_settings.h" 17 #include "grit/locale_settings.h"
19 #include "grit/theme_resources.h"
20 18
21 namespace { 19 namespace {
22 20
23 enum { 21 enum {
24 RESPONSE_SHOW_CERT_INFO = 0, 22 RESPONSE_SHOW_CERT_INFO = 0,
25 }; 23 };
26 24
27 class PageInfoWindowGtk : public PageInfoModel::PageInfoModelObserver { 25 class PageInfoWindowGtk : public PageInfoModel::PageInfoModelObserver {
28 public: 26 public:
29 PageInfoWindowGtk(gfx::NativeWindow parent, 27 PageInfoWindowGtk(gfx::NativeWindow parent,
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 139
142 PangoAttrList* attributes = pango_attr_list_new(); 140 PangoAttrList* attributes = pango_attr_list_new();
143 pango_attr_list_insert(attributes, 141 pango_attr_list_insert(attributes,
144 pango_attr_weight_new(PANGO_WEIGHT_BOLD)); 142 pango_attr_weight_new(PANGO_WEIGHT_BOLD));
145 gtk_label_set_attributes(GTK_LABEL(label), attributes); 143 gtk_label_set_attributes(GTK_LABEL(label), attributes);
146 pango_attr_list_unref(attributes); 144 pango_attr_list_unref(attributes);
147 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); 145 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
148 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); 146 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
149 147
150 GtkWidget* section_box = gtk_hbox_new(FALSE, 0); 148 GtkWidget* section_box = gtk_hbox_new(FALSE, 0);
151 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
152 GtkWidget* image = gtk_image_new_from_pixbuf( 149 GtkWidget* image = gtk_image_new_from_pixbuf(
153 section.state == PageInfoModel::SECTION_STATE_OK ? 150 model_.GetIconImage(section.icon_id));
154 rb.GetPixbufNamed(IDR_PAGEINFO_GOOD) :
155 rb.GetPixbufNamed(IDR_PAGEINFO_WARNING_MAJOR));
156 gtk_box_pack_start(GTK_BOX(section_box), image, FALSE, FALSE, 151 gtk_box_pack_start(GTK_BOX(section_box), image, FALSE, FALSE,
157 gtk_util::kControlSpacing); 152 gtk_util::kControlSpacing);
158 gtk_misc_set_alignment(GTK_MISC(image), 0, 0); 153 gtk_misc_set_alignment(GTK_MISC(image), 0, 0);
159 154
160 GtkWidget* text_box = gtk_vbox_new(FALSE, gtk_util::kControlSpacing); 155 GtkWidget* text_box = gtk_vbox_new(FALSE, gtk_util::kControlSpacing);
161 if (!section.headline.empty()) { 156 if (!section.headline.empty()) {
162 label = gtk_label_new(UTF16ToUTF8(section.headline).c_str()); 157 label = gtk_label_new(UTF16ToUTF8(section.headline).c_str());
163 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); 158 gtk_misc_set_alignment(GTK_MISC(label), 0, 0);
164 gtk_box_pack_start(GTK_BOX(text_box), label, FALSE, FALSE, 0); 159 gtk_box_pack_start(GTK_BOX(text_box), label, FALSE, FALSE, 0);
165 } 160 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 gtk_window_present(GTK_WINDOW(iter->second->widget())); 209 gtk_window_present(GTK_WINDOW(iter->second->widget()));
215 return; 210 return;
216 } 211 }
217 212
218 PageInfoWindowGtk* page_info_window = 213 PageInfoWindowGtk* page_info_window =
219 new PageInfoWindowGtk(parent, profile, url, ssl, show_history); 214 new PageInfoWindowGtk(parent, profile, url, ssl, show_history);
220 page_info_window->Show(); 215 page_info_window->Show();
221 } 216 }
222 217
223 } // namespace browser 218 } // namespace browser
OLDNEW
« no previous file with comments | « chrome/browser/gtk/page_info_bubble_gtk.cc ('k') | chrome/browser/page_info_model.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698