diff options
author | Matthias Clasen <mclasen@redhat.com> | 2020-05-03 09:51:09 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2020-05-04 22:53:08 -0400 |
commit | e2abe6dd2986ac30953a2c8564b3daa9fb5de6c7 (patch) | |
tree | fd0a3e298be0ebca780189bfa00e5ce25f496273 /gtk/gtksearchbar.c | |
parent | 12ecbd15080f1dc3b301ee3df10d50d4899ae007 (diff) | |
download | gtk+-e2abe6dd2986ac30953a2c8564b3daa9fb5de6c7.tar.gz |
searchbar: Add a child property
Diffstat (limited to 'gtk/gtksearchbar.c')
-rw-r--r-- | gtk/gtksearchbar.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/gtk/gtksearchbar.c b/gtk/gtksearchbar.c index 7a2e6178f3..90e342234c 100644 --- a/gtk/gtksearchbar.c +++ b/gtk/gtksearchbar.c @@ -112,6 +112,7 @@ enum { PROP_0, PROP_SEARCH_MODE_ENABLED, PROP_SHOW_CLOSE_BUTTON, + PROP_CHILD, LAST_PROPERTY }; @@ -209,6 +210,9 @@ gtk_search_bar_set_property (GObject *object, case PROP_SHOW_CLOSE_BUTTON: gtk_search_bar_set_show_close_button (bar, g_value_get_boolean (value)); break; + case PROP_CHILD: + gtk_search_bar_set_child (bar, g_value_get_object (value)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -231,6 +235,9 @@ gtk_search_bar_get_property (GObject *object, case PROP_SHOW_CLOSE_BUTTON: g_value_set_boolean (value, gtk_search_bar_get_show_close_button (bar)); break; + case PROP_CHILD: + g_value_set_object (value, gtk_search_bar_get_child (bar)); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -332,6 +339,12 @@ gtk_search_bar_class_init (GtkSearchBarClass *klass) FALSE, GTK_PARAM_READWRITE|G_PARAM_CONSTRUCT|G_PARAM_EXPLICIT_NOTIFY); + widget_props[PROP_CHILD] = g_param_spec_object ("child", + P_("Child"), + P_("The child widget"), + GTK_TYPE_WIDGET, + GTK_PARAM_READWRITE|G_PARAM_CONSTRUCT|G_PARAM_EXPLICIT_NOTIFY); + g_object_class_install_properties (object_class, LAST_PROPERTY, widget_props); gtk_widget_class_set_css_name (widget_class, I_("searchbar")); @@ -657,3 +670,36 @@ gtk_search_bar_get_key_capture_widget (GtkSearchBar *bar) return priv->capture_widget; } + +/** + * gtk_search_bar_set_child: + * @bar: a #GtkSearchBar + * @child: (allow-none): the child widget + * + * Sets the child widget of @bar. + */ +void +gtk_search_bar_set_child (GtkSearchBar *bar, + GtkWidget *child) +{ + if (gtk_bin_get_child (GTK_BIN (bar))) + gtk_search_bar_remove (GTK_CONTAINER (bar), gtk_bin_get_child (GTK_BIN (bar))); + if (child) + gtk_search_bar_add (GTK_CONTAINER (bar), child); + g_object_notify_by_pspec (G_OBJECT (bar), widget_props[PROP_CHILD]); +} + +/** + * gtk_search_bar_get_child: + * @bar: a #GtkSearchBar + * + * Gets the child widget of @bar. + * + * Returns: (nullable) (transfer none): the child widget of @bar + */ +GtkWidget * +gtk_search_bar_get_child (GtkSearchBar *bar) +{ + return gtk_bin_get_child (GTK_BIN (bar)); +} + |