gui: Click columns to sort
I set up a 3-second timeout to decrement the count. When the count is at 0, I reset sorting on the playlist. Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
parent
d430e09a59
commit
f83f8d47fa
|
@ -34,6 +34,16 @@ void PlayqueueModel::on_row_deleted(unsigned int row)
|
||||||
row_deleted(path);
|
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)
|
void PlayqueueModel::on_path_selected(const Gtk::TreePath &path)
|
||||||
{
|
{
|
||||||
audio :: load_trackid(queue->operator[](path[0]));
|
audio :: load_trackid(queue->operator[](path[0]));
|
||||||
|
|
|
@ -700,6 +700,7 @@ Manager</property>
|
||||||
<object class="GtkBox" id="box12">
|
<object class="GtkBox" id="box12">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
|
<property name="homogeneous">True</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkProgressBar" id="o_idle_progress">
|
<object class="GtkProgressBar" id="o_idle_progress">
|
||||||
<property name="can_focus">False</property>
|
<property name="can_focus">False</property>
|
||||||
|
@ -722,6 +723,18 @@ Manager</property>
|
||||||
<property name="position">1</property>
|
<property name="position">1</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="o_sorting_indicator">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="xalign">1</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">True</property>
|
||||||
|
<property name="position">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="o_queue_time">
|
<object class="GtkLabel" id="o_queue_time">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
@ -732,7 +745,7 @@ Manager</property>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">True</property>
|
<property name="fill">True</property>
|
||||||
<property name="padding">5</property>
|
<property name="padding">5</property>
|
||||||
<property name="position">2</property>
|
<property name="position">3</property>
|
||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
|
60
gui/tabs.cpp
60
gui/tabs.cpp
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
class OcarinaPage;
|
class OcarinaPage;
|
||||||
static std::map<Playqueue *, OcarinaPage *> tab_map;
|
static std::map<Playqueue *, OcarinaPage *> tab_map;
|
||||||
|
static unsigned int sort_timeout_count = 0;
|
||||||
|
|
||||||
static class QueueColumns : public Gtk::TreeModelColumnRecord {
|
static class QueueColumns : public Gtk::TreeModelColumnRecord {
|
||||||
public:
|
public:
|
||||||
|
@ -32,6 +33,22 @@ public:
|
||||||
Gtk::TreeModelColumn<std::string> q_col_played;
|
Gtk::TreeModelColumn<std::string> q_col_played;
|
||||||
} queue_cols;
|
} queue_cols;
|
||||||
static unsigned int q_col_width[] = { 20, 300, 60, 100, 100, 45, 100, 60, 1 };
|
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_inserted(unsigned int);
|
||||||
void on_row_deleted(unsigned int);
|
void on_row_deleted(unsigned int);
|
||||||
|
void on_row_changed(unsigned int);
|
||||||
void on_runtime_changed();
|
void on_runtime_changed();
|
||||||
void on_random_toggled();
|
void on_random_toggled();
|
||||||
void on_row_activated(const Gtk::TreePath &, Gtk::TreeViewColumn *);
|
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_resizable();
|
||||||
columns[i]->set_fixed_width(q_col_width[i]);
|
columns[i]->set_fixed_width(q_col_width[i]);
|
||||||
columns[i]->set_sizing(Gtk::TREE_VIEW_COLUMN_FIXED);
|
columns[i]->set_sizing(Gtk::TREE_VIEW_COLUMN_FIXED);
|
||||||
|
columns[i]->set_clickable();
|
||||||
|
columns[i]->signal_clicked().connect(sigc::bind<unsigned int> (
|
||||||
|
sigc::mem_fun(*this, &OcarinaPage::on_column_clicked),
|
||||||
|
i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,6 +243,13 @@ void OcarinaPage::on_row_deleted(unsigned int row)
|
||||||
on_runtime_changed();
|
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()
|
void OcarinaPage::on_runtime_changed()
|
||||||
{
|
{
|
||||||
Gtk::Label *label;
|
Gtk::Label *label;
|
||||||
|
@ -240,6 +270,21 @@ void OcarinaPage::on_row_activated(const Gtk::TreePath &path, Gtk::TreeViewColum
|
||||||
model->on_path_selected(path);
|
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("<sorting>");
|
||||||
|
|
||||||
|
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);
|
it->second->on_row_deleted(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void on_track_changed(Playqueue *pq, unsigned int row)
|
||||||
|
{
|
||||||
|
std::map<Playqueue *, OcarinaPage *>::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)
|
static void on_switch_page(Gtk::Widget *page, int num)
|
||||||
{
|
{
|
||||||
Gtk::Label *label;
|
Gtk::Label *label;
|
||||||
|
@ -277,6 +330,8 @@ static void on_switch_page(Gtk::Widget *page, int num)
|
||||||
tab->on_runtime_changed();
|
tab->on_runtime_changed();
|
||||||
label->show();
|
label->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sort_timeout_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void init_tabs()
|
void init_tabs()
|
||||||
|
@ -286,8 +341,9 @@ void init_tabs()
|
||||||
|
|
||||||
new OcarinaPage("History", "document-open-recent", audio::get_recent_pq(), 0);
|
new OcarinaPage("History", "document-open-recent", audio::get_recent_pq(), 0);
|
||||||
new OcarinaPage("Collection", "media-optical", deck::get_library_pq(), PQ_RANDOM);
|
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_add = on_track_added;
|
||||||
get_callbacks()->on_queue_track_del = on_track_deleted;
|
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->signal_switch_page().connect(sigc::ptr_fun(on_switch_page));
|
||||||
notebook->set_current_page(0);
|
notebook->set_current_page(0);
|
||||||
|
|
|
@ -41,6 +41,7 @@ public:
|
||||||
|
|
||||||
void on_row_inserted(unsigned int);
|
void on_row_inserted(unsigned int);
|
||||||
void on_row_deleted(unsigned int);
|
void on_row_deleted(unsigned int);
|
||||||
|
void on_row_changed(unsigned int);
|
||||||
void on_path_selected(const Gtk::TreePath &);
|
void on_path_selected(const Gtk::TreePath &);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue