Mercurial > mplayer.hg
annotate gui/dialog/playlist.c @ 35982:3fbbee95fc22
Make create_PlayList() static.
It only has file scope.
In order to do so, relocate some other static functions.
Additionally, rename it create_Playlist().
author | ib |
---|---|
date | Thu, 28 Mar 2013 17:39:01 +0000 |
parents | 1d11ed014a53 |
children | 111a018fab28 |
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 |
35981 | 49 GtkWidget * Playlist = NULL; |
33572 | 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 | |
35980 | 95 static void HidePlaylist( void ) |
33572 | 96 { |
35981 | 97 if ( !Playlist ) return; |
33572 | 98 NrOfSelected=NrOfEntrys=0; |
33739 | 99 nfree( CLListSelected ); nfree( CLFileSelected ); |
33572 | 100 free( old_path ); |
101 old_path=strdup( current_path ); | |
35981 | 102 gtk_widget_hide( Playlist ); |
103 gtk_widget_destroy( Playlist ); | |
104 Playlist=NULL; | |
33572 | 105 } |
106 | |
107 static void plRowSelect( GtkCList * clist,gint row,gint column,GdkEvent * event,gpointer user_data ) | |
108 { | |
109 switch ( (int) user_data ) | |
110 { | |
35493 | 111 case 0: CLFileSelected[row]=True; break; |
112 case 1: CLListSelected[row]=True; break; | |
33572 | 113 } |
114 } | |
115 | |
116 static void plUnRowSelect( GtkCList * clist,gint row,gint column,GdkEvent * event,gpointer user_data ) | |
117 { | |
118 switch ( (int) user_data ) | |
119 { | |
35493 | 120 case 0: CLFileSelected[row]=False; break; |
121 case 1: CLListSelected[row]=False; break; | |
33572 | 122 } |
123 } | |
124 | |
125 static void plButtonReleased( GtkButton * button,gpointer user_data ) | |
126 { | |
127 switch ( (int) user_data ) | |
128 { | |
129 case 1: // ok | |
130 { | |
35572
0827fa4c3401
While playing, allow extensive editing of the playlist without stopping.
ib
parents:
35554
diff
changeset
|
131 int i; |
35461 | 132 plItem curr, * item, * old; |
133 item = listMgr( PLAYLIST_ITEM_GET_CURR,0 ); | |
134 if (item) | |
135 { | |
136 curr.path = gstrdup(item->path); | |
137 curr.name = gstrdup(item->name); | |
138 } | |
35573 | 139 else |
140 { | |
141 curr.path = NULL; | |
142 curr.name = NULL; | |
143 } | |
34666 | 144 listMgr( PLAYLIST_DELETE,0 ); |
33572 | 145 for ( i=0;i<NrOfSelected;i++ ) |
146 { | |
35927 | 147 char * text[2]; |
33572 | 148 item=calloc( 1,sizeof( plItem ) ); |
35927 | 149 gtk_clist_get_text( GTK_CLIST( CLSelected ),i,2,&text[0] ); |
150 gtk_clist_get_text( GTK_CLIST( CLSelected ),i,3,&text[1] ); | |
151 item->name = strdup( text[0] ); | |
152 item->path = strdup( text[1] ); | |
34681 | 153 listMgr( PLAYLIST_ITEM_APPEND,item ); |
33572 | 154 } |
35461 | 155 item = listMgr( PLAYLIST_GET,0 ); |
34664
4df4d842d5fb
Remove global variable pointing to current playlist item.
ib
parents:
34663
diff
changeset
|
156 if ( item ) |
33572 | 157 { |
35578 | 158 if ( guiInfo.Playing ) |
35461 | 159 { |
160 old = listMgr( PLAYLIST_ITEM_FIND,&curr ); | |
35572
0827fa4c3401
While playing, allow extensive editing of the playlist without stopping.
ib
parents:
35554
diff
changeset
|
161 if ( old ) |
35461 | 162 { |
163 listMgr( PLAYLIST_ITEM_SET_CURR,old ); | |
35572
0827fa4c3401
While playing, allow extensive editing of the playlist without stopping.
ib
parents:
35554
diff
changeset
|
164 guiInfo.Track = (int) listMgr( PLAYLIST_ITEM_GET_POS,old ); |
35461 | 165 item = NULL; |
166 } | |
167 } | |
168 if ( item ) | |
169 { | |
170 uiSetFile( item->path,item->name,STREAMTYPE_FILE ); | |
171 guiInfo.NewPlay = GUI_FILE_NEW; | |
35577 | 172 guiInfo.PlaylistNext = !guiInfo.Playing; |
35461 | 173 guiInfo.Track = 1; |
174 } | |
33572 | 175 } |
35455
c9c79a011f6f
Fix bug with wrong track number after playlist has been cleared.
ib
parents:
35452
diff
changeset
|
176 else if (isPlaylistStreamtype && !guiInfo.Playing) uiUnsetFile(); |
35554 | 177 guiInfo.Tracks = (int) listMgr( PLAYLIST_ITEM_GET_POS,0 ); |
35461 | 178 free(curr.path); |
179 free(curr.name); | |
33572 | 180 } |
181 case 0: // cancel | |
35980 | 182 HidePlaylist(); |
33572 | 183 break; |
184 case 2: // remove | |
185 { | |
35522 | 186 int i; int j; |
33572 | 187 |
188 gtk_signal_handler_block( GTK_OBJECT( CLSelected ),sigSel ); | |
189 gtk_signal_handler_block( GTK_OBJECT( CLSelected ),sigUnsel ); | |
190 gtk_signal_handler_block( GTK_OBJECT( CLSelected ),sigEvent ); | |
191 | |
192 gtk_clist_freeze( GTK_CLIST( CLSelected ) ); | |
35522 | 193 i = 0; |
194 while ( i<NrOfSelected ) | |
195 { | |
33572 | 196 if ( CLListSelected[i] ) |
197 { | |
35522 | 198 gtk_clist_remove( GTK_CLIST( CLSelected ),i ); |
199 NrOfSelected--; | |
200 for ( j=i;j<NrOfSelected;j++ ) | |
201 CLListSelected[j] = CLListSelected[j+1]; | |
33572 | 202 } |
35522 | 203 else i++; |
204 } | |
33572 | 205 gtk_clist_thaw( GTK_CLIST( CLSelected ) ); |
206 | |
207 gtk_signal_handler_unblock( GTK_OBJECT( CLSelected ),sigSel ); | |
208 gtk_signal_handler_unblock( GTK_OBJECT( CLSelected ),sigUnsel ); | |
209 gtk_signal_handler_unblock( GTK_OBJECT( CLSelected ),sigEvent ); | |
210 | |
211 } | |
212 break; | |
213 case 3: // add | |
214 { | |
215 int i; | |
216 void *p; | |
35927 | 217 char * itext[2]; |
218 char * text[1][5]; text[0][4]=""; | |
33572 | 219 gtk_clist_freeze( GTK_CLIST( CLSelected ) ); |
220 for ( i=0;i<NrOfEntrys;i++ ) | |
221 { | |
222 if ( CLFileSelected[i] ) | |
223 { | |
224 NrOfSelected++; | |
225 p=realloc( CLListSelected,NrOfSelected * sizeof( int ) ); | |
226 if ( !p ) NrOfSelected--; | |
227 else | |
228 { | |
229 CLListSelected=p; | |
35493 | 230 CLListSelected[NrOfSelected - 1]=False; |
35927 | 231 gtk_clist_get_text( GTK_CLIST( CLFiles ),i,0,&itext[0] ); |
232 gtk_clist_get_text( GTK_CLIST( CLFiles ),i,1,&itext[1] ); | |
233 text[0][0]=itext[0]; text[0][1]=g_filename_display_name( current_path ); | |
234 text[0][2]=itext[1]; text[0][3]=current_path; | |
33572 | 235 gtk_clist_append( GTK_CLIST( CLSelected ),text[0] ); |
35927 | 236 g_free( text[0][1] ); |
33572 | 237 } |
238 } | |
239 } | |
240 gtk_clist_thaw( GTK_CLIST( CLSelected ) ); | |
241 } | |
242 break; | |
243 } | |
244 } | |
245 | |
34348 | 246 static gboolean plKeyReleased( GtkWidget * widget, |
247 GdkEventKey * event, | |
248 gpointer user_data ) | |
249 { | |
34349 | 250 if (event->keyval == GDK_Return) |
251 { | |
252 if ( GTK_WIDGET_TYPE( widget ) == GTK_TYPE_BUTTON ) plButtonReleased( NULL, user_data ); | |
253 else | |
254 { | |
255 switch ( (int) user_data ) | |
256 { | |
257 case 0: | |
258 plButtonReleased( NULL, (void *) 3 ); | |
259 break; | |
260 case 1: | |
261 plButtonReleased( NULL, (void *) 2 ); | |
262 break; | |
263 } | |
264 } | |
265 } | |
34348 | 266 return FALSE; |
267 } | |
268 | |
33572 | 269 static gboolean plEvent ( GtkWidget * widget, |
270 GdkEvent * event, | |
271 gpointer user_data ) | |
272 { | |
273 GdkEventButton *bevent; | |
274 gint row, col; | |
275 | |
276 bevent = (GdkEventButton *) event; | |
277 | |
278 if ( event->type == GDK_BUTTON_RELEASE && bevent->button == 2 ) | |
279 { | |
280 if ( gtk_clist_get_selection_info( GTK_CLIST( widget ), bevent->x, bevent->y, &row, &col ) ) | |
281 { | |
282 switch ( (int) user_data ) | |
283 { | |
284 case 0: | |
35493 | 285 CLFileSelected[row] = True; |
33572 | 286 plButtonReleased( NULL, (void *) 3 ); |
35493 | 287 CLFileSelected[row] = False; |
33572 | 288 return TRUE; |
289 | |
290 case 1: | |
35493 | 291 CLListSelected[row] = True; |
33572 | 292 plButtonReleased( NULL, (void *) 2 ); |
293 return TRUE; | |
294 } | |
295 } | |
296 } | |
297 | |
298 return FALSE; | |
299 } | |
300 | |
301 static int check_for_subdir( gchar * path ) | |
302 { | |
303 DIR * dir; | |
304 struct dirent * dirent; | |
305 struct stat statbuf; | |
306 gchar * npath; | |
307 | |
308 if ( (dir=opendir( path )) ) | |
309 { | |
310 while ( (dirent=readdir( dir )) ) | |
311 { | |
312 if ( dirent->d_name[0] != '.' ) | |
313 { | |
314 npath=calloc( 1,strlen( path ) + strlen( dirent->d_name ) + 3 ); | |
315 sprintf( npath,"%s/%s",path,dirent->d_name ); | |
316 if ( stat( npath,&statbuf ) != -1 && S_ISDIR( statbuf.st_mode ) ) | |
35493 | 317 { free( npath ); closedir( dir ); return True; } |
33572 | 318 free( npath ); |
319 } | |
320 } | |
321 closedir( dir ); | |
322 } | |
35493 | 323 return False; |
33572 | 324 } |
325 | |
326 static void plCTree( GtkCTree * ctree,GtkCTreeNode * parent_node,gpointer user_data ) | |
327 { | |
328 GtkCTreeNode * node; | |
329 DirNodeType * DirNode; | |
35938
8515446e81c6
Cosmetic: Rename variables holding data in UTF-8 encoding.
ib
parents:
35927
diff
changeset
|
330 gchar * text, * utf8name = NULL; |
33572 | 331 gchar * dummy = "dummy"; |
35493 | 332 int subdir = True; |
33572 | 333 DIR * dir = NULL; |
334 struct dirent * dirent; | |
335 gchar * path; | |
336 struct stat statbuf; | |
337 | |
338 DirNode=gtk_ctree_node_get_row_data( ctree,parent_node ); | |
339 if ( !DirNode->scaned ) | |
340 { | |
35493 | 341 DirNode->scaned=True; current_path=DirNode->path; |
33572 | 342 gtk_clist_freeze( GTK_CLIST( ctree ) ); |
343 node=gtk_ctree_find_by_row_data( ctree,parent_node,NULL ); | |
344 gtk_ctree_remove_node( ctree,node ); | |
345 | |
346 if ( (dir=opendir( DirNode->path ) ) ) | |
347 { | |
348 while( (dirent=readdir( dir )) ) | |
349 { | |
350 path=calloc( 1,strlen( DirNode->path ) + strlen( dirent->d_name ) + 2 ); | |
351 if ( !strcmp( current_path,"/" ) ) sprintf( path,"/%s",dirent->d_name ); | |
352 else sprintf( path,"%s/%s",current_path,dirent->d_name ); | |
353 text=dirent->d_name; | |
35938
8515446e81c6
Cosmetic: Rename variables holding data in UTF-8 encoding.
ib
parents:
35927
diff
changeset
|
354 g_free( utf8name ); |
8515446e81c6
Cosmetic: Rename variables holding data in UTF-8 encoding.
ib
parents:
35927
diff
changeset
|
355 utf8name=g_filename_display_name( text ); |
33572 | 356 |
357 if ( stat( path,&statbuf ) != -1 && S_ISDIR( statbuf.st_mode ) && dirent->d_name[0] != '.' ) | |
358 { | |
35493 | 359 DirNode=malloc( sizeof( DirNodeType ) ); DirNode->scaned=False; DirNode->path=strdup( path ); |
33572 | 360 subdir=check_for_subdir( path ); |
35938
8515446e81c6
Cosmetic: Rename variables holding data in UTF-8 encoding.
ib
parents:
35927
diff
changeset
|
361 node=gtk_ctree_insert_node( ctree,parent_node,NULL,&utf8name,4,pxOpenedBook,msOpenedBook,pxClosedBook,msClosedBook,!subdir,FALSE ); |
33572 | 362 gtk_ctree_node_set_row_data_full( ctree,node,DirNode,NULL ); |
35403 | 363 if ( subdir ) gtk_ctree_insert_node( ctree,node,NULL,&dummy,4,NULL,NULL,NULL,NULL,FALSE,FALSE ); |
33572 | 364 } |
365 free( path ); path=NULL; | |
366 } | |
367 closedir( dir ); | |
368 } | |
369 | |
370 gtk_ctree_sort_node( ctree,parent_node ); | |
371 gtk_clist_thaw( GTK_CLIST( ctree ) ); | |
372 } | |
373 | |
35938
8515446e81c6
Cosmetic: Rename variables holding data in UTF-8 encoding.
ib
parents:
35927
diff
changeset
|
374 g_free( utf8name ); |
33572 | 375 } |
376 | |
377 static void scan_dir( char * path ) | |
378 { | |
379 DIR * dir = NULL; | |
380 char * curr; | |
381 struct dirent * dirent; | |
382 struct stat statbuf; | |
35927 | 383 char * text[1][3]; text[0][2]=""; |
33572 | 384 |
385 gtk_clist_clear( GTK_CLIST( CLFiles ) ); | |
386 if ( (dir=opendir( path )) ) | |
387 { | |
388 NrOfEntrys=0; | |
389 while( (dirent=readdir( dir )) ) | |
390 { | |
391 curr=calloc( 1,strlen( path ) + strlen( dirent->d_name ) + 3 ); sprintf( curr,"%s/%s",path,dirent->d_name ); | |
392 if ( stat( curr,&statbuf ) != -1 && ( S_ISREG( statbuf.st_mode ) || S_ISLNK( statbuf.st_mode ) ) ) | |
393 { | |
35927 | 394 text[0][0]=g_filename_display_name( dirent->d_name ); |
395 text[0][1]=dirent->d_name; | |
33572 | 396 gtk_clist_append( GTK_CLIST( CLFiles ), text[0] ); |
35927 | 397 g_free( text[0][0] ); |
33572 | 398 NrOfEntrys++; |
399 } | |
400 free( curr ); | |
401 } | |
402 closedir( dir ); | |
403 gtk_clist_sort( GTK_CLIST( CLFiles ) ); | |
404 } | |
405 } | |
406 | |
34466
a650895d50a5
Use correct data types and common variable names in GTK callback functions.
ib
parents:
34349
diff
changeset
|
407 static void plCTRow(GtkCList * clist, gint row, gint column, GdkEvent * event, gpointer user_data) |
33572 | 408 { |
409 DirNodeType * DirNode; | |
410 GtkCTreeNode * node; | |
34466
a650895d50a5
Use correct data types and common variable names in GTK callback functions.
ib
parents:
34349
diff
changeset
|
411 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
|
412 DirNode=gtk_ctree_node_get_row_data( GTK_CTREE( clist ),node ); |
33572 | 413 current_path=DirNode->path; |
34466
a650895d50a5
Use correct data types and common variable names in GTK callback functions.
ib
parents:
34349
diff
changeset
|
414 gtk_ctree_expand( GTK_CTREE( clist ),node ); |
33572 | 415 scan_dir( DirNode->path ); |
416 free( CLFileSelected ); | |
417 CLFileSelected=calloc( 1,NrOfEntrys * sizeof( int ) ); | |
418 } | |
419 | |
35982 | 420 static GtkWidget * create_Playlist( void ) |
33572 | 421 { |
422 GtkWidget * vbox1; | |
423 GtkWidget * hbox1; | |
424 GtkWidget * scrolledwindow1; | |
425 GtkWidget * vbox2; | |
426 GtkWidget * scrolledwindow2; | |
427 GtkWidget * scrolledwindow3; | |
428 GtkWidget * hbuttonbox1; | |
429 GtkAccelGroup * accel_group; | |
430 GdkColor transparent = { 0,0,0,0 }; | |
431 gchar * root = "/"; | |
432 gchar * dummy = "dummy"; | |
433 DirNodeType * DirNode; | |
35963
db72a3183d41
Preselect current playlist directory from last playlist entry.
ib
parents:
35938
diff
changeset
|
434 plItem * last; |
33572 | 435 |
436 accel_group=gtk_accel_group_new(); | |
437 | |
35981 | 438 Playlist=gtk_window_new( GTK_WINDOW_TOPLEVEL ); |
439 gtk_object_set_data( GTK_OBJECT( Playlist ),"PlayList",Playlist ); | |
440 gtk_widget_set_usize( Playlist,512,384 ); | |
441 gtk_window_set_title( GTK_WINDOW( Playlist ),MSGTR_PlayList ); | |
442 gtk_window_set_position( GTK_WINDOW( Playlist ),GTK_WIN_POS_CENTER ); | |
443 // gtk_window_set_policy( GTK_WINDOW( Playlist ),FALSE,FALSE,FALSE ); | |
444 gtk_window_set_wmclass( GTK_WINDOW( Playlist ),"Playlist","MPlayer" ); | |
33572 | 445 |
35981 | 446 gtk_widget_realize( Playlist ); |
447 gtkAddIcon( Playlist ); | |
33572 | 448 |
35981 | 449 vbox1=AddVBox( AddDialogFrame( Playlist ),0 ); |
33572 | 450 hbox1=AddHBox( NULL,1 ); |
451 gtk_box_pack_start( GTK_BOX( vbox1 ),hbox1,TRUE,TRUE,0 ); | |
452 | |
453 scrolledwindow1=gtk_scrolled_window_new( NULL,NULL ); | |
454 gtk_widget_show( scrolledwindow1 ); | |
455 gtk_container_add( GTK_CONTAINER( | |
456 AddFrame( NULL,0,hbox1,1 ) ),scrolledwindow1 ); | |
457 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow1 ),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC ); | |
458 | |
459 CTDirTree=gtk_ctree_new( 1,0 ); | |
460 gtk_signal_connect( GTK_OBJECT( CTDirTree ),"tree_expand",GTK_SIGNAL_FUNC( plCTree ),(void*)0 ); | |
461 gtk_signal_connect( GTK_OBJECT( CTDirTree ),"select_row",GTK_SIGNAL_FUNC( plCTRow ),(void *)0 ); | |
462 gtk_container_add( GTK_CONTAINER( scrolledwindow1 ),CTDirTree ); | |
463 gtk_clist_set_column_auto_resize( GTK_CLIST( CTDirTree ),0,TRUE ); | |
464 gtk_clist_set_column_width( GTK_CLIST( CTDirTree ),0,80 ); | |
465 gtk_clist_set_selection_mode( GTK_CLIST( CTDirTree ),GTK_SELECTION_SINGLE ); | |
466 gtk_ctree_set_line_style( GTK_CTREE( CTDirTree ),GTK_CTREE_LINES_SOLID ); | |
467 gtk_clist_column_titles_show( GTK_CLIST( CTDirTree ) ); | |
468 gtk_clist_set_shadow_type( GTK_CLIST( CTDirTree ),GTK_SHADOW_NONE ); | |
469 | |
35981 | 470 if ( !pxOpenedBook ) pxOpenedBook=gdk_pixmap_create_from_xpm_d( Playlist->window,&msOpenedBook,&transparent,(gchar **)dir2_xpm ); |
471 if ( !pxClosedBook ) pxClosedBook=gdk_pixmap_create_from_xpm_d( Playlist->window,&msClosedBook,&transparent,(gchar **)open2_xpm ); | |
33572 | 472 |
473 parent=gtk_ctree_insert_node( GTK_CTREE( CTDirTree ),NULL,NULL,&root,4,pxOpenedBook,msOpenedBook,pxClosedBook,msClosedBook,FALSE,FALSE ); | |
474 DirNode=malloc( sizeof( DirNodeType ) ); | |
35493 | 475 DirNode->scaned=False; DirNode->path=strdup( root ); |
33572 | 476 gtk_ctree_node_set_row_data_full(GTK_CTREE( CTDirTree ),parent,DirNode,NULL ); |
477 sibling=gtk_ctree_insert_node( GTK_CTREE( CTDirTree ),parent,NULL,&dummy,4,NULL,NULL,NULL,NULL,TRUE,TRUE ); | |
478 gtk_ctree_expand( GTK_CTREE( CTDirTree ),parent ); | |
479 gtk_widget_show( CTDirTree ); | |
480 | |
35963
db72a3183d41
Preselect current playlist directory from last playlist entry.
ib
parents:
35938
diff
changeset
|
481 last=listMgr( PLAYLIST_ITEM_GET_LAST,0 ); |
db72a3183d41
Preselect current playlist directory from last playlist entry.
ib
parents:
35938
diff
changeset
|
482 |
db72a3183d41
Preselect current playlist directory from last playlist entry.
ib
parents:
35938
diff
changeset
|
483 if ( last && last->path ) old_path = strdup( last->path ); |
db72a3183d41
Preselect current playlist directory from last playlist entry.
ib
parents:
35938
diff
changeset
|
484 else if ( fsHistory[0] ) old_path = strdup( cfg_old_filename_from_utf8( fsHistory[0] ) ); |
33572 | 485 |
486 gtk_clist_set_column_widget( GTK_CLIST( CTDirTree ),0, | |
487 AddLabel( MSGTR_PLAYLIST_DirectoryTree,NULL ) ); | |
488 | |
34347 | 489 gtk_clist_column_title_passive( GTK_CLIST( CTDirTree ),0 ); |
490 | |
33572 | 491 vbox2=AddVBox( |
492 AddFrame( NULL,1,hbox1,1 ),0 ); | |
493 | |
494 scrolledwindow2=gtk_scrolled_window_new( NULL,NULL ); | |
495 gtk_widget_show( scrolledwindow2 ); | |
496 gtk_box_pack_start( GTK_BOX( vbox2 ),scrolledwindow2,TRUE,TRUE,0 ); | |
497 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow2 ),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC ); | |
498 | |
35927 | 499 CLFiles=gtk_clist_new( 2 ); |
33572 | 500 gtk_widget_show( CLFiles ); |
501 gtk_container_add( GTK_CONTAINER( scrolledwindow2 ),CLFiles ); | |
502 gtk_clist_set_column_width( GTK_CLIST( CLFiles ),0,80 ); | |
35927 | 503 gtk_clist_set_column_visibility( GTK_CLIST( CLFiles ),1,FALSE ); |
33572 | 504 gtk_clist_set_selection_mode( GTK_CLIST( CLFiles ),GTK_SELECTION_EXTENDED ); |
505 gtk_clist_column_titles_show( GTK_CLIST( CLFiles ) ); | |
506 gtk_clist_set_shadow_type( GTK_CLIST( CLFiles ),GTK_SHADOW_NONE ); | |
507 | |
508 gtk_clist_set_column_widget( GTK_CLIST( CLFiles ),0, | |
509 AddLabel( MSGTR_PLAYLIST_Files,NULL ) ); | |
510 | |
34347 | 511 gtk_clist_column_title_passive( GTK_CLIST( CLFiles ),0 ); |
512 | |
33572 | 513 AddHSeparator( vbox2 ); |
514 | |
515 scrolledwindow3=gtk_scrolled_window_new( NULL,NULL ); | |
516 gtk_widget_show( scrolledwindow3 ); | |
517 gtk_box_pack_start( GTK_BOX( vbox2 ),scrolledwindow3,TRUE,TRUE,0 ); | |
518 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow3 ),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC ); | |
519 | |
35927 | 520 CLSelected=gtk_clist_new( 4 ); |
33572 | 521 gtk_widget_show( CLSelected ); |
522 gtk_container_add( GTK_CONTAINER( scrolledwindow3 ),CLSelected ); | |
523 gtk_clist_set_column_width( GTK_CLIST( CLSelected ),0,295 ); | |
524 gtk_clist_set_column_width( GTK_CLIST( CLSelected ),1,295 ); | |
35927 | 525 gtk_clist_set_column_visibility( GTK_CLIST( CLSelected ),2,FALSE ); |
526 gtk_clist_set_column_visibility( GTK_CLIST( CLSelected ),3,FALSE ); | |
33572 | 527 gtk_clist_set_selection_mode( GTK_CLIST( CLSelected ),GTK_SELECTION_MULTIPLE ); |
528 gtk_clist_column_titles_show( GTK_CLIST( CLSelected ) ); | |
529 gtk_clist_set_shadow_type( GTK_CLIST( CLSelected ),GTK_SHADOW_NONE ); | |
530 | |
531 gtk_clist_set_column_widget( GTK_CLIST( CLSelected ),0, | |
532 AddLabel( MSGTR_PLAYLIST_Selected,NULL ) ); | |
533 | |
534 gtk_clist_set_column_widget( GTK_CLIST( CLSelected ),1, | |
535 AddLabel( MSGTR_PLAYLIST_Path,NULL ) ); | |
536 | |
34347 | 537 gtk_clist_column_title_passive( GTK_CLIST( CLSelected ),0 ); |
538 | |
33572 | 539 AddHSeparator( vbox1 ); |
540 | |
541 hbuttonbox1=AddHButtonBox( vbox1 ); | |
542 gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox1 ),GTK_BUTTONBOX_END ); | |
543 gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox1 ),10 ); | |
544 | |
545 Add=AddButton( MSGTR_Add,hbuttonbox1 ); | |
546 Remove=AddButton( MSGTR_Remove,hbuttonbox1 ); | |
547 Ok=AddButton( MSGTR_Ok,hbuttonbox1 ); | |
548 Cancel=AddButton( MSGTR_Cancel,hbuttonbox1 ); | |
549 | |
550 gtk_widget_add_accelerator( Cancel,"clicked",accel_group,GDK_Escape,0,GTK_ACCEL_VISIBLE ); | |
551 | |
35981 | 552 gtk_signal_connect( GTK_OBJECT( Playlist ),"destroy",GTK_SIGNAL_FUNC( WidgetDestroy ),&Playlist ); |
33572 | 553 |
554 gtk_signal_connect( GTK_OBJECT( CLFiles ),"select_row",GTK_SIGNAL_FUNC( plRowSelect ),(void *)0 ); | |
555 gtk_signal_connect( GTK_OBJECT( CLFiles ),"unselect_row",GTK_SIGNAL_FUNC( plUnRowSelect ),(void *)0 ); | |
556 gtk_signal_connect( GTK_OBJECT( CLFiles ),"event",GTK_SIGNAL_FUNC( plEvent ),(void *)0 ); | |
34349 | 557 gtk_signal_connect( GTK_OBJECT( CLFiles ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void *)0 ); |
33572 | 558 sigSel=gtk_signal_connect( GTK_OBJECT( CLSelected ),"select_row",GTK_SIGNAL_FUNC( plRowSelect ),(void*)1 ); |
559 sigUnsel=gtk_signal_connect( GTK_OBJECT( CLSelected ),"unselect_row",GTK_SIGNAL_FUNC( plUnRowSelect ),(void*)1 ); | |
560 sigEvent=gtk_signal_connect( GTK_OBJECT( CLSelected ),"event",GTK_SIGNAL_FUNC( plEvent ),(void *)1 ); | |
34349 | 561 gtk_signal_connect( GTK_OBJECT( CLSelected ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void *)1 ); |
33572 | 562 |
34348 | 563 gtk_signal_connect( GTK_OBJECT( Add ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)3 ); |
564 gtk_signal_connect( GTK_OBJECT( Add ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void*)3 ); | |
565 gtk_signal_connect( GTK_OBJECT( Remove ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)2 ); | |
566 gtk_signal_connect( GTK_OBJECT( Remove ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void*)2 ); | |
567 gtk_signal_connect( GTK_OBJECT( Ok ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)1 ); | |
568 gtk_signal_connect( GTK_OBJECT( Ok ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void*)1 ); | |
569 gtk_signal_connect( GTK_OBJECT( Cancel ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)0 ); | |
570 gtk_signal_connect( GTK_OBJECT( Cancel ),"key_release_event",GTK_SIGNAL_FUNC( plKeyReleased ),(void*)0 ); | |
33572 | 571 |
35981 | 572 gtk_window_add_accel_group( GTK_WINDOW( Playlist ),accel_group ); |
33572 | 573 |
35981 | 574 return Playlist; |
33572 | 575 } |
35982 | 576 |
577 void ShowPlaylist( void ) | |
578 { | |
579 plItem * next; | |
580 | |
581 if ( Playlist ) gtkActive( Playlist ); | |
582 else Playlist=create_Playlist(); | |
583 | |
584 if ( old_path && *old_path ) | |
585 { | |
586 char * currentdir = strdup( old_path ); | |
587 char * tpath,* pos; | |
588 GtkCTreeNode * node,* nextnode; | |
589 gboolean leaf; | |
590 tpath=strdup( "/" ); | |
591 pos=strtok( currentdir,"/" ); | |
592 node=gtk_ctree_find_by_row_data_custom( GTK_CTREE( CTDirTree ),NULL,"/",compare_func ); | |
593 do | |
594 { | |
595 char * tpathnew = g_strconcat( tpath,pos,"/",NULL ); | |
596 free( tpath ); tpath=tpathnew; | |
597 nextnode=gtk_ctree_find_by_row_data_custom( GTK_CTREE( CTDirTree ),node,tpath,compare_func ); | |
598 if ( !nextnode ) break; | |
599 node=nextnode; | |
600 pos=strtok( NULL,"/" ); | |
601 gtk_ctree_get_node_info( GTK_CTREE( CTDirTree ),node,NULL,NULL,NULL,NULL,NULL,NULL,&leaf,NULL ); | |
602 if ( !leaf && pos ) gtk_ctree_expand( GTK_CTREE( CTDirTree ),node ); | |
603 else | |
604 { | |
605 DirNodeType * DirNode; | |
606 gtk_ctree_select( GTK_CTREE( CTDirTree ),node ); | |
607 DirNode=gtk_ctree_node_get_row_data( GTK_CTREE( CTDirTree ),node ); | |
608 current_path=DirNode->path; | |
609 scan_dir( DirNode->path ); | |
610 free( CLFileSelected ); | |
611 CLFileSelected=calloc( 1,NrOfEntrys * sizeof( int ) ); | |
612 break; | |
613 } | |
614 } while( pos ); | |
615 free( tpath ); | |
616 free( currentdir ); | |
617 } | |
618 else gtk_ctree_select( GTK_CTREE( CTDirTree ),parent ); | |
619 | |
620 gtk_clist_freeze( GTK_CLIST( CLSelected ) ); | |
621 gtk_clist_clear( GTK_CLIST( CLSelected ) ); | |
622 next = listMgr( PLAYLIST_GET,0 ); | |
623 if ( next ) | |
624 { | |
625 while ( next || next->next ) | |
626 { | |
627 char * text[1][5]; text[0][4]=""; | |
628 text[0][0]=g_filename_display_name( next->name ); | |
629 text[0][1]=g_filename_display_name( next->path ); | |
630 text[0][2]=next->name; | |
631 text[0][3]=next->path; | |
632 gtk_clist_append( GTK_CLIST( CLSelected ),text[0] ); | |
633 g_free( text[0][0] ); | |
634 g_free( text[0][1] ); | |
635 NrOfSelected++; | |
636 if ( next->next ) next=next->next; else break; | |
637 } | |
638 CLListSelected=calloc( 1,NrOfSelected * sizeof( int ) ); | |
639 } | |
640 gtk_clist_thaw( GTK_CLIST( CLSelected ) ); | |
641 | |
642 gtk_widget_show( Playlist ); | |
643 } |