lib: Move keyval parsing into lib/
I'll eventually add in checks for keypad vs top row number keys. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
80bed8b956
commit
76f0b7b55f
|
@ -50,21 +50,16 @@ static void on_cursor_changed()
|
|||
cd_chooser(colmgr :: get_path(path));
|
||||
}
|
||||
|
||||
static void on_delete()
|
||||
{
|
||||
Gtk::TreePath path;
|
||||
if (find_cur_path(path))
|
||||
colmgr :: del_path(path);
|
||||
}
|
||||
|
||||
static bool on_key_pressed(GdkEventKey *event)
|
||||
{
|
||||
std::string key = gdk_keyval_name(event->keyval);
|
||||
if (key == "Delete") {
|
||||
on_delete();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
Gtk::TreePath path;
|
||||
|
||||
if (lib :: key_name(event) != "Delete")
|
||||
return false;
|
||||
|
||||
if (find_cur_path(path))
|
||||
colmgr :: del_path(path);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void on_toggled(const Glib::ustring &path)
|
||||
|
|
|
@ -13,6 +13,7 @@ namespace lib
|
|||
void init(int *, char ***, const std::string &);
|
||||
const std::string share_file(const std::string &);
|
||||
Glib::RefPtr<Gtk::Builder> &get_builder();
|
||||
const std::string key_name(GdkEventKey *);
|
||||
|
||||
template <class T>
|
||||
static inline T *get_widget(const std::string &name)
|
||||
|
|
|
@ -45,3 +45,9 @@ Glib::RefPtr<Gtk::Builder> &lib :: get_builder()
|
|||
{
|
||||
return builder;
|
||||
}
|
||||
|
||||
const std::string lib :: key_name(GdkEventKey *event)
|
||||
{
|
||||
std::string key = gdk_keyval_name(event->keyval);
|
||||
return key;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue