static void action_add_to_playlist (void) { if (aud_playlist_by_unique_id (playlist_id) == aud_playlist_get_active ()) return; do_add (FALSE, NULL); }
static void do_add (bool_t play, char * * title) { int list = aud_playlist_by_unique_id (playlist_id); int n_items = index_count (items); int n_selected = 0; Index * filenames = index_new (); Index * tuples = index_new (); for (int i = 0; i < n_items; i ++) { if (! selection->data[i]) continue; Item * item = index_get (items, i); for (int m = 0; m < item->matches->len; m ++) { int entry = g_array_index (item->matches, int, m); index_insert (filenames, -1, aud_playlist_entry_get_filename (list, entry)); index_insert (tuples, -1, aud_playlist_entry_get_tuple (list, entry, TRUE)); } n_selected ++; if (title && n_selected == 1) * title = item->name; } if (title && n_selected != 1) * title = NULL; aud_playlist_entry_insert_batch (aud_playlist_get_active (), -1, filenames, tuples, play); }
static void do_follow (void) { while (! g_queue_is_empty (& follow_queue)) { gint list = aud_playlist_by_unique_id (GPOINTER_TO_INT (g_queue_pop_head (& follow_queue))); gint row = GPOINTER_TO_INT (g_queue_pop_head (& follow_queue)); if (list < 0) continue; GtkWidget * widget = playlist_get_treeview (list); if (row == CURRENT_POS) { row = aud_playlist_get_position (list); audgui_list_set_highlight (widget, row); if (! aud_get_bool ("gtkui", "autoscroll")) continue; } audgui_list_set_focus (widget, row); } }
static void confirm_delete_cb (GtkButton * button, void * data) { int list = aud_playlist_by_unique_id (GPOINTER_TO_INT (data)); if (list < 0) return; aud_playlist_delete (list); if (list > 0) aud_playlist_set_active (list - 1); }
EXPORT void audgui_import_playlist (void) { int list = aud_playlist_get_active (); int id = aud_playlist_get_unique_id (list); char * filename = select_file (FALSE, NULL); if (! filename) return; if ((list = aud_playlist_by_unique_id (id)) < 0) return; aud_playlist_entry_delete (list, 0, aud_playlist_entry_count (list)); aud_playlist_entry_insert (list, 0, filename, NULL, FALSE); aud_playlist_set_filename (list, filename); g_free (filename); }
EXPORT void audgui_export_playlist (void) { int list = aud_playlist_get_active (); int id = aud_playlist_get_unique_id (list); char * def = aud_playlist_get_filename (list); char * filename = select_file (TRUE, def); str_unref (def); if (! filename || (vfs_file_test (filename, G_FILE_TEST_EXISTS) && ! confirm_overwrite (filename))) return; if ((list = aud_playlist_by_unique_id (id)) < 0) return; aud_playlist_save (list, filename); g_free (filename); }
static void finish_job (void * data) { ImportExportJob * job = data; int list = aud_playlist_by_unique_id (job->list_id); if (list >= 0) { aud_playlist_set_filename (list, job->filename); if (job->save) aud_playlist_save (list, job->filename); else { aud_playlist_entry_delete (list, 0, aud_playlist_entry_count (list)); aud_playlist_entry_insert (list, 0, job->filename, NULL, FALSE); } } gtk_widget_destroy (job->selector); }
static int get_playlist (bool_t require_added, bool_t require_scanned) { if (playlist_id < 0) return -1; int list = aud_playlist_by_unique_id (playlist_id); if (list < 0) { playlist_id = -1; return -1; } if (require_added && aud_playlist_add_in_progress (list)) return -1; if (require_scanned && aud_playlist_scan_in_progress (list)) return -1; return list; }
static void pl_tab_rename (void) { int playlist = aud_playlist_by_unique_id (menu_tab_playlist_id); if (playlist >= 0) start_rename_playlist (playlist); }
static void pl_tab_play (void) { int playlist = aud_playlist_by_unique_id (menu_tab_playlist_id); if (playlist >= 0) aud_drct_play_playlist (playlist); }
static void pl_tab_close (void) { int playlist = aud_playlist_by_unique_id (menu_tab_playlist_id); if (playlist >= 0) audgui_confirm_playlist_delete (playlist); }
static void close_button_cb (GtkWidget * button, void * id) { audgui_confirm_playlist_delete (aud_playlist_by_unique_id (GPOINTER_TO_INT (id))); }
static void add_remove_pages (void) { gint lists = aud_playlist_count (); gint pages = gtk_notebook_get_n_pages ((GtkNotebook *) notebook); /* scan through existing treeviews */ for (gint i = 0; i < pages; ) { GtkWidget * page = gtk_notebook_get_nth_page ((GtkNotebook *) notebook, i); GtkWidget * tree = g_object_get_data ((GObject *) page, "treeview"); gint tree_id = GPOINTER_TO_INT (g_object_get_data ((GObject *) tree, "playlist-id")); /* do we have an orphaned treeview? */ if (aud_playlist_by_unique_id (tree_id) < 0) { g_signal_handlers_block_by_func (notebook, (void *) tab_changed, NULL); gtk_notebook_remove_page ((GtkNotebook *) notebook, i); g_signal_handlers_unblock_by_func (notebook, (void *) tab_changed, NULL); pages --; continue; } /* do we have the right treeview? */ gint list_id = aud_playlist_get_unique_id (i); if (tree_id == list_id) { ui_playlist_widget_set_playlist (tree, i); i ++; continue; } /* look for the right treeview */ gint found = FALSE; for (gint j = i + 1; j < pages; j ++) { page = gtk_notebook_get_nth_page ((GtkNotebook *) notebook, j); tree = g_object_get_data ((GObject *) page, "treeview"); tree_id = GPOINTER_TO_INT (g_object_get_data ((GObject *) tree, "playlist-id")); /* found it? move it to the right place */ if (tree_id == list_id) { g_signal_handlers_block_by_func (notebook, (void *) tab_reordered, NULL); gtk_notebook_reorder_child ((GtkNotebook *) notebook, page, i); g_signal_handlers_unblock_by_func (notebook, (void *) tab_reordered, NULL); found = TRUE; break; } } /* didn't find it? create it */ if (! found) { ui_playlist_notebook_create_tab (i); pages ++; continue; } } /* create new treeviews */ while (pages < lists) { ui_playlist_notebook_create_tab (pages); pages ++; } }