From 73928c9b299d7dff763edfcc93e2c29f84f7aa46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Thu, 23 Jan 2025 00:06:17 +0100 Subject: [PATCH] st: Use consistent type for properties/getters gjs now optimizes property accesses if possible, by calling the corresponding getter/setter method. For this to work, the method not only has to exist (obviously), but also match the type of the corresponding property. Both `Label` and `Entry` currently define their `clutter-text` property as `Clutter.Text`, while the corresponding getter returns the more generic `Clutter.Actor`. Fix that so that both property and getter use the more specific type. Part-of: --- src/st/st-entry.c | 8 ++++++-- src/st/st-entry.h | 2 +- src/st/st-label.c | 4 ++-- src/st/st-label.h | 2 +- src/st/st-password-entry.c | 14 +++++++------- 5 files changed, 17 insertions(+), 13 deletions(-) diff --git a/src/st/st-entry.c b/src/st/st-entry.c index d2b9c61cd..5ce08dfd2 100644 --- a/src/st/st-entry.c +++ b/src/st/st-entry.c @@ -1165,12 +1165,16 @@ st_entry_set_text (StEntry *entry, * * Returns: (transfer none): the #ClutterText used by @entry */ -ClutterActor* +ClutterText * st_entry_get_clutter_text (StEntry *entry) { + StEntryPrivate *priv; + g_return_val_if_fail (ST_ENTRY (entry), NULL); - return ((StEntryPrivate *)ST_ENTRY_PRIV (entry))->entry; + priv = st_entry_get_instance_private (entry); + + return CLUTTER_TEXT (priv->entry); } /** diff --git a/src/st/st-entry.h b/src/st/st-entry.h index b0958bbab..b62749082 100644 --- a/src/st/st-entry.h +++ b/src/st/st-entry.h @@ -43,7 +43,7 @@ StWidget *st_entry_new (const gchar *text); const gchar *st_entry_get_text (StEntry *entry); void st_entry_set_text (StEntry *entry, const gchar *text); -ClutterActor *st_entry_get_clutter_text (StEntry *entry); +ClutterText *st_entry_get_clutter_text (StEntry *entry); void st_entry_set_hint_text (StEntry *entry, const gchar *text); diff --git a/src/st/st-label.c b/src/st/st-label.c index fe88f19ea..164c5419c 100644 --- a/src/st/st-label.c +++ b/src/st/st-label.c @@ -429,12 +429,12 @@ st_label_set_text (StLabel *label, * Returns: (transfer none): the #ClutterText used by #StLabel. The actor * is owned by the #StLabel and should not be destroyed by the application. */ -ClutterActor* +ClutterText * st_label_get_clutter_text (StLabel *label) { g_return_val_if_fail (ST_LABEL (label), NULL); - return label->priv->label; + return CLUTTER_TEXT (label->priv->label); } diff --git a/src/st/st-label.h b/src/st/st-label.h index 199a5a006..1c8d1581e 100644 --- a/src/st/st-label.h +++ b/src/st/st-label.h @@ -44,7 +44,7 @@ StWidget * st_label_new (const gchar *text); const gchar * st_label_get_text (StLabel *label); void st_label_set_text (StLabel *label, const gchar *text); -ClutterActor * st_label_get_clutter_text (StLabel *label); +ClutterText * st_label_get_clutter_text (StLabel *label); G_END_DECLS diff --git a/src/st/st-password-entry.c b/src/st/st-password-entry.c index 3fe50082f..b55d7b1da 100644 --- a/src/st/st-password-entry.c +++ b/src/st/st-password-entry.c @@ -205,10 +205,10 @@ clutter_text_password_char_cb (GObject *object, gpointer user_data) { StPasswordEntry *entry = ST_PASSWORD_ENTRY (user_data); - ClutterActor *clutter_text; + ClutterText *clutter_text; clutter_text = st_entry_get_clutter_text (ST_ENTRY (entry)); - if (clutter_text_get_password_char (CLUTTER_TEXT (clutter_text)) == 0) + if (clutter_text_get_password_char (clutter_text) == 0) st_password_entry_set_password_visible (entry, TRUE); else st_password_entry_set_password_visible (entry, FALSE); @@ -218,7 +218,7 @@ static void st_password_entry_init (StPasswordEntry *entry) { StPasswordEntryPrivate *priv = ST_PASSWORD_ENTRY_PRIV (entry); - ClutterActor *clutter_text; + ClutterText *clutter_text; priv->peek_password_icon = g_object_new (ST_TYPE_ICON, "style-class", "peek-password", @@ -235,7 +235,7 @@ st_password_entry_init (StPasswordEntry *entry) 0); clutter_text = st_entry_get_clutter_text (ST_ENTRY (entry)); - clutter_text_set_password_char (CLUTTER_TEXT (clutter_text), BLACK_CIRCLE); + clutter_text_set_password_char (clutter_text, BLACK_CIRCLE); st_entry_set_input_purpose (ST_ENTRY (entry), CLUTTER_INPUT_CONTENT_PURPOSE_PASSWORD); @@ -316,7 +316,7 @@ st_password_entry_set_password_visible (StPasswordEntry *entry, gboolean value) { StPasswordEntryPrivate *priv; - ClutterActor *clutter_text; + ClutterText *clutter_text; g_return_if_fail (ST_IS_PASSWORD_ENTRY (entry)); @@ -329,12 +329,12 @@ st_password_entry_set_password_visible (StPasswordEntry *entry, clutter_text = st_entry_get_clutter_text (ST_ENTRY (entry)); if (priv->password_visible) { - clutter_text_set_password_char (CLUTTER_TEXT (clutter_text), 0); + clutter_text_set_password_char (clutter_text, 0); st_icon_set_icon_name (ST_ICON (priv->peek_password_icon), "view-conceal-symbolic"); } else { - clutter_text_set_password_char (CLUTTER_TEXT (clutter_text), BLACK_CIRCLE); + clutter_text_set_password_char (clutter_text, BLACK_CIRCLE); st_icon_set_icon_name (ST_ICON (priv->peek_password_icon), "view-reveal-symbolic"); }