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