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