#include <gtk/gtk.h>

static gboolean
cb_key_pressed (GtkWidget *window, GdkEvent *event, gpointer data)
{
  return gtk_search_bar_handle_event (GTK_SEARCH_BAR (data), event);
}

int main (int argc, char *argv[])
{
  GtkWidget *window;
  GtkWidget *box;
  GtkWidget *search_bar;
  GtkWidget *search_entry;
  GtkWidget *label;

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  box = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);

  gtk_container_add (GTK_CONTAINER (window), box);

  search_bar = gtk_search_bar_new ();
  gtk_box_pack_start (GTK_BOX (box), search_bar, FALSE, TRUE,0 );

  search_entry = gtk_search_entry_new ();
  gtk_container_add (GTK_CONTAINER (search_bar), search_entry);

  label = gtk_label_new ("Press Menu key...");
  gtk_box_pack_start (GTK_BOX (box), label, TRUE, TRUE, 0);

  g_signal_connect (window, "key-press-event", G_CALLBACK (cb_key_pressed), search_bar);

  gtk_widget_show_all (window);

  gtk_main ();
}
