patch to append files to playlist

Chris Hellberg <[email protected]>
Newsgroups gmane.comp.multimedia.xmms.devel
Message-ID <[email protected]>
Hi,

Below is a quick patch against 1.2.10 to add a new
option to the options menu to allow new files to be
enqueued rather than played. I know there is an
enqueue option that can be specified on the cmd line,
but I think this way is useful as well since if you
call xmms from a browser/other application, you don't
have to specify any cmd switches (if it's even
possible).

The only problem I have with it is, and I can't figure
out why, is that this option doesn't seem to work for
a session where this is first used, i.e. you have to
set the option, then reload xmms so the config is
reread with the option set. Then it works fine from
then on.

Review please?

diff -urN xmms-1.2.10-orig/xmms/main.c
xmms-1.2.10/xmms/main.c
--- xmms-1.2.10-orig/xmms/main.c        Thu Dec  2
09:39:24 2004
+++ xmms-1.2.10/xmms/main.c     Thu Dec  2 09:47:04
2004
@@ -92,6 +92,7 @@

 extern gchar *plugin_dir_list[];

+
 enum
 {
        VOLSET_STARTUP, VOLSET_UPDATE,
VOLUME_ADJUSTED, VOLUME_SET
@@ -116,7 +117,8 @@
        MAINWIN_OPT_REPEAT, MAINWIN_OPT_SHUFFLE,
MAINWIN_OPT_NPA,
        MAINWIN_OPT_TELAPSED, MAINWIN_OPT_TREMAINING,
MAINWIN_OPT_ALWAYS,
        MAINWIN_OPT_STICKY, MAINWIN_OPT_WS,
MAINWIN_OPT_PWS,
-       MAINWIN_OPT_EQWS, MAINWIN_OPT_DOUBLESIZE,
MAINWIN_OPT_EASY_MOVE
+       MAINWIN_OPT_EQWS, MAINWIN_OPT_DOUBLESIZE,
MAINWIN_OPT_EASY_MOVE,
+       MAINWIN_OPT_ATP
 };

 GtkItemFactoryEntry mainwin_options_menu_entries[] =
@@ -128,6 +130,7 @@
        {N_("/Repeat"), "R",
mainwin_options_menu_callback, MAINWIN_OPT_REPEAT,
"<ToggleItem>"},
        {N_("/Shuffle"), "S",
mainwin_options_menu_callback, MAINWIN_OPT_SHUFFLE,
"<ToggleItem>"},
        {N_("/No Playlist Advance"), "<control>N",
mainwin_options_menu_callback, MAINWIN_OPT_NPA,
"<ToggleItem>"},
+       {N_("/Append to playlist"), "<control>T",
mainwin_options_menu_callback, MAINWIN_OPT_ATP,
"<ToggleItem>"},
        {N_("/-"), NULL, NULL, 0, "<Separator>"},
        {N_("/Time Elapsed"), "<control>E",
mainwin_options_menu_callback, MAINWIN_OPT_TELAPSED,
"<RadioItem>"},
        {N_("/Time Remaining"), "<control>R",
mainwin_options_menu_callback, MAINWIN_OPT_TREMAINING,
"/Time Elapsed"},
@@ -341,6 +344,7 @@
        cfg.eq_doublesize_linked = TRUE;
        cfg.player_visible = TRUE;
        cfg.no_playlist_advance = FALSE;
+       cfg.append_to_playlist = FALSE;
        cfg.smooth_title_scroll = TRUE;
        cfg.random_skin_on_play = FALSE;
        cfg.mainwin_use_xfont = FALSE;
@@ -393,6 +397,7 @@
                xmms_cfg_read_boolean(cfgfile, "xmms",
"get_info_on_demand", &cfg.get_info_on_demand);
                xmms_cfg_read_boolean(cfgfile, "xmms",
"eq_doublesize_linked", &cfg.eq_doublesize_linked);
                xmms_cfg_read_boolean(cfgfile, "xmms",
"no_playlist_advance", &cfg.no_playlist_advance);
+               xmms_cfg_read_boolean(cfgfile, "xmms",
"append_to_playlist", &cfg.append_to_playlist);
                xmms_cfg_read_boolean(cfgfile, "xmms",
"sort_jump_to_file", &cfg.sort_jump_to_file);
                xmms_cfg_read_boolean(cfgfile, "xmms",
"use_pl_metadata", &cfg.use_pl_metadata);
                xmms_cfg_read_boolean(cfgfile, "xmms",
"smooth_title_scroll", &cfg.smooth_title_scroll);
@@ -558,6 +563,7 @@
        xmms_cfg_write_boolean(cfgfile, "xmms",
"get_info_on_demand", cfg.get_info_on_demand);
        xmms_cfg_write_boolean(cfgfile, "xmms",
"eq_doublesize_linked", cfg.eq_doublesize_linked);
        xmms_cfg_write_boolean(cfgfile, "xmms",
"no_playlist_advance", cfg.no_playlist_advance);
+       xmms_cfg_write_boolean(cfgfile, "xmms",
"append_to_playlist", cfg.append_to_playlist);
        xmms_cfg_write_boolean(cfgfile, "xmms",
"sort_jump_to_file", cfg.sort_jump_to_file);
        xmms_cfg_write_boolean(cfgfile, "xmms",
"smooth_title_scroll", cfg.smooth_title_scroll);
        xmms_cfg_write_boolean(cfgfile, "xmms",
"use_backslash_as_dir_delimiter",
cfg.use_backslash_as_dir_delimiter);
@@ -2373,6 +2379,7 @@
        case MAINWIN_OPT_REPEAT:
                cfg.repeat =
GTK_CHECK_MENU_ITEM(gtk_item_factory_get_widget(mainwin_options_menu,
"/Repeat"))->active;
                tbutton_set_toggled(mainwin_repeat,
cfg.repeat);
+               printf("Setting widget true. Reapeat
Value is %d.",cfg.append_to_playlist);
                break;
        case MAINWIN_OPT_TELAPSED:
                set_timer_mode_menu_cb(TIMER_ELAPSED);
@@ -2415,9 +2422,14 @@
                break;
        case MAINWIN_OPT_NPA:
                cfg.no_playlist_advance =
GTK_CHECK_MENU_ITEM(gtk_item_factory_get_widget(mainwin_options_menu,
"/No Playlist Advance"))->active;
+               break;
+       case MAINWIN_OPT_ATP:
+               cfg.append_to_playlist =
GTK_CHECK_MENU_ITEM(gtk_item_factory_get_widget(mainwin_options_menu,
"/Append to playlist"))->active;
+               cfg.append_to_playlist = TRUE;
        }
 }

+
 void mainwin_vis_menu_callback(gpointer cb_data,
guint action, GtkWidget * w)
 {
        switch (action)
@@ -2765,6 +2777,7 @@
        CHECK_SET(mainwin_options_menu, "/Repeat",
cfg.repeat);
        CHECK_SET(mainwin_options_menu, "/Easy Move",
cfg.easy_move);
        CHECK_SET(mainwin_options_menu, "/No Playlist
Advance", cfg.no_playlist_advance);
+       CHECK_SET(mainwin_options_menu, "/Append to
playlist", cfg.append_to_playlist);
        if (cfg.timer_mode == TIMER_ELAPSED)
                widget =
gtk_item_factory_get_widget(mainwin_options_menu,
"/Time Elapsed");
        else
@@ -3348,10 +3361,12 @@
                GList *node;
                int pos = 0;

-               if (opt->enqueue && opt->play)
+               if (opt->enqueue && opt->play) {
                        pos =
xmms_remote_get_playlist_length (opt->session);
-               if (!opt->enqueue)
+                       }
+               if (!opt->enqueue &&
!cfg.append_to_playlist) {
                       
xmms_remote_playlist_clear(opt->session);
+                       }
                xmms_remote_playlist_add(opt->session,
opt->filenames);
                node = opt->filenames;
                while (node)
@@ -3562,6 +3577,7 @@
                handle_cmd_line_options(&options,
TRUE);
                exit(0);
        }
+
        gdk_rgb_init();
       
gtk_widget_set_default_colormap(gdk_rgb_get_cmap());
       
gtk_widget_set_default_visual(gdk_rgb_get_visual());
diff -urN xmms-1.2.10-orig/xmms/main.h
xmms-1.2.10/xmms/main.h
--- xmms-1.2.10-orig/xmms/main.h        Thu Dec  2
09:39:24 2004
+++ xmms-1.2.10/xmms/main.h     Thu Dec  2 09:46:59
2004
@@ -44,7 +44,7 @@
        gboolean no_playlist_advance,
smooth_title_scroll, use_pl_metadata;
        gboolean use_backslash_as_dir_delimiter;
        gboolean random_skin_on_play, use_fontsets;
-       gboolean mainwin_use_xfont;
+       gboolean append_to_playlist,
mainwin_use_xfont;
        gfloat equalizer_preamp, equalizer_bands[10];
        gchar *skin, *outputplugin, *filesel_path,
*playlist_path;
        gchar *playlist_font, *mainwin_font;
@@ -94,6 +94,8 @@
 void mainwin_adjust_balance_release(void);
 void mainwin_set_volume_slider(gint percent);
 void mainwin_set_balance_slider(gint percent);
+
+void set_append_playlist(void);

 void mainwin_vis_set_type(VisType mode);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.