gui/playlist: Handle key press events on the main treeview
Setting up a unit test for this is almost impossible, so we don't do that here. Signed-off-by: Anna Schumaker <Anna@NoWheyCreamery.com>
This commit is contained in:
parent
39bc7492d4
commit
3ae5e0f535
|
@ -6,6 +6,7 @@
|
||||||
#include <gui/filter.h>
|
#include <gui/filter.h>
|
||||||
#include <gui/model.h>
|
#include <gui/model.h>
|
||||||
#include <gui/playlist.h>
|
#include <gui/playlist.h>
|
||||||
|
#include <gui/treeview.h>
|
||||||
#include <gui/sidebar.h>
|
#include <gui/sidebar.h>
|
||||||
|
|
||||||
static void (*update_size[PL_MAX_TYPE])(struct playlist *) = {
|
static void (*update_size[PL_MAX_TYPE])(struct playlist *) = {
|
||||||
|
@ -72,9 +73,10 @@ static bool __gui_playlist_erase(struct queue *queue, struct track *track)
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case PL_SYSTEM:
|
case PL_SYSTEM:
|
||||||
if (string_match(name, "Collection"))
|
if (string_match(name, "Collection")) {
|
||||||
name = "Hidden";
|
playlist_add(type, "Hidden", track);
|
||||||
else if (!string_match(name, "Favorites") &&
|
break;
|
||||||
|
} else if (!string_match(name, "Favorites") &&
|
||||||
!string_match(name, "Hidden") &&
|
!string_match(name, "Hidden") &&
|
||||||
!string_match(name, "Queued Tracks"))
|
!string_match(name, "Queued Tracks"))
|
||||||
break;
|
break;
|
||||||
|
@ -99,6 +101,86 @@ struct queue_ops playlist_ops = {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static void __gui_playlist_add_selected_to(struct playlist *playlist)
|
||||||
|
{
|
||||||
|
GList *cur, *list = NULL;
|
||||||
|
struct track *track;
|
||||||
|
|
||||||
|
if (!playlist)
|
||||||
|
return;
|
||||||
|
|
||||||
|
list = gui_treeview_list_selected_tracks();
|
||||||
|
cur = g_list_first(list);
|
||||||
|
while (cur) {
|
||||||
|
track = (struct track *)cur->data;
|
||||||
|
playlist_add(playlist->pl_type, playlist->pl_name, track);
|
||||||
|
cur = g_list_next(cur);
|
||||||
|
}
|
||||||
|
g_list_free(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
void __gui_playlist_add_favorites(GtkMenuItem *item, gpointer data)
|
||||||
|
{
|
||||||
|
__gui_playlist_add_selected_to(playlist_get(PL_SYSTEM, "Favorites"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void __gui_playlist_add_hidden(GtkMenuItem *item, gpointer data)
|
||||||
|
{
|
||||||
|
__gui_playlist_add_selected_to(playlist_get(PL_SYSTEM, "Hidden"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void __gui_playlist_add_user(GtkMenuItem *item, gpointer data)
|
||||||
|
{
|
||||||
|
__gui_playlist_add_selected_to(gui_pl_user_add_dialog());
|
||||||
|
}
|
||||||
|
|
||||||
|
void __gui_playlist_add_queued(GtkMenuItem *item, gpointer data)
|
||||||
|
{
|
||||||
|
__gui_playlist_add_selected_to(playlist_get(PL_SYSTEM, "Queued Tracks"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void __gui_playlist_delete(GtkMenuItem *item, gpointer data)
|
||||||
|
{
|
||||||
|
struct playlist *playlist = gui_model_get_playlist();
|
||||||
|
GList *cur, *list = NULL;
|
||||||
|
struct track *track;
|
||||||
|
|
||||||
|
if (!playlist)
|
||||||
|
return;
|
||||||
|
|
||||||
|
list = gui_treeview_list_selected_tracks();
|
||||||
|
cur = g_list_first(list);
|
||||||
|
while (cur) {
|
||||||
|
track = (struct track *)cur->data;
|
||||||
|
queue_erase_track(&playlist->pl_queue, track);
|
||||||
|
cur = g_list_next(cur);
|
||||||
|
}
|
||||||
|
g_list_free(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
void __gui_playlist_keypress(GtkTreeView *treeview, GdkEventKey *event,
|
||||||
|
gpointer data)
|
||||||
|
{
|
||||||
|
switch (event->keyval) {
|
||||||
|
case GDK_KEY_f:
|
||||||
|
__gui_playlist_add_favorites(NULL, NULL);
|
||||||
|
break;
|
||||||
|
case GDK_KEY_h:
|
||||||
|
__gui_playlist_add_hidden(NULL, NULL);
|
||||||
|
break;
|
||||||
|
case GDK_KEY_p:
|
||||||
|
__gui_playlist_add_user(NULL, NULL);
|
||||||
|
break;
|
||||||
|
case GDK_KEY_q:
|
||||||
|
__gui_playlist_add_queued(NULL, NULL);
|
||||||
|
break;
|
||||||
|
case GDK_KEY_Delete:
|
||||||
|
__gui_playlist_delete(NULL, NULL);
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void __gui_playlist_row_activated(GtkTreeView *treeview, GtkTreePath *path,
|
void __gui_playlist_row_activated(GtkTreeView *treeview, GtkTreePath *path,
|
||||||
GtkTreeViewColumn *col, gpointer data)
|
GtkTreeViewColumn *col, gpointer data)
|
||||||
{
|
{
|
||||||
|
|
|
@ -887,7 +887,7 @@ audio-volume-medium</property>
|
||||||
<property name="rubber_banding">True</property>
|
<property name="rubber_banding">True</property>
|
||||||
<property name="tooltip_column">9</property>
|
<property name="tooltip_column">9</property>
|
||||||
<signal name="button-press-event" handler="__view_button_press" swapped="no"/>
|
<signal name="button-press-event" handler="__view_button_press" swapped="no"/>
|
||||||
<signal name="key-press-event" handler="__view_keypress" swapped="no"/>
|
<signal name="key-press-event" handler="__gui_playlist_keypress" swapped="no"/>
|
||||||
<signal name="row-activated" handler="__gui_treeview_row_activated" swapped="no"/>
|
<signal name="row-activated" handler="__gui_treeview_row_activated" swapped="no"/>
|
||||||
<child internal-child="selection">
|
<child internal-child="selection">
|
||||||
<object class="GtkTreeSelection" id="treeview-selection5">
|
<object class="GtkTreeSelection" id="treeview-selection5">
|
||||||
|
|
Loading…
Reference in New Issue