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