forked from AuroraMiddleware/gtk
entry: Make code do what it's meant to do
With the 3.0 transition, this code went from just querying the entry's height request to doing a full size request. Then it got code to revert the features that a full size request does. And then it grew code that manually computed the baseline. Avoid this and just do what happened back in the days: Do a regular height request. This changes the semantics of the get_frame_size() vfunc wrt its behavior towards subclasses overwriting the get_height() vfuncs, but I'm happy to live with that.
This commit is contained in:
parent
d2881d901b
commit
c5905b13b9
@ -3584,13 +3584,11 @@ gtk_entry_get_text_area_size (GtkEntry *entry,
|
|||||||
{
|
{
|
||||||
GtkWidget *widget = GTK_WIDGET (entry);
|
GtkWidget *widget = GTK_WIDGET (entry);
|
||||||
GtkAllocation allocation;
|
GtkAllocation allocation;
|
||||||
GtkRequisition requisition;
|
gint req_height, unused;
|
||||||
gint req_height;
|
|
||||||
gint frame_height;
|
gint frame_height;
|
||||||
GtkBorder borders;
|
GtkBorder borders;
|
||||||
|
|
||||||
gtk_widget_get_preferred_size (widget, &requisition, NULL);
|
gtk_entry_get_preferred_height_and_baseline_for_width (widget, -1, &req_height, &unused, NULL, NULL);
|
||||||
req_height = requisition.height - gtk_widget_get_margin_top (widget) - gtk_widget_get_margin_bottom (widget);
|
|
||||||
|
|
||||||
gtk_widget_get_allocation (widget, &allocation);
|
gtk_widget_get_allocation (widget, &allocation);
|
||||||
_gtk_entry_get_borders (entry, &borders);
|
_gtk_entry_get_borders (entry, &borders);
|
||||||
@ -3640,16 +3638,11 @@ gtk_entry_get_frame_size (GtkEntry *entry,
|
|||||||
{
|
{
|
||||||
GtkEntryPrivate *priv = entry->priv;
|
GtkEntryPrivate *priv = entry->priv;
|
||||||
GtkAllocation allocation;
|
GtkAllocation allocation;
|
||||||
GtkRequisition requisition;
|
|
||||||
GtkWidget *widget = GTK_WIDGET (entry);
|
GtkWidget *widget = GTK_WIDGET (entry);
|
||||||
gint area_height, y_pos;
|
|
||||||
gint baseline;
|
gint baseline;
|
||||||
gint req_height;
|
gint req_height, req_baseline, unused;
|
||||||
GtkBorder borders;
|
|
||||||
|
|
||||||
gtk_widget_get_preferred_size (widget, &requisition, NULL);
|
gtk_entry_get_preferred_height_and_baseline_for_width (widget, -1, &req_height, &unused, &req_baseline, &unused);
|
||||||
|
|
||||||
req_height = requisition.height - gtk_widget_get_margin_top (widget) - gtk_widget_get_margin_bottom (widget);
|
|
||||||
|
|
||||||
gtk_widget_get_allocation (widget, &allocation);
|
gtk_widget_get_allocation (widget, &allocation);
|
||||||
baseline = gtk_widget_get_allocated_baseline (widget);
|
baseline = gtk_widget_get_allocated_baseline (widget);
|
||||||
@ -3666,12 +3659,7 @@ gtk_entry_get_frame_size (GtkEntry *entry,
|
|||||||
if (baseline == -1)
|
if (baseline == -1)
|
||||||
*y = (allocation.height - req_height) / 2;
|
*y = (allocation.height - req_height) / 2;
|
||||||
else
|
else
|
||||||
{
|
*y = baseline - req_baseline;
|
||||||
_gtk_entry_get_borders (entry, &borders);
|
|
||||||
area_height = req_height - borders.top - borders.bottom;
|
|
||||||
y_pos = ((area_height * PANGO_SCALE - priv->ascent - priv->descent) / 2 + priv->ascent) / PANGO_SCALE;
|
|
||||||
*y = baseline - y_pos - borders.top;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
*y += allocation.y;
|
*y += allocation.y;
|
||||||
|
@ -263,11 +263,6 @@ static void gtk_spin_button_get_text_area_size (GtkEntry *entry,
|
|||||||
gint *y,
|
gint *y,
|
||||||
gint *width,
|
gint *width,
|
||||||
gint *height);
|
gint *height);
|
||||||
static void gtk_spin_button_get_frame_size (GtkEntry *entry,
|
|
||||||
gint *x,
|
|
||||||
gint *y,
|
|
||||||
gint *width,
|
|
||||||
gint *height);
|
|
||||||
static void gtk_spin_button_unset_adjustment (GtkSpinButton *spin_button);
|
static void gtk_spin_button_unset_adjustment (GtkSpinButton *spin_button);
|
||||||
static void gtk_spin_button_set_orientation (GtkSpinButton *spin_button,
|
static void gtk_spin_button_set_orientation (GtkSpinButton *spin_button,
|
||||||
GtkOrientation orientation);
|
GtkOrientation orientation);
|
||||||
@ -335,7 +330,6 @@ gtk_spin_button_class_init (GtkSpinButtonClass *class)
|
|||||||
|
|
||||||
entry_class->activate = gtk_spin_button_activate;
|
entry_class->activate = gtk_spin_button_activate;
|
||||||
entry_class->get_text_area_size = gtk_spin_button_get_text_area_size;
|
entry_class->get_text_area_size = gtk_spin_button_get_text_area_size;
|
||||||
entry_class->get_frame_size = gtk_spin_button_get_frame_size;
|
|
||||||
|
|
||||||
class->input = NULL;
|
class->input = NULL;
|
||||||
class->output = NULL;
|
class->output = NULL;
|
||||||
@ -1858,32 +1852,6 @@ gtk_spin_button_activate (GtkEntry *entry)
|
|||||||
GTK_ENTRY_CLASS (gtk_spin_button_parent_class)->activate (entry);
|
GTK_ENTRY_CLASS (gtk_spin_button_parent_class)->activate (entry);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
gtk_spin_button_get_frame_size (GtkEntry *entry,
|
|
||||||
gint *x,
|
|
||||||
gint *y,
|
|
||||||
gint *width,
|
|
||||||
gint *height)
|
|
||||||
{
|
|
||||||
GtkSpinButtonPrivate *priv = GTK_SPIN_BUTTON (entry)->priv;
|
|
||||||
gint up_panel_width, up_panel_height;
|
|
||||||
gint down_panel_width, down_panel_height;
|
|
||||||
|
|
||||||
gtk_spin_button_panel_get_size (GTK_SPIN_BUTTON (entry), priv->up_panel, &up_panel_width, &up_panel_height);
|
|
||||||
gtk_spin_button_panel_get_size (GTK_SPIN_BUTTON (entry), priv->down_panel, &down_panel_width, &down_panel_height);
|
|
||||||
|
|
||||||
GTK_ENTRY_CLASS (gtk_spin_button_parent_class)->get_frame_size (entry, x, y, width, height);
|
|
||||||
|
|
||||||
if (priv->orientation == GTK_ORIENTATION_VERTICAL)
|
|
||||||
{
|
|
||||||
if (y)
|
|
||||||
*y += up_panel_height;
|
|
||||||
|
|
||||||
if (height)
|
|
||||||
*height -= up_panel_height + down_panel_height;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_spin_button_get_text_area_size (GtkEntry *entry,
|
gtk_spin_button_get_text_area_size (GtkEntry *entry,
|
||||||
gint *x,
|
gint *x,
|
||||||
|
Loading…
Reference in New Issue
Block a user