diff --git a/gui/collection_mgr.cpp b/gui/collection_mgr.cpp index 433b0cb1..bb42876f 100644 --- a/gui/collection_mgr.cpp +++ b/gui/collection_mgr.cpp @@ -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) diff --git a/include/lib/lib.h b/include/lib/lib.h index 2138a8f2..e9a3e244 100644 --- a/include/lib/lib.h +++ b/include/lib/lib.h @@ -13,6 +13,7 @@ namespace lib void init(int *, char ***, const std::string &); const std::string share_file(const std::string &); Glib::RefPtr &get_builder(); + const std::string key_name(GdkEventKey *); template static inline T *get_widget(const std::string &name) diff --git a/lib/lib.cpp b/lib/lib.cpp index 565123e0..bfc5bcea 100644 --- a/lib/lib.cpp +++ b/lib/lib.cpp @@ -45,3 +45,9 @@ Glib::RefPtr &lib :: get_builder() { return builder; } + +const std::string lib :: key_name(GdkEventKey *event) +{ + std::string key = gdk_keyval_name(event->keyval); + return key; +}