| Index: views/widget/gtk_views_fixed.cc
|
| diff --git a/views/widget/gtk_views_fixed.cc b/views/widget/gtk_views_fixed.cc
|
| index 0b322bb6990420a87859f1cf4c57d10b982c9ca0..a2a3f2f44005532ef9f225e476194065dc575131 100644
|
| --- a/views/widget/gtk_views_fixed.cc
|
| +++ b/views/widget/gtk_views_fixed.cc
|
| @@ -4,12 +4,16 @@
|
|
|
| #include "views/widget/gtk_views_fixed.h"
|
|
|
| +#include "base/logging.h"
|
| +
|
| // We store whether we use the widget's allocated size as a property. Ideally
|
| // we would stash this in GtkFixedChild, but GtkFixed doesn't allow subclassing
|
| // gtk_fixed_put. Alternatively we could subclass GtkContainer and use our own
|
| // API (effectively duplicating GtkFixed), but that means folks could no longer
|
| // use the GtkFixed API else where in Chrome. For now I'm going with this route.
|
| static const char* kUseAllocatedSize = "__VIEWS_USE_ALLOCATED_SIZE__";
|
| +static const char* kRequisitionWidth = "__VIEWS_REQUISITION_WIDTH__";
|
| +static const char* kRequisitionHeight = "__VIEWS_REQUISITION_HEIGHT__";
|
|
|
| G_BEGIN_DECLS
|
|
|
| @@ -32,13 +36,14 @@ static void gtk_views_fixed_size_allocate(GtkWidget* widget,
|
| if (GTK_WIDGET_VISIBLE(child->widget)) {
|
| GtkAllocation child_allocation;
|
|
|
| - gpointer use_allocated_size = g_object_get_data(G_OBJECT(child->widget),
|
| - kUseAllocatedSize);
|
| + int width, height;
|
| + bool use_allocated_size =
|
| + gtk_views_fixed_get_widget_size(child->widget, &width, &height);
|
| if (use_allocated_size) {
|
| // NOTE: even though the size isn't changing, we have to call
|
| // size_allocate, otherwise things like buttons won't repaint.
|
| - child_allocation.width = child->widget->allocation.width;
|
| - child_allocation.height = child->widget->allocation.height;
|
| + child_allocation.width = width;
|
| + child_allocation.height = height;
|
| } else {
|
| GtkRequisition child_requisition;
|
| gtk_widget_get_child_requisition(child->widget, &child_requisition);
|
| @@ -71,9 +76,29 @@ GtkWidget* gtk_views_fixed_new(void) {
|
| return GTK_WIDGET(g_object_new(GTK_TYPE_VIEWS_FIXED, NULL));
|
| }
|
|
|
| -void gtk_views_fixed_set_use_allocated_size(GtkWidget* widget, bool value) {
|
| +void gtk_views_fixed_set_widget_size(GtkWidget* widget,
|
| + int width, int height) {
|
| + // Remember the allocation request, and set this widget up to use it.
|
| + bool use_requested_size = (width != 0 && height != 0);
|
| g_object_set_data(G_OBJECT(widget), kUseAllocatedSize,
|
| - reinterpret_cast<gpointer>(value ? 1 : 0));
|
| + reinterpret_cast<gpointer>(use_requested_size ? 1 : 0));
|
| + g_object_set_data(G_OBJECT(widget), kRequisitionWidth,
|
| + reinterpret_cast<gpointer>(width));
|
| + g_object_set_data(G_OBJECT(widget), kRequisitionHeight,
|
| + reinterpret_cast<gpointer>(height));
|
| +
|
| + gtk_widget_queue_resize(widget);
|
| +}
|
| +
|
| +bool gtk_views_fixed_get_widget_size(GtkWidget* widget,
|
| + int* width, int* height) {
|
| + DCHECK(width);
|
| + DCHECK(height);
|
| + *width = reinterpret_cast<glong>(g_object_get_data(G_OBJECT(widget),
|
| + kRequisitionWidth));
|
| + *height = reinterpret_cast<glong>(g_object_get_data(G_OBJECT(widget),
|
| + kRequisitionHeight));
|
| + return (g_object_get_data(G_OBJECT(widget), kUseAllocatedSize) != 0);
|
| }
|
|
|
| G_END_DECLS
|
|
|