From c9ca2604ee808f0c2e95723505518a830dbec5e2 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Sat, 18 Apr 2015 09:27:54 -0400 Subject: [PATCH] gui: Move on_row_activated() into the QueueWindow And out of the Tab class. Signed-off-by: Anna Schumaker --- gui/queue/window.cpp | 13 ++++++++++++- gui/tabs.cpp | 8 -------- include/gui/queue/window.h | 2 ++ include/gui/tabs.h | 1 - 4 files changed, 14 insertions(+), 10 deletions(-) diff --git a/gui/queue/window.cpp b/gui/queue/window.cpp index e4932da2..bc3611c6 100644 --- a/gui/queue/window.cpp +++ b/gui/queue/window.cpp @@ -20,8 +20,12 @@ void QueueWindow :: init(Queue *queue) _queue = queue; q_model = Glib::RefPtr(new QueueModel(queue)); q_filter = Gtk::TreeModelFilter::create(q_model); - q_treeview->set_model(q_filter); + q_filter->set_visible_func(sigc::mem_fun(*this, &QueueWindow::filter_ids)); + + q_treeview->signal_row_activated().connect(sigc::mem_fun(*this, + &QueueWindow :: on_row_activated)); + q_treeview->set_model(q_filter); } void QueueWindow :: filter(std::string &text) @@ -44,3 +48,10 @@ bool QueueWindow :: filter_ids(const Gtk::TreeIter &iter) it = _q_search_res.find(_queue->operator[](id)->index()); return it != _q_search_res.end(); } + +void QueueWindow :: on_row_activated(const Gtk::TreePath &path, + Gtk::TreeViewColumn *col) +{ + Gtk::TreePath real_path = q_filter->convert_path_to_child_path(path); + q_model->on_path_selected(real_path); +} diff --git a/gui/tabs.cpp b/gui/tabs.cpp index 93b1f30a..1b8198bd 100644 --- a/gui/tabs.cpp +++ b/gui/tabs.cpp @@ -37,8 +37,6 @@ Tab :: ~Tab() {} void Tab :: tab_finish_init() { - tab_treeview->signal_row_activated().connect(sigc::mem_fun(*this, - &Tab :: on_row_activated)); tab_treeview->signal_key_press_event().connect(sigc::mem_fun(*this, &Tab :: on_key_pressed)); tab_treeview->signal_button_press_event().connect(sigc::mem_fun(*this, @@ -255,12 +253,6 @@ void Tab :: on_show_rc_menu() * */ -void Tab :: on_row_activated(const Gtk::TreePath &path, Gtk::TreeViewColumn *col) -{ - Gtk::TreePath model_path = tab_filter->convert_path_to_child_path(path); - tab_model->on_path_selected(model_path); -} - bool Tab :: on_key_pressed(GdkEventKey *event) { std::string key = gdk_keyval_name(event->keyval); diff --git a/include/gui/queue/window.h b/include/gui/queue/window.h index 3fa6ba9d..04b23cad 100644 --- a/include/gui/queue/window.h +++ b/include/gui/queue/window.h @@ -27,6 +27,8 @@ public: void filter(std::string &); bool filter_ids(const Gtk::TreeIter &); + + void on_row_activated(const Gtk::TreePath &, Gtk::TreeViewColumn *); }; #endif /* OCARINA_GUI_QUEUE_WINDOW_H */ diff --git a/include/gui/tabs.h b/include/gui/tabs.h index c4eeb1e0..7426ea7b 100644 --- a/include/gui/tabs.h +++ b/include/gui/tabs.h @@ -77,7 +77,6 @@ public: * GTK-MM callback functions */ void on_repeat_toggled(); - void on_row_activated(const Gtk::TreePath &, Gtk::TreeViewColumn *); bool on_key_pressed(GdkEventKey *); void on_column_clicked(unsigned int); bool on_button_pressed(GdkEventButton *);