st/entry: Show hint actor while entry is focused

Also show the hint actor of an StEntry while the entry is focused but
has no text inside it. This is part of the new dialog and lock-screen
design where there are no labels before entries anymore and labels are
instead shown as a hint-text of the entry.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/944
This commit is contained in:
Jonas Dreßler 2020-01-22 20:53:34 +01:00 committed by Florian Müllner
parent ed647f5937
commit 88ac339774

View File

@ -232,8 +232,7 @@ st_entry_update_hint_visibility (StEntry *self)
StEntryPrivate *priv = ST_ENTRY_PRIV (self); StEntryPrivate *priv = ST_ENTRY_PRIV (self);
gboolean hint_visible = gboolean hint_visible =
priv->hint_actor != NULL && priv->hint_actor != NULL &&
strcmp (clutter_text_get_text (CLUTTER_TEXT (priv->entry)), "") == 0 && strcmp (clutter_text_get_text (CLUTTER_TEXT (priv->entry)), "") == 0;
!HAS_FOCUS (priv->entry);
if (priv->hint_actor) if (priv->hint_actor)
g_object_set (priv->hint_actor, "visible", hint_visible, NULL); g_object_set (priv->hint_actor, "visible", hint_visible, NULL);
@ -519,10 +518,6 @@ static void
clutter_text_focus_in_cb (ClutterText *text, clutter_text_focus_in_cb (ClutterText *text,
ClutterActor *actor) ClutterActor *actor)
{ {
StEntry *entry = ST_ENTRY (actor);
st_entry_update_hint_visibility (entry);
st_widget_add_style_pseudo_class (ST_WIDGET (actor), "focus"); st_widget_add_style_pseudo_class (ST_WIDGET (actor), "focus");
clutter_text_set_cursor_visible (text, TRUE); clutter_text_set_cursor_visible (text, TRUE);
} }
@ -531,12 +526,7 @@ static void
clutter_text_focus_out_cb (ClutterText *text, clutter_text_focus_out_cb (ClutterText *text,
ClutterActor *actor) ClutterActor *actor)
{ {
StEntry *entry = ST_ENTRY (actor);
st_widget_remove_style_pseudo_class (ST_WIDGET (actor), "focus"); st_widget_remove_style_pseudo_class (ST_WIDGET (actor), "focus");
st_entry_update_hint_visibility (entry);
clutter_text_set_cursor_visible (text, FALSE); clutter_text_set_cursor_visible (text, FALSE);
} }
@ -548,6 +538,8 @@ clutter_text_changed_cb (GObject *object,
StEntry *entry = ST_ENTRY (user_data); StEntry *entry = ST_ENTRY (user_data);
StEntryPrivate *priv = ST_ENTRY_PRIV (entry); StEntryPrivate *priv = ST_ENTRY_PRIV (entry);
st_entry_update_hint_visibility (entry);
/* Since the text changed, force a regen of the shadow texture */ /* Since the text changed, force a regen of the shadow texture */
cogl_clear_object (&priv->text_shadow_material); cogl_clear_object (&priv->text_shadow_material);
} }
@ -1039,10 +1031,8 @@ st_entry_get_text (StEntry *entry)
g_return_val_if_fail (ST_IS_ENTRY (entry), NULL); g_return_val_if_fail (ST_IS_ENTRY (entry), NULL);
priv = st_entry_get_instance_private (entry); priv = st_entry_get_instance_private (entry);
if (priv->hint_actor != NULL && clutter_actor_is_visible (priv->hint_actor))
return ""; return clutter_text_get_text (CLUTTER_TEXT (priv->entry));
else
return clutter_text_get_text (CLUTTER_TEXT (priv->entry));
} }
/** /**
@ -1064,8 +1054,6 @@ st_entry_set_text (StEntry *entry,
clutter_text_set_text (CLUTTER_TEXT (priv->entry), text); clutter_text_set_text (CLUTTER_TEXT (priv->entry), text);
st_entry_update_hint_visibility (entry);
g_object_notify_by_pspec (G_OBJECT (entry), props[PROP_TEXT]); g_object_notify_by_pspec (G_OBJECT (entry), props[PROP_TEXT]);
} }