/* * Copyright 2014 (c) Anna Schumaker. */ extern "C" { #include #include #include } #include #include const std::string appname = "Ocarina "; static bool on_window_key_pressed(GdkEventKey *event) { Gtk::Notebook *notebook = gui :: get_widget("o_notebook"); Gtk::Window *window = gui :: get_widget("o_window"); std::string key = gdk_keyval_name(event->keyval); if (key.size() >= 3) { if (key.substr(0, 3) == "KP_") key = key.substr(3); } if (key == "Escape") window->set_focus(*window); else if (key == "slash") tab_focus_search(); else if (key >= "0" && key <= "9") { unsigned int n = atoi(key.c_str()); if (n < tempq_count()) notebook->set_current_page(n); } else if (key == "c") notebook->set_current_page(tempq_count()); else if (key == "h") notebook->set_current_page(tempq_count() + 1); else if (key == "m") notebook->set_current_page(tempq_count() + 3); else if (key == "n") gst :: next(); else if (key == "N") audio_prev(); else if (key == "p") notebook->set_current_page(tempq_count() + 2); else return false; return true; } static bool on_window_key_released(GdkEventKey *event) { std::string key = gdk_keyval_name(event->keyval); if (key != "space") return false; gst :: toggle(); return true; } Gtk::Window *window_init() { Gtk::Window *window = gui :: get_widget("o_window"); window->set_can_focus(); window->set_title(appname + get_version()); window->set_icon_from_file(gui :: share_file("ocarina.png")); window->signal_key_press_event().connect(sigc::ptr_fun(on_window_key_pressed)); window->signal_key_release_event().connect(sigc::ptr_fun(on_window_key_released)); return window; }