[libdazzle] radio-box: add API to remove item
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libdazzle] radio-box: add API to remove item
- Date: Tue, 20 Nov 2018 18:00:36 +0000 (UTC)
commit 1001fd9bd9c618f8d4687c596d4d922cceb8a6e0
Author: Christian Hergert <chergert redhat com>
Date: Tue Nov 20 10:00:24 2018 -0800
radio-box: add API to remove item
src/widgets/dzl-radio-box.c | 25 +++++++++++++++++++++++++
src/widgets/dzl-radio-box.h | 3 +++
2 files changed, 28 insertions(+)
---
diff --git a/src/widgets/dzl-radio-box.c b/src/widgets/dzl-radio-box.c
index 780c536..74901cb 100644
--- a/src/widgets/dzl-radio-box.c
+++ b/src/widgets/dzl-radio-box.c
@@ -258,6 +258,31 @@ dzl_radio_box_init (DzlRadioBox *self)
gtk_widget_insert_action_group (GTK_WIDGET (self), "radiobox", G_ACTION_GROUP (group));
}
+void
+dzl_radio_box_remove_item (DzlRadioBox *self,
+ const gchar *id)
+{
+ DzlRadioBoxPrivate *priv = dzl_radio_box_get_instance_private (self);
+
+ g_return_if_fail (DZL_IS_RADIO_BOX (self));
+ g_return_if_fail (id != NULL);
+
+ for (guint i = 0; i < priv->items->len; i++)
+ {
+ DzlRadioBoxItem *item = &g_array_index (priv->items, DzlRadioBoxItem, i);
+
+ if (g_strcmp0 (id, item->id) == 0)
+ {
+ GtkToggleButton *button = item->button;
+
+ g_array_remove_index_fast (priv->items, i);
+ gtk_widget_destroy (GTK_WIDGET (button));
+
+ break;
+ }
+ }
+}
+
void
dzl_radio_box_add_item (DzlRadioBox *self,
const gchar *id,
diff --git a/src/widgets/dzl-radio-box.h b/src/widgets/dzl-radio-box.h
index 0ce3d8c..f727058 100644
--- a/src/widgets/dzl-radio-box.h
+++ b/src/widgets/dzl-radio-box.h
@@ -47,6 +47,9 @@ void dzl_radio_box_add_item (DzlRadioBox *self,
const gchar *id,
const gchar *text);
DZL_AVAILABLE_IN_ALL
+void dzl_radio_box_remove_item (DzlRadioBox *self,
+ const gchar *id);
+DZL_AVAILABLE_IN_ALL
const gchar *dzl_radio_box_get_active_id (DzlRadioBox *self);
DZL_AVAILABLE_IN_ALL
void dzl_radio_box_set_active_id (DzlRadioBox *self,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]