summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-01-21 21:21:09 +0100
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2010-01-21 21:21:09 +0100
commitc88b07cd7a1380482fad62ac6f1716f2ff3524e7 (patch)
tree44c25d17e4b17979f4be43034482e0a847c40820
parent439db34d8cbd2c558829eac501279adb83dddb95 (diff)
added filenumber column
-rw-r--r--deadbeef.h9
-rw-r--r--main.c4
-rw-r--r--playlist.c17
-rw-r--r--playlist.h2
-rw-r--r--plugins.c2
-rw-r--r--plugins/gtkui/callbacks.c8
-rw-r--r--plugins/gtkui/deadbeef.glade3
-rw-r--r--plugins/gtkui/gtkplaylist.c2
-rw-r--r--plugins/gtkui/interface.c1
-rw-r--r--plugins/notification/notification.c2
10 files changed, 33 insertions, 17 deletions
diff --git a/deadbeef.h b/deadbeef.h
index df52223e..cb804113 100644
--- a/deadbeef.h
+++ b/deadbeef.h
@@ -53,6 +53,7 @@ extern "C" {
// DON'T release plugins without DB_PLUGIN_SET_API_VERSION
// api version history:
+// 0.6 -- deadbeef-0.3.3
// 0.5 -- deadbeef-0.3.2
// 0.4 -- deadbeef-0.3.0
// 0.3 -- deadbeef-0.2.3.2
@@ -60,7 +61,7 @@ extern "C" {
// 0.1 -- deadbeef-0.2.0
#define DB_API_VERSION_MAJOR 0
-#define DB_API_VERSION_MINOR 5
+#define DB_API_VERSION_MINOR 6
#define DB_PLUGIN_SET_API_VERSION\
.plugin.api_vmajor = DB_API_VERSION_MAJOR,\
@@ -173,6 +174,7 @@ enum {
// preset columns, working using IDs
enum pl_column_t {
+ DB_COLUMN_FILENUMBER = 0,
DB_COLUMN_PLAYING = 1,
DB_COLUMN_ARTIST_ALBUM = 2,
DB_COLUMN_ARTIST = 3,
@@ -180,7 +182,7 @@ enum pl_column_t {
DB_COLUMN_TITLE = 5,
DB_COLUMN_DURATION = 6,
DB_COLUMN_TRACK = 7,
- DB_COLUMN_ID_MAX = 7
+ DB_COLUMN_ID_MAX
};
// message ids for communicating with player
@@ -295,6 +297,7 @@ typedef struct {
/*
this function formats line for display in playlist
@it pointer to playlist item
+ @idx number of that item in playlist (or -1)
@s output buffer
@size size of output buffer
@id one of IDs defined in pl_column_id_t enum, can be -1
@@ -311,7 +314,7 @@ typedef struct {
%r copyright
more to come
*/
- int (*pl_format_title) (DB_playItem_t *it, char *s, int size, int id, const char *fmt);
+ int (*pl_format_title) (DB_playItem_t *it, int idx, char *s, int size, int id, const char *fmt);
void (*pl_format_item_display_name) (DB_playItem_t *it, char *str, int len);
// void (*pl_set_next) (DB_playItem_t *it, DB_playItem_t *next, int iter);
// void (*pl_set_prev) (DB_playItem_t *it, DB_playItem_t *prev, int iter);
diff --git a/main.c b/main.c
index 6e1ba422..d27c4d4a 100644
--- a/main.c
+++ b/main.c
@@ -130,7 +130,7 @@ server_exec_command_line (const char *cmdline, int len, char *sendback, int sbsi
if (curr && curr->decoder) {
const char np[] = "nowplaying ";
memcpy (sendback, np, sizeof (np)-1);
- pl_format_title (curr, sendback+sizeof(np)-1, sbsize-sizeof(np)+1, -1, parg);
+ pl_format_title (curr, -1, sendback+sizeof(np)-1, sbsize-sizeof(np)+1, -1, parg);
}
else {
strcpy (sendback, "nowplaying nothing");
@@ -140,7 +140,7 @@ server_exec_command_line (const char *cmdline, int len, char *sendback, int sbsi
char out[2048];
playItem_t *curr = streamer_get_playing_track ();
if (curr && curr->decoder) {
- pl_format_title (curr, out, sizeof (out), -1, parg);
+ pl_format_title (curr, -1, out, sizeof (out), -1, parg);
}
else {
strcpy (out, "nothing");
diff --git a/playlist.c b/playlist.c
index 86cb22da..5ae22c94 100644
--- a/playlist.c
+++ b/playlist.c
@@ -1677,9 +1677,10 @@ pl_format_elapsed (const char *ret, char *elapsed, int size) {
}
int
-pl_format_title (playItem_t *it, char *s, int size, int id, const char *fmt) {
+pl_format_title (playItem_t *it, int idx, char *s, int size, int id, const char *fmt) {
char dur[50];
char elp[50];
+ char fno[50];
const char *artist = NULL;
const char *album = NULL;
const char *track = NULL;
@@ -1694,6 +1695,13 @@ pl_format_title (playItem_t *it, char *s, int size, int id, const char *fmt) {
if (id != -1) {
const char *text = NULL;
switch (id) {
+ case DB_COLUMN_FILENUMBER:
+ if (idx == -1) {
+ idx = pl_get_idx_of (it);
+ }
+ snprintf (fno, sizeof (fno), "%d", idx+1);
+ text = fno;
+ break;
case DB_COLUMN_PLAYING:
return pl_format_item_queue (it, s, size);
case DB_COLUMN_ARTIST_ALBUM:
@@ -1815,6 +1823,9 @@ pl_format_title (playItem_t *it, char *s, int size, int id, const char *fmt) {
void
pl_sort (int iter, int id, const char *format, int ascending) {
+ if (id == DB_COLUMN_FILENUMBER) {
+ return;
+ }
int sorted = 0;
do {
sorted = 1;
@@ -1844,8 +1855,8 @@ pl_sort (int iter, int id, const char *format, int ascending) {
}
}
else {
- pl_format_title (it, title1, sizeof (title1), id, format);
- pl_format_title (next, title2, sizeof (title2), id, format);
+ pl_format_title (it, -1, title1, sizeof (title1), id, format);
+ pl_format_title (next, -1, title2, sizeof (title2), id, format);
}
int cmp = ascending ? strcmp (title1, title2) < 0 : strcmp (title1, title2) > 0;
if (cmp) {
diff --git a/playlist.h b/playlist.h
index 4f51ad8f..dfe88c1a 100644
--- a/playlist.h
+++ b/playlist.h
@@ -164,7 +164,7 @@ pl_get_item_duration (playItem_t *it);
// returns number of characters printed, not including trailing 0
// [a]rtist, [t]itle, al[b]um, [l]ength, track[n]umber
int
-pl_format_title (playItem_t *it, char *s, int size, int id, const char *fmt);
+pl_format_title (playItem_t *it, int idx, char *s, int size, int id, const char *fmt);
void
pl_reset_cursor (void);
diff --git a/plugins.c b/plugins.c
index fc779173..5c4ee5af 100644
--- a/plugins.c
+++ b/plugins.c
@@ -118,7 +118,7 @@ static DB_functions_t deadbeef_api = {
.pl_get_last = (DB_playItem_t *(*) (int))pl_get_last,
.pl_get_next = (DB_playItem_t *(*) (DB_playItem_t *, int))pl_get_next,
.pl_get_prev = (DB_playItem_t *(*) (DB_playItem_t *, int))pl_get_prev,
- .pl_format_title = (int (*) (DB_playItem_t *it, char *s, int size, int id, const char *fmt))pl_format_title,
+ .pl_format_title = (int (*) (DB_playItem_t *it, int idx, char *s, int size, int id, const char *fmt))pl_format_title,
.pl_format_item_display_name = (void (*) (DB_playItem_t *it, char *str, int len))pl_format_item_display_name,
.pl_move_items = (void (*) (int iter, DB_playItem_t *drop_before, uint32_t *indexes, int count))pl_move_items,
.pl_search_reset = pl_search_reset,
diff --git a/plugins/gtkui/callbacks.c b/plugins/gtkui/callbacks.c
index 818399fe..603c5267 100644
--- a/plugins/gtkui/callbacks.c
+++ b/plugins/gtkui/callbacks.c
@@ -1790,9 +1790,9 @@ on_add_column_activate (GtkMenuItem *menuitem,
if (response == GTK_RESPONSE_OK) {
const gchar *title = gtk_entry_get_text (GTK_ENTRY (lookup_widget (dlg, "title")));
const gchar *format = gtk_entry_get_text (GTK_ENTRY (lookup_widget (dlg, "format")));
- int id = gtk_combo_box_get_active (GTK_COMBO_BOX (lookup_widget (dlg, "id"))) + 1;
+ int id = gtk_combo_box_get_active (GTK_COMBO_BOX (lookup_widget (dlg, "id")));
int align = gtk_combo_box_get_active (GTK_COMBO_BOX (lookup_widget (dlg, "align")));
- if (id > DB_COLUMN_ID_MAX) {
+ if (id >= DB_COLUMN_ID_MAX) {
id = -1;
}
gtkpl_column_insert_before (ps, ps->active_column, gtkpl_column_alloc (title, 100, id, format, align));
@@ -1882,13 +1882,13 @@ on_column_id_changed (GtkComboBox *combobox,
trace ("failed to get toplevel widget for column id combobox\n");
return;
}
- int act = gtk_combo_box_get_active (combobox) + 1;
+ int act = gtk_combo_box_get_active (combobox);
GtkWidget *fmt = lookup_widget (toplevel, "format");
if (!fmt) {
trace ("failed to get column format widget\n");
return;
}
- gtk_widget_set_sensitive (fmt, act > DB_COLUMN_ID_MAX ? TRUE : FALSE);
+ gtk_widget_set_sensitive (fmt, act >= DB_COLUMN_ID_MAX ? TRUE : FALSE);
}
diff --git a/plugins/gtkui/deadbeef.glade b/plugins/gtkui/deadbeef.glade
index cfd07055..35166688 100644
--- a/plugins/gtkui/deadbeef.glade
+++ b/plugins/gtkui/deadbeef.glade
@@ -3218,7 +3218,8 @@ SOCKS5_HOSTNAME</property>
<child>
<widget class="GtkComboBox" id="id">
<property name="visible">True</property>
- <property name="items" translatable="yes">Playing
+ <property name="items" translatable="yes">File number
+Playing
Artist - Album
Artist
Album
diff --git a/plugins/gtkui/gtkplaylist.c b/plugins/gtkui/gtkplaylist.c
index 762be03f..22fcf630 100644
--- a/plugins/gtkui/gtkplaylist.c
+++ b/plugins/gtkui/gtkplaylist.c
@@ -396,7 +396,7 @@ gtkpl_draw_pl_row (gtkplaylist_t *ps, int row, DB_playItem_t *it) {
}
else {
char text[1024];
- deadbeef->pl_format_title (it, text, sizeof (text), c->id, c->format);
+ deadbeef->pl_format_title (it, row, text, sizeof (text), c->id, c->format);
if (c->align_right) {
draw_text (x+5, row * rowheight - ps->scrollpos * rowheight + rowheight/2 - draw_get_font_size ()/2 - 2, c->width-10, 1, text);
diff --git a/plugins/gtkui/interface.c b/plugins/gtkui/interface.c
index 0b614e97..1ce72388 100644
--- a/plugins/gtkui/interface.c
+++ b/plugins/gtkui/interface.c
@@ -2083,6 +2083,7 @@ create_editcolumndlg (void)
gtk_table_attach (GTK_TABLE (table9), id, 1, 2, 1, 2,
(GtkAttachOptions) (GTK_FILL),
(GtkAttachOptions) (GTK_FILL), 0, 0);
+ gtk_combo_box_append_text (GTK_COMBO_BOX (id), "File number");
gtk_combo_box_append_text (GTK_COMBO_BOX (id), "Playing");
gtk_combo_box_append_text (GTK_COMBO_BOX (id), "Artist - Album");
gtk_combo_box_append_text (GTK_COMBO_BOX (id), "Artist");
diff --git a/plugins/notification/notification.c b/plugins/notification/notification.c
index a55effdd..dc5b669f 100644
--- a/plugins/notification/notification.c
+++ b/plugins/notification/notification.c
@@ -16,7 +16,7 @@ static void
show_notification (DB_playItem_t *track)
{
char cmd [1024];
- deadbeef->pl_format_title (track, cmd, sizeof (cmd), -1, deadbeef->conf_get_str ("notification.command", DEFAULT_COMMAND));
+ deadbeef->pl_format_title (track, -1, cmd, sizeof (cmd), -1, deadbeef->conf_get_str ("notification.command", DEFAULT_COMMAND));
//system (cmd);
}