Mercurial > mplayer.hg
annotate gui/ui/gtk/playlist.c @ 35522:92809c17fc9d
Fix bug with removing items from playlist.
When removing files from the playlist in the playlist editor
not all selected items towards the end of the list were removed.
Patch by Hans-Dieter Kosch, hdkosch kabelbw de.
author | ib |
---|---|
date | Thu, 06 Dec 2012 00:57:30 +0000 |
parents | 411875efca3f |
children | e27855a45128 |
rev | line source |
---|---|
33572 | 1 /* |
2 * This file is part of MPlayer. | |
3 * | |
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. | |
8 * | |
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. | |
13 * | |
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. | |
17 */ | |
18 | |
19 #include <sys/types.h> | |
20 #include <sys/stat.h> | |
21 #include <string.h> | |
22 #include <dirent.h> | |
23 #include <unistd.h> | |
24 #include <stdio.h> | |
25 #include <stdlib.h> | |
26 | |
27 #include <gdk/gdkkeysyms.h> | |
28 #include <gtk/gtk.h> | |
29 | |
30 #include "help_mp.h" | |
31 #include "stream/stream.h" | |
32 | |
33750
8b5898908212
Remove variable holding history of selected files from interface.[ch].
ib
parents:
33742
diff
changeset
|
33 #include "gui/cfg.h" |
35429 | 34 #include "gui/gui.h" |
35381
746e2e0577b2
Without current playlist item, reset guiInfo's Filename and StreamType.
ib
parents:
34681
diff
changeset
|
35 #include "gui/interface.h" |
33572 | 36 #include "gui/ui/widgets.h" |
33742
e1539e14d60f
Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents:
33740
diff
changeset
|
37 #include "gui/util/list.h" |
33739 | 38 #include "gui/util/mem.h" |
35461 | 39 #include "gui/util/string.h" |
33572 | 40 #include "playlist.h" |
41 #include "tools.h" | |
42 | |
33575 | 43 #include "gui/ui/pixmaps/open2.xpm" |
44 #include "gui/ui/pixmaps/dir2.xpm" | |
33572 | 45 |
46 GtkWidget * PlayList = NULL; | |
47 static GtkWidget * CTDirTree; | |
48 static GtkWidget * CLFiles; | |
49 static GtkWidget * CLSelected; | |
50 static GtkWidget * Add; | |
51 static GtkWidget * Remove; | |
52 static GtkWidget * Ok; | |
53 static GtkWidget * Cancel; | |
54 static GdkPixmap * pxOpenedBook; | |
55 static GdkPixmap * pxClosedBook; | |
56 static GdkBitmap * msOpenedBook; | |
57 static GdkBitmap * msClosedBook; | |
58 | |
59 static int NrOfEntrys = 0; | |
60 static int NrOfSelected = 0; | |
61 static int * CLFileSelected = NULL; | |
62 static int * CLListSelected = NULL; | |
63 | |
64 static int sigSel; | |
65 static int sigUnsel; | |
66 static int sigEvent; | |
67 | |
68 typedef struct | |
69 { | |
70 int scaned; | |
71 char * path; | |
72 } DirNodeType; | |
73 | |
74 static GtkCTreeNode * sibling; | |
75 static GtkCTreeNode * parent; | |
76 static gchar * current_path; | |
77 static gchar * old_path = NULL; | |
78 | |
79 static int compare_func(const void *a, const void *b) | |
80 { | |
81 char * tmp; | |
82 int i; | |
83 if ( !a || !b || !( (DirNodeType *)a )->path ) return -1; | |
84 tmp=strdup( (char *)b ); tmp[strlen( tmp )-1]=0; | |
85 i=strcmp( ( (DirNodeType *)a )->path,tmp ); | |
86 free( tmp ); | |
87 return i; | |
88 } | |
89 | |
90 static void scan_dir( char * path ); | |
91 | |
92 void ShowPlayList( void ) | |
93 { | |
34667 | 94 plItem * next; |
95 | |
33572 | 96 if ( PlayList ) gtkActive( PlayList ); |
97 else PlayList=create_PlayList(); | |
98 | |
99 if ( old_path && *old_path ) | |
100 { | |
101 char * currentdir = strdup( old_path ); | |
102 char * tpath,* pos; | |
103 GtkCTreeNode * node,* nextnode; | |
104 gboolean leaf; | |
105 tpath=strdup( "/" ); | |
106 pos=strtok( currentdir,"/" ); | |
107 node=gtk_ctree_find_by_row_data_custom( GTK_CTREE( CTDirTree ),NULL,"/",compare_func ); | |
108 do | |
109 { | |
110 char * tpathnew = g_strconcat( tpath,pos,"/",NULL ); | |
111 free( tpath ); tpath=tpathnew; | |
112 nextnode=gtk_ctree_find_by_row_data_custom( GTK_CTREE( CTDirTree ),node,tpath,compare_func ); | |
113 if ( !nextnode ) break; | |
114 node=nextnode; | |
115 pos=strtok( NULL,"/" ); | |
116 gtk_ctree_get_node_info( GTK_CTREE( CTDirTree ),node,NULL,NULL,NULL,NULL,NULL,NULL,&leaf,NULL ); | |
117 if ( !leaf && pos ) gtk_ctree_expand( GTK_CTREE( CTDirTree ),node ); | |
118 else | |
119 { | |
120 DirNodeType * DirNode; | |
121 gtk_ctree_select( GTK_CTREE( CTDirTree ),node ); | |
122 DirNode=gtk_ctree_node_get_row_data( GTK_CTREE( CTDirTree ),node ); | |
123 current_path=DirNode->path; | |
124 scan_dir( DirNode->path ); | |
125 free( CLFileSelected ); | |
126 CLFileSelected=calloc( 1,NrOfEntrys * sizeof( int ) ); | |
127 break; | |
128 } | |
129 } while( pos ); | |
130 free( tpath ); | |
131 free( currentdir ); | |
132 } | |
133 else gtk_ctree_select( GTK_CTREE( CTDirTree ),parent ); | |
134 | |
135 gtk_clist_freeze( GTK_CLIST( CLSelected ) ); | |
136 gtk_clist_clear( GTK_CLIST( CLSelected ) ); | |
34667 | 137 next = listMgr( PLAYLIST_GET,0 ); |
138 if ( next ) | |
33572 | 139 { |
140 gchar * name, * path; | |
141 while ( next || next->next ) | |
142 { | |
143 char * text[1][3]; text[0][2]=""; | |
144 name = g_filename_to_utf8( next->name, -1, NULL, NULL, NULL ); | |
145 path = g_filename_to_utf8( next->path, -1, NULL, NULL, NULL ); | |
146 text[0][0]=name ? name : next->name; | |
147 text[0][1]=path ? path : next->path; | |
148 gtk_clist_append( GTK_CLIST( CLSelected ),text[0] ); | |
149 g_free( path ); | |
150 g_free( name ); | |
151 NrOfSelected++; | |
152 if ( next->next ) next=next->next; else break; | |
153 } | |
154 CLListSelected=calloc( 1,NrOfSelected * sizeof( int ) ); | |
155 } | |
156 gtk_clist_thaw( GTK_CLIST( CLSelected ) ); | |
157 | |
158 gtk_widget_show( PlayList ); | |
159 } | |
160 | |
161 void HidePlayList( void ) | |
162 { | |
163 if ( !PlayList ) return; | |
164 NrOfSelected=NrOfEntrys=0; | |
33739 | 165 nfree( CLListSelected ); nfree( CLFileSelected ); |
33572 | 166 free( old_path ); |
167 old_path=strdup( current_path ); | |
168 gtk_widget_hide( PlayList ); | |
169 gtk_widget_destroy( PlayList ); | |
170 PlayList=NULL; | |
171 } | |
172 | |
173 static void plRowSelect( GtkCList * clist,gint row,gint column,GdkEvent * event,gpointer user_data ) | |
174 { | |
175 switch ( (int) user_data ) | |
176 { | |
35493 | 177 case 0: CLFileSelected[row]=True; break; |
178 case 1: CLListSelected[row]=True; break; | |
33572 | 179 } |
180 } | |
181 | |
182 static void plUnRowSelect( GtkCList * clist,gint row,gint column,GdkEvent * event,gpointer user_data ) | |
183 { | |
184 switch ( (int) user_data ) | |
185 { | |
35493 | 186 case 0: CLFileSelected[row]=False; break; |
187 case 1: CLListSelected[row]=False; break; | |
33572 | 188 } |
189 } | |
190 | |
191 static void plButtonReleased( GtkButton * button,gpointer user_data ) | |
192 { | |
193 switch ( (int) user_data ) | |
194 { | |
195 case 1: // ok | |
196 { | |
35486 | 197 int pos = 0, i; |
35461 | 198 plItem curr, * item, * old; |
199 item = listMgr( PLAYLIST_ITEM_GET_CURR,0 ); | |
200 if (item) | |
201 { | |
202 curr.path = gstrdup(item->path); | |
203 curr.name = gstrdup(item->name); | |
35486 | 204 pos = (int) listMgr( PLAYLIST_ITEM_GET_POS,item ); |
35461 | 205 } |
206 else curr.path = curr.name = NULL; | |
34666 | 207 listMgr( PLAYLIST_DELETE,0 ); |
33572 | 208 for ( i=0;i<NrOfSelected;i++ ) |
209 { | |
210 char * text[3]; | |
211 item=calloc( 1,sizeof( plItem ) ); | |
212 gtk_clist_get_text( GTK_CLIST( CLSelected ),i,0,&text[0] ); | |
213 gtk_clist_get_text( GTK_CLIST( CLSelected ),i,1,&text[1] ); | |
214 item->name=g_filename_from_utf8( text[0], -1, NULL, NULL, NULL ); | |
215 if ( !item->name ) item->name = strdup( text[0] ); | |
216 item->path=g_filename_from_utf8( text[1], -1, NULL, NULL, NULL ); | |
217 if ( !item->path ) item->path = strdup( text[1] ); | |
34681 | 218 listMgr( PLAYLIST_ITEM_APPEND,item ); |
33572 | 219 } |
35461 | 220 item = listMgr( PLAYLIST_GET,0 ); |
34664
4df4d842d5fb
Remove global variable pointing to current playlist item.
ib
parents:
34663
diff
changeset
|
221 if ( item ) |
33572 | 222 { |
35461 | 223 if ( guiInfo.Playing && curr.name && pos ) |
224 { | |
225 old = listMgr( PLAYLIST_ITEM_FIND,&curr ); | |
226 if ( old && ( pos == (int) listMgr( PLAYLIST_ITEM_GET_POS,old ) ) ) | |
227 { | |
228 listMgr( PLAYLIST_ITEM_SET_CURR,old ); | |
229 item = NULL; | |
230 } | |
231 } | |
232 if ( item ) | |
233 { | |
234 uiSetFile( item->path,item->name,STREAMTYPE_FILE ); | |
235 guiInfo.NewPlay = GUI_FILE_NEW; | |
35493 | 236 guiInfo.PlaylistNext = (curr.name ? False : True); |
35461 | 237 guiInfo.Track = 1; |
238 } | |
35488
9ef9131adfe5
Provide a number of tracks information for files in playlists.
ib
parents:
35486
diff
changeset
|
239 guiInfo.Tracks = (int) listMgr( PLAYLIST_ITEM_GET_POS,NULL ); |
33572 | 240 } |
35455
c9c79a011f6f
Fix bug with wrong track number after playlist has been cleared.
ib
parents:
35452
diff
changeset
|
241 else if (isPlaylistStreamtype && !guiInfo.Playing) uiUnsetFile(); |
35461 | 242 free(curr.path); |
243 free(curr.name); | |
33572 | 244 } |
245 case 0: // cancel | |
246 HidePlayList(); | |
247 break; | |
248 case 2: // remove | |
249 { | |
35522 | 250 int i; int j; |
33572 | 251 |
252 gtk_signal_handler_block( GTK_OBJECT( CLSelected ),sigSel ); | |
253 gtk_signal_handler_block( GTK_OBJECT( CLSelected ),sigUnsel ); | |
254 gtk_signal_handler_block( GTK_OBJECT( CLSelected ),sigEvent ); | |
255 | |
256 gtk_clist_freeze( GTK_CLIST( CLSelected ) ); | |
35522 | 257 i = 0; |
258 while ( i<NrOfSelected ) | |
259 { | |
33572 | 260 if ( CLListSelected[i] ) |
261 { | |
35522 | 262 gtk_clist_remove( GTK_CLIST( CLSelected ),i ); |
263 NrOfSelected--; | |
264 for ( j=i;j<NrOfSelected;j++ ) | |
265 CLListSelected[j] = CLListSelected[j+1]; | |
33572 | 266 } |
35522 | 267 else i++; |
268 } | |
33572 | 269 gtk_clist_thaw( GTK_CLIST( CLSelected ) ); |
270 | |
271 gtk_signal_handler_unblock( GTK_OBJECT( CLSelected ),sigSel ); | |
272 gtk_signal_handler_unblock( GTK_OBJECT( CLSelected ),sigUnsel ); | |
273 gtk_signal_handler_unblock( GTK_OBJECT( CLSelected ),sigEvent ); | |
274 | |
275 } | |
276 break; | |
277 case 3: // add | |
278 { | |
279 int i; | |
280 void *p; | |
281 char * itext[1][2]; | |
282 gchar * cpath; | |
283 char * text[1][3]; text[0][2]=""; | |
284 gtk_clist_freeze( GTK_CLIST( CLSelected ) ); | |
285 for ( i=0;i<NrOfEntrys;i++ ) | |
286 { | |
287 if ( CLFileSelected[i] ) | |
288 { | |
289 NrOfSelected++; | |
290 p=realloc( CLListSelected,NrOfSelected * sizeof( int ) ); | |
291 if ( !p ) NrOfSelected--; | |
292 else | |
293 { | |
294 CLListSelected=p; | |
35493 | 295 CLListSelected[NrOfSelected - 1]=False; |
33572 | 296 gtk_clist_get_text( GTK_CLIST( CLFiles ),i,0,(char **)&itext ); |
297 cpath=g_filename_to_utf8( current_path, -1, NULL, NULL, NULL ); | |
298 text[0][0]=itext[0][0]; text[0][1]=cpath ? cpath : current_path; | |
299 gtk_clist_append( GTK_CLIST( CLSelected ),text[0] ); | |
300 g_free( cpath ); | |
301 } | |
302 } | |
303 } | |
304 gtk_clist_thaw( GTK_CLIST( CLSelected ) ); | |
305 } | |
306 break; | |
307 } | |
308 } | |
309 | |
34348 | 310 static gboolean plKeyReleased( GtkWidget * widget, |
311 GdkEventKey * event, | |
312 gpointer user_data ) | |
313 { | |
34349 | 314 if (event->keyval == GDK_Return) |
315 { | |
316 if ( GTK_WIDGET_TYPE( widget ) == GTK_TYPE_BUTTON ) plButtonReleased( NULL, user_data ); | |
317 else | |
318 { | |
319 switch ( (int) user_data ) | |
320 { | |
321 case 0: | |
322 plButtonReleased( NULL, (void *) 3 ); | |
323 break; | |
324 case 1: | |
325 plButtonReleased( NULL, (void *) 2 ); | |
326 break; | |
327 } | |
328 } | |
329 } | |
34348 | 330 return FALSE; |
331 } | |
332 | |
33572 | 333 static gboolean plEvent ( GtkWidget * widget, |
334 GdkEvent * event, | |
335 gpointer user_data ) | |
336 { | |
337 GdkEventButton *bevent; | |
338 gint row, col; | |
339 | |
340 bevent = (GdkEventButton *) event; | |
341 | |
342 if ( event->type == GDK_BUTTON_RELEASE && bevent->button == 2 ) | |
343 { | |
344 if ( gtk_clist_get_selection_info( GTK_CLIST( widget ), bevent->x, bevent->y, &row, &col ) ) | |
345 { | |
346 switch ( (int) user_data ) | |
347 { | |
348 case 0: | |
35493 | 349 CLFileSelected[row] = True; |
33572 | 350 plButtonReleased( NULL, (void *) 3 ); |
35493 | 351 CLFileSelected[row] = False; |
33572 | 352 return TRUE; |
353 | |
354 case 1: | |
35493 | 355 CLListSelected[row] = True; |
33572 | 356 plButtonReleased( NULL, (void *) 2 ); |
357 return TRUE; | |
358 } | |
359 } | |
360 } | |
361 | |
362 return FALSE; | |
363 } | |
364 | |
365 static int check_for_subdir( gchar * path ) | |
366 { | |
367 DIR * dir; | |
368 struct dirent * dirent; | |
369 struct stat statbuf; | |
370 gchar * npath; | |
371 | |
372 if ( (dir=opendir( path )) ) | |
373 { | |
374 while ( (dirent=readdir( dir )) ) | |
375 { | |
376 if ( dirent->d_name[0] != '.' ) | |
377 { | |
378 npath=calloc( 1,strlen( path ) + strlen( dirent->d_name ) + 3 ); | |
379 sprintf( npath,"%s/%s",path,dirent->d_name ); | |
380 if ( stat( npath,&statbuf ) != -1 && S_ISDIR( statbuf.st_mode ) ) | |
35493 | 381 { free( npath ); closedir( dir ); return True; } |
33572 | 382 free( npath ); |
383 } | |
384 } | |
385 closedir( dir ); | |
386 } | |
35493 | 387 return False; |
33572 | 388 } |
389 | |
390 static void plCTree( GtkCTree * ctree,GtkCTreeNode * parent_node,gpointer user_data ) | |
391 { | |
392 GtkCTreeNode * node; | |
393 DirNodeType * DirNode; | |
394 gchar * text, * name = NULL; | |
395 gchar * dummy = "dummy"; | |
35493 | 396 int subdir = True; |
33572 | 397 DIR * dir = NULL; |
398 struct dirent * dirent; | |
399 gchar * path; | |
400 struct stat statbuf; | |
401 | |
402 DirNode=gtk_ctree_node_get_row_data( ctree,parent_node ); | |
403 if ( !DirNode->scaned ) | |
404 { | |
35493 | 405 DirNode->scaned=True; current_path=DirNode->path; |
33572 | 406 gtk_clist_freeze( GTK_CLIST( ctree ) ); |
407 node=gtk_ctree_find_by_row_data( ctree,parent_node,NULL ); | |
408 gtk_ctree_remove_node( ctree,node ); | |
409 | |
410 if ( (dir=opendir( DirNode->path ) ) ) | |
411 { | |
412 while( (dirent=readdir( dir )) ) | |
413 { | |
414 path=calloc( 1,strlen( DirNode->path ) + strlen( dirent->d_name ) + 2 ); | |
415 if ( !strcmp( current_path,"/" ) ) sprintf( path,"/%s",dirent->d_name ); | |
416 else sprintf( path,"%s/%s",current_path,dirent->d_name ); | |
417 text=dirent->d_name; | |
418 g_free( name ); | |
419 name=g_filename_to_utf8( text, -1, NULL, NULL, NULL ); | |
420 | |
421 if ( stat( path,&statbuf ) != -1 && S_ISDIR( statbuf.st_mode ) && dirent->d_name[0] != '.' ) | |
422 { | |
35493 | 423 DirNode=malloc( sizeof( DirNodeType ) ); DirNode->scaned=False; DirNode->path=strdup( path ); |
33572 | 424 subdir=check_for_subdir( path ); |
425 node=gtk_ctree_insert_node( ctree,parent_node,NULL,(name ? &name : &text ),4,pxOpenedBook,msOpenedBook,pxClosedBook,msClosedBook,!subdir,FALSE ); | |
426 gtk_ctree_node_set_row_data_full( ctree,node,DirNode,NULL ); | |
35403 | 427 if ( subdir ) gtk_ctree_insert_node( ctree,node,NULL,&dummy,4,NULL,NULL,NULL,NULL,FALSE,FALSE ); |
33572 | 428 } |
429 free( path ); path=NULL; | |
430 } | |
431 closedir( dir ); | |
432 } | |
433 | |
434 gtk_ctree_sort_node( ctree,parent_node ); | |
435 gtk_clist_thaw( GTK_CLIST( ctree ) ); | |
436 } | |
437 | |
438 g_free( name ); | |
439 } | |
440 | |
441 static void scan_dir( char * path ) | |
442 { | |
443 DIR * dir = NULL; | |
444 char * curr; | |
445 struct dirent * dirent; | |
446 struct stat statbuf; | |
447 gchar * name; | |
448 char * text[1][2]; text[0][1]=""; | |
449 | |
450 gtk_clist_clear( GTK_CLIST( CLFiles ) ); | |
451 if ( (dir=opendir( path )) ) | |
452 { | |
453 NrOfEntrys=0; | |
454 while( (dirent=readdir( dir )) ) | |
455 { | |
456 curr=calloc( 1,strlen( path ) + strlen( dirent->d_name ) + 3 ); sprintf( curr,"%s/%s",path,dirent->d_name ); | |
457 if ( stat( curr,&statbuf ) != -1 && ( S_ISREG( statbuf.st_mode ) || S_ISLNK( statbuf.st_mode ) ) ) | |
458 { | |
459 name=g_filename_to_utf8( dirent->d_name, -1, NULL, NULL, NULL ); | |
460 text[0][0]=name ? name : dirent->d_name; | |
461 gtk_clist_append( GTK_CLIST( CLFiles ), text[0] ); | |
462 g_free( name ); | |
463 NrOfEntrys++; | |
464 } | |
465 free( curr ); | |
466 } | |
467 closedir( dir ); | |
468 gtk_clist_sort( GTK_CLIST( CLFiles ) ); | |
469 } | |
470 } | |
471 | |
34466
a650895d50a5
Use correct data types and common variable names in GTK callback functions.
ib
parents:
34349
diff
changeset
|
472 static void plCTRow(GtkCList * clist, gint row, gint column, GdkEvent * event, gpointer user_data) |
33572 | 473 { |
474 DirNodeType * DirNode; | |
475 GtkCTreeNode * node; | |
34466
a650895d50a5
Use correct data types and common variable names in GTK callback functions.
ib
parents:
34349
diff
changeset
|
476 node=gtk_ctree_node_nth( GTK_CTREE( clist ),row ); |
a650895d50a5
Use correct data types and common variable names in GTK callback functions.
ib
parents:
34349
diff
changeset
|
477 DirNode=gtk_ctree_node_get_row_data( GTK_CTREE( clist ),node ); |
33572 | 478 current_path=DirNode->path; |
34466
a650895d50a5
Use correct data types and common variable names in GTK callback functions.
ib
parents:
34349
diff
changeset
|
479 gtk_ctree_expand( GTK_CTREE( clist ),node ); |
33572 | 480 scan_dir( DirNode->path ); |
481 free( CLFileSelected ); | |
482 CLFileSelected=calloc( 1,NrOfEntrys * sizeof( int ) ); | |
483 } | |
484 | |
485 GtkWidget * create_PlayList( void ) | |
486 { | |
487 GtkWidget * vbox1; | |
488 GtkWidget * hbox1; | |
489 GtkWidget * scrolledwindow1; | |
490 GtkWidget * vbox2; | |
491 GtkWidget * scrolledwindow2; | |
492 GtkWidget * scrolledwindow3; | |
493 GtkWidget * hbuttonbox1; | |
494 GtkAccelGroup * accel_group; | |
495 GdkColor transparent = { 0,0,0,0 }; | |
496 gchar * root = "/"; | |
497 gchar * dummy = "dummy"; | |
498 DirNodeType * DirNode; | |
499 | |
500 accel_group=gtk_accel_group_new(); | |
501 | |
502 PlayList=gtk_window_new( GTK_WINDOW_TOPLEVEL ); | |
503 gtk_object_set_data( GTK_OBJECT( PlayList ),"PlayList",PlayList ); | |
504 gtk_widget_set_usize( PlayList,512,384 ); | |
505 gtk_window_set_title( GTK_WINDOW( PlayList ),MSGTR_PlayList ); | |
506 gtk_window_set_position( GTK_WINDOW( PlayList ),GTK_WIN_POS_CENTER ); | |
507 // gtk_window_set_policy( GTK_WINDOW( PlayList ),FALSE,FALSE,FALSE ); | |
508 gtk_window_set_wmclass( GTK_WINDOW( PlayList ),"Playlist","MPlayer" ); | |
509 | |
510 gtk_widget_realize( PlayList ); | |
511 gtkAddIcon( PlayList ); | |
512 | |
513 vbox1=AddVBox( AddDialogFrame( PlayList ),0 ); | |
514 hbox1=AddHBox( NULL,1 ); | |
515 gtk_box_pack_start( GTK_BOX( vbox1 ),hbox1,TRUE,TRUE,0 ); | |
516 | |
517 scrolledwindow1=gtk_scrolled_window_new( NULL,NULL ); | |
518 gtk_widget_show( scrolledwindow1 ); | |
519 gtk_container_add( GTK_CONTAINER( | |
520 AddFrame( NULL,0,hbox1,1 ) ),scrolledwindow1 ); | |
521 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow1 ),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC ); | |
522 | |
523 CTDirTree=gtk_ctree_new( 1,0 ); | |
524 gtk_signal_connect( GTK_OBJECT( CTDirTree ),"tree_expand",GTK_SIGNAL_FUNC( plCTree ),(void*)0 ); | |
525 gtk_signal_connect( GTK_OBJECT( CTDirTree ),"select_row",GTK_SIGNAL_FUNC( plCTRow ),(void *)0 ); | |
526 gtk_container_add( GTK_CONTAINER( scrolledwindow1 ),CTDirTree ); | |
527 gtk_clist_set_column_auto_resize( GTK_CLIST( CTDirTree ),0,TRUE ); | |
528 gtk_clist_set_column_width( GTK_CLIST( CTDirTree ),0,80 ); | |
529 gtk_clist_set_selection_mode( GTK_CLIST( CTDirTree ),GTK_SELECTION_SINGLE ); | |
530 gtk_ctree_set_line_style( GTK_CTREE( CTDirTree ),GTK_CTREE_LINES_SOLID ); | |
531 gtk_clist_column_titles_show( GTK_CLIST( CTDirTree ) ); | |
532 gtk_clist_set_shadow_type( GTK_CLIST( CTDirTree ),GTK_SHADOW_NONE ); | |
533 | |
33575 | 534 if ( !pxOpenedBook ) pxOpenedBook=gdk_pixmap_create_from_xpm_d( PlayList->window,&msOpenedBook,&transparent,(gchar **)dir2_xpm ); |
535 if ( !pxClosedBook ) pxClosedBook=gdk_pixmap_create_from_xpm_d( PlayList->window,&msClosedBook,&transparent,(gchar **)open2_xpm ); | |
33572 | 536 |
537 parent=gtk_ctree_insert_node( GTK_CTREE( CTDirTree ),NULL,NULL,&root,4,pxOpenedBook,msOpenedBook,pxClosedBook,msClosedBook,FALSE,FALSE ); | |
538 DirNode=malloc( sizeof( DirNodeType ) ); | |
35493 | 539 DirNode->scaned=False; DirNode->path=strdup( root ); |
33572 | 540 gtk_ctree_node_set_row_data_full(GTK_CTREE( CTDirTree ),parent,DirNode,NULL ); |
541 sibling=gtk_ctree_insert_node( GTK_CTREE( CTDirTree ),parent,NULL,&dummy,4,NULL,NULL,NULL,NULL,TRUE,TRUE ); | |
542 gtk_ctree_expand( GTK_CTREE( CTDirTree ),parent ); | |
543 gtk_widget_show( CTDirTree ); | |
544 | |
33873 | 545 if ( fsHistory[0] ) old_path = g_filename_from_utf8( fsHistory[0], -1, NULL, NULL, NULL ); |
33572 | 546 |
547 gtk_clist_set_column_widget( GTK_CLIST( CTDirTree ),0, | |
548 AddLabel( MSGTR_PLAYLIST_DirectoryTree,NULL ) ); | |
549 | |
34347 | 550 gtk_clist_column_title_passive( GTK_CLIST( CTDirTree ),0 ); |
551 | |
33572 | 552 vbox2=AddVBox( |
553 AddFrame( NULL,1,hbox1,1 ),0 ); | |
554 | |
555 scrolledwindow2=gtk_scrolled_window_new( NULL,NULL ); | |
556 gtk_widget_show( scrolledwindow2 ); | |
557 gtk_box_pack_start( GTK_BOX( vbox2 ),scrolledwindow2,TRUE,TRUE,0 ); | |
558 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow2 ),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC ); | |
559 | |
560 CLFiles=gtk_clist_new( 1 ); | |
561 gtk_widget_show( CLFiles ); | |
562 gtk_container_add( GTK_CONTAINER( scrolledwindow2 ),CLFiles ); | |
563 gtk_clist_set_column_width( GTK_CLIST( CLFiles ),0,80 ); | |
564 gtk_clist_set_selection_mode( GTK_CLIST( CLFiles ),GTK_SELECTION_EXTENDED ); | |
565 gtk_clist_column_titles_show( GTK_CLIST( CLFiles ) ); | |
566 gtk_clist_set_shadow_type( GTK_CLIST( CLFiles ),GTK_SHADOW_NONE ); | |
567 | |
568 gtk_clist_set_column_widget( GTK_CLIST( CLFiles ),0, | |
569 AddLabel( MSGTR_PLAYLIST_Files,NULL ) ); | |
570 | |
34347 | 571 gtk_clist_column_title_passive( GTK_CLIST( CLFiles ),0 ); |
572 | |
33572 | 573 AddHSeparator( vbox2 ); |
574 | |
575 scrolledwindow3=gtk_scrolled_window_new( NULL,NULL ); | |
576 gtk_widget_show( scrolledwindow3 ); | |
577 gtk_box_pack_start( GTK_BOX( vbox2 ),scrolledwindow3,TRUE,TRUE,0 ); | |
578 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow3 ),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC ); | |
579 | |
580 CLSelected=gtk_clist_new( 2 ); | |
581 gtk_widget_show( CLSelected ); | |
582 gtk_container_add( GTK_CONTAINER( scrolledwindow3 ),CLSelected ); | |
583 gtk_clist_set_column_width( GTK_CLIST( CLSelected ),0,295 ); | |
584 gtk_clist_set_column_width( GTK_CLIST( CLSelected ),1,295 ); | |
585 gtk_clist_set_selection_mode( GTK_CLIST( CLSelected ),GTK_SELECTION_MULTIPLE ); | |
586 gtk_clist_column_titles_show( GTK_CLIST( CLSelected ) ); | |
587 gtk_clist_set_shadow_type( GTK_CLIST( CLSelected ),GTK_SHADOW_NONE ); | |
588 | |
589 gtk_clist_set_column_widget( GTK_CLIST( CLSelected ),0, | |
590 AddLabel( MSGTR_PLAYLIST_Selected,NULL ) ); | |
591 | |
592 gtk_clist_set_column_widget( GTK_CLIST( CLSelected ),1, | |
593 AddLabel( MSGTR_PLAYLIST_Path,NULL ) ); | |
594 | |
34347 | 595 gtk_clist_column_title_passive( GTK_CLIST( CLSelected ),0 ); |
596 | |
33572 | 597 AddHSeparator( vbox1 ); |
598 | |
599 hbuttonbox1=AddHButtonBox( vbox1 ); | |
600 gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox1 ),GTK_BUTTONBOX_END ); | |
601 gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox1 ),10 ); | |
602 | |
603 Add=AddButton( MSGTR_Add,hbuttonbox1 ); | |
604 Remove=AddButton( MSGTR_Remove,hbuttonbox1 ); | |
605 Ok=AddButton( MSGTR_Ok,hbuttonbox1 ); | |
606 Cancel=AddButton( MSGTR_Cancel,hbuttonbox1 ); | |
607 | |
608 gtk_widget_add_accelerator( Cancel,"clicked",accel_group,GDK_Escape,0,GTK_ACCEL_VISIBLE ); | |
609 | |
610 gtk_signal_connect( GTK_OBJECT( PlayList ),"destroy",GTK_SIGNAL_FUNC( WidgetDestroy ),&PlayList ); | |
611 | |
612 gtk_signal_connect( GTK_OBJECT( CLFiles ),"select_row",GTK_SIGNAL_FUNC( plRowSelect ),(void *)0 ); | |
613 gtk_signal_connect( GTK_OBJECT( CLFiles ),"unselect_row",GTK_SIGNAL_FUNC( plUnRowSelect ),(void *)0 ); | |
614 gtk_signal_connect( GTK_OBJECT( CLFiles ),"event",GTK_SIGNAL_FUNC( plEvent ),(void *)0 ); | |
34349 | 615 gtk_signal_connect( GTK_OBJECT( CLFiles ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void *)0 ); |
33572 | 616 sigSel=gtk_signal_connect( GTK_OBJECT( CLSelected ),"select_row",GTK_SIGNAL_FUNC( plRowSelect ),(void*)1 ); |
617 sigUnsel=gtk_signal_connect( GTK_OBJECT( CLSelected ),"unselect_row",GTK_SIGNAL_FUNC( plUnRowSelect ),(void*)1 ); | |
618 sigEvent=gtk_signal_connect( GTK_OBJECT( CLSelected ),"event",GTK_SIGNAL_FUNC( plEvent ),(void *)1 ); | |
34349 | 619 gtk_signal_connect( GTK_OBJECT( CLSelected ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void *)1 ); |
33572 | 620 |
34348 | 621 gtk_signal_connect( GTK_OBJECT( Add ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)3 ); |
622 gtk_signal_connect( GTK_OBJECT( Add ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void*)3 ); | |
623 gtk_signal_connect( GTK_OBJECT( Remove ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)2 ); | |
624 gtk_signal_connect( GTK_OBJECT( Remove ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void*)2 ); | |
625 gtk_signal_connect( GTK_OBJECT( Ok ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)1 ); | |
626 gtk_signal_connect( GTK_OBJECT( Ok ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void*)1 ); | |
627 gtk_signal_connect( GTK_OBJECT( Cancel ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)0 ); | |
628 gtk_signal_connect( GTK_OBJECT( Cancel ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void*)0 ); | |
33572 | 629 |
630 gtk_window_add_accel_group( GTK_WINDOW( PlayList ),accel_group ); | |
631 | |
632 return PlayList; | |
633 } |