[libhandy] action-row: Drop the title prop and its accessors
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libhandy] action-row: Drop the title prop and its accessors
- Date: Fri, 31 Jul 2020 00:55:46 +0000 (UTC)
commit 7143fc2bc373c78f958fc3eaabe50bba8af2fc2c
Author: Adrien Plazas <kekun plazas laposte net>
Date: Mon Jul 27 09:52:06 2020 +0200
action-row: Drop the title prop and its accessors
Use the title property inherited from HdyPreferencesRow instead.
Fixes https://gitlab.gnome.org/GNOME/libhandy/-/issues/258
debian/libhandy-1-0.symbols | 2 -
src/hdy-action-row.c | 91 +++++++++-----------------------------------
src/hdy-action-row.h | 6 ---
src/hdy-action-row.ui | 1 +
src/hdy-expander-row.c | 4 +-
src/hdy-preferences-window.c | 2 +-
tests/test-action-row.c | 16 --------
7 files changed, 22 insertions(+), 100 deletions(-)
---
diff --git a/debian/libhandy-1-0.symbols b/debian/libhandy-1-0.symbols
index 0c3fc88b..5e9320bf 100644
--- a/debian/libhandy-1-0.symbols
+++ b/debian/libhandy-1-0.symbols
@@ -5,14 +5,12 @@ libhandy-1.so.0 libhandy-1-0 #MINVER#
hdy_action_row_get_activatable_widget@LIBHANDY_1_0 0.0.7
hdy_action_row_get_icon_name@LIBHANDY_1_0 0.0.6
hdy_action_row_get_subtitle@LIBHANDY_1_0 0.0.6
- hdy_action_row_get_title@LIBHANDY_1_0 0.0.6
hdy_action_row_get_type@LIBHANDY_1_0 0.0.6
hdy_action_row_get_use_underline@LIBHANDY_1_0 0.0.6
hdy_action_row_new@LIBHANDY_1_0 0.0.6
hdy_action_row_set_activatable_widget@LIBHANDY_1_0 0.0.7
hdy_action_row_set_icon_name@LIBHANDY_1_0 0.0.6
hdy_action_row_set_subtitle@LIBHANDY_1_0 0.0.6
- hdy_action_row_set_title@LIBHANDY_1_0 0.0.6
hdy_action_row_set_use_underline@LIBHANDY_1_0 0.0.6
hdy_application_window_get_type@LIBHANDY_1_0 0.80.0
hdy_application_window_new@LIBHANDY_1_0 0.80.0
diff --git a/src/hdy-action-row.c b/src/hdy-action-row.c
index d95b106f..a0b5ba60 100644
--- a/src/hdy-action-row.c
+++ b/src/hdy-action-row.c
@@ -74,7 +74,6 @@ enum {
PROP_ICON_NAME,
PROP_ACTIVATABLE_WIDGET,
PROP_SUBTITLE,
- PROP_TITLE,
PROP_USE_UNDERLINE,
LAST_PROP,
};
@@ -143,9 +142,6 @@ hdy_action_row_get_property (GObject *object,
case PROP_SUBTITLE:
g_value_set_string (value, hdy_action_row_get_subtitle (self));
break;
- case PROP_TITLE:
- g_value_set_string (value, hdy_action_row_get_title (self));
- break;
case PROP_USE_UNDERLINE:
g_value_set_boolean (value, hdy_action_row_get_use_underline (self));
break;
@@ -172,9 +168,6 @@ hdy_action_row_set_property (GObject *object,
case PROP_SUBTITLE:
hdy_action_row_set_subtitle (self, g_value_get_string (value));
break;
- case PROP_TITLE:
- hdy_action_row_set_title (self, g_value_get_string (value));
- break;
case PROP_USE_UNDERLINE:
hdy_action_row_set_use_underline (self, g_value_get_boolean (value));
break;
@@ -391,20 +384,6 @@ hdy_action_row_class_init (HdyActionRowClass *klass)
"",
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
- /**
- * HdyActionRow:title:
- *
- * The title for this row.
- *
- * Since: 0.0.6
- */
- props[PROP_TITLE] =
- g_param_spec_string ("title",
- _("Title"),
- _("Title"),
- "",
- G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY);
-
/**
* HdyActionRow:use-underline:
*
@@ -450,11 +429,29 @@ hdy_action_row_class_init (HdyActionRowClass *klass)
gtk_widget_class_bind_template_child_private (widget_class, HdyActionRow, title_box);
}
+static gboolean
+string_is_not_empty (GBinding *binding,
+ const GValue *from_value,
+ GValue *to_value,
+ gpointer user_data)
+{
+ const gchar *string = g_value_get_string (from_value);
+
+ g_value_set_boolean (to_value, string != NULL && g_strcmp0 (string, "") != 0);
+
+ return TRUE;
+}
+
static void
hdy_action_row_init (HdyActionRow *self)
{
+ HdyActionRowPrivate *priv = hdy_action_row_get_instance_private (self);
+
gtk_widget_init_template (GTK_WIDGET (self));
+ g_object_bind_property_full (self, "title", priv->title, "visible", G_BINDING_SYNC_CREATE,
+ string_is_not_empty, NULL, NULL, NULL);
+
update_subtitle_visibility (self);
g_signal_connect (self, "notify::parent", G_CALLBACK (parent_cb), NULL);
@@ -500,58 +497,6 @@ hdy_action_row_new (void)
return g_object_new (HDY_TYPE_ACTION_ROW, NULL);
}
-/**
- * hdy_action_row_get_title:
- * @self: a #HdyActionRow
- *
- * Gets the title for @self.
- *
- * Returns: the title for @self.
- *
- * Since: 0.0.6
- */
-const gchar *
-hdy_action_row_get_title (HdyActionRow *self)
-{
- HdyActionRowPrivate *priv;
-
- g_return_val_if_fail (HDY_IS_ACTION_ROW (self), NULL);
-
- priv = hdy_action_row_get_instance_private (self);
-
- return gtk_label_get_text (priv->title);
-}
-
-/**
- * hdy_action_row_set_title:
- * @self: a #HdyActionRow
- * @title: the title
- *
- * Sets the title for @self.
- *
- * Since: 0.0.6
- */
-void
-hdy_action_row_set_title (HdyActionRow *self,
- const gchar *title)
-{
- HdyActionRowPrivate *priv;
-
- g_return_if_fail (HDY_IS_ACTION_ROW (self));
-
- priv = hdy_action_row_get_instance_private (self);
- hdy_preferences_row_set_title (HDY_PREFERENCES_ROW (self), title);
-
- if (g_strcmp0 (gtk_label_get_text (priv->title), title) == 0)
- return;
-
- gtk_label_set_text (priv->title, title);
- gtk_widget_set_visible (GTK_WIDGET (priv->title),
- title != NULL && g_strcmp0 (title, "") != 0);
-
- g_object_notify_by_pspec (G_OBJECT (self), props[PROP_TITLE]);
-}
-
/**
* hdy_action_row_get_subtitle:
* @self: a #HdyActionRow
diff --git a/src/hdy-action-row.h b/src/hdy-action-row.h
index 32135a3e..7b5dd53e 100644
--- a/src/hdy-action-row.h
+++ b/src/hdy-action-row.h
@@ -39,12 +39,6 @@ struct _HdyActionRowClass
HDY_AVAILABLE_IN_ALL
GtkWidget *hdy_action_row_new (void);
-HDY_AVAILABLE_IN_ALL
-const gchar *hdy_action_row_get_title (HdyActionRow *self);
-HDY_AVAILABLE_IN_ALL
-void hdy_action_row_set_title (HdyActionRow *self,
- const gchar *title);
-
HDY_AVAILABLE_IN_ALL
const gchar *hdy_action_row_get_subtitle (HdyActionRow *self);
HDY_AVAILABLE_IN_ALL
diff --git a/src/hdy-action-row.ui b/src/hdy-action-row.ui
index 57e4e826..ff54c152 100644
--- a/src/hdy-action-row.ui
+++ b/src/hdy-action-row.ui
@@ -43,6 +43,7 @@
<property name="ellipsize">end</property>
<property name="halign">start</property>
<property name="hexpand">True</property>
+ <property name="label" bind-source="HdyActionRow" bind-property="title"
bind-flags="sync-create"/>
<property name="visible">True</property>
<property name="xalign">0</property>
<style>
diff --git a/src/hdy-expander-row.c b/src/hdy-expander-row.c
index b6b6fbfe..7c577a16 100644
--- a/src/hdy-expander-row.c
+++ b/src/hdy-expander-row.c
@@ -476,7 +476,7 @@ hdy_expander_row_get_title (HdyExpanderRow *self)
priv = hdy_expander_row_get_instance_private (self);
- return hdy_action_row_get_title (priv->action_row);
+ return hdy_preferences_row_get_title (HDY_PREFERENCES_ROW (priv->action_row));
}
/**
@@ -498,7 +498,7 @@ hdy_expander_row_set_title (HdyExpanderRow *self,
priv = hdy_expander_row_get_instance_private (self);
- hdy_action_row_set_title (priv->action_row, title);
+ hdy_preferences_row_set_title (HDY_PREFERENCES_ROW (priv->action_row), title);
}
/**
diff --git a/src/hdy-preferences-window.c b/src/hdy-preferences-window.c
index fd19f1ad..3618d580 100644
--- a/src/hdy-preferences-window.c
+++ b/src/hdy-preferences-window.c
@@ -66,7 +66,7 @@ filter_search_results (HdyActionRow *row,
{
HdyPreferencesWindowPrivate *priv = hdy_preferences_window_get_instance_private (self);
g_autofree gchar *text = g_utf8_casefold (gtk_entry_get_text (GTK_ENTRY (priv->search_entry)), -1);
- g_autofree gchar *title = g_utf8_casefold (hdy_action_row_get_title (row), -1);
+ g_autofree gchar *title = g_utf8_casefold (hdy_preferences_row_get_title (HDY_PREFERENCES_ROW (row)), -1);
g_autofree gchar *subtitle = NULL;
/* The CSS engine works in such a way that invisible children are treated as
diff --git a/tests/test-action-row.c b/tests/test-action-row.c
index 38c63424..c7c4843b 100644
--- a/tests/test-action-row.c
+++ b/tests/test-action-row.c
@@ -48,21 +48,6 @@ test_hdy_action_row_add_prefix (void)
}
-static void
-test_hdy_action_row_title (void)
-{
- g_autoptr (HdyActionRow) row = NULL;
-
- row = g_object_ref_sink (HDY_ACTION_ROW (hdy_action_row_new ()));
- g_assert_nonnull (row);
-
- g_assert_cmpstr (hdy_action_row_get_title (row), ==, "");
-
- hdy_action_row_set_title (row, "Dummy title");
- g_assert_cmpstr (hdy_action_row_get_title (row), ==, "Dummy title");
-}
-
-
static void
test_hdy_action_row_subtitle (void)
{
@@ -136,7 +121,6 @@ main (gint argc,
g_test_add_func("/Handy/ActionRow/add", test_hdy_action_row_add);
g_test_add_func("/Handy/ActionRow/add_prefix", test_hdy_action_row_add_prefix);
- g_test_add_func("/Handy/ActionRow/title", test_hdy_action_row_title);
g_test_add_func("/Handy/ActionRow/subtitle", test_hdy_action_row_subtitle);
g_test_add_func("/Handy/ActionRow/icon_name", test_hdy_action_row_icon_name);
g_test_add_func("/Handy/ActionRow/use_underline", test_hdy_action_row_use_undeline);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]