gui: Implement add to {favorites, banned} menu items
Signed-off-by: Anna Schumaker <schumaker.anna@gmail.com>
This commit is contained in:
parent
2abc498fde
commit
a529d569f6
66
gui/tabs.cpp
66
gui/tabs.cpp
|
@ -51,6 +51,8 @@ void Tab :: tab_finish_init()
|
|||
&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,
|
||||
&Tab :: on_button_pressed), false);
|
||||
|
||||
std::vector<Gtk::TreeViewColumn *> columns = tab_treeview->get_columns();
|
||||
for (unsigned int i = 0; i < columns.size(); i++) {
|
||||
|
@ -150,6 +152,7 @@ void Tab :: tab_selected_ids(std::vector<unsigned int> &ids)
|
|||
path = tab_filter->convert_path_to_child_path(rows[i]);
|
||||
ids.push_back(tab_model->path_to_id(path));
|
||||
}
|
||||
sel->unselect_all();
|
||||
}
|
||||
|
||||
void Tab :: tab_queue_add(Playqueue *pq)
|
||||
|
@ -181,17 +184,27 @@ bool Tab :: tab_add_to_queue(unsigned int n)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Tab :: tab_favorite_selected()
|
||||
bool Tab :: tab_add_to_playlist(const std::string &playlist)
|
||||
{
|
||||
std::vector<unsigned int> ids;
|
||||
|
||||
tab_selected_ids(ids);
|
||||
for (unsigned int i = 0; i < ids.size(); i++)
|
||||
playlist :: add("Favorites", ids[i]);
|
||||
playlist :: add(playlist, ids[i]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Tab :: tab_favorite_selected()
|
||||
{
|
||||
return tab_add_to_playlist("Favorites");
|
||||
}
|
||||
|
||||
void Tab :: tab_ban_selected()
|
||||
{
|
||||
tab_add_to_playlist("Banned");
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -235,6 +248,10 @@ bool Tab :: on_key_press_event(const std::string &key)
|
|||
return true;
|
||||
}
|
||||
|
||||
void Tab :: on_show_rc_menu()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -285,6 +302,20 @@ void Tab :: on_column_clicked(unsigned int col)
|
|||
sigc::mem_fun(*this, &Tab::tab_dec_sort_count), 2);
|
||||
}
|
||||
|
||||
bool Tab :: on_button_pressed(GdkEventButton *button)
|
||||
{
|
||||
if (button->button != 3)
|
||||
return false;
|
||||
|
||||
Gtk::TreeModel::Path path;
|
||||
if (tab_treeview->get_path_at_pos(button->x, button->y, path))
|
||||
tab_treeview->get_selection()->select(path);
|
||||
|
||||
on_show_rc_menu();
|
||||
get_widget<Gtk::Menu>("o_rc_menu")->popup(button->button, button->time);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
@ -345,6 +376,16 @@ static Tab *find_tab(int num)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
static Tab *cur_tab()
|
||||
{
|
||||
std::map<Playqueue *, Tab *>::iterator it;
|
||||
for (it = queue_mapping.begin(); it != queue_mapping.end(); it++) {
|
||||
if (it->second->tab_is_cur())
|
||||
return it->second;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void on_track_added(Playqueue *pq, unsigned int row)
|
||||
{
|
||||
Tab *tab = find_tab(pq);
|
||||
|
@ -384,6 +425,20 @@ void tab_focus_search()
|
|||
tab->tab_focus_search();
|
||||
}
|
||||
|
||||
static void on_add_to_favs()
|
||||
{
|
||||
Tab *tab = cur_tab();
|
||||
if (tab)
|
||||
tab->tab_favorite_selected();
|
||||
}
|
||||
|
||||
static void on_add_to_banned()
|
||||
{
|
||||
Tab *tab = cur_tab();
|
||||
if (tab)
|
||||
tab->tab_ban_selected();
|
||||
}
|
||||
|
||||
void init_tabs()
|
||||
{
|
||||
struct Callbacks *cb = get_callbacks();
|
||||
|
@ -395,6 +450,13 @@ void init_tabs()
|
|||
struct Gtk::Notebook *notebook = get_widget<Gtk::Notebook>("o_notebook");
|
||||
notebook->signal_switch_page().connect(sigc::ptr_fun(on_switch_page));
|
||||
|
||||
/* Menu signals */
|
||||
get_widget<Gtk::Menu>("o_rc_menu")->show_all();
|
||||
get_widget<Gtk::MenuItem>("o_add_to_favorites")->signal_activate().connect(
|
||||
sigc::ptr_fun(on_add_to_favs));
|
||||
get_widget<Gtk::MenuItem>("o_add_to_banned")->signal_activate().connect(
|
||||
sigc::ptr_fun(on_add_to_banned));
|
||||
|
||||
/* Initialize other tabs */
|
||||
init_collection_tab();
|
||||
init_history_tab();
|
||||
|
|
|
@ -41,7 +41,6 @@ protected:
|
|||
void tab_init_random();
|
||||
void tab_init_repeat();
|
||||
void tab_toggle_button(Gtk::ToggleButton *, playqueue_flags);
|
||||
bool tab_is_cur();
|
||||
void tab_dec_sort_count();
|
||||
virtual void tab_set_size();
|
||||
void tab_unmap();
|
||||
|
@ -55,6 +54,7 @@ public:
|
|||
*/
|
||||
void tab_finish_init();
|
||||
int tab_page_num();
|
||||
bool tab_is_cur();
|
||||
void tab_runtime_changed();
|
||||
void tab_display_sorting();
|
||||
void tab_focus_search();
|
||||
|
@ -62,7 +62,9 @@ public:
|
|||
void tab_queue_add(Playqueue *);
|
||||
bool tab_queue_selected(bool);
|
||||
bool tab_add_to_queue(unsigned int);
|
||||
bool tab_add_to_playlist(const std::string &);
|
||||
bool tab_favorite_selected();
|
||||
void tab_ban_selected();
|
||||
|
||||
/**
|
||||
* internal callback functions that can be overridden if necessary
|
||||
|
@ -72,7 +74,7 @@ public:
|
|||
virtual void on_track_deleted(unsigned int);
|
||||
virtual void on_track_changed(unsigned int);
|
||||
virtual bool on_key_press_event(const std::string &);
|
||||
virtual void on_column_clicked(unsigned int);
|
||||
virtual void on_show_rc_menu();
|
||||
|
||||
/**
|
||||
* GTK-MM callback functions
|
||||
|
@ -80,7 +82,9 @@ public:
|
|||
void on_random_toggled();
|
||||
void on_repeat_toggled();
|
||||
void on_row_activated(const Gtk::TreePath &, Gtk::TreeViewColumn *);
|
||||
bool on_key_pressed(GdkEventKey *key);
|
||||
bool on_key_pressed(GdkEventKey *);
|
||||
void on_column_clicked(unsigned int);
|
||||
bool on_button_pressed(GdkEventButton *);
|
||||
|
||||
/* Filtering functions */
|
||||
bool on_filter_visible(const Gtk::TreeIter &);
|
||||
|
|
|
@ -19,12 +19,30 @@
|
|||
<property name="stock">gtk-add</property>
|
||||
<property name="icon_size">1</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image18">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="icon_name">emblem-documents</property>
|
||||
<property name="icon_size">1</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image19">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="icon_name">face-sad</property>
|
||||
<property name="icon_size">1</property>
|
||||
</object>
|
||||
<object class="GtkImage" id="image20">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="icon_name">emblem-favorite</property>
|
||||
<property name="icon_size">1</property>
|
||||
</object>
|
||||
<object class="GtkMenu" id="o_rc_menu">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="o_new_pq">
|
||||
<property name="label" translatable="yes">New Playqueue</property>
|
||||
<property name="label" translatable="yes">New Queue</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="image">image12</property>
|
||||
|
@ -33,7 +51,7 @@
|
|||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="o_add_to_pq">
|
||||
<property name="label" translatable="yes">Add to Playqueue</property>
|
||||
<property name="label" translatable="yes">Add to Queue</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="image">image13</property>
|
||||
|
@ -46,7 +64,7 @@
|
|||
<object class="GtkMenuItem" id="o_pq_0">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Playqueue 0</property>
|
||||
<property name="label" translatable="yes">Queue 0</property>
|
||||
<property name="use_underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
|
@ -54,7 +72,7 @@
|
|||
<object class="GtkMenuItem" id="o_pq_1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Playqueue 1</property>
|
||||
<property name="label" translatable="yes">Queue 1</property>
|
||||
<property name="use_underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
|
@ -62,7 +80,7 @@
|
|||
<object class="GtkMenuItem" id="o_pq_2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Playqueue 2</property>
|
||||
<property name="label" translatable="yes">Queue 2</property>
|
||||
<property name="use_underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
|
@ -70,7 +88,7 @@
|
|||
<object class="GtkMenuItem" id="o_pq_3">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Playqueue 3</property>
|
||||
<property name="label" translatable="yes">Queue 3</property>
|
||||
<property name="use_underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
|
@ -78,7 +96,7 @@
|
|||
<object class="GtkMenuItem" id="o_pq_4">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Playqueue 4</property>
|
||||
<property name="label" translatable="yes">Queue 4</property>
|
||||
<property name="use_underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
|
@ -86,7 +104,7 @@
|
|||
<object class="GtkMenuItem" id="o_pq_5">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Playqueue 5</property>
|
||||
<property name="label" translatable="yes">Queue 5</property>
|
||||
<property name="use_underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
|
@ -94,7 +112,7 @@
|
|||
<object class="GtkMenuItem" id="o_pq_6">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Playqueue 6</property>
|
||||
<property name="label" translatable="yes">Queue 6</property>
|
||||
<property name="use_underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
|
@ -102,7 +120,7 @@
|
|||
<object class="GtkMenuItem" id="o_pq_7">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Playqueue 7</property>
|
||||
<property name="label" translatable="yes">Queue 7</property>
|
||||
<property name="use_underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
|
@ -110,7 +128,7 @@
|
|||
<object class="GtkMenuItem" id="o_pq_8">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Playqueue 8</property>
|
||||
<property name="label" translatable="yes">Queue 8</property>
|
||||
<property name="use_underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
|
@ -118,7 +136,7 @@
|
|||
<object class="GtkMenuItem" id="o_pq_9">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="label" translatable="yes">Playqueue 9</property>
|
||||
<property name="label" translatable="yes">Queue 9</property>
|
||||
<property name="use_underline">True</property>
|
||||
</object>
|
||||
</child>
|
||||
|
@ -126,6 +144,39 @@
|
|||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="o_add_to_playlist">
|
||||
<property name="label" translatable="yes">Add to Playlist</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="image">image18</property>
|
||||
<property name="use_stock">False</property>
|
||||
<child type="submenu">
|
||||
<object class="GtkMenu" id="menu2">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="o_add_to_favorites">
|
||||
<property name="label" translatable="yes">Favorites</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="image">image20</property>
|
||||
<property name="use_stock">False</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkImageMenuItem" id="o_add_to_banned">
|
||||
<property name="label" translatable="yes">Banned</property>
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="image">image19</property>
|
||||
<property name="use_stock">False</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
<object class="GtkListStore" id="o_collection_dirs">
|
||||
<columns>
|
||||
|
|
Loading…
Reference in New Issue