(GTK only) Add icons to the conenction tab of the website settings UI.


BUG=140450


Review URL: https://chromiumcodereview.appspot.com/10834410

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@152394 0039d316-1c4b-4281-b951-d872f2087c98
parent afdda539
...@@ -51,6 +51,35 @@ GtkWidget* CreateTextLabel(const std::string& text, ...@@ -51,6 +51,35 @@ GtkWidget* CreateTextLabel(const std::string& text,
return label; return label;
} }
void ClearContainer(GtkWidget* container) {
GList* child = gtk_container_get_children(GTK_CONTAINER(container));
while (child) {
gtk_container_remove(GTK_CONTAINER(container), GTK_WIDGET(child->data));
child = child->next;
}
}
void SetConnectionSection(GtkWidget* section_box,
const gfx::Image& icon,
GtkWidget* content_box) {
DCHECK(section_box);
ClearContainer(section_box);
const int kSectionPadding = 10;
gtk_container_set_border_width(GTK_CONTAINER(section_box), kSectionPadding);
GtkWidget* hbox = gtk_hbox_new(FALSE, ui::kControlSpacing);
GdkPixbuf* pixbuf = icon.ToGdkPixbuf();
GtkWidget* image = gtk_image_new_from_pixbuf(pixbuf);
gtk_box_pack_start(GTK_BOX(hbox), image, FALSE, FALSE, 0);
gtk_misc_set_alignment(GTK_MISC(image), 0, 0);
gtk_box_pack_start(GTK_BOX(hbox), content_box, TRUE, TRUE, 0);
gtk_box_pack_start(GTK_BOX(section_box), hbox, TRUE, TRUE, 0);
gtk_widget_show_all(section_box);
}
class InternalPageInfoPopupGtk : public BubbleDelegateGtk { class InternalPageInfoPopupGtk : public BubbleDelegateGtk {
public: public:
explicit InternalPageInfoPopupGtk(gfx::NativeWindow parent, explicit InternalPageInfoPopupGtk(gfx::NativeWindow parent,
...@@ -149,7 +178,8 @@ WebsiteSettingsPopupGtk::WebsiteSettingsPopupGtk( ...@@ -149,7 +178,8 @@ WebsiteSettingsPopupGtk::WebsiteSettingsPopupGtk(
header_box_(NULL), header_box_(NULL),
cookies_section_contents_(NULL), cookies_section_contents_(NULL),
permissions_section_contents_(NULL), permissions_section_contents_(NULL),
identity_tab_contents_(NULL), identity_contents_(NULL),
connection_contents_(NULL),
first_visit_contents_(NULL), first_visit_contents_(NULL),
presenter_(NULL) { presenter_(NULL) {
BrowserWindowGtk* browser_window = BrowserWindowGtk* browser_window =
...@@ -230,19 +260,20 @@ void WebsiteSettingsPopupGtk::InitContents() { ...@@ -230,19 +260,20 @@ void WebsiteSettingsPopupGtk::InitContents() {
FALSE, FALSE, 0); FALSE, FALSE, 0);
// Create the container for the contents of the identity tab. // Create the container for the contents of the identity tab.
GtkWidget* info_tab = gtk_vbox_new(FALSE, ui::kControlSpacing); GtkWidget* connection_tab = gtk_vbox_new(FALSE, ui::kControlSpacing);
identity_tab_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing); identity_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing);
gtk_container_set_border_width(GTK_CONTAINER(identity_tab_contents_), 10); gtk_box_pack_start(GTK_BOX(connection_tab), identity_contents_, FALSE, FALSE,
gtk_box_pack_start(GTK_BOX(info_tab), 0);
identity_tab_contents_, gtk_box_pack_start(GTK_BOX(connection_tab), gtk_hseparator_new(), FALSE,
FALSE, FALSE, 0); FALSE, 0);
connection_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing);
gtk_box_pack_start(GTK_BOX(connection_tab), connection_contents_, FALSE,
FALSE, 0);
gtk_box_pack_start(GTK_BOX(connection_tab), gtk_hseparator_new(), FALSE,
FALSE, 0);
first_visit_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing); first_visit_contents_ = gtk_vbox_new(FALSE, ui::kControlSpacing);
GtkWidget* history_contents = CreateSection( gtk_box_pack_start(GTK_BOX(connection_tab), first_visit_contents_, FALSE,
l10n_util::GetStringUTF8(IDS_PAGE_INFO_SITE_INFO_TITLE), FALSE, 0);
first_visit_contents_);
gtk_container_set_border_width(GTK_CONTAINER(history_contents), 10);
gtk_box_pack_start(GTK_BOX(info_tab), gtk_hseparator_new(), FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(info_tab), history_contents, FALSE, FALSE, 0);
// Create tab container and add all tabs. // Create tab container and add all tabs.
GtkWidget* notebook = gtk_notebook_new(); GtkWidget* notebook = gtk_notebook_new();
...@@ -262,20 +293,12 @@ void WebsiteSettingsPopupGtk::InitContents() { ...@@ -262,20 +293,12 @@ void WebsiteSettingsPopupGtk::InitContents() {
l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_TAB_LABEL_CONNECTION), l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_TAB_LABEL_CONNECTION),
ui::kGdkBlack); ui::kGdkBlack);
gtk_widget_show(label); gtk_widget_show(label);
gtk_notebook_append_page(GTK_NOTEBOOK(notebook), info_tab, label); gtk_notebook_append_page(GTK_NOTEBOOK(notebook), connection_tab, label);
gtk_box_pack_start(GTK_BOX(contents_), notebook, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(contents_), notebook, FALSE, FALSE, 0);
gtk_widget_show_all(contents_); gtk_widget_show_all(contents_);
} }
void WebsiteSettingsPopupGtk::ClearContainer(GtkWidget* container) {
GList* child = gtk_container_get_children(GTK_CONTAINER(container));
while (child) {
gtk_container_remove(GTK_CONTAINER(container), GTK_WIDGET(child->data));
child = child->next;
}
}
GtkWidget* WebsiteSettingsPopupGtk::CreateSection(std::string section_title, GtkWidget* WebsiteSettingsPopupGtk::CreateSection(std::string section_title,
GtkWidget* section_content) { GtkWidget* section_content) {
GtkWidget* section_box = gtk_vbox_new(FALSE, ui::kControlSpacing); GtkWidget* section_box = gtk_vbox_new(FALSE, ui::kControlSpacing);
...@@ -291,7 +314,6 @@ GtkWidget* WebsiteSettingsPopupGtk::CreateSection(std::string section_title, ...@@ -291,7 +314,6 @@ GtkWidget* WebsiteSettingsPopupGtk::CreateSection(std::string section_title,
pango_attr_weight_new(PANGO_WEIGHT_BOLD)); pango_attr_weight_new(PANGO_WEIGHT_BOLD));
gtk_label_set_attributes(GTK_LABEL(label), attributes); gtk_label_set_attributes(GTK_LABEL(label), attributes);
pango_attr_list_unref(attributes); pango_attr_list_unref(attributes);
gtk_util::SetLabelWidth(label, 400);
gtk_box_pack_start(GTK_BOX(section_box), title_hbox, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(section_box), title_hbox, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(title_hbox), label, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(title_hbox), label, FALSE, FALSE, 0);
...@@ -299,9 +321,9 @@ GtkWidget* WebsiteSettingsPopupGtk::CreateSection(std::string section_title, ...@@ -299,9 +321,9 @@ GtkWidget* WebsiteSettingsPopupGtk::CreateSection(std::string section_title,
// Add section content // Add section content
gtk_box_pack_start(GTK_BOX(section_box), section_content, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(section_box), section_content, FALSE, FALSE, 0);
return section_box; return section_box;
} }
void WebsiteSettingsPopupGtk::OnPermissionChanged( void WebsiteSettingsPopupGtk::OnPermissionChanged(
PermissionSelector* selector) { PermissionSelector* selector) {
presenter_->OnSitePermissionChanged(selector->type(), presenter_->OnSitePermissionChanged(selector->type(),
...@@ -401,17 +423,13 @@ void WebsiteSettingsPopupGtk::SetIdentityInfo( ...@@ -401,17 +423,13 @@ void WebsiteSettingsPopupGtk::SetIdentityInfo(
GTK_BOX(header_box_), status_label, FALSE, FALSE, 0); GTK_BOX(header_box_), status_label, FALSE, FALSE, 0);
gtk_widget_show_all(header_box_); gtk_widget_show_all(header_box_);
// Create identity tab contents.
DCHECK(identity_tab_contents_);
ClearContainer(identity_tab_contents_);
// Create identity section. // Create identity section.
GtkWidget* section_content = gtk_vbox_new(FALSE, ui::kControlSpacing);
GtkWidget* identity_description = GtkWidget* identity_description =
CreateTextLabel(identity_info.identity_status_description, 300, CreateTextLabel(identity_info.identity_status_description, 300,
theme_service_); theme_service_);
GtkWidget* identity_box = gtk_vbox_new(FALSE, ui::kControlSpacing); gtk_box_pack_start(GTK_BOX(section_content), identity_description, FALSE,
gtk_box_pack_start(GTK_BOX(identity_box), identity_description, FALSE, FALSE, FALSE, 0);
0);
if (identity_info.cert_id) { if (identity_info.cert_id) {
cert_id_ = identity_info.cert_id; cert_id_ = identity_info.cert_id;
GtkWidget* view_cert_link = theme_service_->BuildChromeLinkButton( GtkWidget* view_cert_link = theme_service_->BuildChromeLinkButton(
...@@ -421,51 +439,49 @@ void WebsiteSettingsPopupGtk::SetIdentityInfo( ...@@ -421,51 +439,49 @@ void WebsiteSettingsPopupGtk::SetIdentityInfo(
GtkWidget* link_hbox = gtk_hbox_new(FALSE, 0); GtkWidget* link_hbox = gtk_hbox_new(FALSE, 0);
gtk_box_pack_start(GTK_BOX(link_hbox), view_cert_link, gtk_box_pack_start(GTK_BOX(link_hbox), view_cert_link,
FALSE, FALSE, 0); FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(identity_box), link_hbox, FALSE, FALSE, 0); gtk_box_pack_start(GTK_BOX(section_content), link_hbox, FALSE, FALSE, 0);
} }
SetConnectionSection(
identity_contents_,
WebsiteSettingsUI::GetIdentityIcon(identity_info.identity_status),
section_content);
// Create connection section. // Create connection section.
GtkWidget* connection_description = GtkWidget* connection_description =
CreateTextLabel(identity_info.connection_status_description, 300, CreateTextLabel(identity_info.connection_status_description, 300,
theme_service_); theme_service_);
GtkWidget* connection_box = gtk_vbox_new(FALSE, ui::kControlSpacing); section_content = gtk_vbox_new(FALSE, ui::kControlSpacing);
gtk_box_pack_start(GTK_BOX(connection_box), connection_description, FALSE, gtk_box_pack_start(GTK_BOX(section_content), connection_description, FALSE,
FALSE, 0); FALSE, 0);
SetConnectionSection(
// Add to contents. connection_contents_,
gtk_box_pack_start( WebsiteSettingsUI::GetConnectionIcon(identity_info.connection_status),
GTK_BOX(identity_tab_contents_), CreateSection( section_content);
l10n_util::GetStringUTF8(IDS_WEBSITE_SETTINGS_TITLE_IDENTITY),
identity_box),
TRUE,
FALSE,
0);
gtk_box_pack_start(GTK_BOX(identity_tab_contents_),
gtk_hseparator_new(),
FALSE, FALSE, 0);
gtk_box_pack_start(
GTK_BOX(identity_tab_contents_),
CreateSection(
l10n_util::GetStringUTF8(
IDS_WEBSITE_SETTINGS_TITLE_CONNECTION),
connection_box),
TRUE,
FALSE,
0);
gtk_widget_show_all(identity_tab_contents_);
} }
void WebsiteSettingsPopupGtk::SetFirstVisit(const string16& first_visit) { void WebsiteSettingsPopupGtk::SetFirstVisit(const string16& first_visit) {
DCHECK(first_visit_contents_); GtkWidget* titel = theme_service_->BuildLabel(
ClearContainer(first_visit_contents_); l10n_util::GetStringUTF8(IDS_PAGE_INFO_SITE_INFO_TITLE),
ui::kGdkBlack);
gtk_label_set_selectable(GTK_LABEL(titel), TRUE);
PangoAttrList* attributes = pango_attr_list_new();
pango_attr_list_insert(attributes,
pango_attr_weight_new(PANGO_WEIGHT_BOLD));
gtk_label_set_attributes(GTK_LABEL(titel), attributes);
pango_attr_list_unref(attributes);
gtk_misc_set_alignment(GTK_MISC(titel), 0, 0);
GtkWidget* first_visit_label = CreateTextLabel(UTF16ToUTF8(first_visit), 400, GtkWidget* first_visit_label = CreateTextLabel(UTF16ToUTF8(first_visit), 400,
theme_service_); theme_service_);
GtkWidget* section_contents = gtk_vbox_new(FALSE, ui::kControlSpacing);
gtk_box_pack_start(GTK_BOX(section_contents), titel, FALSE, FALSE, 0);
gtk_box_pack_start( gtk_box_pack_start(
GTK_BOX(first_visit_contents_), first_visit_label, FALSE, FALSE, 0); GTK_BOX(section_contents), first_visit_label, FALSE, FALSE, 0);
gtk_widget_show_all(first_visit_contents_);
SetConnectionSection(
first_visit_contents_,
WebsiteSettingsUI::GetFirstVisitIcon(first_visit),
section_contents);
} }
void WebsiteSettingsPopupGtk::SetPermissionInfo( void WebsiteSettingsPopupGtk::SetPermissionInfo(
......
...@@ -65,15 +65,11 @@ class WebsiteSettingsPopupGtk : public WebsiteSettingsUI, ...@@ -65,15 +65,11 @@ class WebsiteSettingsPopupGtk : public WebsiteSettingsUI,
// BubbleDelegateGtk implementation. // BubbleDelegateGtk implementation.
virtual void BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) OVERRIDE; virtual void BubbleClosing(BubbleGtk* bubble, bool closed_by_escape) OVERRIDE;
virtual ~WebsiteSettingsPopupGtk(); virtual ~WebsiteSettingsPopupGtk();
// Layouts the different sections retrieved from the model. // Layouts the different sections retrieved from the model.
void InitContents(); void InitContents();
// Removes all children of |container|.
void ClearContainer(GtkWidget* container);
// Creates a popup section and returns a virtual box that contains the // Creates a popup section and returns a virtual box that contains the
// section content. // section content.
GtkWidget* CreateSection(std::string section_title, GtkWidget* CreateSection(std::string section_title,
...@@ -119,8 +115,12 @@ class WebsiteSettingsPopupGtk : public WebsiteSettingsUI, ...@@ -119,8 +115,12 @@ class WebsiteSettingsPopupGtk : public WebsiteSettingsUI,
// Container for the permissions section content. // Container for the permissions section content.
GtkWidget* permissions_section_contents_; GtkWidget* permissions_section_contents_;
// Container for the identity tab content. // Container for the remote host (website) identity section of the connection
GtkWidget* identity_tab_contents_; // tab.
GtkWidget* identity_contents_;
// Container for the connection section of the connection tab.
GtkWidget* connection_contents_;
// Container for the information about the first visit date of the website. // Container for the information about the first visit date of the website.
GtkWidget* first_visit_contents_; GtkWidget* first_visit_contents_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment