diff options
author | Alexey Yakovenko <wakeroid@gmail.com> | 2009-11-15 13:08:21 +0100 |
---|---|---|
committer | Alexey Yakovenko <wakeroid@gmail.com> | 2009-11-15 13:08:21 +0100 |
commit | 5c2b089be764990d6947e142223b12647ca40fa9 (patch) | |
tree | 5d9bc7370cbd5aabedcd8faee6b63b664035a00c | |
parent | 55f8c64a00144aae19270d1b21cd2ce25d9a0dba (diff) |
gtkui plugin WIP
-rw-r--r-- | deadbeef.h | 6 | ||||
-rw-r--r-- | playlist.c | 11 | ||||
-rw-r--r-- | playlist.h | 6 | ||||
-rw-r--r-- | plugins.c | 6 | ||||
-rw-r--r-- | plugins/gtkui/callbacks.c | 18 | ||||
-rw-r--r-- | plugins/gtkui/gtkplaylist.h | 2 | ||||
-rw-r--r-- | plugins/gtkui/gtkui.c | 25 | ||||
-rw-r--r-- | plugins/gtkui/support.c (renamed from support.c) | 0 | ||||
-rw-r--r-- | plugins/gtkui/support.h (renamed from support.h) | 0 |
9 files changed, 56 insertions, 18 deletions
@@ -241,7 +241,13 @@ typedef struct { void (*pl_item_copy) (DB_playItem_t *out, DB_playItem_t *in); DB_playItem_t *(*pl_insert_item) (DB_playItem_t *after, DB_playItem_t *it); int (*pl_get_idx_of) (DB_playItem_t *it); + DB_playItem_t * (*pl_get_for_idx) (int); float (*pl_get_totaltime) (void); + int (*pl_getcount) (void); + DB_playItem_t *(*pl_getcurrent) (void); + int (*pl_delete_selected) (void); + void (*pl_set_cursor) (int cursor); + void (*pl_set_selected) (DB_playItem_t *it, int sel); // metainfo void (*pl_add_meta) (DB_playItem_t *it, const char *key, const char *value); const char *(*pl_find_meta) (DB_playItem_t *song, const char *meta); @@ -1658,3 +1658,14 @@ float pl_get_totaltime (void) { return pl_totaltime; } + +playItem_t * +pl_getcurrent (void) { + return playlist_current_ptr; +} + +void +pl_set_selected (playItem_t *it, int sel) { + it->selected = sel; +} + @@ -177,4 +177,10 @@ pl_reset_cursor (void); float pl_get_totaltime (void); +playItem_t * +pl_getcurrent (void); + +void +pl_set_selected (playItem_t *it, int sel); + #endif // __PLAYLIST_H @@ -89,9 +89,15 @@ static DB_functions_t deadbeef_api = { .pl_item_copy = (void (*)(DB_playItem_t *, DB_playItem_t *))pl_item_copy, .pl_insert_item = (DB_playItem_t *(*) (DB_playItem_t *after, DB_playItem_t *it))pl_insert_item, .pl_get_idx_of = (int (*) (DB_playItem_t *it))pl_get_idx_of, + .pl_get_for_idx = (DB_playItem_t * (*)(int))pl_get_for_idx, .pl_set_item_duration = (void (*) (DB_playItem_t *it, float duration))pl_set_item_duration, .pl_get_item_duration = (float (*) (DB_playItem_t *it))pl_get_item_duration, .pl_get_totaltime = pl_get_totaltime, + .pl_getcount = pl_getcount, + .pl_getcurrent = (DB_playItem_t *(*)(void))pl_getcurrent, + .pl_delete_selected = pl_delete_selected, + .pl_set_cursor = pl_set_cursor, + .pl_set_selected = (void (*) (DB_playItem_t *, int))pl_set_selected, // metainfo .pl_add_meta = (void (*) (DB_playItem_t *, const char *, const char *))pl_add_meta, .pl_find_meta = (const char *(*) (DB_playItem_t *, const char *))pl_find_meta, diff --git a/plugins/gtkui/callbacks.c b/plugins/gtkui/callbacks.c index 8d6d9bbf..a5c51b5a 100644 --- a/plugins/gtkui/callbacks.c +++ b/plugins/gtkui/callbacks.c @@ -51,11 +51,12 @@ extern GtkWidget *mainwin; extern gtkplaylist_t main_playlist; extern gtkplaylist_t search_playlist; +extern DB_functions_t *deadbeef; // defined in gtkui.c gboolean playlist_tooltip_handler (GtkWidget *widget, gint x, gint y, gboolean keyboard_mode, GtkTooltip *tooltip, gpointer unused) { - playItem_t *item = gtkpl_get_for_idx (&main_playlist, main_playlist.scrollpos + y / rowheight); + DB_playItem_t *item = deadbeef->pl_get_for_idx (main_playlist.scrollpos + y / rowheight); if (item && item->fname) { gtk_tooltip_set_text (tooltip, item->fname); return TRUE; @@ -72,13 +73,13 @@ main_playlist_init (GtkWidget *widget) { main_playlist.header = lookup_widget (mainwin, "header"); main_playlist.scrollbar = lookup_widget (mainwin, "playscroll"); main_playlist.hscrollbar = lookup_widget (mainwin, "playhscroll"); - main_playlist.pcurr = &playlist_current_ptr; +// main_playlist.pcurr = &playlist_current_ptr; main_playlist.pcount = &pl_count; main_playlist.iterator = PL_MAIN; main_playlist.multisel = 1; main_playlist.scrollpos = 0; main_playlist.hscrollpos = 0; - main_playlist.row = -1; +// main_playlist.row = -1; main_playlist.clicktime = -1; main_playlist.nvisiblerows = 0; @@ -135,7 +136,7 @@ search_playlist_init (GtkWidget *widget) { search_playlist.iterator = PL_SEARCH; search_playlist.scrollpos = 0; search_playlist.hscrollpos = 0; - search_playlist.row = -1; +// search_playlist.row = -1; search_playlist.clicktime = -1; search_playlist.nvisiblerows = 0; @@ -444,11 +445,12 @@ on_remove1_activate (GtkMenuItem *menuitem, { gtkplaylist_t *ps = &main_playlist; GtkWidget *widget = ps->playlist; - ps->row = pl_delete_selected (); - if (ps->row != -1) { - playItem_t *it = pl_get_for_idx (ps->row); + int row = deadbeef->pl_delete_selected (); + deadbeef->pl_set_cursor (row); + if (row != -1) { + DB_playItem_t *it = deadbeef->pl_get_for_idx (row); if (it) { - it->selected = 1; + deadbeef->pl_set_selected (it, 1); } } gtkpl_setup_scrollbar (ps); diff --git a/plugins/gtkui/gtkplaylist.h b/plugins/gtkui/gtkplaylist.h index 5547fa54..88677e12 100644 --- a/plugins/gtkui/gtkplaylist.h +++ b/plugins/gtkui/gtkplaylist.h @@ -73,7 +73,7 @@ typedef struct { GdkPixmap *backbuf_header; const char *title; // unique id, used for config writing, etc // parameters - DB_playItem_t **pcurr; // pointer to current item +// DB_playItem_t **pcurr; // pointer to current item int *pcount; // pointer to count of items in list int iterator; // index into next array of DB_playItem_t struct int lastpos[2]; // last mouse position (for playlist widget) diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c index 7f29ef4a..0fa69714 100644 --- a/plugins/gtkui/gtkui.c +++ b/plugins/gtkui/gtkui.c @@ -25,12 +25,13 @@ #include "interface.h" #include "callbacks.h" #include "support.h" +#include "session.h" #define trace(...) { fprintf(stderr, __VA_ARGS__); } //#define trace(fmt,...) static DB_gui_t plugin; -static DB_functions_t *deadbeef; +DB_functions_t *deadbeef; // main widgets GtkWidget *mainwin; @@ -74,7 +75,7 @@ update_songinfo (void) { float duration = deadbeef->pl_get_item_duration (track); if (deadbeef->playback_isstopped ()) { - snprintf (sbtext_new, sizeof (sbtext_new), "Stopped | %d tracks | %s total playtime", pl_getcount (), totaltime_str); + snprintf (sbtext_new, sizeof (sbtext_new), "Stopped | %d tracks | %s total playtime", deadbeef->pl_getcount (), totaltime_str); songpos = 0; } else if (track->decoder) { @@ -108,7 +109,7 @@ update_songinfo (void) { } #endif const char *spaused = deadbeef->playback_ispaused () ? "Paused | " : ""; - snprintf (sbtext_new, sizeof (sbtext_new), "%s%s %s| %dHz | %d bit | %s | %d:%02d / %s | %d tracks | %s total playtime", spaused, track->filetype ? track->filetype:"-", sbitrate, samplerate, bitspersample, mode, minpos, secpos, t, pl_getcount (), totaltime_str); + snprintf (sbtext_new, sizeof (sbtext_new), "%s%s %s| %dHz | %d bit | %s | %d:%02d / %s | %d tracks | %s total playtime", spaused, track->filetype ? track->filetype:"-", sbitrate, samplerate, bitspersample, mode, minpos, secpos, t, deadbeef->pl_getcount (), totaltime_str); } if (strcmp (sbtext_new, sb_text)) { @@ -239,6 +240,7 @@ guiplug_shutdown (void) { GDK_THREADS_LEAVE(); } +#if 0 void guiplug_start_current_track (void) { gtkpl_playsong (&main_playlist); @@ -248,6 +250,7 @@ guiplug_start_current_track (void) { GDK_THREADS_LEAVE(); } } +#endif void guiplug_start_track (int idx) { @@ -319,7 +322,7 @@ static int gtkui_on_trackinfochanged (DB_event_track_t *ev, uintptr_t data) { GDK_THREADS_ENTER(); gtkpl_redraw_pl_row (&main_playlist, ev->index, ev->track); - if (ev->track == playlist_current_ptr) { + if (ev->track == deadbeef->pl_getcurrent ()) { gtkpl_current_track_changed (ev->track); } GDK_THREADS_LEAVE(); @@ -328,7 +331,11 @@ gtkui_on_trackinfochanged (DB_event_track_t *ev, uintptr_t data) { static int gtkui_on_paused (DB_event_state_t *ev, uintptr_t data) { GDK_THREADS_ENTER(); - gtkpl_redraw_pl_row (&main_playlist, pl_get_idx_of (playlist_current_ptr), playlist_current_ptr); + DB_playItem_t *curr = deadbeef->pl_getcurrent (); + if (curr) { + int idx = deadbeef->pl_get_idx_of (curr); + gtkpl_redraw_pl_row (&main_playlist, idx, curr); + } GDK_THREADS_LEAVE(); } @@ -359,7 +366,7 @@ gtkui_start (void) { gdk_threads_init (); gdk_threads_enter (); gtk_set_locale (); - gtk_init (&argc, &argv); + gtk_init (0, NULL); // system tray icon traymenu = create_traymenu (); @@ -390,11 +397,11 @@ gtkui_start (void) { const char *orderwidgets[3] = { "order_linear", "order_shuffle", "order_random" }; const char *loopingwidgets[3] = { "loop_all", "loop_disable", "loop_single" }; const char *w; - w = orderwidgets[conf_get_int ("playback.order", 0)]; + w = orderwidgets[deadbeef->conf_get_int ("playback.order", 0)]; gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (lookup_widget (mainwin, w)), TRUE); - w = loopingwidgets[conf_get_int ("playback.loop", 0)]; + w = loopingwidgets[deadbeef->conf_get_int ("playback.loop", 0)]; gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (lookup_widget (mainwin, w)), TRUE); - gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (lookup_widget (mainwin, "scroll_follows_playback")), conf_get_int ("playlist.scroll.followplayback", 0) ? TRUE : FALSE); + gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (lookup_widget (mainwin, "scroll_follows_playback")), deadbeef->conf_get_int ("playlist.scroll.followplayback", 0) ? TRUE : FALSE); searchwin = create_searchwin (); gtk_window_set_transient_for (GTK_WINDOW (searchwin), GTK_WINDOW (mainwin)); diff --git a/support.c b/plugins/gtkui/support.c index 7dc3c78c..7dc3c78c 100644 --- a/support.c +++ b/plugins/gtkui/support.c diff --git a/support.h b/plugins/gtkui/support.h index 2dea079c..2dea079c 100644 --- a/support.h +++ b/plugins/gtkui/support.h |