st: Use ClutterClickAction on StEntry primary/secondary icons

This makes them work on touchscreens as well.

Closes: #116


(cherry picked from commit dd59212d3f)
This commit is contained in:
Carlos Garnacho 2018-08-17 18:12:31 +00:00 committed by Florian Müllner
parent af50a7829f
commit dca43c7b24

View File

@ -1287,9 +1287,9 @@ st_entry_get_input_hints (StEntry *entry)
return clutter_text_get_input_hints (CLUTTER_TEXT (priv->entry)); return clutter_text_get_input_hints (CLUTTER_TEXT (priv->entry));
} }
static gboolean static void
_st_entry_icon_press_cb (ClutterActor *actor, _st_entry_icon_clicked_cb (ClutterClickAction *action,
ClutterButtonEvent *event, ClutterActor *actor,
StEntry *entry) StEntry *entry)
{ {
StEntryPrivate *priv = ST_ENTRY_PRIV (entry); StEntryPrivate *priv = ST_ENTRY_PRIV (entry);
@ -1298,8 +1298,6 @@ _st_entry_icon_press_cb (ClutterActor *actor,
g_signal_emit (entry, entry_signals[PRIMARY_ICON_CLICKED], 0); g_signal_emit (entry, entry_signals[PRIMARY_ICON_CLICKED], 0);
else else
g_signal_emit (entry, entry_signals[SECONDARY_ICON_CLICKED], 0); g_signal_emit (entry, entry_signals[SECONDARY_ICON_CLICKED], 0);
return FALSE;
} }
static void static void
@ -1309,21 +1307,24 @@ _st_entry_set_icon (StEntry *entry,
{ {
if (*icon) if (*icon)
{ {
g_signal_handlers_disconnect_by_func (*icon, clutter_actor_remove_action_by_name (*icon, "entry-icon-action");
_st_entry_icon_press_cb,
entry);
clutter_actor_remove_child (CLUTTER_ACTOR (entry), *icon); clutter_actor_remove_child (CLUTTER_ACTOR (entry), *icon);
*icon = NULL; *icon = NULL;
} }
if (new_icon) if (new_icon)
{ {
ClutterAction *action;
*icon = g_object_ref (new_icon); *icon = g_object_ref (new_icon);
clutter_actor_set_reactive (*icon, TRUE); clutter_actor_set_reactive (*icon, TRUE);
clutter_actor_add_child (CLUTTER_ACTOR (entry), *icon); clutter_actor_add_child (CLUTTER_ACTOR (entry), *icon);
g_signal_connect (*icon, "button-release-event",
G_CALLBACK (_st_entry_icon_press_cb), entry); action = clutter_click_action_new ();
clutter_actor_add_action_with_name (*icon, "entry-icon-action", action);
g_signal_connect (action, "clicked",
G_CALLBACK (_st_entry_icon_clicked_cb), entry);
} }
clutter_actor_queue_relayout (CLUTTER_ACTOR (entry)); clutter_actor_queue_relayout (CLUTTER_ACTOR (entry));