diff options
-rw-r--r-- | deadbeef.h | 3 | ||||
-rw-r--r-- | plugins/gtkui/callbacks.c | 2 | ||||
-rw-r--r-- | plugins/gtkui/gtkui.c | 18 | ||||
-rw-r--r-- | plugins/gtkui/gtkui.h | 3 | ||||
-rw-r--r-- | plugins/gtkui/widgets.c | 38 |
5 files changed, 42 insertions, 22 deletions
@@ -278,6 +278,8 @@ enum { DB_EV_SONGFINISHED = 1002, // song finished playing, ctx=ddb_event_track_t DB_EV_TRACKINFOCHANGED = 1004, // trackinfo was changed (included medatata and playback status), ctx=ddb_event_track_t DB_EV_SEEKED = 1005, // seek happened, ctx=ddb_event_playpos_t + // new in 1.4 + DB_EV_TRACKFOCUSCURRENT = 1006, // user wants to highlight/find the current playing track DB_EV_MAX }; @@ -755,6 +757,7 @@ typedef struct { // ******* new 1.3 APIs ******** int (*streamer_dsp_chain_save) (void); + } DB_functions_t; // NOTE: an item placement must be selected like this diff --git a/plugins/gtkui/callbacks.c b/plugins/gtkui/callbacks.c index fae22fe1..b70b6a17 100644 --- a/plugins/gtkui/callbacks.c +++ b/plugins/gtkui/callbacks.c @@ -1102,7 +1102,7 @@ void on_jump_to_current_track1_activate (GtkMenuItem *menuitem, gpointer user_data) { - gtkui_focus_on_playing_track (); + deadbeef->sendmessage (DB_EV_TRACKFOCUSCURRENT, 0, 0, 0); } static GtkWidget *translatorswindow; diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c index 938eec39..77d15e1c 100644 --- a/plugins/gtkui/gtkui.c +++ b/plugins/gtkui/gtkui.c @@ -1196,24 +1196,6 @@ gtkui_plt_load (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname, in } void -gtkui_focus_on_playing_track (void) { - DB_playItem_t *it = deadbeef->streamer_get_playing_track (); - if (it) { - int plt = deadbeef->streamer_get_current_playlist (); - if (plt != deadbeef->plt_get_curr_idx ()) { - deadbeef->plt_set_curr_idx (plt); - } - int idx = deadbeef->pl_get_idx_of (it); - if (idx != -1) { - DdbListview *pl = DDB_LISTVIEW (lookup_widget (mainwin, "playlist")); - ddb_listview_scroll_to (pl, idx); - ddb_listview_set_cursor (pl, idx); - } - deadbeef->pl_item_unref (it); - } -} - -void gtkui_playlist_set_curr (int playlist) { deadbeef->plt_set_curr_idx (playlist); deadbeef->conf_set_int ("playlist.current", playlist); diff --git a/plugins/gtkui/gtkui.h b/plugins/gtkui/gtkui.h index afef4788..2d4ddf11 100644 --- a/plugins/gtkui/gtkui.h +++ b/plugins/gtkui/gtkui.h @@ -140,9 +140,6 @@ extern int (*gtkui_original_plt_add_dir) (ddb_playlist_t *plt, const char *dirna extern int (*gtkui_original_plt_add_file) (ddb_playlist_t *plt, const char *fname, int (*cb)(DB_playItem_t *it, void *data), void *user_data); void -gtkui_focus_on_playing_track (void); - -void gtkui_playlist_set_curr (int playlist); void diff --git a/plugins/gtkui/widgets.c b/plugins/gtkui/widgets.c index 47e8f918..dca0b915 100644 --- a/plugins/gtkui/widgets.c +++ b/plugins/gtkui/widgets.c @@ -1194,6 +1194,38 @@ songchanged_cb (gpointer data) { return FALSE; } +static gboolean +tabbed_trackfocus_cb (gpointer p) { + w_tabbed_playlist_t *tp = p; + DB_playItem_t *it = deadbeef->streamer_get_playing_track (); + if (it) { + int idx = deadbeef->pl_get_idx_of (it); + if (idx != -1) { + ddb_listview_scroll_to (tp->list, idx); + ddb_listview_set_cursor (tp->list, idx); + } + deadbeef->pl_item_unref (it); + } + + return FALSE; +} + +static gboolean +trackfocus_cb (gpointer p) { + w_playlist_t *tp = p; + DB_playItem_t *it = deadbeef->streamer_get_playing_track (); + if (it) { + int idx = deadbeef->pl_get_idx_of (it); + if (idx != -1) { + ddb_listview_scroll_to (tp->list, idx); + ddb_listview_set_cursor (tp->list, idx); + } + deadbeef->pl_item_unref (it); + } + + return FALSE; +} + static int w_tabbed_playlist_message (ddb_gtkui_widget_t *w, uint32_t id, uintptr_t ctx, uint32_t p1, uint32_t p2) { w_tabbed_playlist_t *tp = (w_tabbed_playlist_t *)w; @@ -1235,6 +1267,9 @@ w_tabbed_playlist_message (ddb_gtkui_widget_t *w, uint32_t id, uintptr_t ctx, ui case DB_EV_PLAYLISTSWITCHED: g_idle_add (tabbed_playlistswitch_cb, w); break; + case DB_EV_TRACKFOCUSCURRENT: + g_idle_add (tabbed_trackfocus_cb, w); + break; } return 0; } @@ -1280,6 +1315,9 @@ w_playlist_message (ddb_gtkui_widget_t *w, uint32_t id, uintptr_t ctx, uint32_t case DB_EV_PLAYLISTSWITCHED: g_idle_add (playlistswitch_cb, w); break; + case DB_EV_TRACKFOCUSCURRENT: + g_idle_add (trackfocus_cb, w); + break; } return 0; } |