summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorzork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-16 20:58:28 +0000
committerzork@chromium.org <zork@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-12-16 20:58:28 +0000
commit969ee0d4eb01ab770892020e5ba7baf4bf4fda6a (patch)
treee9d1c707959392f8d7156f5b64dd330e514c813c /chrome
parent3762aeb6b417e032ff7d97acaf02670fd2b83248 (diff)
downloadchromium_src-969ee0d4eb01ab770892020e5ba7baf4bf4fda6a.zip
chromium_src-969ee0d4eb01ab770892020e5ba7baf4bf4fda6a.tar.gz
chromium_src-969ee0d4eb01ab770892020e5ba7baf4bf4fda6a.tar.bz2
Fix labels on the content options page to wrap properly. Also, add a utility function to allow other labels to do the same.
BUG=29797 TEST=Open the content options page, and check that the labels wrap at the width of the page. Review URL: http://codereview.chromium.org/500026 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@34745 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/gtk/options/content_page_gtk.cc11
-rw-r--r--chrome/common/gtk_util.cc10
-rw-r--r--chrome/common/gtk_util.h9
3 files changed, 26 insertions, 4 deletions
diff --git a/chrome/browser/gtk/options/content_page_gtk.cc b/chrome/browser/gtk/options/content_page_gtk.cc
index 9db5cbd..af67c8c 100644
--- a/chrome/browser/gtk/options/content_page_gtk.cc
+++ b/chrome/browser/gtk/options/content_page_gtk.cc
@@ -230,6 +230,8 @@ GtkWidget* ContentPageGtk::InitBrowsingDataGroup() {
// Browsing data label.
GtkWidget* browsing_data_label = gtk_label_new(
l10n_util::GetStringUTF8(IDS_OPTIONS_BROWSING_DATA_INFO).c_str());
+ gtk_util::WrapLabelAtAllocationHack(browsing_data_label);
+
gtk_label_set_line_wrap(GTK_LABEL(browsing_data_label), TRUE);
gtk_misc_set_alignment(GTK_MISC(browsing_data_label), 0, 0);
gtk_box_pack_start(GTK_BOX(vbox), browsing_data_label, FALSE, FALSE, 0);
@@ -311,13 +313,13 @@ GtkWidget* ContentPageGtk::InitSyncGroup() {
GtkWidget* vbox = gtk_vbox_new(FALSE, gtk_util::kControlSpacing);
// Sync label.
- GtkWidget* label_hbox = gtk_hbox_new(FALSE, gtk_util::kLabelSpacing);
sync_status_label_background_ = gtk_event_box_new();
sync_status_label_ = gtk_label_new("");
+ gtk_util::WrapLabelAtAllocationHack(sync_status_label_);
+
gtk_label_set_line_wrap(GTK_LABEL(sync_status_label_), TRUE);
gtk_misc_set_alignment(GTK_MISC(sync_status_label_), 0, 0);
- gtk_box_pack_start(GTK_BOX(vbox), label_hbox, FALSE, FALSE, 0);
- gtk_box_pack_start(GTK_BOX(label_hbox), sync_status_label_background_, FALSE,
+ gtk_box_pack_start(GTK_BOX(vbox), sync_status_label_background_, FALSE,
FALSE, 0);
gtk_container_add(GTK_CONTAINER(sync_status_label_background_),
sync_status_label_);
@@ -333,7 +335,6 @@ GtkWidget* ContentPageGtk::InitSyncGroup() {
FALSE, 0);
gtk_container_add(GTK_CONTAINER(sync_action_link_background_),
sync_action_link_);
- gtk_widget_set_no_show_all(sync_action_link_background_, TRUE);
gtk_widget_hide(sync_action_link_background_);
// Add the sync button into its own horizontal box so it does not
@@ -374,8 +375,10 @@ void ContentPageGtk::UpdateSyncControls() {
gtk_chrome_link_button_set_label(GTK_CHROME_LINK_BUTTON(sync_action_link_),
UTF16ToUTF8(link_label).c_str());
if (link_label.empty()) {
+ gtk_widget_set_no_show_all(sync_action_link_background_, TRUE);
gtk_widget_hide(sync_action_link_background_);
} else {
+ gtk_widget_set_no_show_all(sync_action_link_background_, FALSE);
gtk_widget_show(sync_action_link_background_);
}
if (status_has_error) {
diff --git a/chrome/common/gtk_util.cc b/chrome/common/gtk_util.cc
index 9154b92..5b078fb 100644
--- a/chrome/common/gtk_util.cc
+++ b/chrome/common/gtk_util.cc
@@ -113,6 +113,11 @@ gboolean PaintNoBackground(GtkWidget* widget,
return TRUE;
}
+void OnLabelAllocate(GtkWidget* label, GtkAllocation* allocation,
+ gpointer user_data) {
+ gtk_widget_set_size_request(label, allocation->width, -1);
+}
+
} // namespace
namespace event_utils {
@@ -660,4 +665,9 @@ void SuppressDefaultPainting(GtkWidget* container) {
G_CALLBACK(PaintNoBackground), NULL);
}
+void WrapLabelAtAllocationHack(GtkWidget* label) {
+ g_signal_connect(label, "size-allocate",
+ G_CALLBACK(OnLabelAllocate), NULL);
+}
+
} // namespace gtk_util
diff --git a/chrome/common/gtk_util.h b/chrome/common/gtk_util.h
index b46db0a..4eab8c6 100644
--- a/chrome/common/gtk_util.h
+++ b/chrome/common/gtk_util.h
@@ -213,6 +213,15 @@ void ApplyMessageDialogQuirks(GtkWidget* dialog);
// expose events are connected.
void SuppressDefaultPainting(GtkWidget* container);
+// Set the label to use a request size equal to the allocation size. This
+// causes the label to wrap at the width of the container it is in, instead of
+// at the default width.
+// This is called a hack because the gtk docs state that it is logically
+// inconsistent for a widget to make its size request depend on its allocation.
+// It does, however, have the intended effect of wrapping the label at the
+// proper width.
+void WrapLabelAtAllocationHack(GtkWidget* label);
+
} // namespace gtk_util
#endif // CHROME_COMMON_GTK_UTIL_H_