-#ifdef GTKOSX
- string label = (*k);
-
- /* Gtk/Quartz maps:
- NSAlternate/NSOption key to Mod1
- NSCommand key to Meta
- */
-
- replace_all (label, "<Meta>", _("Command-"));
- replace_all (label, "<Alt>", _("Option-"));
- replace_all (label, "<Shift>", _("Shift-"));
- replace_all (label, "<Control>", _("Control-"));
- row[columns.binding] = label;
-#else
- row[columns.binding] = (*k);
+ return data_model->children().size();
+}
+
+void
+KeyEditor::Tab::sort_column_changed ()
+{
+ int column;
+ SortType type;
+ if (data_model->get_sort_column_id (column, type)) {
+ owner.sort_column = column;
+ owner.sort_type = type;
+ }
+}
+
+void
+KeyEditor::Tab::tab_mapped ()
+{
+ data_model->set_sort_column (owner.sort_column, owner.sort_type);
+ filter->refilter ();
+}
+
+bool
+KeyEditor::Tab::visible_func(const Gtk::TreeModel::const_iterator& iter) const
+{
+ if (!iter) {
+ return false;
+ }
+
+ // never filter when search string is empty or item is a category
+ if (owner.filter_string.empty () || !(*iter)[columns.bindable]) {
+ return true;
+ }
+
+ // search name
+ std::string name = (*iter)[columns.name];
+ boost::to_lower (name);
+ if (name.find (owner.filter_string) != std::string::npos) {
+ return true;
+ }
+
+ // search binding
+ std::string binding = (*iter)[columns.binding];
+ boost::to_lower (binding);
+ if (binding.find (owner.filter_string) != std::string::npos) {
+ return true;
+ }
+
+ return false;
+}
+
+TreeModel::iterator
+KeyEditor::Tab::find_action_path (TreeModel::const_iterator begin, TreeModel::const_iterator end, const std::string& action_path) const
+{
+ if (!begin) {
+ return end;
+ }
+
+ for (TreeModel::iterator it = begin; it != end; ++it) {
+ if (it->children()) {
+ TreeModel::iterator jt = find_action_path (it->children().begin(), it->children().end(), action_path);
+ if (jt != it->children().end()) {
+ return jt;
+ }
+ }
+ const std::string& path = (*it)[columns.path];
+ if (action_path.compare(path) == 0) {
+ return it;
+ }
+ }
+ return end;
+}
+
+void
+KeyEditor::reset ()
+{
+ Keyboard::the_keyboard().reset_bindings ();
+ refresh ();
+}
+
+void
+KeyEditor::refresh ()
+{
+ for (Tabs::iterator t = tabs.begin(); t != tabs.end(); ++t) {
+ (*t)->view.get_selection()->unselect_all ();
+ (*t)->populate ();
+ }
+}
+
+KeyEditor::Tab*
+KeyEditor::current_tab ()
+{
+ return dynamic_cast<Tab*> (notebook.get_nth_page (notebook.get_current_page()));
+}
+
+void
+KeyEditor::search_string_updated (const std::string& filter)
+{
+ filter_string = boost::to_lower_copy(filter);
+ KeyEditor::Tab* tab = current_tab ();
+ if (tab) {
+ tab->filter->refilter ();
+ }
+}
+
+void
+KeyEditor::print () const
+{
+ stringstream sstr;
+ Bindings::save_all_bindings_as_html (sstr);
+
+ if (sstr.str().empty()) {
+ return;
+ }
+
+
+ gchar* file_name;
+ GError *err = NULL;
+ gint fd;
+
+ if ((fd = g_file_open_tmp ("akprintXXXXXX.html", &file_name, &err)) < 0) {
+ if (err) {
+ error << string_compose (_("Could not open temporary file to print bindings (%1)"), err->message) << endmsg;
+ g_error_free (err);
+ }
+ return;
+ }
+
+#ifdef PLATFORM_WINDOWS
+ ::close (fd);