/** * gtk_search_bar_get_search_mode: * @bar: a #GtkSearchBar * * Returns whether the search mode is on or off. * * Returns: whether search mode is toggled on * * Since: 3.10 */ gboolean gtk_search_bar_get_search_mode (GtkSearchBar *bar) { GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar); g_return_val_if_fail (GTK_IS_SEARCH_BAR (bar), FALSE); return priv->reveal_child; }
/** * gtk_search_bar_get_show_close_button: * @bar: a #GtkSearchBar * * Returns whether the close button is shown. * * Returns: whether the close button is shown * * Since: 3.10 */ gboolean gtk_search_bar_get_show_close_button (GtkSearchBar *bar) { GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar); g_return_val_if_fail (GTK_IS_SEARCH_BAR (bar), FALSE); return gtk_widget_get_visible (priv->close_button); }
/** * gtk_search_bar_connect_entry: * @bar: a #GtkSearchBar * @entry: a #GtkEntry * * Connects the #GtkEntry widget passed as the one to be used in * this search bar. The entry should be a descendant of the search bar. * This is only required if the entry isn’t the direct child of the * search bar (as in our main example). * * Since: 3.10 */ void gtk_search_bar_connect_entry (GtkSearchBar *bar, GtkEntry *entry) { g_return_if_fail (GTK_IS_SEARCH_BAR (bar)); g_return_if_fail (entry == NULL || GTK_IS_ENTRY (entry)); gtk_search_bar_set_entry (bar, entry); }
static void test_search_bar_basic (void) { GtkWidget *widget; widget = gtk_search_bar_new (); g_assert (GTK_IS_SEARCH_BAR (widget)); gtk_widget_destroy (widget); }
/** * gtk_search_bar_set_search_mode: * @bar: a #GtkSearchBar * @search_mode: the new state of the search mode * * Switches the search mode on or off. * * Since: 3.10 */ void gtk_search_bar_set_search_mode (GtkSearchBar *bar, gboolean search_mode) { GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar); g_return_if_fail (GTK_IS_SEARCH_BAR (bar)); gtk_revealer_set_reveal_child (GTK_REVEALER (priv->revealer), search_mode); }
/** * gtk_search_bar_set_show_close_button: * @bar: a #GtkSearchBar * @visible: whether the close button will be shown or not * * Shows or hides the close button. Applications that * already have a "search" toggle button should not show a close * button in their search bar, as it duplicates the role of the * toggle button. * * Since: 3.10 */ void gtk_search_bar_set_show_close_button (GtkSearchBar *bar, gboolean visible) { GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar); g_return_if_fail (GTK_IS_SEARCH_BAR (bar)); gtk_widget_set_visible (priv->close_button, visible); }
/** * gtk_search_bar_set_show_close_button: * @bar: a #GtkSearchBar * @visible: whether the close button will be shown or not * * Shows or hides the close button. Applications that * already have a “search” toggle button should not show a close * button in their search bar, as it duplicates the role of the * toggle button. * * Since: 3.10 */ void gtk_search_bar_set_show_close_button (GtkSearchBar *bar, gboolean visible) { GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar); g_return_if_fail (GTK_IS_SEARCH_BAR (bar)); visible = visible != FALSE; if (gtk_widget_get_visible (priv->close_button) != visible) { gtk_widget_set_visible (priv->close_button, visible); g_object_notify (G_OBJECT (bar), "show-close-button"); } }
/** * gtk_search_bar_connect_entry: * @bar: a #GtkSearchBar * @entry: a #GtkEntry * * Connects the #GtkEntry widget passed as the one to be used in * this search bar. The entry should be a descendant of the search bar. * This is only required if the entry isn’t the direct child of the * search bar (as in our main example). * * Since: 3.10 */ void gtk_search_bar_connect_entry (GtkSearchBar *bar, GtkEntry *entry) { GtkSearchBarPrivate *priv = gtk_search_bar_get_instance_private (bar); g_return_if_fail (GTK_IS_SEARCH_BAR (bar)); g_return_if_fail (entry == NULL || GTK_IS_ENTRY (entry)); if (priv->entry != NULL) { g_signal_handlers_disconnect_by_func (priv->entry, entry_key_pressed_event_cb, bar); g_object_remove_weak_pointer (G_OBJECT (priv->entry), (gpointer *) &priv->entry); priv->entry = NULL; } if (entry != NULL) { priv->entry = GTK_WIDGET (entry); g_object_add_weak_pointer (G_OBJECT (priv->entry), (gpointer *) &priv->entry); g_signal_connect (priv->entry, "key-press-event", G_CALLBACK (entry_key_pressed_event_cb), bar); } }