ocarina/ocarina/header/entry.cpp

39 lines
654 B
C++

#include <ocarina/header.h>
#include <ocarina/shortcut.h>
#include <libsaria/library.h>
#include <libsaria/print.h>
#include "header.h"
static GtkWidget *entry = NULL;
static void do_filter(GtkWidget *entry)
{
string text = gtk_entry_get_text(GTK_ENTRY(entry));
libsaria::library::filter(text);
}
static void filter_focus()
{
gtk_widget_grab_focus(entry);
}
static void make_entry()
{
entry = gtk_entry_new();
GTK_CONNECT(entry, "changed", do_filter, NULL);
register_shortcut("slash", filter_focus);
}
GtkWidget *get_entry()
{
if (entry == NULL)
make_entry();
return entry;
}
bool entry_focused()
{
return gtk_widget_is_focus(entry);
}