gui: Reactivate the "slash" keyboard shortcut

Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
Anna Schumaker 2014-02-23 15:27:19 -05:00 committed by Anna Schumaker
parent 697c07e2df
commit 6ecb8f6b7f
4 changed files with 38 additions and 32 deletions

View File

@ -85,6 +85,11 @@ void Tab :: tab_unmap()
queue_mapping.erase(tab_pq); queue_mapping.erase(tab_pq);
} }
void Tab :: tab_focus_search()
{
tab_search->grab_focus();
}
/** /**
@ -170,7 +175,7 @@ void Tab :: on_entry_changed()
* Global functions * Global functions
*/ */
Tab *find_tab(Playqueue *pq) static Tab *find_tab(Playqueue *pq)
{ {
std::map<Playqueue *, Tab *>::iterator it; std::map<Playqueue *, Tab *>::iterator it;
it = queue_mapping.find(pq); it = queue_mapping.find(pq);
@ -179,38 +184,52 @@ Tab *find_tab(Playqueue *pq)
return NULL; return NULL;
} }
void on_track_added(Playqueue *pq, unsigned int row) static Tab *find_tab(int num)
{
std::map<Playqueue *, Tab *>::iterator it;
for (it = queue_mapping.begin(); it != queue_mapping.end(); it++) {
if (it->second->tab_page_num() == num)
return it->second;
}
return NULL;
}
static void on_track_added(Playqueue *pq, unsigned int row)
{ {
Tab *tab = find_tab(pq); Tab *tab = find_tab(pq);
if (tab) if (tab)
tab->on_track_added(row); tab->on_track_added(row);
} }
void on_track_deleted(Playqueue *pq, unsigned int row) static void on_track_deleted(Playqueue *pq, unsigned int row)
{ {
Tab *tab = find_tab(pq); Tab *tab = find_tab(pq);
if (tab) if (tab)
tab->on_track_deleted(row); tab->on_track_deleted(row);
} }
void on_track_changed(Playqueue *pq, unsigned int row) static void on_track_changed(Playqueue *pq, unsigned int row)
{ {
Tab *tab = find_tab(pq); Tab *tab = find_tab(pq);
if (tab) if (tab)
tab->on_track_changed(row); tab->on_track_changed(row);
} }
void on_switch_page(Gtk::Widget *page, int num) static void on_switch_page(Gtk::Widget *page, int num)
{ {
std::map<Playqueue *, Tab *>::iterator it; Tab *tab = find_tab(num);
for (it = queue_mapping.begin(); it != queue_mapping.end(); it++) { if (tab)
if (it->second->tab_page_num() == num) { tab->tab_runtime_changed();
it->second->tab_runtime_changed(); else
return; get_widget<Gtk::Label>("o_queue_time")->set_text("");
} }
}
get_widget<Gtk::Label>("o_queue_time")->set_text(""); void tab_focus_search()
{
int page = get_widget<Gtk::Notebook>("o_notebook")->get_current_page();
Tab *tab = find_tab(page);
if (tab)
tab->tab_focus_search();
} }
void init_tabs() void init_tabs()
@ -743,10 +762,6 @@ bool OcarinaPage::on_view_button_pressed(GdkEventButton *button)
return true; return true;
} }
void OcarinaPage::on_focus_search()
{
page_entry.grab_focus();
}
*/ */
@ -829,17 +844,7 @@ static void init_menu_item(const std::string &name, unsigned int num)
sigc::ptr_fun(on_add_to_queue), num)); sigc::ptr_fun(on_add_to_queue), num));
}*/ }*/
/*void focus_tab_search() /*
{
std::map<Playqueue *, OcarinaPage *>::iterator it;
for (it = tab_map.begin(); it != tab_map.end(); it++) {
if (it->second->is_current_tab()) {
it->second->on_focus_search();
return;
}
}
}
void init_tabs() void init_tabs()
{ {
Gtk::Notebook *notebook; Gtk::Notebook *notebook;

View File

@ -143,8 +143,8 @@ static bool on_window_key_pressed(GdkEventKey *event)
if (key == "Escape") if (key == "Escape")
window->set_focus(*window); window->set_focus(*window);
//else if (key == "slash") else if (key == "slash")
// focus_tab_search(); tab_focus_search();
else if (key >= "0" && key <= "9") { else if (key >= "0" && key <= "9") {
unsigned int n = atoi(key.c_str()); unsigned int n = atoi(key.c_str());
if (n < deck::size()) if (n < deck::size())

View File

@ -57,7 +57,6 @@ public:
/* tabs.cpp */ /* tabs.cpp */
//void queue_selected(bool); //void queue_selected(bool);
//void focus_tab_search();
/* wires.cpp */ /* wires.cpp */

View File

@ -48,8 +48,9 @@ public:
* More helper functions * More helper functions
*/ */
void tab_finish_init(); void tab_finish_init();
int tab_page_num(); int tab_page_num();
void tab_runtime_changed(); void tab_runtime_changed();
void tab_focus_search();
/** /**
* internal callback functions * internal callback functions
@ -72,6 +73,7 @@ public:
}; };
void tab_focus_search();
void init_tabs(); void init_tabs();
void post_init_tabs(); void post_init_tabs();
void cleanup_tabs(); void cleanup_tabs();