2
* This file is part of MPlayer.
4
* MPlayer is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* MPlayer is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License along
15
* with MPlayer; if not, write to the Free Software Foundation, Inc.,
16
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
31
void *listSet(int cmd, void *vparam)
33
plItem *item = (plItem *)vparam;
34
urlItem *url_item = (urlItem *)vparam;
40
// add item to playlist
43
plItem *next = plList;
47
// printf( "%s\n",next->name );
55
item->prev = item->next = NULL;
56
plCurrent = plList = item;
60
// add item into playlist after current
63
plItem *curr = plCurrent;
64
item->next = curr->next;
67
item->next->prev = item;
71
plCurrent = plCurrent->next;
75
return listSet(gtkAddPlItem, item);
77
// get next item from playlist
78
case gtkGetNextPlItem:
79
if (plCurrent && plCurrent->next) {
80
plCurrent = plCurrent->next;
81
// if (!plCurrent && plList)
83
// plItem *next = plList;
87
// if (!next->next) break;
97
// get previous item from playlist
98
case gtkGetPrevPlItem:
99
if (plCurrent && plCurrent->prev) {
100
plCurrent = plCurrent->prev;
101
// if ( !plCurrent && plList ) plCurrent=plList;
107
case gtkSetCurrPlItem:
112
case gtkGetCurrPlItem:
115
// delete current item
116
case gtkDelCurrPlItem:
118
plItem *curr = plCurrent;
124
curr->prev->next = curr->next;
126
curr->next->prev = curr->prev;
130
plCurrent = curr->next;
137
//uiCurr(); // instead of using uiNext && uiPrev
143
plItem *curr = plList;
171
urlItem *next_url = urlList;
174
while (next_url->next) {
175
if (!gstrcmp(next_url->url, url_item->url)) {
180
next_url = next_url->next;
183
if (!is_added && gstrcmp(next_url->url, url_item->url))
184
next_url->next = url_item;
186
url_item->next = NULL;
196
* \brief This actually creates a new list containing only one element...
198
void gaddlist(char ***list, const char *entry)
203
for (i = 0; (*list)[i]; i++)
209
*list = malloc(2 * sizeof(char **));
210
(*list)[0] = gstrdup(entry);
215
* \brief This replaces a string starting with search by replace.
216
* If not found, replace is appended.
218
void greplace(char ***list, const char *search, const char *replace)
221
int len = (search ? strlen(search) : 0);
224
for (i = 0; (*list)[i]; i++) {
225
if (search && (strncmp((*list)[i], search, len) == 0)) {
227
(*list)[i] = gstrdup(replace);
232
*list = realloc(*list, (i + 2) * sizeof(char *));
234
*list = malloc(2 * sizeof(char *));
236
(*list)[i] = gstrdup(replace);
237
(*list)[i + 1] = NULL;