diff --git a/gui/model.cpp b/gui/model.cpp
index 75baf70d..8d826127 100644
--- a/gui/model.cpp
+++ b/gui/model.cpp
@@ -34,6 +34,16 @@ void PlayqueueModel::on_row_deleted(unsigned int row)
row_deleted(path);
}
+void PlayqueueModel::on_row_changed(unsigned int row)
+{
+ Gtk::TreePath path;
+ Gtk::TreeIter iter;
+
+ path.push_back(row);
+ stamp++;
+ row_changed(path, iter);
+}
+
void PlayqueueModel::on_path_selected(const Gtk::TreePath &path)
{
audio :: load_trackid(queue->operator[](path[0]));
diff --git a/gui/ocarina6.glade b/gui/ocarina6.glade
index cdac5354..8237d77d 100644
--- a/gui/ocarina6.glade
+++ b/gui/ocarina6.glade
@@ -700,6 +700,7 @@ Manager
diff --git a/gui/tabs.cpp b/gui/tabs.cpp
index 800e9462..a2224b86 100644
--- a/gui/tabs.cpp
+++ b/gui/tabs.cpp
@@ -13,6 +13,7 @@
class OcarinaPage;
static std::map tab_map;
+static unsigned int sort_timeout_count = 0;
static class QueueColumns : public Gtk::TreeModelColumnRecord {
public:
@@ -32,6 +33,22 @@ public:
Gtk::TreeModelColumn q_col_played;
} queue_cols;
static unsigned int q_col_width[] = { 20, 300, 60, 100, 100, 45, 100, 60, 1 };
+static sort_t q_col_sorts[] = {
+ SORT_TRACK, SORT_TITLE, SORT_LENGTH,
+ SORT_ARTIST, SORT_ALBUM, SORT_YEAR,
+ SORT_GENRE, SORT_COUNT, SORT_PLAYED
+};
+
+static void dec_sort_timeout()
+{
+ if (sort_timeout_count > 0)
+ sort_timeout_count--;
+ if (sort_timeout_count == 0) {
+ Gtk::Label *label;
+ get_builder()->get_widget("o_sorting_indicator", label);
+ label->set_text("");
+ }
+}
@@ -112,9 +129,11 @@ public:
void on_row_inserted(unsigned int);
void on_row_deleted(unsigned int);
+ void on_row_changed(unsigned int);
void on_runtime_changed();
void on_random_toggled();
void on_row_activated(const Gtk::TreePath &, Gtk::TreeViewColumn *);
+ void on_column_clicked(unsigned int);
};
@@ -182,6 +201,10 @@ void OcarinaPage::setup_columns()
columns[i]->set_resizable();
columns[i]->set_fixed_width(q_col_width[i]);
columns[i]->set_sizing(Gtk::TREE_VIEW_COLUMN_FIXED);
+ columns[i]->set_clickable();
+ columns[i]->signal_clicked().connect(sigc::bind (
+ sigc::mem_fun(*this, &OcarinaPage::on_column_clicked),
+ i));
}
}
@@ -220,6 +243,13 @@ void OcarinaPage::on_row_deleted(unsigned int row)
on_runtime_changed();
}
+void OcarinaPage::on_row_changed(unsigned int row)
+{
+ model->on_row_changed(row);
+ if (is_current_tab())
+ on_runtime_changed();
+}
+
void OcarinaPage::on_runtime_changed()
{
Gtk::Label *label;
@@ -240,6 +270,21 @@ void OcarinaPage::on_row_activated(const Gtk::TreePath &path, Gtk::TreeViewColum
model->on_path_selected(path);
}
+void OcarinaPage::on_column_clicked(unsigned int col_index)
+{
+ Gtk::Label *sorting;
+ get_builder()->get_widget("o_sorting_indicator", sorting);
+ sorting->set_text("");
+
+ if (sort_timeout_count == 0)
+ model->queue->reset_sort(q_col_sorts[col_index]);
+ else
+ model->queue->add_sort(q_col_sorts[col_index]);
+ sort_timeout_count++;
+ Glib::signal_timeout().connect_seconds_once(
+ sigc::ptr_fun(dec_sort_timeout), 3);
+}
+
@@ -262,6 +307,14 @@ static void on_track_deleted(Playqueue *pq, unsigned int row)
it->second->on_row_deleted(row);
}
+static void on_track_changed(Playqueue *pq, unsigned int row)
+{
+ std::map::iterator it;
+ it = tab_map.find(pq);
+ if (it != tab_map.end())
+ it->second->on_row_changed(row);
+}
+
static void on_switch_page(Gtk::Widget *page, int num)
{
Gtk::Label *label;
@@ -277,6 +330,8 @@ static void on_switch_page(Gtk::Widget *page, int num)
tab->on_runtime_changed();
label->show();
}
+
+ sort_timeout_count = 0;
}
void init_tabs()
@@ -286,8 +341,9 @@ void init_tabs()
new OcarinaPage("History", "document-open-recent", audio::get_recent_pq(), 0);
new OcarinaPage("Collection", "media-optical", deck::get_library_pq(), PQ_RANDOM);
- get_callbacks()->on_queue_track_add = on_track_added;
- get_callbacks()->on_queue_track_del = on_track_deleted;
+ get_callbacks()->on_queue_track_add = on_track_added;
+ get_callbacks()->on_queue_track_del = on_track_deleted;
+ get_callbacks()->on_queue_track_changed = on_track_changed;
notebook->signal_switch_page().connect(sigc::ptr_fun(on_switch_page));
notebook->set_current_page(0);
diff --git a/include/ocarina.h b/include/ocarina.h
index b79379d7..5e8e8484 100644
--- a/include/ocarina.h
+++ b/include/ocarina.h
@@ -41,6 +41,7 @@ public:
void on_row_inserted(unsigned int);
void on_row_deleted(unsigned int);
+ void on_row_changed(unsigned int);
void on_path_selected(const Gtk::TreePath &);
};