summaryrefslogtreecommitdiffstats
path: root/chrome/browser/gtk
diff options
context:
space:
mode:
authorevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-24 19:37:22 +0000
committerevan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-24 19:37:22 +0000
commit2451f831e8bbfca6bb63c2ce610bfd2ed5c50c2e (patch)
tree655f65d8cb1c8d5a111e38fb5f1e8652c9b31506 /chrome/browser/gtk
parent79fdaa6a2da3a8b4f3b75cb9c5648415f426ed84 (diff)
downloadchromium_src-2451f831e8bbfca6bb63c2ce610bfd2ed5c50c2e.zip
chromium_src-2451f831e8bbfca6bb63c2ce610bfd2ed5c50c2e.tar.gz
chromium_src-2451f831e8bbfca6bb63c2ce610bfd2ed5c50c2e.tar.bz2
linux: allow options dialog to be resized smaller
BUG=37786 Review URL: http://codereview.chromium.org/1253001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42510 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/gtk')
-rw-r--r--chrome/browser/gtk/gtk_util.cc10
-rw-r--r--chrome/browser/gtk/gtk_util.h9
-rw-r--r--chrome/browser/gtk/options/content_page_gtk.cc27
3 files changed, 26 insertions, 20 deletions
diff --git a/chrome/browser/gtk/gtk_util.cc b/chrome/browser/gtk/gtk_util.cc
index 44dd69c..bb3725c 100644
--- a/chrome/browser/gtk/gtk_util.cc
+++ b/chrome/browser/gtk/gtk_util.cc
@@ -121,11 +121,6 @@ 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 {
@@ -807,11 +802,6 @@ void SuppressDefaultPainting(GtkWidget* container) {
G_CALLBACK(PaintNoBackground), NULL);
}
-void WrapLabelAtAllocationHack(GtkWidget* label) {
- g_signal_connect(label, "size-allocate",
- G_CALLBACK(OnLabelAllocate), NULL);
-}
-
WindowOpenDisposition DispositionForCurrentButtonPressEvent() {
GdkEvent* event = gtk_get_current_event();
if (!event) {
diff --git a/chrome/browser/gtk/gtk_util.h b/chrome/browser/gtk/gtk_util.h
index 541464b..5d261ca 100644
--- a/chrome/browser/gtk/gtk_util.h
+++ b/chrome/browser/gtk/gtk_util.h
@@ -242,15 +242,6 @@ gfx::Rect GetWidgetRectRelativeToToplevel(GtkWidget* widget);
// 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);
-
// Get the window open disposition from the state in gtk_get_current_event().
// This is designed to be called inside a "clicked" event handler. It is an
// error to call it when gtk_get_current_event() won't return a GdkEventButton*.
diff --git a/chrome/browser/gtk/options/content_page_gtk.cc b/chrome/browser/gtk/options/content_page_gtk.cc
index 45ccd26..a64ffb9 100644
--- a/chrome/browser/gtk/options/content_page_gtk.cc
+++ b/chrome/browser/gtk/options/content_page_gtk.cc
@@ -31,9 +31,34 @@
#include "grit/generated_resources.h"
#include "grit/locale_settings.h"
+namespace {
+
// Background color for the status label when it's showing an error.
static const GdkColor kSyncLabelErrorBgColor = GDK_COLOR_RGB(0xff, 0x9a, 0x9a);
+// Helper for WrapLabelAtAllocationHack.
+void OnLabelAllocate(GtkWidget* label, GtkAllocation* allocation) {
+ gtk_widget_set_size_request(label, allocation->width, -1);
+
+ // Disconnect ourselves. Repeatedly resizing based on allocation causes
+ // the dialog to become unshrinkable.
+ g_signal_handlers_disconnect_by_func(label, (void*)OnLabelAllocate,
+ NULL);
+}
+
+// Set the label to use a request size equal to its initial 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 GTK doesn't really work when 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) {
+ g_signal_connect(label, "size-allocate",
+ G_CALLBACK(OnLabelAllocate), NULL);
+}
+
+} // anonymous namespace
+
///////////////////////////////////////////////////////////////////////////////
// ContentPageGtk, public:
@@ -328,7 +353,7 @@ GtkWidget* ContentPageGtk::InitSyncGroup() {
// Sync label.
sync_status_label_background_ = gtk_event_box_new();
sync_status_label_ = gtk_label_new("");
- gtk_util::WrapLabelAtAllocationHack(sync_status_label_);
+ 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);