Mercurial > mplayer.hg
annotate gui/dialog/playlist.c @ 35862:35f8c524864d
Do not set AVCodecContext->sub_id: It does not exist anymore.
author | cehoyos |
---|---|
date | Tue, 12 Mar 2013 21:37:44 +0000 |
parents | d186ebe43c68 |
children | 93ab56bda68a |
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 | |
35525 | 33 #include "gui/app/cfg.h" |
34 #include "gui/app/gui.h" | |
35381
746e2e0577b2
Without current playlist item, reset guiInfo's Filename and StreamType.
ib
parents:
34681
diff
changeset
|
35 #include "gui/interface.h" |
35529 | 36 #include "dialog.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 | |
35526 | 43 #include "pixmaps/open2.xpm" |
44 #include "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 { | |
35572
0827fa4c3401
While playing, allow extensive editing of the playlist without stopping.
ib
parents:
35554
diff
changeset
|
197 int 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); | |
204 } | |
35573 | 205 else |
206 { | |
207 curr.path = NULL; | |
208 curr.name = NULL; | |
209 } | |
34666 | 210 listMgr( PLAYLIST_DELETE,0 ); |
33572 | 211 for ( i=0;i<NrOfSelected;i++ ) |
212 { | |
213 char * text[3]; | |
214 item=calloc( 1,sizeof( plItem ) ); | |
215 gtk_clist_get_text( GTK_CLIST( CLSelected ),i,0,&text[0] ); | |
216 gtk_clist_get_text( GTK_CLIST( CLSelected ),i,1,&text[1] ); | |
217 item->name=g_filename_from_utf8( text[0], -1, NULL, NULL, NULL ); | |
218 if ( !item->name ) item->name = strdup( text[0] ); | |
219 item->path=g_filename_from_utf8( text[1], -1, NULL, NULL, NULL ); | |
220 if ( !item->path ) item->path = strdup( text[1] ); | |
34681 | 221 listMgr( PLAYLIST_ITEM_APPEND,item ); |
33572 | 222 } |
35461 | 223 item = listMgr( PLAYLIST_GET,0 ); |
34664
4df4d842d5fb
Remove global variable pointing to current playlist item.
ib
parents:
34663
diff
changeset
|
224 if ( item ) |
33572 | 225 { |
35578 | 226 if ( guiInfo.Playing ) |
35461 | 227 { |
228 old = listMgr( PLAYLIST_ITEM_FIND,&curr ); | |
35572
0827fa4c3401
While playing, allow extensive editing of the playlist without stopping.
ib
parents:
35554
diff
changeset
|
229 if ( old ) |
35461 | 230 { |
231 listMgr( PLAYLIST_ITEM_SET_CURR,old ); | |
35572
0827fa4c3401
While playing, allow extensive editing of the playlist without stopping.
ib
parents:
35554
diff
changeset
|
232 guiInfo.Track = (int) listMgr( PLAYLIST_ITEM_GET_POS,old ); |
35461 | 233 item = NULL; |
234 } | |
235 } | |
236 if ( item ) | |
237 { | |
238 uiSetFile( item->path,item->name,STREAMTYPE_FILE ); | |
239 guiInfo.NewPlay = GUI_FILE_NEW; | |
35577 | 240 guiInfo.PlaylistNext = !guiInfo.Playing; |
35461 | 241 guiInfo.Track = 1; |
242 } | |
33572 | 243 } |
35455
c9c79a011f6f
Fix bug with wrong track number after playlist has been cleared.
ib
parents:
35452
diff
changeset
|
244 else if (isPlaylistStreamtype && !guiInfo.Playing) uiUnsetFile(); |
35554 | 245 guiInfo.Tracks = (int) listMgr( PLAYLIST_ITEM_GET_POS,0 ); |
35461 | 246 free(curr.path); |
247 free(curr.name); | |
33572 | 248 } |
249 case 0: // cancel | |
250 HidePlayList(); | |
251 break; | |
252 case 2: // remove | |
253 { | |
35522 | 254 int i; int j; |
33572 | 255 |
256 gtk_signal_handler_block( GTK_OBJECT( CLSelected ),sigSel ); | |
257 gtk_signal_handler_block( GTK_OBJECT( CLSelected ),sigUnsel ); | |
258 gtk_signal_handler_block( GTK_OBJECT( CLSelected ),sigEvent ); | |
259 | |
260 gtk_clist_freeze( GTK_CLIST( CLSelected ) ); | |
35522 | 261 i = 0; |
262 while ( i<NrOfSelected ) | |
263 { | |
33572 | 264 if ( CLListSelected[i] ) |
265 { | |
35522 | 266 gtk_clist_remove( GTK_CLIST( CLSelected ),i ); |
267 NrOfSelected--; | |
268 for ( j=i;j<NrOfSelected;j++ ) | |
269 CLListSelected[j] = CLListSelected[j+1]; | |
33572 | 270 } |
35522 | 271 else i++; |
272 } | |
33572 | 273 gtk_clist_thaw( GTK_CLIST( CLSelected ) ); |
274 | |
275 gtk_signal_handler_unblock( GTK_OBJECT( CLSelected ),sigSel ); | |
276 gtk_signal_handler_unblock( GTK_OBJECT( CLSelected ),sigUnsel ); | |
277 gtk_signal_handler_unblock( GTK_OBJECT( CLSelected ),sigEvent ); | |
278 | |
279 } | |
280 break; | |
281 case 3: // add | |
282 { | |
283 int i; | |
284 void *p; | |
285 char * itext[1][2]; | |
286 gchar * cpath; | |
287 char * text[1][3]; text[0][2]=""; | |
288 gtk_clist_freeze( GTK_CLIST( CLSelected ) ); | |
289 for ( i=0;i<NrOfEntrys;i++ ) | |
290 { | |
291 if ( CLFileSelected[i] ) | |
292 { | |
293 NrOfSelected++; | |
294 p=realloc( CLListSelected,NrOfSelected * sizeof( int ) ); | |
295 if ( !p ) NrOfSelected--; | |
296 else | |
297 { | |
298 CLListSelected=p; | |
35493 | 299 CLListSelected[NrOfSelected - 1]=False; |
33572 | 300 gtk_clist_get_text( GTK_CLIST( CLFiles ),i,0,(char **)&itext ); |
301 cpath=g_filename_to_utf8( current_path, -1, NULL, NULL, NULL ); | |
302 text[0][0]=itext[0][0]; text[0][1]=cpath ? cpath : current_path; | |
303 gtk_clist_append( GTK_CLIST( CLSelected ),text[0] ); | |
304 g_free( cpath ); | |
305 } | |
306 } | |
307 } | |
308 gtk_clist_thaw( GTK_CLIST( CLSelected ) ); | |
309 } | |
310 break; | |
311 } | |
312 } | |
313 | |
34348 | 314 static gboolean plKeyReleased( GtkWidget * widget, |
315 GdkEventKey * event, | |
316 gpointer user_data ) | |
317 { | |
34349 | 318 if (event->keyval == GDK_Return) |
319 { | |
320 if ( GTK_WIDGET_TYPE( widget ) == GTK_TYPE_BUTTON ) plButtonReleased( NULL, user_data ); | |
321 else | |
322 { | |
323 switch ( (int) user_data ) | |
324 { | |
325 case 0: | |
326 plButtonReleased( NULL, (void *) 3 ); | |
327 break; | |
328 case 1: | |
329 plButtonReleased( NULL, (void *) 2 ); | |
330 break; | |
331 } | |
332 } | |
333 } | |
34348 | 334 return FALSE; |
335 } | |
336 | |
33572 | 337 static gboolean plEvent ( GtkWidget * widget, |
338 GdkEvent * event, | |
339 gpointer user_data ) | |
340 { | |
341 GdkEventButton *bevent; | |
342 gint row, col; | |
343 | |
344 bevent = (GdkEventButton *) event; | |
345 | |
346 if ( event->type == GDK_BUTTON_RELEASE && bevent->button == 2 ) | |
347 { | |
348 if ( gtk_clist_get_selection_info( GTK_CLIST( widget ), bevent->x, bevent->y, &row, &col ) ) | |
349 { | |
350 switch ( (int) user_data ) | |
351 { | |
352 case 0: | |
35493 | 353 CLFileSelected[row] = True; |
33572 | 354 plButtonReleased( NULL, (void *) 3 ); |
35493 | 355 CLFileSelected[row] = False; |
33572 | 356 return TRUE; |
357 | |
358 case 1: | |
35493 | 359 CLListSelected[row] = True; |
33572 | 360 plButtonReleased( NULL, (void *) 2 ); |
361 return TRUE; | |
362 } | |
363 } | |
364 } | |
365 | |
366 return FALSE; | |
367 } | |
368 | |
369 static int check_for_subdir( gchar * path ) | |
370 { | |
371 DIR * dir; | |
372 struct dirent * dirent; | |
373 struct stat statbuf; | |
374 gchar * npath; | |
375 | |
376 if ( (dir=opendir( path )) ) | |
377 { | |
378 while ( (dirent=readdir( dir )) ) | |
379 { | |
380 if ( dirent->d_name[0] != '.' ) | |
381 { | |
382 npath=calloc( 1,strlen( path ) + strlen( dirent->d_name ) + 3 ); | |
383 sprintf( npath,"%s/%s",path,dirent->d_name ); | |
384 if ( stat( npath,&statbuf ) != -1 && S_ISDIR( statbuf.st_mode ) ) | |
35493 | 385 { free( npath ); closedir( dir ); return True; } |
33572 | 386 free( npath ); |
387 } | |
388 } | |
389 closedir( dir ); | |
390 } | |
35493 | 391 return False; |
33572 | 392 } |
393 | |
394 static void plCTree( GtkCTree * ctree,GtkCTreeNode * parent_node,gpointer user_data ) | |
395 { | |
396 GtkCTreeNode * node; | |
397 DirNodeType * DirNode; | |
398 gchar * text, * name = NULL; | |
399 gchar * dummy = "dummy"; | |
35493 | 400 int subdir = True; |
33572 | 401 DIR * dir = NULL; |
402 struct dirent * dirent; | |
403 gchar * path; | |
404 struct stat statbuf; | |
405 | |
406 DirNode=gtk_ctree_node_get_row_data( ctree,parent_node ); | |
407 if ( !DirNode->scaned ) | |
408 { | |
35493 | 409 DirNode->scaned=True; current_path=DirNode->path; |
33572 | 410 gtk_clist_freeze( GTK_CLIST( ctree ) ); |
411 node=gtk_ctree_find_by_row_data( ctree,parent_node,NULL ); | |
412 gtk_ctree_remove_node( ctree,node ); | |
413 | |
414 if ( (dir=opendir( DirNode->path ) ) ) | |
415 { | |
416 while( (dirent=readdir( dir )) ) | |
417 { | |
418 path=calloc( 1,strlen( DirNode->path ) + strlen( dirent->d_name ) + 2 ); | |
419 if ( !strcmp( current_path,"/" ) ) sprintf( path,"/%s",dirent->d_name ); | |
420 else sprintf( path,"%s/%s",current_path,dirent->d_name ); | |
421 text=dirent->d_name; | |
422 g_free( name ); | |
423 name=g_filename_to_utf8( text, -1, NULL, NULL, NULL ); | |
424 | |
425 if ( stat( path,&statbuf ) != -1 && S_ISDIR( statbuf.st_mode ) && dirent->d_name[0] != '.' ) | |
426 { | |
35493 | 427 DirNode=malloc( sizeof( DirNodeType ) ); DirNode->scaned=False; DirNode->path=strdup( path ); |
33572 | 428 subdir=check_for_subdir( path ); |
429 node=gtk_ctree_insert_node( ctree,parent_node,NULL,(name ? &name : &text ),4,pxOpenedBook,msOpenedBook,pxClosedBook,msClosedBook,!subdir,FALSE ); | |
430 gtk_ctree_node_set_row_data_full( ctree,node,DirNode,NULL ); | |
35403 | 431 if ( subdir ) gtk_ctree_insert_node( ctree,node,NULL,&dummy,4,NULL,NULL,NULL,NULL,FALSE,FALSE ); |
33572 | 432 } |
433 free( path ); path=NULL; | |
434 } | |
435 closedir( dir ); | |
436 } | |
437 | |
438 gtk_ctree_sort_node( ctree,parent_node ); | |
439 gtk_clist_thaw( GTK_CLIST( ctree ) ); | |
440 } | |
441 | |
442 g_free( name ); | |
443 } | |
444 | |
445 static void scan_dir( char * path ) | |
446 { | |
447 DIR * dir = NULL; | |
448 char * curr; | |
449 struct dirent * dirent; | |
450 struct stat statbuf; | |
451 gchar * name; | |
452 char * text[1][2]; text[0][1]=""; | |
453 | |
454 gtk_clist_clear( GTK_CLIST( CLFiles ) ); | |
455 if ( (dir=opendir( path )) ) | |
456 { | |
457 NrOfEntrys=0; | |
458 while( (dirent=readdir( dir )) ) | |
459 { | |
460 curr=calloc( 1,strlen( path ) + strlen( dirent->d_name ) + 3 ); sprintf( curr,"%s/%s",path,dirent->d_name ); | |
461 if ( stat( curr,&statbuf ) != -1 && ( S_ISREG( statbuf.st_mode ) || S_ISLNK( statbuf.st_mode ) ) ) | |
462 { | |
463 name=g_filename_to_utf8( dirent->d_name, -1, NULL, NULL, NULL ); | |
464 text[0][0]=name ? name : dirent->d_name; | |
465 gtk_clist_append( GTK_CLIST( CLFiles ), text[0] ); | |
466 g_free( name ); | |
467 NrOfEntrys++; | |
468 } | |
469 free( curr ); | |
470 } | |
471 closedir( dir ); | |
472 gtk_clist_sort( GTK_CLIST( CLFiles ) ); | |
473 } | |
474 } | |
475 | |
34466
a650895d50a5
Use correct data types and common variable names in GTK callback functions.
ib
parents:
34349
diff
changeset
|
476 static void plCTRow(GtkCList * clist, gint row, gint column, GdkEvent * event, gpointer user_data) |
33572 | 477 { |
478 DirNodeType * DirNode; | |
479 GtkCTreeNode * node; | |
34466
a650895d50a5
Use correct data types and common variable names in GTK callback functions.
ib
parents:
34349
diff
changeset
|
480 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
|
481 DirNode=gtk_ctree_node_get_row_data( GTK_CTREE( clist ),node ); |
33572 | 482 current_path=DirNode->path; |
34466
a650895d50a5
Use correct data types and common variable names in GTK callback functions.
ib
parents:
34349
diff
changeset
|
483 gtk_ctree_expand( GTK_CTREE( clist ),node ); |
33572 | 484 scan_dir( DirNode->path ); |
485 free( CLFileSelected ); | |
486 CLFileSelected=calloc( 1,NrOfEntrys * sizeof( int ) ); | |
487 } | |
488 | |
489 GtkWidget * create_PlayList( void ) | |
490 { | |
491 GtkWidget * vbox1; | |
492 GtkWidget * hbox1; | |
493 GtkWidget * scrolledwindow1; | |
494 GtkWidget * vbox2; | |
495 GtkWidget * scrolledwindow2; | |
496 GtkWidget * scrolledwindow3; | |
497 GtkWidget * hbuttonbox1; | |
498 GtkAccelGroup * accel_group; | |
499 GdkColor transparent = { 0,0,0,0 }; | |
500 gchar * root = "/"; | |
501 gchar * dummy = "dummy"; | |
502 DirNodeType * DirNode; | |
503 | |
504 accel_group=gtk_accel_group_new(); | |
505 | |
506 PlayList=gtk_window_new( GTK_WINDOW_TOPLEVEL ); | |
507 gtk_object_set_data( GTK_OBJECT( PlayList ),"PlayList",PlayList ); | |
508 gtk_widget_set_usize( PlayList,512,384 ); | |
509 gtk_window_set_title( GTK_WINDOW( PlayList ),MSGTR_PlayList ); | |
510 gtk_window_set_position( GTK_WINDOW( PlayList ),GTK_WIN_POS_CENTER ); | |
511 // gtk_window_set_policy( GTK_WINDOW( PlayList ),FALSE,FALSE,FALSE ); | |
512 gtk_window_set_wmclass( GTK_WINDOW( PlayList ),"Playlist","MPlayer" ); | |
513 | |
514 gtk_widget_realize( PlayList ); | |
515 gtkAddIcon( PlayList ); | |
516 | |
517 vbox1=AddVBox( AddDialogFrame( PlayList ),0 ); | |
518 hbox1=AddHBox( NULL,1 ); | |
519 gtk_box_pack_start( GTK_BOX( vbox1 ),hbox1,TRUE,TRUE,0 ); | |
520 | |
521 scrolledwindow1=gtk_scrolled_window_new( NULL,NULL ); | |
522 gtk_widget_show( scrolledwindow1 ); | |
523 gtk_container_add( GTK_CONTAINER( | |
524 AddFrame( NULL,0,hbox1,1 ) ),scrolledwindow1 ); | |
525 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow1 ),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC ); | |
526 | |
527 CTDirTree=gtk_ctree_new( 1,0 ); | |
528 gtk_signal_connect( GTK_OBJECT( CTDirTree ),"tree_expand",GTK_SIGNAL_FUNC( plCTree ),(void*)0 ); | |
529 gtk_signal_connect( GTK_OBJECT( CTDirTree ),"select_row",GTK_SIGNAL_FUNC( plCTRow ),(void *)0 ); | |
530 gtk_container_add( GTK_CONTAINER( scrolledwindow1 ),CTDirTree ); | |
531 gtk_clist_set_column_auto_resize( GTK_CLIST( CTDirTree ),0,TRUE ); | |
532 gtk_clist_set_column_width( GTK_CLIST( CTDirTree ),0,80 ); | |
533 gtk_clist_set_selection_mode( GTK_CLIST( CTDirTree ),GTK_SELECTION_SINGLE ); | |
534 gtk_ctree_set_line_style( GTK_CTREE( CTDirTree ),GTK_CTREE_LINES_SOLID ); | |
535 gtk_clist_column_titles_show( GTK_CLIST( CTDirTree ) ); | |
536 gtk_clist_set_shadow_type( GTK_CLIST( CTDirTree ),GTK_SHADOW_NONE ); | |
537 | |
33575 | 538 if ( !pxOpenedBook ) pxOpenedBook=gdk_pixmap_create_from_xpm_d( PlayList->window,&msOpenedBook,&transparent,(gchar **)dir2_xpm ); |
539 if ( !pxClosedBook ) pxClosedBook=gdk_pixmap_create_from_xpm_d( PlayList->window,&msClosedBook,&transparent,(gchar **)open2_xpm ); | |
33572 | 540 |
541 parent=gtk_ctree_insert_node( GTK_CTREE( CTDirTree ),NULL,NULL,&root,4,pxOpenedBook,msOpenedBook,pxClosedBook,msClosedBook,FALSE,FALSE ); | |
542 DirNode=malloc( sizeof( DirNodeType ) ); | |
35493 | 543 DirNode->scaned=False; DirNode->path=strdup( root ); |
33572 | 544 gtk_ctree_node_set_row_data_full(GTK_CTREE( CTDirTree ),parent,DirNode,NULL ); |
545 sibling=gtk_ctree_insert_node( GTK_CTREE( CTDirTree ),parent,NULL,&dummy,4,NULL,NULL,NULL,NULL,TRUE,TRUE ); | |
546 gtk_ctree_expand( GTK_CTREE( CTDirTree ),parent ); | |
547 gtk_widget_show( CTDirTree ); | |
548 | |
33873 | 549 if ( fsHistory[0] ) old_path = g_filename_from_utf8( fsHistory[0], -1, NULL, NULL, NULL ); |
33572 | 550 |
551 gtk_clist_set_column_widget( GTK_CLIST( CTDirTree ),0, | |
552 AddLabel( MSGTR_PLAYLIST_DirectoryTree,NULL ) ); | |
553 | |
34347 | 554 gtk_clist_column_title_passive( GTK_CLIST( CTDirTree ),0 ); |
555 | |
33572 | 556 vbox2=AddVBox( |
557 AddFrame( NULL,1,hbox1,1 ),0 ); | |
558 | |
559 scrolledwindow2=gtk_scrolled_window_new( NULL,NULL ); | |
560 gtk_widget_show( scrolledwindow2 ); | |
561 gtk_box_pack_start( GTK_BOX( vbox2 ),scrolledwindow2,TRUE,TRUE,0 ); | |
562 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow2 ),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC ); | |
563 | |
564 CLFiles=gtk_clist_new( 1 ); | |
565 gtk_widget_show( CLFiles ); | |
566 gtk_container_add( GTK_CONTAINER( scrolledwindow2 ),CLFiles ); | |
567 gtk_clist_set_column_width( GTK_CLIST( CLFiles ),0,80 ); | |
568 gtk_clist_set_selection_mode( GTK_CLIST( CLFiles ),GTK_SELECTION_EXTENDED ); | |
569 gtk_clist_column_titles_show( GTK_CLIST( CLFiles ) ); | |
570 gtk_clist_set_shadow_type( GTK_CLIST( CLFiles ),GTK_SHADOW_NONE ); | |
571 | |
572 gtk_clist_set_column_widget( GTK_CLIST( CLFiles ),0, | |
573 AddLabel( MSGTR_PLAYLIST_Files,NULL ) ); | |
574 | |
34347 | 575 gtk_clist_column_title_passive( GTK_CLIST( CLFiles ),0 ); |
576 | |
33572 | 577 AddHSeparator( vbox2 ); |
578 | |
579 scrolledwindow3=gtk_scrolled_window_new( NULL,NULL ); | |
580 gtk_widget_show( scrolledwindow3 ); | |
581 gtk_box_pack_start( GTK_BOX( vbox2 ),scrolledwindow3,TRUE,TRUE,0 ); | |
582 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow3 ),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC ); | |
583 | |
584 CLSelected=gtk_clist_new( 2 ); | |
585 gtk_widget_show( CLSelected ); | |
586 gtk_container_add( GTK_CONTAINER( scrolledwindow3 ),CLSelected ); | |
587 gtk_clist_set_column_width( GTK_CLIST( CLSelected ),0,295 ); | |
588 gtk_clist_set_column_width( GTK_CLIST( CLSelected ),1,295 ); | |
589 gtk_clist_set_selection_mode( GTK_CLIST( CLSelected ),GTK_SELECTION_MULTIPLE ); | |
590 gtk_clist_column_titles_show( GTK_CLIST( CLSelected ) ); | |
591 gtk_clist_set_shadow_type( GTK_CLIST( CLSelected ),GTK_SHADOW_NONE ); | |
592 | |
593 gtk_clist_set_column_widget( GTK_CLIST( CLSelected ),0, | |
594 AddLabel( MSGTR_PLAYLIST_Selected,NULL ) ); | |
595 | |
596 gtk_clist_set_column_widget( GTK_CLIST( CLSelected ),1, | |
597 AddLabel( MSGTR_PLAYLIST_Path,NULL ) ); | |
598 | |
34347 | 599 gtk_clist_column_title_passive( GTK_CLIST( CLSelected ),0 ); |
600 | |
33572 | 601 AddHSeparator( vbox1 ); |
602 | |
603 hbuttonbox1=AddHButtonBox( vbox1 ); | |
604 gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox1 ),GTK_BUTTONBOX_END ); | |
605 gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox1 ),10 ); | |
606 | |
607 Add=AddButton( MSGTR_Add,hbuttonbox1 ); | |
608 Remove=AddButton( MSGTR_Remove,hbuttonbox1 ); | |
609 Ok=AddButton( MSGTR_Ok,hbuttonbox1 ); | |
610 Cancel=AddButton( MSGTR_Cancel,hbuttonbox1 ); | |
611 | |
612 gtk_widget_add_accelerator( Cancel,"clicked",accel_group,GDK_Escape,0,GTK_ACCEL_VISIBLE ); | |
613 | |
614 gtk_signal_connect( GTK_OBJECT( PlayList ),"destroy",GTK_SIGNAL_FUNC( WidgetDestroy ),&PlayList ); | |
615 | |
616 gtk_signal_connect( GTK_OBJECT( CLFiles ),"select_row",GTK_SIGNAL_FUNC( plRowSelect ),(void *)0 ); | |
617 gtk_signal_connect( GTK_OBJECT( CLFiles ),"unselect_row",GTK_SIGNAL_FUNC( plUnRowSelect ),(void *)0 ); | |
618 gtk_signal_connect( GTK_OBJECT( CLFiles ),"event",GTK_SIGNAL_FUNC( plEvent ),(void *)0 ); | |
34349 | 619 gtk_signal_connect( GTK_OBJECT( CLFiles ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void *)0 ); |
33572 | 620 sigSel=gtk_signal_connect( GTK_OBJECT( CLSelected ),"select_row",GTK_SIGNAL_FUNC( plRowSelect ),(void*)1 ); |
621 sigUnsel=gtk_signal_connect( GTK_OBJECT( CLSelected ),"unselect_row",GTK_SIGNAL_FUNC( plUnRowSelect ),(void*)1 ); | |
622 sigEvent=gtk_signal_connect( GTK_OBJECT( CLSelected ),"event",GTK_SIGNAL_FUNC( plEvent ),(void *)1 ); | |
34349 | 623 gtk_signal_connect( GTK_OBJECT( CLSelected ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void *)1 ); |
33572 | 624 |
34348 | 625 gtk_signal_connect( GTK_OBJECT( Add ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)3 ); |
626 gtk_signal_connect( GTK_OBJECT( Add ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void*)3 ); | |
627 gtk_signal_connect( GTK_OBJECT( Remove ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)2 ); | |
628 gtk_signal_connect( GTK_OBJECT( Remove ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void*)2 ); | |
629 gtk_signal_connect( GTK_OBJECT( Ok ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)1 ); | |
630 gtk_signal_connect( GTK_OBJECT( Ok ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void*)1 ); | |
631 gtk_signal_connect( GTK_OBJECT( Cancel ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)0 ); | |
632 gtk_signal_connect( GTK_OBJECT( Cancel ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void*)0 ); | |
33572 | 633 |
634 gtk_window_add_accel_group( GTK_WINDOW( PlayList ),accel_group ); | |
635 | |
636 return PlayList; | |
637 } |