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