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