Exemplo n.º 1
0
void audgui_queue_manager_show (void)
{
    if (qm_win)
    {
        gtk_window_present ((GtkWindow *) qm_win);
        return;
    }

    qm_win = gtk_dialog_new_with_buttons (_("Queue Manager"), NULL, 0,
     GTK_STOCK_REMOVE, RESPONSE_REMOVE, GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE,
     NULL);
    gtk_window_set_default_size ((GtkWindow *) qm_win, 250, 250);

    GtkWidget * vbox = gtk_dialog_get_content_area ((GtkDialog *) qm_win);

    GtkWidget * scrolled = gtk_scrolled_window_new (NULL, NULL);
    gtk_box_pack_start ((GtkBox *) vbox, scrolled, TRUE, TRUE, 0);

    gint count = aud_playlist_queue_count (aud_playlist_get_active ());
    qm_list = audgui_list_new (& callbacks, NULL, count);
    gtk_tree_view_set_headers_visible ((GtkTreeView *) qm_list, FALSE);
    audgui_list_add_column (qm_list, NULL, 0, G_TYPE_INT, FALSE);
    audgui_list_add_column (qm_list, NULL, 1, G_TYPE_STRING, TRUE);
    gtk_container_add ((GtkContainer *) scrolled, qm_list);

    hook_associate ("playlist activate", update_hook, NULL);
    hook_associate ("playlist update", update_hook, NULL);

    g_signal_connect (qm_win, "destroy", (GCallback) destroy_cb, NULL);
    g_signal_connect (qm_win, "key-press-event", (GCallback) keypress_cb, NULL);
    g_signal_connect (qm_win, "response", (GCallback) response_cb, NULL);

    gtk_widget_show_all (qm_win);
}
Exemplo n.º 2
0
static void shift_rows (void * user, gint row, gint before)
{
    GArray * shift = g_array_new (FALSE, FALSE, sizeof (gint));
    gint list = aud_playlist_get_active ();
    gint count = aud_playlist_queue_count (list);

    for (gint i = 0; i < count; i ++)
    {
        gint entry = aud_playlist_queue_get_entry (list, i);

        if (aud_playlist_entry_get_selected (list, entry))
        {
            g_array_append_val (shift, entry);

            if (i < before)
                before --;
        }
    }

    aud_playlist_queue_delete_selected (list);

    for (gint i = 0; i < shift->len; i ++)
        aud_playlist_queue_insert (list, before + i, g_array_index (shift, gint, i));

    g_array_free (shift, TRUE);
}
Exemplo n.º 3
0
static void select_all (void * user, gboolean selected)
{
    gint list = aud_playlist_get_active ();
    gint count = aud_playlist_queue_count (list);

    for (gint i = 0; i < count; i ++)
        aud_playlist_entry_set_selected (list, aud_playlist_queue_get_entry (list, i), selected);
}
Exemplo n.º 4
0
static void action_play (void)
{
    int list = aud_playlist_get_temporary ();
    aud_playlist_set_active (list);

    if (aud_get_bool (NULL, "clear_playlist"))
        aud_playlist_entry_delete (list, 0, aud_playlist_entry_count (list));
    else
        aud_playlist_queue_delete (list, 0, aud_playlist_queue_count (list));

    do_add (TRUE, NULL);
}
Exemplo n.º 5
0
static void update_queue (GtkWidget * widget, PlaylistWidgetData * data)
{
    for (GList * node = data->queue; node; node = node->next)
        audgui_list_update_rows (widget, GPOINTER_TO_INT (node->data), 1);

    g_list_free (data->queue);
    data->queue = NULL;

    for (gint i = aud_playlist_queue_count (data->list); i --; )
        data->queue = g_list_prepend (data->queue, GINT_TO_POINTER
         (aud_playlist_queue_get_entry (data->list, i)));

    for (GList * node = data->queue; node; node = node->next)
        audgui_list_update_rows (widget, GPOINTER_TO_INT (node->data), 1);
}
Exemplo n.º 6
0
static void remove_selected (void)
{
    gint list = aud_playlist_get_active ();
    gint count = aud_playlist_queue_count (list);

    for (gint i = 0; i < count; )
    {
        gint entry = aud_playlist_queue_get_entry (list, i);

        if (aud_playlist_entry_get_selected (list, entry))
        {
            aud_playlist_queue_delete (list, i, 1);
            aud_playlist_entry_set_selected (list, entry, FALSE);
            count --;
        }
        else
            i ++;
    }
}
Exemplo n.º 7
0
static void update_hook (void * data, void * user)
{
    audgui_list_delete_rows (qm_list, 0, audgui_list_row_count (qm_list));
    audgui_list_insert_rows (qm_list, 0, aud_playlist_queue_count (aud_playlist_get_active ()));
}