After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 783484 - Improvements for StEntry
Improvements for StEntry
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: st
unspecified
Other All
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2017-06-06 15:46 UTC by Cosimo Cecchi
Modified: 2017-06-14 22:16 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
st-entry: Add support for a "hint actor" (11.20 KB, patch)
2017-06-06 15:46 UTC, Cosimo Cecchi
none Details | Review
st-entry: Add support for the text-shadow CSS property (5.13 KB, patch)
2017-06-06 15:46 UTC, Cosimo Cecchi
none Details | Review
st-entry: Add primary-icon and secondary-icon read-write properties (4.63 KB, patch)
2017-06-06 15:46 UTC, Cosimo Cecchi
committed Details | Review
st: initialize static variables to NULL (1.24 KB, patch)
2017-06-07 00:59 UTC, Cosimo Cecchi
committed Details | Review
st-entry: don't assume a cursor func has been set (856 bytes, patch)
2017-06-07 00:59 UTC, Cosimo Cecchi
committed Details | Review
st-im-text: don't require st_im_text_set_event_window() to be called (2.50 KB, patch)
2017-06-07 00:59 UTC, Cosimo Cecchi
committed Details | Review
tests/entry: remove unused import (868 bytes, patch)
2017-06-07 00:59 UTC, Cosimo Cecchi
committed Details | Review
st-entry: Add support for the text-shadow CSS property (5.10 KB, patch)
2017-06-07 01:00 UTC, Cosimo Cecchi
none Details | Review
tests/entry: add text-shadow (1.36 KB, patch)
2017-06-07 01:00 UTC, Cosimo Cecchi
none Details | Review
st-entry: don't possibly allocate actors a negative size (1.27 KB, patch)
2017-06-07 01:00 UTC, Cosimo Cecchi
none Details | Review
st-entry: Add support for a "hint actor" (13.21 KB, patch)
2017-06-07 01:00 UTC, Cosimo Cecchi
none Details | Review
tests/entry: add interactive tests for entry hints (2.12 KB, patch)
2017-06-07 01:00 UTC, Cosimo Cecchi
none Details | Review
st-entry: Add support for the text-shadow CSS property (5.41 KB, patch)
2017-06-14 21:04 UTC, Cosimo Cecchi
committed Details | Review
tests/entry: add text-shadow (1.36 KB, patch)
2017-06-14 21:04 UTC, Cosimo Cecchi
committed Details | Review
st-entry: don't possibly allocate actors a negative size (1.27 KB, patch)
2017-06-14 21:04 UTC, Cosimo Cecchi
committed Details | Review
st-entry: Add support for a "hint actor" (13.58 KB, patch)
2017-06-14 21:05 UTC, Cosimo Cecchi
committed Details | Review
tests/entry: add interactive tests for entry hints (2.12 KB, patch)
2017-06-14 21:05 UTC, Cosimo Cecchi
committed Details | Review

Description Cosimo Cecchi 2017-06-06 15:46:03 UTC
See attached patches.
Comment 1 Cosimo Cecchi 2017-06-06 15:46:06 UTC
Created attachment 353267 [details] [review]
st-entry: Add support for a "hint actor"

This allows a full ClutterActor to be used as hint in the entry, instead
of a simple string.
Comment 2 Cosimo Cecchi 2017-06-06 15:46:10 UTC
Created attachment 353268 [details] [review]
st-entry: Add support for the text-shadow CSS property

It's supported everywhere else, we should also support it here.
Comment 3 Cosimo Cecchi 2017-06-06 15:46:14 UTC
Created attachment 353269 [details] [review]
st-entry: Add primary-icon and secondary-icon read-write properties

Instead of simply providing a setter, we now provide real properties.
Comment 4 Florian Müllner 2017-06-06 19:05:32 UTC
Review of attachment 353268 [details] [review]:

This needs better documentation - "Add support for the text-shadow CSS property" sounds like text-shadow support for entry text, but the patch appears to add some support under some specific (but unexplained) conditions only. Either make the patch implement the advertised behavior, or explain the limitations in the commit message and a comment.

Also a test case would be neat.
Comment 5 Florian Müllner 2017-06-06 19:05:38 UTC
Review of attachment 353269 [details] [review]:

OK
Comment 6 Florian Müllner 2017-06-06 19:05:47 UTC
Review of attachment 353267 [details] [review]:

This appears to break the existing hint-text property, at least in some cases (the overview search box). As that's even a simple case - hint-actor isn't used at all - I wonder if the best way to avoid odd interaction issues between both properties is to make the existing hint-text a shorthand:

 st_entry_set_hint_text (StEntry *entry, const char *text)
   {
     st_entry_set_hint_actor (entry, st_label_new (text));
   }

 st_entry_get_hint_text (StEntry *entry)
   {
     if (priv->hint_actor && ST_IS_LABEL (priv->hint_actor))
       return st_label_get_text (ST_LABEL (priv->hint_actor));
     return NULL;
   }

In any case, adding a test case to tests/interactive looks like a good idea as well.
Comment 7 Cosimo Cecchi 2017-06-06 21:56:46 UTC
Comment on attachment 353269 [details] [review]
st-entry: Add primary-icon and secondary-icon read-write properties

Attachment 353269 [details] pushed as 7f7d187 - st-entry: Add primary-icon and secondary-icon read-write properties
Comment 8 Cosimo Cecchi 2017-06-07 00:59:43 UTC
Created attachment 353280 [details] [review]
st: initialize static variables to NULL
Comment 9 Cosimo Cecchi 2017-06-07 00:59:48 UTC
Created attachment 353281 [details] [review]
st-entry: don't assume a cursor func has been set

That won't be the case when called from tests.
Comment 10 Cosimo Cecchi 2017-06-07 00:59:53 UTC
Created attachment 353282 [details] [review]
st-im-text: don't require st_im_text_set_event_window() to be called

Tests like tests/interactive/entry.js don't call it; make sure we still
display an entry in that case.
Comment 11 Cosimo Cecchi 2017-06-07 00:59:58 UTC
Created attachment 353283 [details] [review]
tests/entry: remove unused import

This is actually harmful, since it will drag a depepdency chain that
we're not able to satisfy from the tests.
Comment 12 Cosimo Cecchi 2017-06-07 01:00:05 UTC
Created attachment 353284 [details] [review]
st-entry: Add support for the text-shadow CSS property

It's supported everywhere else, we should also support it here.
Comment 13 Cosimo Cecchi 2017-06-07 01:00:10 UTC
Created attachment 353285 [details] [review]
tests/entry: add text-shadow

Also make the text larger and add an example string, since event
delivery does not seem to work properly under tests.
Comment 14 Cosimo Cecchi 2017-06-07 01:00:14 UTC
Created attachment 353286 [details] [review]
st-entry: don't possibly allocate actors a negative size

Clutter will complain about this, so protect the code against such edge
case.
Comment 15 Cosimo Cecchi 2017-06-07 01:00:20 UTC
Created attachment 353287 [details] [review]
st-entry: Add support for a "hint actor"

This allows a full ClutterActor to be used as hint in the entry, instead
of a simple string.

The string case has been now re-implemented on top of the hint actor.
Comment 16 Cosimo Cecchi 2017-06-07 01:00:26 UTC
Created attachment 353288 [details] [review]
tests/entry: add interactive tests for entry hints
Comment 17 Cosimo Cecchi 2017-06-07 01:01:31 UTC
Thanks for the reviews, Florian. I updated the patches and included testcases too (I had to fix a few things to get the entry testcase to run).
Comment 18 Florian Müllner 2017-06-14 00:47:31 UTC
Review of attachment 353280 [details] [review]:

OK
Comment 19 Florian Müllner 2017-06-14 00:47:35 UTC
Review of attachment 353281 [details] [review]:

OK
Comment 20 Florian Müllner 2017-06-14 00:47:40 UTC
Review of attachment 353282 [details] [review]:

::: src/st/st-im-text.c
@@ +237,3 @@
+    {
+      g_object_unref (priv->window);
+      priv->window = NULL;

Or:
g_object_clear (&priv->window);
Comment 21 Florian Müllner 2017-06-14 00:47:46 UTC
Review of attachment 353283 [details] [review]:

depepdency, otherwise LGTM
Comment 22 Florian Müllner 2017-06-14 00:47:52 UTC
Review of attachment 353284 [details] [review]:

Overall this looks good to me, but shadow updates still don't quite work (but should be easy to fix)

::: src/st/st-entry.c
@@ +1065,3 @@
+    {
+      cogl_handle_unref (priv->text_shadow_material);
+      priv->text_shadow_material = COGL_INVALID_HANDLE;

This doesn't really work - that code is only called when the text was changed programmatically, not in the more common case where the user actually types in some text. I don't think we get around a ::text-changed handler ...
Comment 23 Florian Müllner 2017-06-14 00:47:57 UTC
Review of attachment 353285 [details] [review]:

OK (the event delivery regression really is painful, we need to look into that eventually)
Comment 24 Florian Müllner 2017-06-14 00:48:02 UTC
Review of attachment 353286 [details] [review]:

Is the issue that we use both the icons' min- and nat width in the size request, but always allocate them at their natural width? I don't mind the patch, I just wonder whether using the icons' nat width for the minimum size as well would fix the issue without starting to overlap elements ...
Comment 25 Florian Müllner 2017-06-14 00:48:21 UTC
Review of attachment 353287 [details] [review]:

::: src/st/st-entry.c
@@ +278,3 @@
 static void
+st_entry_set_hint_visible (StEntry *self,
+                           gboolean visible)

As far as I can see, this could be

st_entry_update_hint_visibility (StEntry *self)

In the end, the visible parameter always boils down to

  strcmp (clutter_text_get_text (priv->entry, "") == 0 && !HAS_FOCUS (priv->entry),

so we could just as well compute it in the function itself. And maybe add "priv->hint_actor != NULL" to the conditions, so we don't set the indeterminate style when no hint has been set?

@@ +284,3 @@
+  if (visible)
+    {
+      priv->hint_visible = TRUE;

This was needed to differentiate between "priv->entry shows hint" and "priv->entry shows entry text". Now that priv->entry is never used for the hint, we don't need this anymore. In fact, I think the entire function can be reduced to:

gboolean visible = strcmp (st_entry_get_text (self), "") == 0 &&
                   !HAS_FOCUS (priv->entry);

if (priv->hint_actor)
  g_object_set (priv->hint_actor, "visible", visible, NULL);

if (visible)
  st_widget_add_style_pseudo_class (...);
else
  st_widget_remove_style_pseudo_class (...);

@@ +611,2 @@
   /* add a hint if the entry is empty */
+  if (g_strcmp0 (clutter_text_get_text (text), "") == 0)

Neither argument can be NULL, so strcmp

@@ +1143,2 @@
   else
+    st_entry_set_hint_visible (entry, FALSE);

Alternatively:

gboolean hint_visible = g_strcmp0 (text, "") == 0 && !HAS_FOCUS (priv->entry);
st_entry_set_hint_visible (entry, show_hint);

@@ +1451,3 @@
+        st_entry_set_hint_visible (entry, TRUE);
+      else
+        st_entry_set_hint_visible (entry, FALSE);

If we decide on not setting the :indeterminate style when no hint has been set, that bit should be moved out of the if block

::: src/st/st-entry.h
@@ +67,3 @@
 
+void            st_entry_set_hint_actor    (StEntry      *entry,
+                                            ClutterActor *hint_actor);

Maybe add a getter as well for the sake of completeness?
Comment 26 Florian Müllner 2017-06-14 00:48:26 UTC
Review of attachment 353288 [details] [review]:

LGTM
Comment 27 Florian Müllner 2017-06-14 00:50:23 UTC
(In reply to Florian Müllner from comment #26)
> Review of attachment 353288 [details] [review] [review]:
> 
> LGTM

(except that I don't see the neat swap-hints-every-second case, so maybe the problem here isn't even delivery, but the main loop?)
Comment 28 Cosimo Cecchi 2017-06-14 21:00:27 UTC
Attachment 353280 [details] pushed as d5cac65 - st: initialize static variables to NULL
Attachment 353281 [details] pushed as a256a35 - st-entry: don't assume a cursor func has been set
Attachment 353282 [details] pushed as 9e0e7a4 - st-im-text: don't require st_im_text_set_event_window() to be called
Attachment 353283 [details] pushed as 4c72244 - tests/entry: remove unused import
Comment 29 Cosimo Cecchi 2017-06-14 21:04:47 UTC
Created attachment 353770 [details] [review]
st-entry: Add support for the text-shadow CSS property

It's supported everywhere else, we should also support it here.
Comment 30 Cosimo Cecchi 2017-06-14 21:04:51 UTC
Created attachment 353771 [details] [review]
tests/entry: add text-shadow

Also make the text larger and add an example string, since event
delivery does not seem to work properly under tests.
Comment 31 Cosimo Cecchi 2017-06-14 21:04:56 UTC
Created attachment 353772 [details] [review]
st-entry: don't possibly allocate actors a negative size

Clutter will complain about this, so protect the code against such edge
case.
Comment 32 Cosimo Cecchi 2017-06-14 21:05:01 UTC
Created attachment 353773 [details] [review]
st-entry: Add support for a "hint actor"

This allows a full ClutterActor to be used as hint in the entry, instead
of a simple string.

The string case has been now re-implemented on top of the hint actor.
Comment 33 Cosimo Cecchi 2017-06-14 21:05:06 UTC
Created attachment 353774 [details] [review]
tests/entry: add interactive tests for entry hints
Comment 34 Cosimo Cecchi 2017-06-14 21:07:46 UTC
(In reply to Florian Müllner from comment #24)
> Review of attachment 353286 [details] [review] [review]:
> 
> Is the issue that we use both the icons' min- and nat width in the size
> request, but always allocate them at their natural width? I don't mind the
> patch, I just wonder whether using the icons' nat width for the minimum size
> as well would fix the issue without starting to overlap elements ...

That does not seem to be the issue... We do report the natural size of the icon in both the minimum and natural size of the entry as far as I can see. However under some circumstances (I believe this happened when booting without a monitor attached, but it's been a long time), it can happen that the entry is underallocated.
Comment 35 Cosimo Cecchi 2017-06-14 21:08:27 UTC
(In reply to Florian Müllner from comment #27)
> (In reply to Florian Müllner from comment #26)
> > Review of attachment 353288 [details] [review] [review] [review]:
> > 
> > LGTM
> 
> (except that I don't see the neat swap-hints-every-second case, so maybe the
> problem here isn't even delivery, but the main loop?)

Weird; I do see the swap here, so I don't think there's an issue with the mainloop though.
Comment 36 Cosimo Cecchi 2017-06-14 21:09:26 UTC
Thanks, Florian. I addressed the review comments and applied your suggestions to simplify further the hint actor patch.
Comment 37 Florian Müllner 2017-06-14 21:26:29 UTC
Review of attachment 353770 [details] [review]:

LGTM
Comment 38 Florian Müllner 2017-06-14 21:26:34 UTC
Review of attachment 353771 [details] [review]:

Reattached acn patch
Comment 39 Florian Müllner 2017-06-14 21:26:37 UTC
Review of attachment 353772 [details] [review]:

OK, let's go with this then
Comment 40 Florian Müllner 2017-06-14 21:26:39 UTC
Review of attachment 353773 [details] [review]:

Nice
Comment 41 Florian Müllner 2017-06-14 21:26:42 UTC
Review of attachment 353774 [details] [review]:

Reattached acn patch
Comment 42 Cosimo Cecchi 2017-06-14 22:16:27 UTC
Thanks for all the review Florian!

Attachment 353770 [details] pushed as 8783654 - st-entry: Add support for the text-shadow CSS property
Attachment 353771 [details] pushed as 708f65e - tests/entry: add text-shadow
Attachment 353772 [details] pushed as 4e07d0b - st-entry: don't possibly allocate actors a negative size
Attachment 353773 [details] pushed as 6ed7034 - st-entry: Add support for a "hint actor"
Attachment 353774 [details] pushed as 47b109d - tests/entry: add interactive tests for entry hints