mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2024-11-12 20:00:09 +00:00
46a43461c1
The merge request !5235 switched tests and examples from G_APPLICATION_FLAGS_NONE, which has been deprecated in GLib 2.74, to G_APPLICATION_DEFAULT_FLAGS. Sadly, it was done unconditionally, which means we'd have to bump the required version of GLib. To avoid that, let's just use the numeric value of the enum member.
58 lines
1.5 KiB
C
58 lines
1.5 KiB
C
#include <gtk/gtk.h>
|
|
|
|
static gboolean
|
|
window_key_press_event_cb (GtkWidget *window,
|
|
GdkEvent *event,
|
|
GtkSearchBar *search_bar)
|
|
{
|
|
return gtk_search_bar_handle_event (search_bar, event);
|
|
}
|
|
|
|
static void
|
|
activate_cb (GtkApplication *app,
|
|
gpointer user_data)
|
|
{
|
|
GtkWidget *window;
|
|
GtkWidget *search_bar;
|
|
GtkWidget *box;
|
|
GtkWidget *entry;
|
|
GtkWidget *menu_button;
|
|
|
|
window = gtk_application_window_new (app);
|
|
gtk_widget_show (window);
|
|
|
|
search_bar = gtk_search_bar_new ();
|
|
gtk_container_add (GTK_CONTAINER (window), search_bar);
|
|
gtk_widget_show (search_bar);
|
|
|
|
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
|
|
gtk_container_add (GTK_CONTAINER (search_bar), box);
|
|
gtk_widget_show (box);
|
|
|
|
entry = gtk_search_entry_new ();
|
|
gtk_box_pack_start (GTK_BOX (box), entry, TRUE, TRUE, 0);
|
|
gtk_widget_show (entry);
|
|
|
|
menu_button = gtk_menu_button_new ();
|
|
gtk_box_pack_start (GTK_BOX (box), menu_button, FALSE, FALSE, 0);
|
|
gtk_widget_show (menu_button);
|
|
|
|
gtk_search_bar_connect_entry (GTK_SEARCH_BAR (search_bar), GTK_ENTRY (entry));
|
|
|
|
g_signal_connect (window, "key-press-event",
|
|
G_CALLBACK (window_key_press_event_cb),
|
|
search_bar);
|
|
}
|
|
|
|
int
|
|
main (int argc,
|
|
char *argv[])
|
|
{
|
|
GtkApplication *app;
|
|
|
|
app = gtk_application_new ("org.gtk.Example.GtkSearchBar", 0);
|
|
g_signal_connect (app, "activate", G_CALLBACK (activate_cb), NULL);
|
|
|
|
return g_application_run (G_APPLICATION (app), argc, argv);
|
|
}
|