74a557739d
This is all contained in the gui code now. Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
72 lines
1.8 KiB
C++
72 lines
1.8 KiB
C++
/*
|
|
* Copyright 2014 (c) Anna Schumaker.
|
|
*/
|
|
#include <core/audio.h>
|
|
#include <core/deck.h>
|
|
#include <core/version.h>
|
|
#include <gui/ocarina.h>
|
|
#include <gui/tabs.h>
|
|
|
|
const std::string appname = "Ocarina ";
|
|
|
|
static bool on_window_key_pressed(GdkEventKey *event)
|
|
{
|
|
Gtk::Notebook *notebook = gui :: get_widget<Gtk::Notebook>("o_notebook");
|
|
Gtk::Window *window = gui :: get_widget<Gtk::Window>("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 < deck::get_queues().size())
|
|
notebook->set_current_page(n);
|
|
} else if (key == "c")
|
|
notebook->set_current_page(deck::get_queues().size());
|
|
else if (key == "h")
|
|
notebook->set_current_page(deck::get_queues().size() + 1);
|
|
else if (key == "m")
|
|
notebook->set_current_page(deck::get_queues().size() + 3);
|
|
else if (key == "n")
|
|
gst :: next();
|
|
else if (key == "N")
|
|
audio :: prev();
|
|
else if (key == "p")
|
|
notebook->set_current_page(deck::get_queues().size() + 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<Gtk::Window>("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;
|
|
}
|