diff options
author | waker <wakeroid@gmail.com> | 2009-08-23 18:52:45 +0200 |
---|---|---|
committer | waker <wakeroid@gmail.com> | 2009-08-23 18:52:45 +0200 |
commit | 0362134c01113aecff6936e1125bafdbaf6378a9 (patch) | |
tree | 92f1aa74f73dce1f23c6e52a57c775598a79e217 | |
parent | 16b01f9f0da4263e20c2944490b77005e0a0ce1d (diff) |
updated session to store playback order and looping mode
-rw-r--r-- | callbacks.c | 6 | ||||
-rw-r--r-- | deadbeef.glade | 1 | ||||
-rw-r--r-- | main.c | 18 | ||||
-rw-r--r-- | session.c | 41 | ||||
-rw-r--r-- | session.h | 12 |
5 files changed, 78 insertions, 0 deletions
diff --git a/callbacks.c b/callbacks.c index 3bc07513..81906ec3 100644 --- a/callbacks.c +++ b/callbacks.c @@ -693,6 +693,7 @@ void on_order_linear_activate (GtkMenuItem *menuitem, gpointer user_data) { + session_set_playlist_order (0); pl_set_order (0); } @@ -701,6 +702,7 @@ void on_order_shuffle_activate (GtkMenuItem *menuitem, gpointer user_data) { + session_set_playlist_order (1); pl_set_order (1); } @@ -709,6 +711,7 @@ void on_order_random_activate (GtkMenuItem *menuitem, gpointer user_data) { + session_set_playlist_order (2); pl_set_order (2); } @@ -717,6 +720,7 @@ void on_loop_all_activate (GtkMenuItem *menuitem, gpointer user_data) { + session_set_playlist_looping (0); pl_set_loop_mode (0); } @@ -725,6 +729,7 @@ void on_loop_single_activate (GtkMenuItem *menuitem, gpointer user_data) { + session_set_playlist_looping (2); pl_set_loop_mode (2); } @@ -733,6 +738,7 @@ void on_loop_disable_activate (GtkMenuItem *menuitem, gpointer user_data) { + session_set_playlist_looping (1); pl_set_loop_mode (1); } diff --git a/deadbeef.glade b/deadbeef.glade index ae43df5f..ad3f85c0 100644 --- a/deadbeef.glade +++ b/deadbeef.glade @@ -14,6 +14,7 @@ <property name="default_height">300</property> <property name="resizable">True</property> <property name="destroy_with_parent">False</property> + <property name="icon">play_24.png</property> <property name="icon_name"></property> <property name="decorated">True</property> <property name="skip_taskbar_hint">False</property> @@ -606,8 +606,26 @@ main (int argc, char *argv[]) { gtkpl_init (); mainwin = create_mainwin (); + GdkPixbuf *mainwin_icon_pixbuf; + mainwin_icon_pixbuf = create_pixbuf ("play_24.png"); + if (mainwin_icon_pixbuf) + { + gtk_window_set_icon (GTK_WINDOW (mainwin), mainwin_icon_pixbuf); + gdk_pixbuf_unref (mainwin_icon_pixbuf); + } session_restore_window_attrs ((uintptr_t)mainwin); volume_set_db (session_get_volume ()); + // order and looping + 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[session_get_playlist_order ()]; + printf ("%s\n", w); + gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (lookup_widget (mainwin, w)), TRUE); + w = loopingwidgets[session_get_playlist_looping ()]; + printf ("%s\n", w); + gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (lookup_widget (mainwin, w)), TRUE); + searchwin = create_searchwin (); gtk_window_set_transient_for (GTK_WINDOW (searchwin), GTK_WINDOW (mainwin)); extern void main_playlist_init (GtkWidget *widget); @@ -24,6 +24,8 @@ char session_dir[2048]; float session_volume; +int session_playlist_order; +int session_playlist_looping; int session_win_attrs[5] = { 40, 40, 500, 300, 0 }; static uint8_t sessfile_magic[] = { 0xdb, 0xef, 0x5e, 0x55 }; // dbefsess in hexspeak @@ -107,6 +109,8 @@ void session_reset (void) { session_volume = 0; session_dir[0] = 0; + session_playlist_looping = 0; + session_playlist_order = 0; session_win_attrs[0] = 40; session_win_attrs[1] = 40; session_win_attrs[2] = 500; @@ -139,6 +143,12 @@ session_save (const char *fname) { if (write_i32_be (*((uint32_t*)&session_volume), fp) != 4) { goto session_save_fail; } + if (write_i32_be (session_playlist_order, fp) != 4) { + goto session_save_fail; + } + if (write_i32_be (session_playlist_looping, fp) != 4) { + goto session_save_fail; + } for (int k = 0; k < 5; k++) { if (write_i32_be (session_win_attrs[k], fp) != 4) { goto session_save_fail; @@ -187,6 +197,18 @@ session_load (const char *fname) { if (read_i32_be ((uint32_t*)&session_volume, fp) != 4) { goto session_load_fail; } + if (read_i32_be (&session_playlist_order, fp) != 4) { + goto session_load_fail; + } + if (session_playlist_order < 0 || session_playlist_order > 2) { + goto session_load_fail; + } + if (read_i32_be (&session_playlist_looping, fp) != 4) { + goto session_load_fail; + } + if (session_playlist_looping < 0 || session_playlist_looping > 2) { + goto session_load_fail; + } for (int k = 0; k < 5; k++) { if (read_i32_be (&session_win_attrs[k], fp) != 4) { goto session_load_fail; @@ -224,3 +246,22 @@ session_get_volume (void) { return session_volume; } +void +session_set_playlist_order (int order) { + session_playlist_order = order; +} + +int +session_get_playlist_order (void) { + return session_playlist_order; +} + +void +session_set_playlist_looping (int looping) { + session_playlist_looping = looping; +} + +int +session_get_playlist_looping (void) { + return session_playlist_looping; +} @@ -45,4 +45,16 @@ session_get_directory (void); float session_get_volume (void); +void +session_set_playlist_order (int order); + +int +session_get_playlist_order (void); + +void +session_set_playlist_looping (int looping); + +int +session_get_playlist_looping (void); + #endif // __SESSION_H |