Mercurial > mplayer.hg
annotate gui/dialog/playlist.c @ 35960:13d09ba17e97
Be more precise about type.
author | ib |
---|---|
date | Sun, 24 Mar 2013 15:12:16 +0000 |
parents | 8515446e81c6 |
children | db72a3183d41 |
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 |
35872
93ab56bda68a
Utilize new cfg_old_filename_from_utf8() in playlist code.
ib
parents:
35578
diff
changeset
|
46 #define CFG_OLD_PLAYLIST 1 |
93ab56bda68a
Utilize new cfg_old_filename_from_utf8() in playlist code.
ib
parents:
35578
diff
changeset
|
47 #include "gui/app/cfg-old.c" |
93ab56bda68a
Utilize new cfg_old_filename_from_utf8() in playlist code.
ib
parents:
35578
diff
changeset
|
48 |
33572 | 49 GtkWidget * PlayList = NULL; |
50 static GtkWidget * CTDirTree; | |
51 static GtkWidget * CLFiles; | |
52 static GtkWidget * CLSelected; | |
53 static GtkWidget * Add; | |
54 static GtkWidget * Remove; | |
55 static GtkWidget * Ok; | |
56 static GtkWidget * Cancel; | |
57 static GdkPixmap * pxOpenedBook; | |
58 static GdkPixmap * pxClosedBook; | |
59 static GdkBitmap * msOpenedBook; | |
60 static GdkBitmap * msClosedBook; | |
61 | |
62 static int NrOfEntrys = 0; | |
63 static int NrOfSelected = 0; | |
64 static int * CLFileSelected = NULL; | |
65 static int * CLListSelected = NULL; | |
66 | |
67 static int sigSel; | |
68 static int sigUnsel; | |
69 static int sigEvent; | |
70 | |
71 typedef struct | |
72 { | |
73 int scaned; | |
74 char * path; | |
75 } DirNodeType; | |
76 | |
77 static GtkCTreeNode * sibling; | |
78 static GtkCTreeNode * parent; | |
79 static gchar * current_path; | |
80 static gchar * old_path = NULL; | |
81 | |
82 static int compare_func(const void *a, const void *b) | |
83 { | |
84 char * tmp; | |
85 int i; | |
86 if ( !a || !b || !( (DirNodeType *)a )->path ) return -1; | |
87 tmp=strdup( (char *)b ); tmp[strlen( tmp )-1]=0; | |
88 i=strcmp( ( (DirNodeType *)a )->path,tmp ); | |
89 free( tmp ); | |
90 return i; | |
91 } | |
92 | |
93 static void scan_dir( char * path ); | |
94 | |
95 void ShowPlayList( void ) | |
96 { | |
34667 | 97 plItem * next; |
98 | |
33572 | 99 if ( PlayList ) gtkActive( PlayList ); |
100 else PlayList=create_PlayList(); | |
101 | |
102 if ( old_path && *old_path ) | |
103 { | |
104 char * currentdir = strdup( old_path ); | |
105 char * tpath,* pos; | |
106 GtkCTreeNode * node,* nextnode; | |
107 gboolean leaf; | |
108 tpath=strdup( "/" ); | |
109 pos=strtok( currentdir,"/" ); | |
110 node=gtk_ctree_find_by_row_data_custom( GTK_CTREE( CTDirTree ),NULL,"/",compare_func ); | |
111 do | |
112 { | |
113 char * tpathnew = g_strconcat( tpath,pos,"/",NULL ); | |
114 free( tpath ); tpath=tpathnew; | |
115 nextnode=gtk_ctree_find_by_row_data_custom( GTK_CTREE( CTDirTree ),node,tpath,compare_func ); | |
116 if ( !nextnode ) break; | |
117 node=nextnode; | |
118 pos=strtok( NULL,"/" ); | |
119 gtk_ctree_get_node_info( GTK_CTREE( CTDirTree ),node,NULL,NULL,NULL,NULL,NULL,NULL,&leaf,NULL ); | |
120 if ( !leaf && pos ) gtk_ctree_expand( GTK_CTREE( CTDirTree ),node ); | |
121 else | |
122 { | |
123 DirNodeType * DirNode; | |
124 gtk_ctree_select( GTK_CTREE( CTDirTree ),node ); | |
125 DirNode=gtk_ctree_node_get_row_data( GTK_CTREE( CTDirTree ),node ); | |
126 current_path=DirNode->path; | |
127 scan_dir( DirNode->path ); | |
128 free( CLFileSelected ); | |
129 CLFileSelected=calloc( 1,NrOfEntrys * sizeof( int ) ); | |
130 break; | |
131 } | |
132 } while( pos ); | |
133 free( tpath ); | |
134 free( currentdir ); | |
135 } | |
136 else gtk_ctree_select( GTK_CTREE( CTDirTree ),parent ); | |
137 | |
138 gtk_clist_freeze( GTK_CLIST( CLSelected ) ); | |
139 gtk_clist_clear( GTK_CLIST( CLSelected ) ); | |
34667 | 140 next = listMgr( PLAYLIST_GET,0 ); |
141 if ( next ) | |
33572 | 142 { |
143 while ( next || next->next ) | |
144 { | |
35927 | 145 char * text[1][5]; text[0][4]=""; |
146 text[0][0]=g_filename_display_name( next->name ); | |
147 text[0][1]=g_filename_display_name( next->path ); | |
148 text[0][2]=next->name; | |
149 text[0][3]=next->path; | |
33572 | 150 gtk_clist_append( GTK_CLIST( CLSelected ),text[0] ); |
35927 | 151 g_free( text[0][0] ); |
152 g_free( text[0][1] ); | |
33572 | 153 NrOfSelected++; |
154 if ( next->next ) next=next->next; else break; | |
155 } | |
156 CLListSelected=calloc( 1,NrOfSelected * sizeof( int ) ); | |
157 } | |
158 gtk_clist_thaw( GTK_CLIST( CLSelected ) ); | |
159 | |
160 gtk_widget_show( PlayList ); | |
161 } | |
162 | |
163 void HidePlayList( void ) | |
164 { | |
165 if ( !PlayList ) return; | |
166 NrOfSelected=NrOfEntrys=0; | |
33739 | 167 nfree( CLListSelected ); nfree( CLFileSelected ); |
33572 | 168 free( old_path ); |
169 old_path=strdup( current_path ); | |
170 gtk_widget_hide( PlayList ); | |
171 gtk_widget_destroy( PlayList ); | |
172 PlayList=NULL; | |
173 } | |
174 | |
175 static void plRowSelect( GtkCList * clist,gint row,gint column,GdkEvent * event,gpointer user_data ) | |
176 { | |
177 switch ( (int) user_data ) | |
178 { | |
35493 | 179 case 0: CLFileSelected[row]=True; break; |
180 case 1: CLListSelected[row]=True; break; | |
33572 | 181 } |
182 } | |
183 | |
184 static void plUnRowSelect( GtkCList * clist,gint row,gint column,GdkEvent * event,gpointer user_data ) | |
185 { | |
186 switch ( (int) user_data ) | |
187 { | |
35493 | 188 case 0: CLFileSelected[row]=False; break; |
189 case 1: CLListSelected[row]=False; break; | |
33572 | 190 } |
191 } | |
192 | |
193 static void plButtonReleased( GtkButton * button,gpointer user_data ) | |
194 { | |
195 switch ( (int) user_data ) | |
196 { | |
197 case 1: // ok | |
198 { | |
35572
0827fa4c3401
While playing, allow extensive editing of the playlist without stopping.
ib
parents:
35554
diff
changeset
|
199 int i; |
35461 | 200 plItem curr, * item, * old; |
201 item = listMgr( PLAYLIST_ITEM_GET_CURR,0 ); | |
202 if (item) | |
203 { | |
204 curr.path = gstrdup(item->path); | |
205 curr.name = gstrdup(item->name); | |
206 } | |
35573 | 207 else |
208 { | |
209 curr.path = NULL; | |
210 curr.name = NULL; | |
211 } | |
34666 | 212 listMgr( PLAYLIST_DELETE,0 ); |
33572 | 213 for ( i=0;i<NrOfSelected;i++ ) |
214 { | |
35927 | 215 char * text[2]; |
33572 | 216 item=calloc( 1,sizeof( plItem ) ); |
35927 | 217 gtk_clist_get_text( GTK_CLIST( CLSelected ),i,2,&text[0] ); |
218 gtk_clist_get_text( GTK_CLIST( CLSelected ),i,3,&text[1] ); | |
219 item->name = strdup( text[0] ); | |
220 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; | |
35927 | 285 char * itext[2]; |
286 char * text[1][5]; text[0][4]=""; | |
33572 | 287 gtk_clist_freeze( GTK_CLIST( CLSelected ) ); |
288 for ( i=0;i<NrOfEntrys;i++ ) | |
289 { | |
290 if ( CLFileSelected[i] ) | |
291 { | |
292 NrOfSelected++; | |
293 p=realloc( CLListSelected,NrOfSelected * sizeof( int ) ); | |
294 if ( !p ) NrOfSelected--; | |
295 else | |
296 { | |
297 CLListSelected=p; | |
35493 | 298 CLListSelected[NrOfSelected - 1]=False; |
35927 | 299 gtk_clist_get_text( GTK_CLIST( CLFiles ),i,0,&itext[0] ); |
300 gtk_clist_get_text( GTK_CLIST( CLFiles ),i,1,&itext[1] ); | |
301 text[0][0]=itext[0]; text[0][1]=g_filename_display_name( current_path ); | |
302 text[0][2]=itext[1]; text[0][3]=current_path; | |
33572 | 303 gtk_clist_append( GTK_CLIST( CLSelected ),text[0] ); |
35927 | 304 g_free( text[0][1] ); |
33572 | 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; | |
35938
8515446e81c6
Cosmetic: Rename variables holding data in UTF-8 encoding.
ib
parents:
35927
diff
changeset
|
398 gchar * text, * utf8name = NULL; |
33572 | 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; | |
35938
8515446e81c6
Cosmetic: Rename variables holding data in UTF-8 encoding.
ib
parents:
35927
diff
changeset
|
422 g_free( utf8name ); |
8515446e81c6
Cosmetic: Rename variables holding data in UTF-8 encoding.
ib
parents:
35927
diff
changeset
|
423 utf8name=g_filename_display_name( text ); |
33572 | 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 ); |
35938
8515446e81c6
Cosmetic: Rename variables holding data in UTF-8 encoding.
ib
parents:
35927
diff
changeset
|
429 node=gtk_ctree_insert_node( ctree,parent_node,NULL,&utf8name,4,pxOpenedBook,msOpenedBook,pxClosedBook,msClosedBook,!subdir,FALSE ); |
33572 | 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 | |
35938
8515446e81c6
Cosmetic: Rename variables holding data in UTF-8 encoding.
ib
parents:
35927
diff
changeset
|
442 g_free( utf8name ); |
33572 | 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; | |
35927 | 451 char * text[1][3]; text[0][2]=""; |
33572 | 452 |
453 gtk_clist_clear( GTK_CLIST( CLFiles ) ); | |
454 if ( (dir=opendir( path )) ) | |
455 { | |
456 NrOfEntrys=0; | |
457 while( (dirent=readdir( dir )) ) | |
458 { | |
459 curr=calloc( 1,strlen( path ) + strlen( dirent->d_name ) + 3 ); sprintf( curr,"%s/%s",path,dirent->d_name ); | |
460 if ( stat( curr,&statbuf ) != -1 && ( S_ISREG( statbuf.st_mode ) || S_ISLNK( statbuf.st_mode ) ) ) | |
461 { | |
35927 | 462 text[0][0]=g_filename_display_name( dirent->d_name ); |
463 text[0][1]=dirent->d_name; | |
33572 | 464 gtk_clist_append( GTK_CLIST( CLFiles ), text[0] ); |
35927 | 465 g_free( text[0][0] ); |
33572 | 466 NrOfEntrys++; |
467 } | |
468 free( curr ); | |
469 } | |
470 closedir( dir ); | |
471 gtk_clist_sort( GTK_CLIST( CLFiles ) ); | |
472 } | |
473 } | |
474 | |
34466
a650895d50a5
Use correct data types and common variable names in GTK callback functions.
ib
parents:
34349
diff
changeset
|
475 static void plCTRow(GtkCList * clist, gint row, gint column, GdkEvent * event, gpointer user_data) |
33572 | 476 { |
477 DirNodeType * DirNode; | |
478 GtkCTreeNode * node; | |
34466
a650895d50a5
Use correct data types and common variable names in GTK callback functions.
ib
parents:
34349
diff
changeset
|
479 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
|
480 DirNode=gtk_ctree_node_get_row_data( GTK_CTREE( clist ),node ); |
33572 | 481 current_path=DirNode->path; |
34466
a650895d50a5
Use correct data types and common variable names in GTK callback functions.
ib
parents:
34349
diff
changeset
|
482 gtk_ctree_expand( GTK_CTREE( clist ),node ); |
33572 | 483 scan_dir( DirNode->path ); |
484 free( CLFileSelected ); | |
485 CLFileSelected=calloc( 1,NrOfEntrys * sizeof( int ) ); | |
486 } | |
487 | |
488 GtkWidget * create_PlayList( void ) | |
489 { | |
490 GtkWidget * vbox1; | |
491 GtkWidget * hbox1; | |
492 GtkWidget * scrolledwindow1; | |
493 GtkWidget * vbox2; | |
494 GtkWidget * scrolledwindow2; | |
495 GtkWidget * scrolledwindow3; | |
496 GtkWidget * hbuttonbox1; | |
497 GtkAccelGroup * accel_group; | |
498 GdkColor transparent = { 0,0,0,0 }; | |
499 gchar * root = "/"; | |
500 gchar * dummy = "dummy"; | |
501 DirNodeType * DirNode; | |
502 | |
503 accel_group=gtk_accel_group_new(); | |
504 | |
505 PlayList=gtk_window_new( GTK_WINDOW_TOPLEVEL ); | |
506 gtk_object_set_data( GTK_OBJECT( PlayList ),"PlayList",PlayList ); | |
507 gtk_widget_set_usize( PlayList,512,384 ); | |
508 gtk_window_set_title( GTK_WINDOW( PlayList ),MSGTR_PlayList ); | |
509 gtk_window_set_position( GTK_WINDOW( PlayList ),GTK_WIN_POS_CENTER ); | |
510 // gtk_window_set_policy( GTK_WINDOW( PlayList ),FALSE,FALSE,FALSE ); | |
511 gtk_window_set_wmclass( GTK_WINDOW( PlayList ),"Playlist","MPlayer" ); | |
512 | |
513 gtk_widget_realize( PlayList ); | |
514 gtkAddIcon( PlayList ); | |
515 | |
516 vbox1=AddVBox( AddDialogFrame( PlayList ),0 ); | |
517 hbox1=AddHBox( NULL,1 ); | |
518 gtk_box_pack_start( GTK_BOX( vbox1 ),hbox1,TRUE,TRUE,0 ); | |
519 | |
520 scrolledwindow1=gtk_scrolled_window_new( NULL,NULL ); | |
521 gtk_widget_show( scrolledwindow1 ); | |
522 gtk_container_add( GTK_CONTAINER( | |
523 AddFrame( NULL,0,hbox1,1 ) ),scrolledwindow1 ); | |
524 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow1 ),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC ); | |
525 | |
526 CTDirTree=gtk_ctree_new( 1,0 ); | |
527 gtk_signal_connect( GTK_OBJECT( CTDirTree ),"tree_expand",GTK_SIGNAL_FUNC( plCTree ),(void*)0 ); | |
528 gtk_signal_connect( GTK_OBJECT( CTDirTree ),"select_row",GTK_SIGNAL_FUNC( plCTRow ),(void *)0 ); | |
529 gtk_container_add( GTK_CONTAINER( scrolledwindow1 ),CTDirTree ); | |
530 gtk_clist_set_column_auto_resize( GTK_CLIST( CTDirTree ),0,TRUE ); | |
531 gtk_clist_set_column_width( GTK_CLIST( CTDirTree ),0,80 ); | |
532 gtk_clist_set_selection_mode( GTK_CLIST( CTDirTree ),GTK_SELECTION_SINGLE ); | |
533 gtk_ctree_set_line_style( GTK_CTREE( CTDirTree ),GTK_CTREE_LINES_SOLID ); | |
534 gtk_clist_column_titles_show( GTK_CLIST( CTDirTree ) ); | |
535 gtk_clist_set_shadow_type( GTK_CLIST( CTDirTree ),GTK_SHADOW_NONE ); | |
536 | |
33575 | 537 if ( !pxOpenedBook ) pxOpenedBook=gdk_pixmap_create_from_xpm_d( PlayList->window,&msOpenedBook,&transparent,(gchar **)dir2_xpm ); |
538 if ( !pxClosedBook ) pxClosedBook=gdk_pixmap_create_from_xpm_d( PlayList->window,&msClosedBook,&transparent,(gchar **)open2_xpm ); | |
33572 | 539 |
540 parent=gtk_ctree_insert_node( GTK_CTREE( CTDirTree ),NULL,NULL,&root,4,pxOpenedBook,msOpenedBook,pxClosedBook,msClosedBook,FALSE,FALSE ); | |
541 DirNode=malloc( sizeof( DirNodeType ) ); | |
35493 | 542 DirNode->scaned=False; DirNode->path=strdup( root ); |
33572 | 543 gtk_ctree_node_set_row_data_full(GTK_CTREE( CTDirTree ),parent,DirNode,NULL ); |
544 sibling=gtk_ctree_insert_node( GTK_CTREE( CTDirTree ),parent,NULL,&dummy,4,NULL,NULL,NULL,NULL,TRUE,TRUE ); | |
545 gtk_ctree_expand( GTK_CTREE( CTDirTree ),parent ); | |
546 gtk_widget_show( CTDirTree ); | |
547 | |
35872
93ab56bda68a
Utilize new cfg_old_filename_from_utf8() in playlist code.
ib
parents:
35578
diff
changeset
|
548 if ( fsHistory[0] ) old_path = strdup( cfg_old_filename_from_utf8( fsHistory[0] ) ); |
33572 | 549 |
550 gtk_clist_set_column_widget( GTK_CLIST( CTDirTree ),0, | |
551 AddLabel( MSGTR_PLAYLIST_DirectoryTree,NULL ) ); | |
552 | |
34347 | 553 gtk_clist_column_title_passive( GTK_CLIST( CTDirTree ),0 ); |
554 | |
33572 | 555 vbox2=AddVBox( |
556 AddFrame( NULL,1,hbox1,1 ),0 ); | |
557 | |
558 scrolledwindow2=gtk_scrolled_window_new( NULL,NULL ); | |
559 gtk_widget_show( scrolledwindow2 ); | |
560 gtk_box_pack_start( GTK_BOX( vbox2 ),scrolledwindow2,TRUE,TRUE,0 ); | |
561 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow2 ),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC ); | |
562 | |
35927 | 563 CLFiles=gtk_clist_new( 2 ); |
33572 | 564 gtk_widget_show( CLFiles ); |
565 gtk_container_add( GTK_CONTAINER( scrolledwindow2 ),CLFiles ); | |
566 gtk_clist_set_column_width( GTK_CLIST( CLFiles ),0,80 ); | |
35927 | 567 gtk_clist_set_column_visibility( GTK_CLIST( CLFiles ),1,FALSE ); |
33572 | 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 | |
35927 | 584 CLSelected=gtk_clist_new( 4 ); |
33572 | 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 ); | |
35927 | 589 gtk_clist_set_column_visibility( GTK_CLIST( CLSelected ),2,FALSE ); |
590 gtk_clist_set_column_visibility( GTK_CLIST( CLSelected ),3,FALSE ); | |
33572 | 591 gtk_clist_set_selection_mode( GTK_CLIST( CLSelected ),GTK_SELECTION_MULTIPLE ); |
592 gtk_clist_column_titles_show( GTK_CLIST( CLSelected ) ); | |
593 gtk_clist_set_shadow_type( GTK_CLIST( CLSelected ),GTK_SHADOW_NONE ); | |
594 | |
595 gtk_clist_set_column_widget( GTK_CLIST( CLSelected ),0, | |
596 AddLabel( MSGTR_PLAYLIST_Selected,NULL ) ); | |
597 | |
598 gtk_clist_set_column_widget( GTK_CLIST( CLSelected ),1, | |
599 AddLabel( MSGTR_PLAYLIST_Path,NULL ) ); | |
600 | |
34347 | 601 gtk_clist_column_title_passive( GTK_CLIST( CLSelected ),0 ); |
602 | |
33572 | 603 AddHSeparator( vbox1 ); |
604 | |
605 hbuttonbox1=AddHButtonBox( vbox1 ); | |
606 gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox1 ),GTK_BUTTONBOX_END ); | |
607 gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox1 ),10 ); | |
608 | |
609 Add=AddButton( MSGTR_Add,hbuttonbox1 ); | |
610 Remove=AddButton( MSGTR_Remove,hbuttonbox1 ); | |
611 Ok=AddButton( MSGTR_Ok,hbuttonbox1 ); | |
612 Cancel=AddButton( MSGTR_Cancel,hbuttonbox1 ); | |
613 | |
614 gtk_widget_add_accelerator( Cancel,"clicked",accel_group,GDK_Escape,0,GTK_ACCEL_VISIBLE ); | |
615 | |
616 gtk_signal_connect( GTK_OBJECT( PlayList ),"destroy",GTK_SIGNAL_FUNC( WidgetDestroy ),&PlayList ); | |
617 | |
618 gtk_signal_connect( GTK_OBJECT( CLFiles ),"select_row",GTK_SIGNAL_FUNC( plRowSelect ),(void *)0 ); | |
619 gtk_signal_connect( GTK_OBJECT( CLFiles ),"unselect_row",GTK_SIGNAL_FUNC( plUnRowSelect ),(void *)0 ); | |
620 gtk_signal_connect( GTK_OBJECT( CLFiles ),"event",GTK_SIGNAL_FUNC( plEvent ),(void *)0 ); | |
34349 | 621 gtk_signal_connect( GTK_OBJECT( CLFiles ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void *)0 ); |
33572 | 622 sigSel=gtk_signal_connect( GTK_OBJECT( CLSelected ),"select_row",GTK_SIGNAL_FUNC( plRowSelect ),(void*)1 ); |
623 sigUnsel=gtk_signal_connect( GTK_OBJECT( CLSelected ),"unselect_row",GTK_SIGNAL_FUNC( plUnRowSelect ),(void*)1 ); | |
624 sigEvent=gtk_signal_connect( GTK_OBJECT( CLSelected ),"event",GTK_SIGNAL_FUNC( plEvent ),(void *)1 ); | |
34349 | 625 gtk_signal_connect( GTK_OBJECT( CLSelected ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void *)1 ); |
33572 | 626 |
34348 | 627 gtk_signal_connect( GTK_OBJECT( Add ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)3 ); |
628 gtk_signal_connect( GTK_OBJECT( Add ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void*)3 ); | |
629 gtk_signal_connect( GTK_OBJECT( Remove ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)2 ); | |
630 gtk_signal_connect( GTK_OBJECT( Remove ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void*)2 ); | |
631 gtk_signal_connect( GTK_OBJECT( Ok ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)1 ); | |
632 gtk_signal_connect( GTK_OBJECT( Ok ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void*)1 ); | |
633 gtk_signal_connect( GTK_OBJECT( Cancel ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)0 ); | |
634 gtk_signal_connect( GTK_OBJECT( Cancel ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void*)0 ); | |
33572 | 635 |
636 gtk_window_add_accel_group( GTK_WINDOW( PlayList ),accel_group ); | |
637 | |
638 return PlayList; | |
639 } |