summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.am2
-rw-r--r--configure.ac9
-rw-r--r--plugins/gtkui/Makefile.am3
-rw-r--r--plugins/gtkui/ddblistview.c78
-rw-r--r--plugins/gtkui/ddblistview.h1
-rw-r--r--plugins/gtkui/gtkui.c51
-rw-r--r--plugins/gtkui/mainplaylist.c554
-rw-r--r--plugins/gtkui/mainplaylist.h3
-rw-r--r--plugins/gtkui/search.c244
-rw-r--r--plugins/gtkui/search.h8
10 files changed, 313 insertions, 640 deletions
diff --git a/Makefile.am b/Makefile.am
index da4e28eb..0620601a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -22,7 +22,7 @@ SUBDIRS = ${MPGMAD_DIR}\
${CDDA_DIR}\
${OSS_DIR}\
${PULSE_DIR}\
- plugins/artwork
+ ${ARTWORK_DIR}
dumbpath=@top_srcdir@/dumb
gmepath=@top_srcdir@/gme/Game_Music_Emu-0.5.2
diff --git a/configure.ac b/configure.ac
index 7ad3bc50..491b705b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -35,7 +35,7 @@ esac
test "x$prefix" = xNONE && prefix=$ac_default_prefix
-dnl INSANE_CFLAGS="-Wcomment -Wchar-subscripts -Wunused-function -Wunused-value -Wuninitialized -Wtype-limits -Wbad-function-cast"
+INSANE_CFLAGS="-Wcomment -Wchar-subscripts -Wunused-function -Wunused-value -Wuninitialized -Wtype-limits -Wbad-function-cast"
dnl INSANE_CXXFLAGS="-Wcomment -Wchar-subscripts -Wunused-function -Wunused-value -Wuninitialized -Wtype-limits"
AC_SUBST(INSANE_CFLAGS)
@@ -262,6 +262,12 @@ if test ${HAVE_PULSE}; then
AC_SUBST(PULSE_DIR)
fi
+if test ${HAVE_CURL}; then
+ HAVE_ARTWORK=1
+ ARTWORK_DIR="plugins/artwork"
+ AC_SUBST(ARTWORK_DIR)
+fi
+
dnl print summary
echo
echo "plugin summary:"
@@ -301,6 +307,7 @@ PRINT_PLUGIN_INFO([libnotify],[Current track notification],[test $HAVE_NOTIFY])
PRINT_PLUGIN_INFO([ffmpeg],[ffmpeg codecs],[test $HAVE_FFMPEG])
PRINT_PLUGIN_INFO([oss],[oss output plugin],[test "x$have_oss" = "xyes"])
PRINT_PLUGIN_INFO([pulse],[PulseAudio output plugin],[test $HAVE_PULSE])
+PRINT_PLUGIN_INFO([artwork],[Cover art plugin],[test $HAVE_ARTWORK])
echo
AC_OUTPUT([
diff --git a/plugins/gtkui/Makefile.am b/plugins/gtkui/Makefile.am
index ed8d1c24..b4d6dfe9 100644
--- a/plugins/gtkui/Makefile.am
+++ b/plugins/gtkui/Makefile.am
@@ -14,7 +14,8 @@ gtkui_la_SOURCES = gtkui.c gtkui.h\
ddbtabstrip.c ddbtabstrip.h\
ddbvolumebar.c ddbvolumebar.h\
trkproperties.c trkproperties.h\
- coverart.c coverart.h
+ coverart.c coverart.h\
+ plcommon.c plcommon.h
gtkui_la_LDFLAGS = -module
diff --git a/plugins/gtkui/ddblistview.c b/plugins/gtkui/ddblistview.c
index 2c699e51..32f31f4f 100644
--- a/plugins/gtkui/ddblistview.c
+++ b/plugins/gtkui/ddblistview.c
@@ -35,20 +35,13 @@
#include <sys/time.h>
#include "ddblistview.h"
#include "drawing.h"
-//#include "callbacks.h"
-//#include "interface.h"
-//#include "support.h"
-//#include "search.h"
-//#include "progress.h"
-//#include "../../session.h"
-//#include "parser.h"
-//#include "gtkui.h"
+
+#pragma GCC optimize("O0")
#define min(x,y) ((x)<(y)?(x):(y))
#define max(x,y) ((x)>(y)?(x):(y))
#define DEFAULT_GROUP_TITLE_HEIGHT 30
-int GROUP_TITLE_HEIGHT = 0;
#define SCROLL_STEP 20
#define AUTOSCROLL_UPDATE_FREQ 0.01f
@@ -86,12 +79,10 @@ typedef struct _DdbListviewGroup DdbListviewGroup;
static void ddb_listview_class_init(DdbListviewClass *klass);
static void ddb_listview_init(DdbListview *listview);
-static void ddb_listview_size_request(GtkWidget *widget,
- GtkRequisition *requisition);
-static void ddb_listview_size_allocate(GtkWidget *widget,
- GtkAllocation *allocation);
-static void ddb_listview_realize(GtkWidget *widget);
-static void ddb_listview_paint(GtkWidget *widget);
+//static void ddb_listview_size_request(GtkWidget *widget, GtkRequisition *requisition);
+//static void ddb_listview_size_allocate(GtkWidget *widget, GtkAllocation *allocation);
+//static void ddb_listview_realize(GtkWidget *widget);
+//static void ddb_listview_paint(GtkWidget *widget);
static void ddb_listview_destroy(GtkObject *object);
// fwd decls
@@ -318,6 +309,7 @@ ddb_listview_init(DdbListview *listview)
listview->groups = NULL;
listview->block_redraw_on_scroll = 0;
+ listview->grouptitle_height = DEFAULT_GROUP_TITLE_HEIGHT;
GtkWidget *hbox;
GtkWidget *vbox;
@@ -533,7 +525,7 @@ ddb_listview_get_row_pos (DdbListview *listview, int row_idx) {
DdbListviewGroup *grp = listview->groups;
while (grp) {
if (idx + grp->num_items > row_idx) {
- return y + GROUP_TITLE_HEIGHT + (row_idx - idx) * listview->rowheight;
+ return y + listview->grouptitle_height + (row_idx - idx) * listview->rowheight;
}
y += grp->height;
idx += grp->num_items;
@@ -555,7 +547,7 @@ ddb_listview_list_pickpoint_y (DdbListview *listview, int y, DdbListviewGroup **
if (y >= grp_y && y < grp_y + h) {
*group = grp;
y -= grp_y;
- if (y < GROUP_TITLE_HEIGHT) {
+ if (y < listview->grouptitle_height) {
*group_idx = -1;
*global_idx = -1;
}
@@ -564,7 +556,7 @@ ddb_listview_list_pickpoint_y (DdbListview *listview, int y, DdbListviewGroup **
*global_idx = -1;
}
else {
- *group_idx = (y - GROUP_TITLE_HEIGHT) / listview->rowheight;
+ *group_idx = (y - listview->grouptitle_height) / listview->rowheight;
*global_idx = idx + *group_idx;
}
return 0;
@@ -608,23 +600,25 @@ ddb_listview_list_render (DdbListview *listview, int x, int y, int w, int h) {
if (grp_y >= y + h + listview->scrollpos) {
break;
}
- if (grp_y + GROUP_TITLE_HEIGHT >= y + listview->scrollpos && grp_y < y + h + listview->scrollpos) {
- ddb_listview_list_render_row_background (listview, NULL, idx & 1, 0, -listview->hscrollpos, grp_y - listview->scrollpos, listview->totalwidth, GROUP_TITLE_HEIGHT);
- listview->binding->draw_group_title (listview, listview->backbuf, it, -listview->hscrollpos, grp_y - listview->scrollpos, listview->totalwidth, GROUP_TITLE_HEIGHT);
+ if (grp_y + listview->grouptitle_height >= y + listview->scrollpos && grp_y < y + h + listview->scrollpos) {
+ ddb_listview_list_render_row_background (listview, NULL, idx & 1, 0, -listview->hscrollpos, grp_y - listview->scrollpos, listview->totalwidth, listview->grouptitle_height);
+ if (listview->binding->draw_group_title && listview->grouptitle_height > 0) {
+ listview->binding->draw_group_title (listview, listview->backbuf, it, -listview->hscrollpos, grp_y - listview->scrollpos, listview->totalwidth, listview->grouptitle_height);
+ }
}
for (int i = 0; i < grp->num_items; i++) {
ii++;
-// if (grp_y + GROUP_TITLE_HEIGHT + (i+1) * listview->rowheight >= y + h + listview->scrollpos) {
+// if (grp_y + listview->grouptitle_height + (i+1) * listview->rowheight >= y + h + listview->scrollpos) {
// break;
// }
- if (grp_y + GROUP_TITLE_HEIGHT + i * listview->rowheight >= y + h + listview->scrollpos) {
+ if (grp_y + listview->grouptitle_height + i * listview->rowheight >= y + h + listview->scrollpos) {
break;
}
- if (grp_y + GROUP_TITLE_HEIGHT + (i+1) * listview->rowheight >= y + listview->scrollpos
- && grp_y + GROUP_TITLE_HEIGHT + i * listview->rowheight < y + h + listview->scrollpos) {
- gdk_draw_rectangle (listview->backbuf, listview->list->style->bg_gc[GTK_STATE_NORMAL], TRUE, -listview->hscrollpos, grp_y + GROUP_TITLE_HEIGHT + i * listview->rowheight - listview->scrollpos, listview->totalwidth, listview->rowheight);
- ddb_listview_list_render_row_background (listview, it, (idx + 1 + i) & 1, (abs_idx+i) == listview->binding->cursor () ? 1 : 0, -listview->hscrollpos, grp_y + GROUP_TITLE_HEIGHT + i * listview->rowheight - listview->scrollpos, listview->totalwidth, listview->rowheight);
- ddb_listview_list_render_row_foreground (listview, it, grp->head, (idx + 1 + i) & 1, (idx+i) == listview->binding->cursor () ? 1 : 0, i * listview->rowheight, -listview->hscrollpos, grp_y + GROUP_TITLE_HEIGHT + i * listview->rowheight - listview->scrollpos, listview->totalwidth, listview->rowheight);
+ if (grp_y + listview->grouptitle_height + (i+1) * listview->rowheight >= y + listview->scrollpos
+ && grp_y + listview->grouptitle_height + i * listview->rowheight < y + h + listview->scrollpos) {
+ gdk_draw_rectangle (listview->backbuf, listview->list->style->bg_gc[GTK_STATE_NORMAL], TRUE, -listview->hscrollpos, grp_y + listview->grouptitle_height + i * listview->rowheight - listview->scrollpos, listview->totalwidth, listview->rowheight);
+ ddb_listview_list_render_row_background (listview, it, (idx + 1 + i) & 1, (abs_idx+i) == listview->binding->cursor () ? 1 : 0, -listview->hscrollpos, grp_y + listview->grouptitle_height + i * listview->rowheight - listview->scrollpos, listview->totalwidth, listview->rowheight);
+ ddb_listview_list_render_row_foreground (listview, it, grp->head, (idx + 1 + i) & 1, (idx+i) == listview->binding->cursor () ? 1 : 0, i * listview->rowheight, -listview->hscrollpos, grp_y + listview->grouptitle_height + i * listview->rowheight - listview->scrollpos, listview->totalwidth, listview->rowheight);
}
DdbListviewIter next = listview->binding->next (it);
listview->binding->unref (it);
@@ -636,10 +630,10 @@ ddb_listview_list_render (DdbListview *listview, int x, int y, int w, int h) {
idx += grp->num_items + 1;
abs_idx += grp->num_items;
- int filler = grpheight - (GROUP_TITLE_HEIGHT + listview->rowheight * grp->num_items);
+ int filler = grpheight - (listview->grouptitle_height + listview->rowheight * grp->num_items);
if (filler > 0) {
- gtk_paint_flat_box (treeview->style, listview->backbuf, GTK_STATE_NORMAL, GTK_SHADOW_NONE, NULL, treeview, "cell_even_ruled", x, grp_y - listview->scrollpos + GROUP_TITLE_HEIGHT + listview->rowheight * grp->num_items, w, filler);
- ddb_listview_list_render_row_foreground (listview, NULL, grp->head, 0, 0, grp->num_items * listview->rowheight, -listview->hscrollpos, grp_y - listview->scrollpos + GROUP_TITLE_HEIGHT + listview->rowheight * grp->num_items, listview->totalwidth, filler);
+ gtk_paint_flat_box (treeview->style, listview->backbuf, GTK_STATE_NORMAL, GTK_SHADOW_NONE, NULL, treeview, "cell_even_ruled", x, grp_y - listview->scrollpos + listview->grouptitle_height + listview->rowheight * grp->num_items, w, filler);
+ ddb_listview_list_render_row_foreground (listview, NULL, grp->head, 0, 0, grp->num_items * listview->rowheight, -listview->hscrollpos, grp_y - listview->scrollpos + listview->grouptitle_height + listview->rowheight * grp->num_items, listview->totalwidth, filler);
}
grp_y += grpheight;
@@ -1060,7 +1054,7 @@ ddb_listview_list_get_drawinfo (DdbListview *listview, int row, DdbListviewGroup
*cursor = (row == listview->binding->cursor ()) ? 1 : 0;
*group_y = idx_in_group * listview->rowheight;
*x = -listview->hscrollpos;
- *y += GROUP_TITLE_HEIGHT + (row - idx) * listview->rowheight;
+ *y += listview->grouptitle_height + (row - idx) * listview->rowheight;
*w = listview->totalwidth;
*h = listview->rowheight;
return 0;
@@ -1139,7 +1133,7 @@ ddb_listview_list_render_row_foreground (DdbListview *ps, DdbListviewIter it, Dd
int cidx = 0;
for (c = ps->columns; c; c = c->next, cidx++) {
int cw = c->width;
- ps->binding->draw_column_data (ps, ps->backbuf, it, GROUP_TITLE_HEIGHT > 0 ? group_it : NULL, cidx, group_y, x, y, cw, h);
+ ps->binding->draw_column_data (ps, ps->backbuf, it, ps->grouptitle_height > 0 ? group_it : NULL, cidx, group_y, x, y, cw, h);
x += cw;
}
}
@@ -2554,7 +2548,7 @@ ddb_listview_build_groups (DdbListview *listview) {
}
}
- GROUP_TITLE_HEIGHT = DEFAULT_GROUP_TITLE_HEIGHT;
+ listview->grouptitle_height = DEFAULT_GROUP_TITLE_HEIGHT;
DdbListviewIter it = listview->binding->head ();
while (it) {
int res = listview->binding->get_group (it, curr, sizeof (curr));
@@ -2565,21 +2559,21 @@ ddb_listview_build_groups (DdbListview *listview) {
grp->head = it;
listview->binding->ref (it);
grp->num_items = listview->binding->count ();
- GROUP_TITLE_HEIGHT = 0;
- grp->height = GROUP_TITLE_HEIGHT + grp->num_items * listview->rowheight;
+ listview->grouptitle_height = 0;
+ grp->height = listview->grouptitle_height + grp->num_items * listview->rowheight;
// if (grp->height < min_height) {
// grp->height = min_height;
// }
listview->fullheight = grp->height;
- listview->fullheight += GROUP_TITLE_HEIGHT;
+ listview->fullheight += listview->grouptitle_height;
return;
}
if (!grp || strcmp (str, curr)) {
strcpy (str, curr);
DdbListviewGroup *newgroup = malloc (sizeof (DdbListviewGroup));
if (grp) {
- if (grp->height - GROUP_TITLE_HEIGHT < min_height) {
- grp->height = min_height + GROUP_TITLE_HEIGHT;
+ if (grp->height - listview->grouptitle_height < min_height) {
+ grp->height = min_height + listview->grouptitle_height;
}
listview->fullheight += grp->height;
grp->next = newgroup;
@@ -2592,7 +2586,7 @@ ddb_listview_build_groups (DdbListview *listview) {
grp->head = it;
listview->binding->ref (it);
grp->num_items = 0;
- grp->height = GROUP_TITLE_HEIGHT;
+ grp->height = listview->grouptitle_height;
}
grp->height += listview->rowheight;
grp->num_items++;
@@ -2601,8 +2595,8 @@ ddb_listview_build_groups (DdbListview *listview) {
it = next;
}
if (grp) {
- if (grp->height - GROUP_TITLE_HEIGHT < min_height) {
- grp->height = min_height + GROUP_TITLE_HEIGHT;
+ if (grp->height - listview->grouptitle_height < min_height) {
+ grp->height = min_height + listview->grouptitle_height;
}
listview->fullheight += grp->height;
}
diff --git a/plugins/gtkui/ddblistview.h b/plugins/gtkui/ddblistview.h
index 2bd40b21..f87c4ba2 100644
--- a/plugins/gtkui/ddblistview.h
+++ b/plugins/gtkui/ddblistview.h
@@ -146,6 +146,7 @@ struct _DdbListview {
struct _DdbListviewGroup *groups;
int fullheight;
int block_redraw_on_scroll;
+ int grouptitle_height;
};
struct _DdbListviewClass {
diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c
index 2fea980f..a87322a2 100644
--- a/plugins/gtkui/gtkui.c
+++ b/plugins/gtkui/gtkui.c
@@ -428,7 +428,6 @@ static gboolean
trackinfochanged_cb (gpointer data) {
struct trackinfo_t *ti = (struct trackinfo_t *)data;
GtkWidget *playlist = lookup_widget (mainwin, "playlist");
-// gtkpl_redraw_pl_row (&main_playlist, ti->index, ti->track);
ddb_listview_draw_row (DDB_LISTVIEW (playlist), ti->index, (DdbListviewIter)ti->track);
if (ti->track == deadbeef->pl_getcurrent ()) {
current_track_changed (ti->track);
@@ -452,7 +451,6 @@ paused_cb (gpointer nothing) {
if (curr) {
int idx = deadbeef->pl_get_idx_of (curr);
GtkWidget *playlist = lookup_widget (mainwin, "playlist");
- //gtkpl_redraw_pl_row (&main_playlist, idx, curr);
ddb_listview_draw_row (DDB_LISTVIEW (playlist), idx, (DdbListviewIter)curr);
}
return FALSE;
@@ -599,55 +597,6 @@ on_add_location_activate (GtkMenuItem *menuitem,
}
gtk_widget_destroy (dlg);
}
-static int
-search_get_count (void) {
- return deadbeef->pl_getcount (PL_SEARCH);
-}
-
-void
-search_playlist_init (GtkWidget *widget) {
-#if 0
- extern GtkWidget *searchwin;
- // init playlist control structure, and put it into widget user-data
- memset (&search_playlist, 0, sizeof (search_playlist));
- search_playlist.title = "search";
- search_playlist.playlist = widget;
- search_playlist.header = lookup_widget (searchwin, "searchheader");
- search_playlist.scrollbar = lookup_widget (searchwin, "searchscroll");
- search_playlist.hscrollbar = lookup_widget (searchwin, "searchhscroll");
- assert (search_playlist.header);
- assert (search_playlist.scrollbar);
-// main_playlist.pcurr = &search_current;
-// search_playlist.pcount = &search_count;
- search_playlist.get_count = search_get_count;
-// search_playlist.multisel = 0;
- search_playlist.iterator = PL_SEARCH;
- search_playlist.scrollpos = 0;
- search_playlist.hscrollpos = 0;
-// search_playlist.row = -1;
- search_playlist.clicktime = -1;
- search_playlist.nvisiblerows = 0;
-
- // create default set of columns
- DB_conf_item_t *col = deadbeef->conf_find ("search.column.", NULL);
- if (!col) {
- gtkpl_column_append (&search_playlist, gtkpl_column_alloc ("Artist / Album", 150, DB_COLUMN_ARTIST_ALBUM, NULL, 0));
- gtkpl_column_append (&search_playlist, gtkpl_column_alloc ("Track №", 50, DB_COLUMN_TRACK, NULL, 1));
- gtkpl_column_append (&search_playlist, gtkpl_column_alloc ("Title / Track Artist", 150, DB_COLUMN_TITLE, NULL, 0));
- gtkpl_column_append (&search_playlist, gtkpl_column_alloc ("Duration", 50, DB_COLUMN_DURATION, NULL, 0));
- }
- else {
- while (col) {
- gtkpl_append_column_from_textdef (&search_playlist, col->value);
- col = deadbeef->conf_find ("search.column.", col);
- }
- }
- gtk_object_set_data (GTK_OBJECT (search_playlist.playlist), "ps", &search_playlist);
- gtk_object_set_data (GTK_OBJECT (search_playlist.header), "ps", &search_playlist);
- gtk_object_set_data (GTK_OBJECT (search_playlist.scrollbar), "ps", &search_playlist);
- gtk_object_set_data (GTK_OBJECT (search_playlist.hscrollbar), "ps", &search_playlist);
-#endif
-}
static void
songchanged (DdbListview *ps, int from, int to) {
diff --git a/plugins/gtkui/mainplaylist.c b/plugins/gtkui/mainplaylist.c
index 6c98238e..533546df 100644
--- a/plugins/gtkui/mainplaylist.c
+++ b/plugins/gtkui/mainplaylist.c
@@ -22,20 +22,22 @@
#include "gtkui.h"
#include "ddblistview.h"
#include "mainplaylist.h"
+#include "search.h"
#include "interface.h"
#include "support.h"
#include "drawing.h"
#include "trkproperties.h"
#include "coverart.h"
+#include "plcommon.h"
//#define trace(...) { fprintf(stderr, __VA_ARGS__); }
#define trace(fmt,...)
#define min(x,y) ((x)<(y)?(x):(y))
-static uintptr_t play16_pixbuf;
-static uintptr_t pause16_pixbuf;
-static uintptr_t buffering16_pixbuf;
+uintptr_t play16_pixbuf;
+uintptr_t pause16_pixbuf;
+uintptr_t buffering16_pixbuf;
// HACK!!
extern GtkWidget *theme_treeview;
@@ -80,7 +82,7 @@ static DdbListviewIter main_get_for_idx (int idx) {
return deadbeef->pl_get_for_idx_and_iter (idx, PL_MAIN);
}
-static int main_get_idx (DdbListviewIter it) {
+int main_get_idx (DdbListviewIter it) {
DB_playItem_t *c = deadbeef->pl_get_first (PL_MAIN);
int idx = 0;
while (c && c != it) {
@@ -118,254 +120,21 @@ playlist_tooltip_handler (GtkWidget *widget, gint x, gint y, gboolean keyboard_m
// columns
-typedef struct {
- int id;
- char *format;
-} col_info_t;
-
void
main_col_sort (int col, int sort_order, void *user_data) {
col_info_t *c = (col_info_t*)user_data;
deadbeef->pl_sort (PL_MAIN, c->id, c->format, sort_order-1);
}
-
-static DdbListview *last_playlist;
-static int active_column;
-
-void
-append_column_from_textdef (DdbListview *listview, const uint8_t *def) {
- // syntax: "title" "format" id width alignright
- char token[MAX_TOKEN];
- const char *p = def;
- char title[MAX_TOKEN];
- int id;
- char fmt[MAX_TOKEN];
- int width;
- int align;
-
- parser_init ();
-
- p = gettoken_warn_eof (p, token);
- if (!p) {
- return;
- }
- strcpy (title, token);
-
- p = gettoken_warn_eof (p, token);
- if (!p) {
- return;
- }
- strcpy (fmt, token);
-
- p = gettoken_warn_eof (p, token);
- if (!p) {
- return;
- }
- id = atoi (token);
-
- p = gettoken_warn_eof (p, token);
- if (!p) {
- return;
- }
- width = atoi (token);
-
- p = gettoken_warn_eof (p, token);
- if (!p) {
- return;
- }
- align = atoi (token);
-
- col_info_t *inf = malloc (sizeof (col_info_t));
- memset (inf, 0, sizeof (col_info_t));
- inf->format = strdup (fmt);
- inf->id = id;
- ddb_listview_column_append (listview, title, width, align, id == DB_COLUMN_ALBUM_ART ? width : 0, inf);
-}
-
-void
-on_add_column_activate (GtkMenuItem *menuitem,
- gpointer user_data)
-{
- GtkWidget *dlg = create_editcolumndlg ();
- gtk_window_set_title (GTK_WINDOW (dlg), "Add column");
- gtk_combo_box_set_active (GTK_COMBO_BOX (lookup_widget (dlg, "id")), 0);
- gtk_combo_box_set_active (GTK_COMBO_BOX (lookup_widget (dlg, "align")), 0);
- gint response = gtk_dialog_run (GTK_DIALOG (dlg));
- 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")));
- int align = gtk_combo_box_get_active (GTK_COMBO_BOX (lookup_widget (dlg, "align")));
- if (id >= DB_COLUMN_ID_MAX) {
- id = -1;
- }
- col_info_t *inf = malloc (sizeof (col_info_t));
- memset (inf, 0, sizeof (col_info_t));
- inf->format = strdup (format);
- inf->id = id;
- ddb_listview_column_insert (last_playlist, active_column, title, 100, align, id == DB_COLUMN_ALBUM_ART ? 100 : 0, inf);
- ddb_listview_refresh (last_playlist, DDB_REFRESH_COLUMNS | DDB_REFRESH_LIST | DDB_REFRESH_HSCROLL | DDB_EXPOSE_LIST | DDB_EXPOSE_COLUMNS);
- }
- gtk_widget_destroy (dlg);
-}
-
-
-void
-on_edit_column_activate (GtkMenuItem *menuitem,
- gpointer user_data)
-{
- if (active_column == -1)
- return;
- GtkWidget *dlg = create_editcolumndlg ();
- gtk_window_set_title (GTK_WINDOW (dlg), "Edit column");
-
- const char *title;
- int width;
- int align_right;
- col_info_t *inf;
- int minheight;
- int res = ddb_listview_column_get_info (last_playlist, active_column, &title, &width, &align_right, &minheight, (void **)&inf);
- if (res == -1) {
- trace ("attempted to edit non-existing column\n");
- return;
- }
-
- gtk_entry_set_text (GTK_ENTRY (lookup_widget (dlg, "title")), title);
- gtk_entry_set_text (GTK_ENTRY (lookup_widget (dlg, "format")), inf->format);
- if (inf->id == -1) {
- gtk_combo_box_set_active (GTK_COMBO_BOX (lookup_widget (dlg, "id")), DB_COLUMN_ID_MAX);
- }
- else {
- gtk_combo_box_set_active (GTK_COMBO_BOX (lookup_widget (dlg, "id")), inf->id);
- }
- gtk_combo_box_set_active (GTK_COMBO_BOX (lookup_widget (dlg, "align")), align_right);
- gint response = gtk_dialog_run (GTK_DIALOG (dlg));
- 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")));
- int align = gtk_combo_box_get_active (GTK_COMBO_BOX (lookup_widget (dlg, "align")));
- if (id >= DB_COLUMN_ID_MAX) {
- id = -1;
- }
- free (inf->format);
- inf->format = strdup (format);
- inf->id = id;
- ddb_listview_column_set_info (last_playlist, active_column, title, width, align, id == DB_COLUMN_ALBUM_ART ? width : 0, inf);
-
- ddb_listview_refresh (last_playlist, DDB_REFRESH_COLUMNS | DDB_REFRESH_LIST | DDB_EXPOSE_LIST | DDB_EXPOSE_COLUMNS);
- }
- gtk_widget_destroy (dlg);
-}
-
-
-void
-on_remove_column_activate (GtkMenuItem *menuitem,
- gpointer user_data)
-{
- if (active_column == -1)
- return;
-
- ddb_listview_column_remove (last_playlist, active_column);
- ddb_listview_refresh (last_playlist, DDB_REFRESH_COLUMNS | DDB_REFRESH_LIST | DDB_REFRESH_HSCROLL | DDB_EXPOSE_LIST | DDB_EXPOSE_COLUMNS);
-}
-
void main_handle_doubleclick (DdbListview *listview, DdbListviewIter iter, int idx) {
deadbeef->sendmessage (M_PLAYSONGNUM, 0, idx, 0);
}
void main_selection_changed (DdbListviewIter it, int idx) {
DdbListview *search = DDB_LISTVIEW (lookup_widget (searchwin, "searchlist"));
- ddb_listview_draw_row (search, idx, it);
-}
-
-#define ART_PADDING 10
-
-void main_draw_column_data (DdbListview *listview, GdkDrawable *drawable, DdbListviewIter it, DdbListviewIter group_it, int column, int group_y, int x, int y, int width, int height) {
- const char *ctitle;
- int cwidth;
- int calign_right;
- col_info_t *cinf;
- int minheight;
- int res = ddb_listview_column_get_info (listview, column, &ctitle, &cwidth, &calign_right, &minheight, (void **)&cinf);
- if (res == -1) {
- return;
- }
- if (cinf->id == DB_COLUMN_ALBUM_ART) {
- gtk_paint_flat_box (theme_treeview->style, drawable, GTK_STATE_NORMAL, GTK_SHADOW_NONE, NULL, theme_treeview, "cell_even_ruled", x, y, width, height);
- int art_width = width - ART_PADDING * 2;
- int art_y = y; // dest y
- int art_h = height;
- int sy; // source y
- if (group_y < ART_PADDING) {
- art_y = y - group_y + ART_PADDING;
- art_h = height - (art_y - y);
- sy = group_y;
- }
- else {
- sy = group_y - ART_PADDING;
- }
- if (art_width > 0) {
- if (group_it) {
- int h = cwidth - group_y;
- h = min (height, art_h);
-// gdk_draw_rectangle (drawable, GTK_WIDGET (listview)->style->white_gc, TRUE, x, y, width, h);
- const char *album = deadbeef->pl_find_meta (group_it, "album");
- const char *artist = deadbeef->pl_find_meta (group_it, "artist");
- GdkPixbuf *pixbuf = get_cover_art (((DB_playItem_t *)group_it)->fname, artist, album, art_width);
- if (pixbuf) {
- int pw = gdk_pixbuf_get_width (pixbuf);
- int ph = gdk_pixbuf_get_height (pixbuf);
- if (sy < ph)
- {
- pw = min (art_width, pw);
- ph -= sy;
- ph = min (ph, h);
- gdk_draw_pixbuf (drawable, GTK_WIDGET (listview)->style->white_gc, pixbuf, 0, sy, x + ART_PADDING, art_y, pw, ph, GDK_RGB_DITHER_NONE, 0, 0);
-// gdk_draw_rectangle (drawable, GTK_WIDGET (listview)->style->black_gc, FALSE, x + ART_PADDING, art_y, pw, ph);
- }
- }
- }
- }
- }
- else if (it && it == deadbeef->streamer_get_playing_track () && cinf->id == DB_COLUMN_PLAYING) {
- int paused = deadbeef->get_output ()->state () == OUTPUT_STATE_PAUSED;
- int buffering = !deadbeef->streamer_ok_to_read (-1);
- uintptr_t pixbuf;
- if (paused) {
- pixbuf = pause16_pixbuf;
- }
- else if (!buffering) {
- pixbuf = play16_pixbuf;
- }
- else {
- pixbuf = buffering16_pixbuf;
- }
- draw_pixbuf ((uintptr_t)drawable, pixbuf, x + cwidth/2 - 8, y + height/2 - 8, 0, 0, 16, 16);
- }
- else if (it) {
- char text[1024];
- deadbeef->pl_format_title (it, -1, text, sizeof (text), cinf->id, cinf->format);
- GdkColor *color = NULL;
- if (deadbeef->pl_is_selected (it)) {
- color = &theme_treeview->style->text[GTK_STATE_SELECTED];
- }
- else {
- color = &theme_treeview->style->text[GTK_STATE_NORMAL];
- }
- float fg[3] = {(float)color->red/0xffff, (float)color->green/0xffff, (float)color->blue/0xffff};
- draw_set_fg_color (fg);
-
- if (calign_right) {
- draw_text (x+5, y + height/2 - draw_get_font_size ()/2 - 2, cwidth-10, 1, text);
- }
- else {
- draw_text (x + 5, y + height/2 - draw_get_font_size ()/2 - 2, cwidth-10, 0, text);
- }
- }
+ ddb_listview_draw_row (search, search_get_idx ((DB_playItem_t *)it), it);
}
-static const char *group_by_str = "";
+const char *group_by_str = "";
void main_draw_group_title (DdbListview *listview, GdkDrawable *drawable, DdbListviewIter it, int x, int y, int width, int height) {
if (group_by_str && group_by_str[0]) {
@@ -376,266 +145,6 @@ void main_draw_group_title (DdbListview *listview, GdkDrawable *drawable, DdbLis
draw_text (x + 5, y + height/2 - draw_get_font_size ()/2 - 2, width-10, 0, str);
}
}
-
-void
-on_group_by_none_activate (GtkMenuItem *menuitem,
- gpointer user_data)
-{
- group_by_str = "";
- deadbeef->conf_set_str ("playlist.group_by", group_by_str);
- main_refresh ();
-}
-
-void
-on_group_by_artist_date_album_activate (GtkMenuItem *menuitem,
- gpointer user_data)
-{
- group_by_str = "%a - [%y] %b";
- deadbeef->conf_set_str ("playlist.group_by", group_by_str);
- main_refresh ();
-}
-
-void
-on_group_by_artist_activate (GtkMenuItem *menuitem,
- gpointer user_data)
-{
- group_by_str = "%a";
- deadbeef->conf_set_str ("playlist.group_by", group_by_str);
- main_refresh ();
-}
-
-GtkWidget*
-create_headermenu (void)
-{
- GtkWidget *headermenu;
- GtkWidget *add_column;
- GtkWidget *edit_column;
- GtkWidget *remove_column;
- GtkWidget *separator;
- GtkWidget *group_by;
- GtkWidget *group_by_menu;
- GtkWidget *none;
- GtkWidget *artist_date_album;
- GtkWidget *artist;
-
- headermenu = gtk_menu_new ();
-
- add_column = gtk_menu_item_new_with_mnemonic ("Add column");
- gtk_widget_show (add_column);
- gtk_container_add (GTK_CONTAINER (headermenu), add_column);
-
- edit_column = gtk_menu_item_new_with_mnemonic ("Edit column");
- gtk_widget_show (edit_column);
- gtk_container_add (GTK_CONTAINER (headermenu), edit_column);
-
- remove_column = gtk_menu_item_new_with_mnemonic ("Remove column");
- gtk_widget_show (remove_column);
- gtk_container_add (GTK_CONTAINER (headermenu), remove_column);
-
- separator = gtk_separator_menu_item_new ();
- gtk_widget_show (separator);
- gtk_container_add (GTK_CONTAINER (headermenu), separator);
- gtk_widget_set_sensitive (separator, FALSE);
-
- group_by = gtk_menu_item_new_with_mnemonic ("Group by");
- gtk_widget_show (group_by);
- gtk_container_add (GTK_CONTAINER (headermenu), group_by);
-
- group_by_menu = gtk_menu_new ();
- gtk_menu_item_set_submenu (GTK_MENU_ITEM (group_by), group_by_menu);
-
- none = gtk_menu_item_new_with_mnemonic ("None");
- gtk_widget_show (none);
- gtk_container_add (GTK_CONTAINER (group_by_menu), none);
-
- artist_date_album = gtk_menu_item_new_with_mnemonic ("Artist/Date/Album");
- gtk_widget_show (artist_date_album);
- gtk_container_add (GTK_CONTAINER (group_by_menu), artist_date_album);
-
- artist = gtk_menu_item_new_with_mnemonic ("Artist");
- gtk_widget_show (artist);
- gtk_container_add (GTK_CONTAINER (group_by_menu), artist);
-
- g_signal_connect ((gpointer) add_column, "activate",
- G_CALLBACK (on_add_column_activate),
- NULL);
- g_signal_connect ((gpointer) edit_column, "activate",
- G_CALLBACK (on_edit_column_activate),
- NULL);
- g_signal_connect ((gpointer) remove_column, "activate",
- G_CALLBACK (on_remove_column_activate),
- NULL);
-
- g_signal_connect ((gpointer) none, "activate",
- G_CALLBACK (on_group_by_none_activate),
- NULL);
-
- g_signal_connect ((gpointer) artist_date_album, "activate",
- G_CALLBACK (on_group_by_artist_date_album_activate),
- NULL);
-
- g_signal_connect ((gpointer) artist, "activate",
- G_CALLBACK (on_group_by_artist_activate),
- NULL);
-
- return headermenu;
-}
-
-void
-main_header_context_menu (DdbListview *ps, int column) {
- GtkWidget *menu = create_headermenu ();
- last_playlist = ps;
- active_column = column;
- gtk_menu_popup (GTK_MENU (menu), NULL, NULL, NULL, ps, 3, gtk_get_current_event_time());
-}
-
-void
-main_add_to_playback_queue_activate (GtkMenuItem *menuitem,
- gpointer user_data)
-{
- DdbListview *ps = DDB_LISTVIEW (gtk_object_get_data (GTK_OBJECT (menuitem), "ps"));
- DB_playItem_t *it = deadbeef->pl_get_first (PL_MAIN);
- while (it) {
- if (deadbeef->pl_is_selected (it)) {
- deadbeef->pl_playqueue_push (it);
- }
- DB_playItem_t *next = deadbeef->pl_get_next (it, PL_MAIN);
- deadbeef->pl_item_unref (it);
- it = next;
- }
- playlist_refresh ();
-}
-
-void
-main_remove_from_playback_queue_activate
- (GtkMenuItem *menuitem,
- gpointer user_data)
-{
- DdbListview *ps = DDB_LISTVIEW (gtk_object_get_data (GTK_OBJECT (menuitem), "ps"));
- DB_playItem_t *it = deadbeef->pl_get_first (PL_MAIN);
- while (it) {
- if (deadbeef->pl_is_selected (it)) {
- deadbeef->pl_playqueue_remove (it);
- }
- DB_playItem_t *next = deadbeef->pl_get_next (it, PL_MAIN);
- deadbeef->pl_item_unref (it);
- it = next;
- }
- playlist_refresh ();
-}
-
-void
-main_properties_activate (GtkMenuItem *menuitem,
- gpointer user_data)
-{
- DB_playItem_t *it = deadbeef->pl_get_for_idx_and_iter (deadbeef->pl_get_cursor (PL_MAIN), PL_MAIN);
- if (!it) {
- fprintf (stderr, "attempt to view properties of non-existing item\n");
- return;
- }
- show_track_properties_dlg (it);
-}
-
-// FIXME: wrong place for these functions
-void
-on_clear1_activate (GtkMenuItem *menuitem,
- gpointer user_data)
-{
- deadbeef->pl_clear ();
- main_refresh ();
- search_refresh ();
-}
-
-void
-on_remove1_activate (GtkMenuItem *menuitem,
- gpointer user_data)
-{
- int cursor = deadbeef->pl_delete_selected ();
- main_refresh ();
- search_refresh ();
-}
-
-
-void
-on_crop1_activate (GtkMenuItem *menuitem,
- gpointer user_data)
-{
- DdbListview *pl = DDB_LISTVIEW (lookup_widget (mainwin, "playlist"));
- deadbeef->pl_crop_selected ();
- main_refresh ();
- search_refresh ();
-}
-
-void
-on_remove2_activate (GtkMenuItem *menuitem,
- gpointer user_data)
-{
- GtkWidget *widget = GTK_WIDGET (menuitem);
- int cursor = deadbeef->pl_delete_selected ();
- main_refresh ();
- search_refresh ();
-}
-
-void
-main_list_context_menu (DdbListview *listview, DdbListviewIter it, int idx) {
- int inqueue = deadbeef->pl_playqueue_test (it);
- GtkWidget *playlist_menu;
- GtkWidget *add_to_playback_queue1;
- GtkWidget *remove_from_playback_queue1;
- GtkWidget *separator9;
- GtkWidget *remove2;
- GtkWidget *separator8;
- GtkWidget *properties1;
-
- playlist_menu = gtk_menu_new ();
- add_to_playback_queue1 = gtk_menu_item_new_with_mnemonic ("Add to playback queue");
- gtk_widget_show (add_to_playback_queue1);
- gtk_container_add (GTK_CONTAINER (playlist_menu), add_to_playback_queue1);
- gtk_object_set_data (GTK_OBJECT (add_to_playback_queue1), "ps", listview);
-
- remove_from_playback_queue1 = gtk_menu_item_new_with_mnemonic ("Remove from playback queue");
- if (inqueue == -1) {
- gtk_widget_set_sensitive (remove_from_playback_queue1, FALSE);
- }
- gtk_widget_show (remove_from_playback_queue1);
- gtk_container_add (GTK_CONTAINER (playlist_menu), remove_from_playback_queue1);
- gtk_object_set_data (GTK_OBJECT (remove_from_playback_queue1), "ps", listview);
-
- separator9 = gtk_separator_menu_item_new ();
- gtk_widget_show (separator9);
- gtk_container_add (GTK_CONTAINER (playlist_menu), separator9);
- gtk_widget_set_sensitive (separator9, FALSE);
-
- remove2 = gtk_menu_item_new_with_mnemonic ("Remove");
- gtk_widget_show (remove2);
- gtk_container_add (GTK_CONTAINER (playlist_menu), remove2);
- gtk_object_set_data (GTK_OBJECT (remove2), "ps", listview);
-
- separator8 = gtk_separator_menu_item_new ();
- gtk_widget_show (separator8);
- gtk_container_add (GTK_CONTAINER (playlist_menu), separator8);
- gtk_widget_set_sensitive (separator8, FALSE);
-
- properties1 = gtk_menu_item_new_with_mnemonic ("Properties");
- gtk_widget_show (properties1);
- gtk_container_add (GTK_CONTAINER (playlist_menu), properties1);
- gtk_object_set_data (GTK_OBJECT (properties1), "ps", listview);
-
- g_signal_connect ((gpointer) add_to_playback_queue1, "activate",
- G_CALLBACK (main_add_to_playback_queue_activate),
- NULL);
- g_signal_connect ((gpointer) remove_from_playback_queue1, "activate",
- G_CALLBACK (main_remove_from_playback_queue_activate),
- NULL);
- g_signal_connect ((gpointer) remove2, "activate",
- G_CALLBACK (on_remove2_activate),
- NULL);
- g_signal_connect ((gpointer) properties1, "activate",
- G_CALLBACK (main_properties_activate),
- NULL);
- gtk_menu_popup (GTK_MENU (playlist_menu), NULL, NULL, NULL, listview, 0, gtk_get_current_event_time());
-}
-
void
main_delete_selected (void) {
deadbeef->pl_delete_selected ();
@@ -662,34 +171,7 @@ main_get_group (DdbListviewIter it, char *str, int size) {
return 0;
}
-void
-write_column_config (const char *name, int idx, const char *title, int width, int align_right, int id, const char *format) {
- char key[128];
- char value[128];
- snprintf (key, sizeof (key), "%s.column.%d", name, idx);
- snprintf (value, sizeof (value), "\"%s\" \"%s\" %d %d %d", title, format ? format : "", id, width, align_right);
- deadbeef->conf_set_str (key, value);
-}
-
-void
-rewrite_column_config (DdbListview *listview, const char *name) {
- char key[128];
- snprintf (key, sizeof (key), "%s.column.", name);
- deadbeef->conf_remove_items (key);
-
- int cnt = ddb_listview_column_get_count (listview);
- for (int i = 0; i < cnt; i++) {
- const char *title;
- int width;
- int align_right;
- col_info_t *info;
- int minheight;
- ddb_listview_column_get_info (listview, i, &title, &width, &align_right, &minheight, (void **)&info);
- write_column_config (name, i, title, width, align_right, info->id, info->format);
- }
-}
-
-int lock_column_config = 0;
+static int lock_column_config = 0;
void
main_columns_changed (DdbListview *listview) {
@@ -744,7 +226,7 @@ DdbListviewBinding main_binding = {
.drag_n_drop = main_drag_n_drop,
.external_drag_n_drop = main_external_drag_n_drop,
- .draw_column_data = main_draw_column_data,
+ .draw_column_data = draw_column_data,
.draw_group_title = main_draw_group_title,
// columns
@@ -756,24 +238,12 @@ DdbListviewBinding main_binding = {
// callbacks
.handle_doubleclick = main_handle_doubleclick,
.selection_changed = main_selection_changed,
- .header_context_menu = main_header_context_menu,
- .list_context_menu = main_list_context_menu,
+ .header_context_menu = header_context_menu,
+ .list_context_menu = list_context_menu,
.delete_selected = main_delete_selected,
};
void
-add_column_helper (DdbListview *listview, const char *title, int width, int id, const char *format, int align_right) {
- if (!format) {
- format = "";
- }
- col_info_t *inf = malloc (sizeof (col_info_t));
- memset (inf, 0, sizeof (col_info_t));
- inf->id = id;
- inf->format = strdup (format);
- ddb_listview_column_append (listview, title, width, align_right, id == DB_COLUMN_ALBUM_ART ? width : 0, inf);
-}
-
-void
main_playlist_init (GtkWidget *widget) {
play16_pixbuf = draw_load_pixbuf ("play_16.png");
pause16_pixbuf = draw_load_pixbuf ("pause_16.png");
diff --git a/plugins/gtkui/mainplaylist.h b/plugins/gtkui/mainplaylist.h
index 306c3db3..af266c4a 100644
--- a/plugins/gtkui/mainplaylist.h
+++ b/plugins/gtkui/mainplaylist.h
@@ -28,4 +28,7 @@ main_playlist_free (void);
void
main_refresh (void);
+int
+main_get_idx (DdbListviewIter it);
+
#endif
diff --git a/plugins/gtkui/search.c b/plugins/gtkui/search.c
index 026a3c61..bde3aba7 100644
--- a/plugins/gtkui/search.c
+++ b/plugins/gtkui/search.c
@@ -31,7 +31,9 @@
#include "search.h"
#include "ddblistview.h"
+#include "plcommon.h"
#include "../../deadbeef.h"
+#include "mainplaylist.h"
#define min(x,y) ((x)<(y)?(x):(y))
#define max(x,y) ((x)>(y)?(x):(y))
@@ -103,7 +105,7 @@ on_searchentry_changed (GtkEditable *editable,
void
search_refresh (void) {
if (searchwin && GTK_WIDGET_VISIBLE (searchwin)) {
- GtkWidget *pl = lookup_widget (mainwin, "searchlist");
+ GtkWidget *pl = lookup_widget (searchwin, "searchlist");
ddb_listview_refresh (DDB_LISTVIEW (pl), DDB_REFRESH_VSCROLL | DDB_REFRESH_LIST | DDB_EXPOSE_LIST);
}
}
@@ -180,7 +182,7 @@ on_searchwin_key_press_event (GtkWidget *widget,
}
}
else if (event->keyval != GDK_Delete && event->keyval != GDK_Home && event->keyval != GDK_End){
- GtkWidget *pl = lookup_widget (mainwin, "searchlist");
+ GtkWidget *pl = lookup_widget (searchwin, "searchlist");
if (!ddb_listview_handle_keypress (DDB_LISTVIEW (pl), event->keyval, event->state)) {
return FALSE;
}
@@ -259,3 +261,241 @@ on_searchwin_window_state_event (GtkWidget *widget,
return FALSE;
}
+static int
+search_get_count (void) {
+ return deadbeef->pl_getcount (PL_SEARCH);
+}
+
+static int
+search_get_sel_count (void) {
+ int cnt = 0;
+ DB_playItem_t *it = deadbeef->pl_get_first (PL_SEARCH);
+ while (it) {
+ if (deadbeef->pl_is_selected (it)) {
+ cnt++;
+ }
+ DB_playItem_t *next = deadbeef->pl_get_next (it, PL_SEARCH);
+ deadbeef->pl_item_unref (it);
+ it = next;
+ }
+ return cnt;
+}
+
+static int
+search_get_cursor (void) {
+ return deadbeef->pl_get_cursor (PL_SEARCH);
+}
+
+static void
+search_set_cursor (int cursor) {
+ return deadbeef->pl_set_cursor (PL_SEARCH, cursor);
+}
+
+static DdbListviewIter search_head (void) {
+ return (DdbListviewIter)deadbeef->pl_get_first (PL_SEARCH);
+}
+
+static DdbListviewIter search_tail (void) {
+ return (DdbListviewIter)deadbeef->pl_get_last(PL_SEARCH);
+}
+
+static DdbListviewIter search_next (DdbListviewIter it) {
+ return (DdbListviewIter)deadbeef->pl_get_next(it, PL_SEARCH);
+}
+
+static DdbListviewIter search_prev (DdbListviewIter it) {
+ return (DdbListviewIter)deadbeef->pl_get_prev(it, PL_SEARCH);
+}
+
+static DdbListviewIter search_get_for_idx (int idx) {
+ return deadbeef->pl_get_for_idx_and_iter (idx, PL_SEARCH);
+}
+
+int search_get_idx (DdbListviewIter it) {
+ DB_playItem_t *c = deadbeef->pl_get_first (PL_SEARCH);
+ int idx = 0;
+ while (c && c != it) {
+ DB_playItem_t *next = deadbeef->pl_get_next (c, PL_SEARCH);
+ deadbeef->pl_item_unref (c);
+ c = next;
+ idx++;
+ }
+ if (!c) {
+ return -1;
+ }
+ deadbeef->pl_item_unref (c);
+ return idx;
+}
+
+int
+search_is_selected (DdbListviewIter it) {
+ return deadbeef->pl_is_selected ((DB_playItem_t *)it);
+}
+
+void
+search_select (DdbListviewIter it, int sel) {
+ deadbeef->pl_set_selected ((DB_playItem_t *)it, sel);
+}
+
+int
+search_get_group (DdbListviewIter it, char *str, int size) {
+ return -1;
+}
+
+void
+search_col_sort (int col, int sort_order, void *user_data) {
+ col_info_t *c = (col_info_t*)user_data;
+ deadbeef->pl_sort (PL_SEARCH, c->id, c->format, sort_order-1);
+}
+
+static int lock_column_config = 0;
+
+void
+search_columns_changed (DdbListview *listview) {
+ if (!lock_column_config) {
+ rewrite_column_config (listview, "search");
+ }
+}
+
+void
+search_column_size_changed (DdbListview *listview, int col) {
+ const char *title;
+ int width;
+ int align_right;
+ col_info_t *inf;
+ int minheight;
+ int res = ddb_listview_column_get_info (listview, col, &title, &width, &align_right, &minheight, (void **)&inf);
+ if (res == -1) {
+ return;
+ }
+}
+
+void search_col_free_user_data (void *data) {
+ if (data) {
+ free (data);
+ }
+}
+
+void search_handle_doubleclick (DdbListview *listview, DdbListviewIter iter, int idx) {
+ deadbeef->sendmessage (M_PLAYSONGNUM, 0, deadbeef->pl_get_idx_of ((DB_playItem_t *)iter), 0);
+}
+
+void search_selection_changed (DdbListviewIter it, int idx) {
+ DdbListview *main = DDB_LISTVIEW (lookup_widget (searchwin, "playlist"));
+ ddb_listview_draw_row (main, main_get_idx ((DB_playItem_t *)it), it);
+}
+
+void
+search_delete_selected (void) {
+ deadbeef->pl_delete_selected ();
+ main_refresh ();
+ search_refresh ();
+}
+
+DdbListviewBinding search_binding = {
+ // rows
+ .count = search_get_count,
+ .sel_count = search_get_sel_count,
+
+ .cursor = search_get_cursor,
+ .set_cursor = search_set_cursor,
+
+ .head = search_head,
+ .tail = search_tail,
+ .next = search_next,
+ .prev = search_prev,
+
+ .get_for_idx = search_get_for_idx,
+ .get_idx = search_get_idx,
+
+ .is_selected = search_is_selected,
+ .select = search_select,
+
+ .get_group = search_get_group,
+
+ .drag_n_drop = NULL,
+ .external_drag_n_drop = NULL,
+
+ .draw_column_data = draw_column_data,
+ .draw_group_title = NULL,
+
+ // columns
+ .col_sort = search_col_sort,
+ .columns_changed = search_columns_changed,
+ .column_size_changed = search_column_size_changed,
+ .col_free_user_data = search_col_free_user_data,
+
+ // callbacks
+ .handle_doubleclick = search_handle_doubleclick,
+ .selection_changed = search_selection_changed,
+ .header_context_menu = header_context_menu,
+ .list_context_menu = list_context_menu,
+ .delete_selected = search_delete_selected,
+};
+
+void
+search_playlist_init (GtkWidget *widget) {
+ DdbListview *listview = DDB_LISTVIEW(widget);
+ search_binding.ref = (void (*) (DdbListviewIter))deadbeef->pl_item_ref;
+ search_binding.unref = (void (*) (DdbListviewIter))deadbeef->pl_item_unref;
+ search_binding.is_selected = (int (*) (DdbListviewIter))deadbeef->pl_is_selected;
+ ddb_listview_set_binding (listview, &search_binding);
+ lock_column_config = 1;
+ // create default set of columns
+ DB_conf_item_t *col = deadbeef->conf_find ("search.column.", NULL);
+ if (!col) {
+ add_column_helper (listview, "Artist / Album", 150, DB_COLUMN_ARTIST_ALBUM, NULL, 0);
+ add_column_helper (listview, "Track №", 50, DB_COLUMN_TRACK, NULL, 1);
+ add_column_helper (listview, "Title / Track Artist", 150, DB_COLUMN_TITLE, NULL, 0);
+ add_column_helper (listview, "Duration", 50, DB_COLUMN_DURATION, NULL, 0);
+ }
+ else {
+ while (col) {
+ append_column_from_textdef (listview, col->value);
+ col = deadbeef->conf_find ("search.column.", col);
+ }
+ }
+ lock_column_config = 0;
+#if 0
+ extern GtkWidget *searchwin;
+ // init playlist control structure, and put it into widget user-data
+ memset (&search_playlist, 0, sizeof (search_playlist));
+ search_playlist.title = "search";
+ search_playlist.playlist = widget;
+ search_playlist.header = lookup_widget (searchwin, "searchheader");
+ search_playlist.scrollbar = lookup_widget (searchwin, "searchscroll");
+ search_playlist.hscrollbar = lookup_widget (searchwin, "searchhscroll");
+ assert (search_playlist.header);
+ assert (search_playlist.scrollbar);
+// search_playlist.pcurr = &search_current;
+// search_playlist.pcount = &search_count;
+ search_playlist.get_count = search_get_count;
+// search_playlist.multisel = 0;
+ search_playlist.iterator = PL_SEARCH;
+ search_playlist.scrollpos = 0;
+ search_playlist.hscrollpos = 0;
+// search_playlist.row = -1;
+ search_playlist.clicktime = -1;
+ search_playlist.nvisiblerows = 0;
+
+ // create default set of columns
+ DB_conf_item_t *col = deadbeef->conf_find ("search.column.", NULL);
+ if (!col) {
+ gtkpl_column_append (&search_playlist, gtkpl_column_alloc ("Artist / Album", 150, DB_COLUMN_ARTIST_ALBUM, NULL, 0));
+ gtkpl_column_append (&search_playlist, gtkpl_column_alloc ("Track №", 50, DB_COLUMN_TRACK, NULL, 1));
+ gtkpl_column_append (&search_playlist, gtkpl_column_alloc ("Title / Track Artist", 150, DB_COLUMN_TITLE, NULL, 0));
+ gtkpl_column_append (&search_playlist, gtkpl_column_alloc ("Duration", 50, DB_COLUMN_DURATION, NULL, 0));
+ }
+ else {
+ while (col) {
+ gtkpl_append_column_from_textdef (&search_playlist, col->value);
+ col = deadbeef->conf_find ("search.column.", col);
+ }
+ }
+ gtk_object_set_data (GTK_OBJECT (search_playlist.playlist), "ps", &search_playlist);
+ gtk_object_set_data (GTK_OBJECT (search_playlist.header), "ps", &search_playlist);
+ gtk_object_set_data (GTK_OBJECT (search_playlist.scrollbar), "ps", &search_playlist);
+ gtk_object_set_data (GTK_OBJECT (search_playlist.hscrollbar), "ps", &search_playlist);
+#endif
+}
+
diff --git a/plugins/gtkui/search.h b/plugins/gtkui/search.h
index 94ead63f..7e34d4db 100644
--- a/plugins/gtkui/search.h
+++ b/plugins/gtkui/search.h
@@ -18,6 +18,8 @@
#ifndef __SEARCH_H
#define __SEARCH_H
+#include "ddblistview.h"
+
extern struct playItem_s *search_current;
extern int search_count;
@@ -31,4 +33,10 @@ search_refresh (void);
void
search_restore_attrs (void);
+int
+search_get_idx (DdbListviewIter it);
+
+void
+search_playlist_init (GtkWidget *widget);
+
#endif // __SEARCH_H