summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2009-08-09 22:09:05 +0200
committerGravatar waker <wakeroid@gmail.com>2009-08-09 22:09:05 +0200
commitcdaa84065ba42c730991c22893ddc8c0d9ce7107 (patch)
treef3ab367fe33080661de87f31c2bf56ad57d112a2
parent53f8dec0b5a74ac8e2bec719cf34bc9ddaf21e75 (diff)
playlist save/load (+autosave/autoload of default playlist)
-rw-r--r--gtkplaylist.c45
-rw-r--r--main.c20
2 files changed, 21 insertions, 44 deletions
diff --git a/gtkplaylist.c b/gtkplaylist.c
index 63eb0306..cc8e56b8 100644
--- a/gtkplaylist.c
+++ b/gtkplaylist.c
@@ -685,31 +685,6 @@ gtkpl_scroll (gtkplaylist_t *ps, int newscroll) {
}
}
-#if 0
-void
-gtkpl_prevsong (void) {
- GtkWidget *widget = ps->playlist;
- playItem_t *prev = playlist_current_ptr;
-
- if (playlist_current_ptr) {
- printf ("gtkpl_prevsong\n");
- pl_set_current (playlist_current_ptr->prev);
- }
- if (!playlist_current_ptr) {
- printf ("gtkpl_prevsong2\n");
- pl_set_current (playlist_tail);
- }
- if (playlist_current_ptr != prev) {
- if (prev) {
- gtkpl_redraw_pl_row (widget, gtkpl_get_idx_of (ps, prev));
- }
- if (playlist_current_ptr) {
- gtkpl_redraw_pl_row (widget, gtkpl_get_idx_of (ps, playlist_current_ptr));
- }
- }
-}
-#endif
-
void
gtkpl_randomsong (void) {
p_stop ();
@@ -720,24 +695,6 @@ void
gtkpl_playsongnum (int idx) {
p_stop ();
streamer_set_nextsong (idx, 1);
-#if 0
- playItem_t *it = gtkpl_get_for_idx (ps, ps->row);
- if (it) {
- //if (it != playlist_current_ptr)
- {
- GtkWidget *widget = ps->playlist;
- int prev = -1;
- if (playlist_current_ptr) {
- prev = gtkpl_get_idx_of (ps, playlist_current_ptr);
- }
- pl_set_current (it);
- if (prev != -1) {
- gtkpl_redraw_pl_row (widget, prev);
- }
- gtkpl_redraw_pl_row (widget, idx);
- }
- }
-#endif
}
void
@@ -939,7 +896,7 @@ gtkpl_handle_drag_drop (gtkplaylist_t *ps, int drop_y, uint32_t *d, int length)
// printf ("idx: %d\n", d[i]);
next = it->next[ps->iterator];
if (idx == d[processed]) {
- if (it->prev) {
+ if (it->prev[ps->iterator]) {
it->prev[ps->iterator]->next[ps->iterator] = it->next[ps->iterator];
}
else {
diff --git a/main.c b/main.c
index e982a2ab..45a5ab03 100644
--- a/main.c
+++ b/main.c
@@ -19,6 +19,9 @@
#include <stdio.h>
#include <stdint.h>
#include <string.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <sys/types.h>
#include "interface.h"
#include "support.h"
#include "playlist.h"
@@ -203,6 +206,20 @@ psdl_thread (uintptr_t ctx) {
int
main (int argc, char *argv[]) {
+ char *homedir = getenv ("HOME");
+ if (!homedir) {
+ fprintf (stderr, "unable to find home directory. stopping.\n");
+ return -1;
+ }
+ char defpl[1024];
+ snprintf (defpl, 1024, "%s/.config/deadbeef/default.dbpl", homedir);
+ char confdir[1024];
+ snprintf (confdir, 1024, "%s/.config", homedir);
+ mkdir (confdir, 0755);
+ char dbconfdir[1024];
+ snprintf (dbconfdir, 1024, "%s/.config/deadbeef", homedir);
+ mkdir (dbconfdir, 0755);
+
messagepump_init ();
codec_init_locking ();
streamer_init ();
@@ -215,6 +232,7 @@ main (int argc, char *argv[]) {
gtk_set_locale ();
gtk_init (&argc, &argv);
+ pl_load (defpl);
mainwin = create_mainwin ();
gtk_widget_show (mainwin);
gtk_main ();
@@ -224,6 +242,8 @@ main (int argc, char *argv[]) {
p_free ();
streamer_free ();
codec_free_locking ();
+
+ pl_save (defpl);
pl_free ();
return 0;
}