Esempio n. 1
0
void drct_pl_set_pos (gint pos)
{
    gint playlist = playlist_get_active ();
    gboolean play = playback_get_playing ();

    playlist_set_position (playlist, pos);

    if (play)
    {
        playlist_set_playing (playlist);
        playback_play (0, FALSE);
    }
}
Esempio n. 2
0
void drct_play (void)
{
    if (drct_get_playing ())
    {
        if (drct_get_paused ())
            drct_pause ();
        else
        {
            int a, b;
            drct_get_ab_repeat (& a, & b);
            drct_seek (MAX (a, 0));
        }
    }
    else
    {
        int playlist = playlist_get_active ();
        playlist_set_position (playlist, playlist_get_position (playlist));
        drct_play_playlist (playlist);
    }
}
Esempio n. 3
0
static gboolean add_cb(void *data)
{
    struct AddRequest *request = data;
    gint playlist = playlist_get_active();

    if (request->position < 0)
        request->position = playlist_entry_count (playlist);

    drct_pl_add (request->filename, request->position);

    if (request->play)
    {
        playlist_set_playing(playlist);
        playlist_set_position(playlist, request->position);
        playback_play (0, FALSE);
    }

    g_free(request);
    return FALSE;
}
Esempio n. 4
0
static bool_t end_cb (void * unused)
{
    g_return_val_if_fail (playing, FALSE);

    hook_call ("playback end", NULL);

    if (playback_error)
        failed_entries ++;
    else
        failed_entries = 0;

    playback_cleanup ();

    int playlist = playlist_get_playing ();
    bool_t play;

    if (get_bool (NULL, "no_playlist_advance"))
        play = get_bool (NULL, "repeat") && ! failed_entries;
    else if (! (play = playlist_next_song (playlist, get_bool (NULL, "repeat"))))
        playlist_set_position (playlist, -1);
    else if (failed_entries >= 10)
        play = FALSE;

    if (get_bool (NULL, "stop_after_current_song"))
        play = FALSE;

    if (play)
        playback_start (playlist, playlist_get_position (playlist), 0, FALSE);
    else
    {
        complete_stop ();
        hook_call ("playlist end reached", NULL);
    }

    return FALSE;
}
Esempio n. 5
0
void playlist_list_button_press_cb(GtkWidget * widget, GdkEventButton * event, PlayList_List * pl)
{
	if (event->button == 1 && pl->pl_fheight &&
	    inside_widget(event->x, event->y, &pl->pl_widget))
	{
		int nr, y;

		y = event->y - pl->pl_widget.y;
		nr = (y / pl->pl_fheight) + pl->pl_first;
		if (nr >= get_playlist_length())
			nr = get_playlist_length() - 1;
		if (!(event->state & GDK_CONTROL_MASK))
			playlist_select_all(FALSE);
		
		if (event->state & GDK_SHIFT_MASK && pl->pl_prev_selected != -1)
		{
			playlist_select_range(pl->pl_prev_selected, nr, TRUE);
			pl->pl_prev_min = pl->pl_prev_selected;
			pl->pl_prev_max = nr;
			pl->pl_drag_pos = nr - pl->pl_first;
		}
		else
		{
			if (playlist_select_invert(nr))
			{
				if (event->state & GDK_CONTROL_MASK)
				{
					if (pl->pl_prev_min == -1)
					{
						pl->pl_prev_min =
							pl->pl_prev_selected;
						pl->pl_prev_max =
							pl->pl_prev_selected;
					}
					if (nr < pl->pl_prev_min)
						pl->pl_prev_min = nr;
					else if (nr > pl->pl_prev_max)
						pl->pl_prev_max = nr;
				}
				else
					pl->pl_prev_min = -1;
				pl->pl_prev_selected = nr;
				pl->pl_drag_pos = nr - pl->pl_first;
			}
		}
		if (event->type == GDK_2BUTTON_PRESS)
		{
			/*
			 * Ungrab the pointer to prevent us from
			 * hanging on to it during the sometimes slow
			 * playlist_play().
			 */
			gdk_pointer_ungrab(GDK_CURRENT_TIME);
			gdk_flush();
			playlist_set_position(nr);
			if (!get_input_playing())
				playlist_play();
		}
		pl->pl_dragging = TRUE;
		playlistwin_update_list();
	}
}