[gtk] entry: Fix primary icon allocation in RTL entries
- From: Timm Bäder <baedert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk] entry: Fix primary icon allocation in RTL entries
- Date: Sun, 28 Apr 2019 06:37:32 +0000 (UTC)
commit 59fd48cee029af9039da5ef097123eeea84dbea3
Author: Timm Bäder <mail baedert org>
Date: Sun Apr 28 08:30:18 2019 +0200
entry: Fix primary icon allocation in RTL entries
The primary icon is on the right in RTL, so don't offset the text child
to the right for it.
Fixes the text and icon overlapping in the second entry
in tests/testentryicons
gtk/gtkentry.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index eb48816b39..03b7271fd7 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -1547,6 +1547,7 @@ gtk_entry_size_allocate (GtkWidget *widget,
int height,
int baseline)
{
+ const gboolean is_rtl = gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL;
GtkEntry *entry = GTK_ENTRY (widget);
GtkEntryPrivate *priv = gtk_entry_get_instance_private (entry);
gint i;
@@ -1572,8 +1573,8 @@ gtk_entry_size_allocate (GtkWidget *widget,
NULL, &icon_width,
NULL, NULL);
- if ((gtk_widget_get_direction (widget) == GTK_TEXT_DIR_RTL && i == GTK_ENTRY_ICON_PRIMARY) ||
- (gtk_widget_get_direction (widget) == GTK_TEXT_DIR_LTR && i == GTK_ENTRY_ICON_SECONDARY))
+ if ((is_rtl && i == GTK_ENTRY_ICON_PRIMARY) ||
+ (!is_rtl && i == GTK_ENTRY_ICON_SECONDARY))
icon_alloc.x = width - icon_width;
else
icon_alloc.x = 0;
@@ -1584,7 +1585,9 @@ gtk_entry_size_allocate (GtkWidget *widget,
gtk_widget_size_allocate (icon_info->widget, &icon_alloc, baseline);
text_alloc.width -= icon_width;
- if (i == 0)
+
+ if ((!is_rtl && i == GTK_ENTRY_ICON_PRIMARY) ||
+ (is_rtl && i == GTK_ENTRY_ICON_SECONDARY))
text_alloc.x += icon_width;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]