Mercurial > mplayer.hg
annotate Gui/mplayer/gtk/pl.c @ 7250:27a1315d6af4
Checked if the connection succeeded before writing in the socket.
author | bertrand |
---|---|
date | Tue, 03 Sep 2002 01:25:31 +0000 |
parents | 35bab6be713b |
children | e5dda05f9aab |
rev | line source |
---|---|
2901 | 1 |
6713 | 2 #include <sys/types.h> |
3 #include <sys/stat.h> | |
4 #include <string.h> | |
5 #include <dirent.h> | |
6 #include <unistd.h> | |
7 #include <stdio.h> | |
8 #include <stdlib.h> | |
9 | |
10 #include <gdk/gdkkeysyms.h> | |
11 #include <gtk/gtk.h> | |
12 | |
2901 | 13 #include "../../../config.h" |
14 #include "../../../help_mp.h" | |
7009 | 15 #include "../../libmpdemux/stream.h" |
2901 | 16 |
6713 | 17 #include "../../interface.h" |
2901 | 18 #include "../widgets.h" |
19 #include "pl.h" | |
20 | |
6713 | 21 static char * book_open_xpm[] = { |
22 "16 16 4 1", | |
23 " c None s None", | |
24 ". c black", | |
25 "X c #808080", | |
26 "o c white", | |
27 " ", | |
28 " .. ", | |
29 " .Xo. ... ", | |
30 " .Xoo. ..oo. ", | |
31 " .Xooo.Xooo... ", | |
32 " .Xooo.oooo.X. ", | |
33 " .Xooo.Xooo.X. ", | |
34 " .Xooo.oooo.X. ", | |
35 " .Xooo.Xooo.X. ", | |
36 " .Xooo.oooo.X. ", | |
37 " .Xoo.Xoo..X. ", | |
38 " .Xo.o..ooX. ", | |
39 " .X..XXXXX. ", | |
40 " ..X....... ", | |
41 " .. ", | |
42 " "}; | |
43 | |
44 static char * book_closed_xpm[] = { | |
45 "16 16 6 1", | |
46 " c None s None", | |
47 ". c black", | |
48 "X c red", | |
49 "o c yellow", | |
50 "O c #808080", | |
51 "# c white", | |
52 " ", | |
53 " .. ", | |
54 " ..XX. ", | |
55 " ..XXXXX. ", | |
56 " ..XXXXXXXX. ", | |
57 ".ooXXXXXXXXX. ", | |
58 "..ooXXXXXXXXX. ", | |
59 ".X.ooXXXXXXXXX. ", | |
60 ".XX.ooXXXXXX.. ", | |
61 " .XX.ooXXX..#O ", | |
62 " .XX.oo..##OO. ", | |
63 " .XX..##OO.. ", | |
64 " .X.#OO.. ", | |
65 " ..O.. ", | |
66 " .. ", | |
67 " "}; | |
68 | |
69 GtkWidget * PlayList; | |
70 static GtkWidget * CTDirTree; | |
71 static GtkWidget * CLFiles; | |
72 static GtkWidget * CLSelected; | |
73 static GtkWidget * Add; | |
74 static GtkWidget * Remove; | |
75 static GtkWidget * Ok; | |
76 static GtkWidget * Cancel; | |
77 static GdkPixmap * pxOpenedBook; | |
78 static GdkPixmap * pxClosedBook; | |
79 static GdkBitmap * msOpenedBook; | |
80 static GdkBitmap * msClosedBook; | |
81 | |
82 static int gtkVPlaylist = 0; | |
83 static int NrOfEntrys = 0; | |
84 static int NrOfSelected = 0; | |
85 static int * CLFileSelected = NULL; | |
86 static int * CLListSelected = NULL; | |
87 | |
88 static int sigSel; | |
89 static int sigUnsel; | |
90 | |
91 typedef struct | |
92 { | |
93 int scaned; | |
94 char * path; | |
95 } DirNodeType; | |
96 | |
97 static GtkCTreeNode * sibling; | |
98 static GtkCTreeNode * parent; | |
99 static gchar * current_path; | |
100 static gchar * old_path = NULL; | |
101 | |
102 static int compare_func(const void *a, const void *b) | |
103 { | |
104 char * tmp; | |
105 int i; | |
106 if ( !a || !b || !( (DirNodeType *)a )->path ) return -1; | |
107 tmp=strdup( (char *)b ); tmp[strlen( tmp )-1]=0; | |
108 i=strcmp( ( (DirNodeType *)a )->path,tmp ); | |
109 free( tmp ); | |
110 return i; | |
111 } | |
112 | |
113 static void scan_dir( char * path ); | |
114 | |
115 void ShowPlayList( void ) | |
116 { | |
117 if ( gtkVPlaylist ) gtkActive( PlayList ); | |
118 else PlayList=create_PlayList(); | |
119 | |
120 if ( old_path && *old_path ) | |
121 { | |
122 char * currentdir = strdup( old_path ); | |
123 char * tpath,* pos; | |
124 GtkCTreeNode * node,* nextnode; | |
125 gboolean leaf; | |
126 tpath=strdup( "/" ); | |
127 pos=strtok( currentdir,"/" ); | |
128 node=gtk_ctree_find_by_row_data_custom( GTK_CTREE( CTDirTree ),NULL,"/",compare_func ); | |
129 do | |
130 { | |
131 char * tpathnew = g_strconcat( tpath,pos,"/",NULL ); | |
132 free( tpath ); tpath=tpathnew; | |
133 nextnode=gtk_ctree_find_by_row_data_custom( GTK_CTREE( CTDirTree ),node,tpath,compare_func ); | |
134 if ( !nextnode ) break; | |
135 node=nextnode; | |
136 pos=strtok( NULL,"/" ); | |
137 gtk_ctree_get_node_info( GTK_CTREE( CTDirTree ),node,NULL,NULL,NULL,NULL,NULL,NULL,&leaf,NULL ); | |
138 if ( !leaf && pos ) gtk_ctree_expand( GTK_CTREE( CTDirTree ),node ); | |
139 else | |
140 { | |
141 DirNodeType * DirNode; | |
142 gtk_ctree_select( GTK_CTREE( CTDirTree ),node ); | |
143 DirNode=gtk_ctree_node_get_row_data( GTK_CTREE( CTDirTree ),node ); | |
144 current_path=DirNode->path; | |
145 scan_dir( DirNode->path ); | |
146 if ( CLFileSelected ) free( CLFileSelected ); CLFileSelected=calloc( 1,NrOfEntrys * sizeof( int ) ); | |
147 break; | |
148 } | |
149 } while( pos ); | |
150 free( tpath ); | |
151 free( currentdir ); | |
152 } | |
153 else gtk_ctree_select( GTK_CTREE( CTDirTree ),parent ); | |
154 | |
155 gtk_clist_freeze( GTK_CLIST( CLSelected ) ); | |
156 gtk_clist_clear( GTK_CLIST( CLSelected ) ); | |
157 if ( plList ) | |
158 { | |
159 plItem * next = plList; | |
160 while ( next || next->next ) | |
161 { | |
162 char * text[1][3]; text[0][2]=""; | |
163 text[0][0]=next->name; | |
164 text[0][1]=next->path; | |
165 gtk_clist_append( GTK_CLIST( CLSelected ),text[0] ); | |
166 NrOfSelected++; | |
167 if ( next->next ) next=next->next; else break; | |
168 } | |
169 CLListSelected=calloc( 1,NrOfSelected * sizeof( int ) ); | |
170 } | |
171 gtk_clist_thaw( GTK_CLIST( CLSelected ) ); | |
172 | |
6903 | 173 gtk_widget_show( PlayList ); |
6713 | 174 } |
175 | |
2901 | 176 void HidePlayList( void ) |
177 { | |
6755 | 178 if ( !gtkVPlaylist ) return; |
6713 | 179 gtkVPlaylist=NrOfSelected=NrOfEntrys=0; |
180 if ( CLListSelected ) free( CLListSelected ); CLListSelected=NULL; | |
181 if ( CLFileSelected ) free( CLFileSelected ); CLFileSelected=NULL; | |
182 if ( old_path ) free( old_path ); old_path=strdup( current_path ); | |
183 gtk_widget_hide( PlayList ); | |
6903 | 184 gtk_widget_destroy( PlayList ); |
2901 | 185 } |
186 | |
6713 | 187 static void plDestroy( GtkObject * object,gpointer user_data ) |
2901 | 188 { HidePlayList(); } |
189 | |
6713 | 190 static void plRowSelect( GtkCList * clist,gint row,gint column,GdkEvent * event,gpointer user_data ) |
2901 | 191 { |
6713 | 192 switch ( (int) user_data ) |
193 { | |
194 case 0: CLFileSelected[row]=1; break; | |
195 case 1: CLListSelected[row]=1; break; | |
196 } | |
2901 | 197 } |
198 | |
6713 | 199 static void plUnRowSelect( GtkCList * clist,gint row,gint column,GdkEvent * event,gpointer user_data ) |
2901 | 200 { |
6713 | 201 switch ( (int) user_data ) |
202 { | |
203 case 0: CLFileSelected[row]=0; break; | |
204 case 1: CLListSelected[row]=0; break; | |
205 } | |
2901 | 206 } |
207 | |
6713 | 208 static void plButtonReleased( GtkButton * button,gpointer user_data ) |
2901 | 209 { |
6713 | 210 switch ( (int) user_data ) |
211 { | |
212 case 1: // ok | |
213 { | |
214 int i; | |
215 if ( plList ) gtkSet( gtkDelPl,0,NULL ); | |
216 for ( i=0;i<NrOfSelected;i++ ) | |
217 { | |
218 plItem * item; | |
219 char * text[3]; | |
220 item=calloc( 1,sizeof( plItem ) ); | |
221 gtk_clist_get_text( GTK_CLIST( CLSelected ),i,0,&text[0] ); | |
222 gtk_clist_get_text( GTK_CLIST( CLSelected ),i,1,&text[1] ); | |
223 item->name=strdup( text[0] ); | |
224 item->path=strdup( text[1] ); | |
225 gtkSet( gtkAddPlItem,0,(void*)item ); | |
226 } | |
227 if ( plCurrent ) | |
228 { | |
229 guiSetDF( guiIntfStruct.Filename,plCurrent->path,plCurrent->name ); | |
230 guiIntfStruct.FilenameChanged=1; | |
231 guiIntfStruct.StreamType=STREAMTYPE_FILE; | |
232 } | |
233 } | |
234 case 0: // cancel | |
235 HidePlayList(); | |
236 break; | |
237 case 2: // remove | |
238 { | |
239 int i; int c=0; | |
240 | |
241 gtk_signal_handler_block( GTK_OBJECT( CLSelected ),sigSel ); | |
242 gtk_signal_handler_block( GTK_OBJECT( CLSelected ),sigUnsel ); | |
2901 | 243 |
6713 | 244 gtk_clist_freeze( GTK_CLIST( CLSelected ) ); |
245 for ( i=0;i<NrOfSelected;i++ ) | |
246 if ( CLListSelected[i] ) | |
247 { | |
248 gtk_clist_remove( GTK_CLIST( CLSelected ),i - c ); | |
249 c++; | |
250 } | |
251 NrOfSelected-=c; | |
252 gtk_clist_thaw( GTK_CLIST( CLSelected ) ); | |
253 | |
254 gtk_signal_handler_unblock( GTK_OBJECT( CLSelected ),sigSel ); | |
255 gtk_signal_handler_unblock( GTK_OBJECT( CLSelected ),sigUnsel ); | |
2901 | 256 |
6713 | 257 } |
258 break; | |
259 case 3: // add | |
260 { | |
261 int i; | |
262 char * itext[1][2]; | |
263 char * text[1][3]; text[0][2]=""; | |
264 gtk_clist_freeze( GTK_CLIST( CLSelected ) ); | |
265 for ( i=0;i<NrOfEntrys;i++ ) | |
266 { | |
267 if ( CLFileSelected[i] ) | |
268 { | |
7092
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
7009
diff
changeset
|
269 gtk_clist_get_text( GTK_CLIST( CLFiles ),i,0,(char **)&itext ); |
6713 | 270 text[0][0]=itext[0][0]; text[0][1]=current_path; |
271 gtk_clist_append( GTK_CLIST( CLSelected ),text[0] ); | |
272 NrOfSelected++; | |
273 CLListSelected=realloc( CLListSelected,NrOfSelected * sizeof( int ) ); | |
274 CLListSelected[NrOfSelected - 1]=0; | |
275 } | |
276 } | |
277 gtk_clist_thaw( GTK_CLIST( CLSelected ) ); | |
278 } | |
279 break; | |
280 } | |
2901 | 281 } |
282 | |
6713 | 283 static int check_for_subdir( gchar * path ) |
2901 | 284 { |
6713 | 285 DIR * dir; |
286 struct dirent * dirent; | |
287 struct stat statbuf; | |
288 gchar * npath; | |
289 | |
290 if ( (dir=opendir( path )) ) | |
291 { | |
292 while ( (dirent=readdir( dir )) ) | |
293 { | |
294 if ( dirent->d_name[0] != '.' ) | |
295 { | |
296 npath=calloc( 1,strlen( path ) + strlen( dirent->d_name ) + 3 ); | |
297 sprintf( npath,"%s/%s",path,dirent->d_name ); | |
298 if ( stat( npath,&statbuf ) != -1 && S_ISDIR( statbuf.st_mode ) ) | |
299 { free( npath ); closedir( dir ); return 1; } | |
300 free( npath ); | |
301 } | |
302 } | |
303 closedir( dir ); | |
304 } | |
305 return 0; | |
2901 | 306 } |
307 | |
6713 | 308 static void plCTree( GtkCTree * ctree,GtkCTreeNode * parent_node,gpointer user_data ) |
2901 | 309 { |
6713 | 310 GtkCTreeNode * node; |
311 DirNodeType * DirNode; | |
312 gchar * text; | |
313 gchar * dummy = "dummy"; | |
314 int subdir = 1; | |
315 DIR * dir = NULL; | |
316 struct dirent * dirent; | |
317 gchar * path; | |
318 struct stat statbuf; | |
2901 | 319 |
6713 | 320 DirNode=gtk_ctree_node_get_row_data( ctree,parent_node ); |
321 if ( !DirNode->scaned ) | |
322 { | |
323 DirNode->scaned=1; current_path=DirNode->path; | |
324 gtk_clist_freeze( GTK_CLIST( ctree ) ); | |
325 node=gtk_ctree_find_by_row_data( ctree,parent_node,NULL ); | |
326 gtk_ctree_remove_node( ctree,node ); | |
327 | |
328 if ( (dir=opendir( DirNode->path ) ) ) | |
329 { | |
330 while( (dirent=readdir( dir )) ) | |
331 { | |
332 path=calloc( 1,strlen( DirNode->path ) + strlen( dirent->d_name ) + 2 ); | |
333 if ( !strcmp( current_path,"/" ) ) sprintf( path,"/%s",dirent->d_name ); | |
334 else sprintf( path,"%s/%s",current_path,dirent->d_name ); | |
335 text=dirent->d_name; | |
2901 | 336 |
6713 | 337 if ( stat( path,&statbuf ) != -1 && S_ISDIR( statbuf.st_mode ) && dirent->d_name[0] != '.' ) |
338 { | |
339 DirNode=malloc( sizeof( DirNodeType ) ); DirNode->scaned=0; DirNode->path=strdup( path ); | |
340 subdir=check_for_subdir( path ); | |
341 node=gtk_ctree_insert_node( ctree,parent_node,NULL,&text,4,pxOpenedBook,msOpenedBook,pxClosedBook,msClosedBook,!subdir,FALSE ); | |
342 gtk_ctree_node_set_row_data_full( ctree,node,DirNode,NULL ); | |
343 if ( subdir ) node=gtk_ctree_insert_node( ctree,node,NULL,&dummy,4,NULL,NULL,NULL,NULL,FALSE,FALSE ); | |
344 } | |
345 free( path ); path=NULL; | |
346 } | |
347 closedir( dir ); | |
348 } | |
349 | |
350 gtk_ctree_sort_node( ctree,parent_node ); | |
351 gtk_clist_thaw( GTK_CLIST( ctree ) ); | |
352 } | |
2901 | 353 } |
354 | |
6713 | 355 static void scan_dir( char * path ) |
356 { | |
357 DIR * dir = NULL; | |
358 char * curr; | |
359 struct dirent * dirent; | |
360 struct stat statbuf; | |
361 char * text[1][2]; text[0][1]=""; | |
362 | |
363 gtk_clist_clear( GTK_CLIST( CLFiles ) ); | |
364 if ( (dir=opendir( path )) ) | |
365 { | |
366 NrOfEntrys=0; | |
367 while( (dirent=readdir( dir )) ) | |
368 { | |
369 curr=calloc( 1,strlen( path ) + strlen( dirent->d_name ) + 3 ); sprintf( curr,"%s/%s",path,dirent->d_name ); | |
370 if ( stat( curr,&statbuf ) != -1 && ( S_ISREG( statbuf.st_mode ) || S_ISLNK( statbuf.st_mode ) ) ) | |
371 { | |
372 text[0][0]=dirent->d_name; | |
373 gtk_clist_append( GTK_CLIST( CLFiles ),text[0] ); | |
374 NrOfEntrys++; | |
375 } | |
376 free( curr ); | |
377 } | |
378 closedir( dir ); | |
379 gtk_clist_sort( GTK_CLIST( CLFiles ) ); | |
380 } | |
381 } | |
382 | |
383 static void plCTRow(GtkWidget * widget, gint row, gint column, GdkEventButton * bevent, gpointer data) | |
2901 | 384 { |
6713 | 385 DirNodeType * DirNode; |
386 GtkCTreeNode * node; | |
387 node=gtk_ctree_node_nth( GTK_CTREE( widget ),row ); | |
388 DirNode=gtk_ctree_node_get_row_data( GTK_CTREE( widget ),node ); | |
389 current_path=DirNode->path; | |
390 gtk_ctree_expand( GTK_CTREE( widget ),node ); | |
391 scan_dir( DirNode->path ); | |
392 if ( CLFileSelected ) free( CLFileSelected ); CLFileSelected=calloc( 1,NrOfEntrys * sizeof( int ) ); | |
393 } | |
394 | |
395 static void plShow( GtkWidget * widget,gpointer user_data ) | |
396 { gtkVPlaylist=(int)user_data; } | |
2901 | 397 |
6713 | 398 GtkWidget * create_PlayList( void ) |
399 { | |
400 GtkWidget * frame1; | |
401 GtkWidget * frame2; | |
402 GtkWidget * frame3; | |
403 GtkWidget * frame4; | |
404 GtkWidget * vbox1; | |
405 GtkWidget * hbox1; | |
406 GtkWidget * frame5; | |
407 GtkWidget * scrolledwindow1; | |
408 GtkWidget * label2; | |
409 GtkWidget * frame6; | |
410 GtkWidget * vbox2; | |
411 GtkWidget * scrolledwindow2; | |
412 GtkWidget * label3; | |
413 GtkWidget * hseparator2; | |
414 GtkWidget * scrolledwindow3; | |
415 GtkWidget * label5; | |
416 GtkWidget * hseparator1; | |
417 GtkWidget * hbuttonbox1; | |
418 GtkAccelGroup * accel_group; | |
419 GdkColor transparent = { 0 }; | |
420 gchar * root = "/"; | |
421 gchar * dummy = "dummy"; | |
422 DirNodeType * DirNode; | |
423 | |
424 accel_group=gtk_accel_group_new(); | |
425 | |
426 PlayList=gtk_window_new( GTK_WINDOW_DIALOG ); | |
427 gtk_object_set_data( GTK_OBJECT( PlayList ),"PlayList",PlayList ); | |
428 gtk_widget_set_usize( PlayList,512,300 ); | |
2901 | 429 gtk_window_set_title( GTK_WINDOW( PlayList ),MSGTR_PlayList ); |
430 gtk_window_set_position( GTK_WINDOW( PlayList ),GTK_WIN_POS_CENTER ); | |
6713 | 431 // gtk_window_set_policy( GTK_WINDOW( PlayList ),FALSE,FALSE,FALSE ); |
432 gtk_window_set_wmclass( GTK_WINDOW( PlayList ),"Playlist","MPlayer" ); | |
433 | |
434 gtk_widget_realize( PlayList ); | |
435 gtkAddIcon( PlayList ); | |
2901 | 436 |
6713 | 437 frame1=gtk_frame_new( NULL ); |
438 gtk_widget_ref( frame1 ); | |
439 gtk_object_set_data_full( GTK_OBJECT( PlayList ),"frame1",frame1,(GtkDestroyNotify)gtk_widget_unref ); | |
440 gtk_widget_show( frame1 ); | |
441 gtk_container_add( GTK_CONTAINER( PlayList ),frame1 ); | |
442 gtk_container_set_border_width( GTK_CONTAINER( frame1 ),1 ); | |
443 gtk_frame_set_shadow_type( GTK_FRAME( frame1 ),GTK_SHADOW_IN ); | |
2901 | 444 |
6713 | 445 frame2=gtk_frame_new( NULL ); |
446 gtk_widget_ref( frame2 ); | |
447 gtk_object_set_data_full( GTK_OBJECT( PlayList ),"frame2",frame2,(GtkDestroyNotify)gtk_widget_unref ); | |
448 gtk_widget_show( frame2 ); | |
449 gtk_container_add( GTK_CONTAINER( frame1 ),frame2 ); | |
450 gtk_frame_set_shadow_type( GTK_FRAME( frame2 ),GTK_SHADOW_NONE ); | |
2901 | 451 |
6713 | 452 frame3=gtk_frame_new( NULL ); |
453 gtk_widget_ref( frame3 ); | |
454 gtk_object_set_data_full( GTK_OBJECT( PlayList ),"frame3",frame3,(GtkDestroyNotify)gtk_widget_unref ); | |
455 gtk_widget_show( frame3 ); | |
456 gtk_container_add( GTK_CONTAINER( frame2 ),frame3 ); | |
457 gtk_frame_set_shadow_type( GTK_FRAME( frame3 ),GTK_SHADOW_ETCHED_OUT ); | |
458 | |
459 frame4=gtk_frame_new( NULL ); | |
460 gtk_widget_ref( frame4 ); | |
461 gtk_object_set_data_full( GTK_OBJECT( PlayList ),"frame4",frame4,(GtkDestroyNotify)gtk_widget_unref ); | |
462 gtk_widget_show( frame4 ); | |
463 gtk_container_add( GTK_CONTAINER( frame3 ),frame4 ); | |
464 gtk_frame_set_shadow_type( GTK_FRAME( frame4 ),GTK_SHADOW_NONE ); | |
2901 | 465 |
6713 | 466 vbox1=gtk_vbox_new( FALSE,0 ); |
467 gtk_widget_ref( vbox1 ); | |
468 gtk_object_set_data_full( GTK_OBJECT( PlayList ),"vbox1",vbox1,(GtkDestroyNotify)gtk_widget_unref ); | |
469 gtk_widget_show( vbox1 ); | |
470 gtk_container_add( GTK_CONTAINER( frame4 ),vbox1 ); | |
2901 | 471 |
6713 | 472 hbox1=gtk_hbox_new( FALSE,0 ); |
473 gtk_widget_ref( hbox1 ); | |
474 gtk_object_set_data_full( GTK_OBJECT( PlayList ),"hbox1",hbox1,(GtkDestroyNotify)gtk_widget_unref ); | |
475 gtk_widget_show( hbox1 ); | |
476 gtk_box_pack_start( GTK_BOX( vbox1 ),hbox1,TRUE,TRUE,0 ); | |
477 | |
478 frame5=gtk_frame_new( NULL ); | |
479 gtk_widget_ref( frame5 ); | |
480 gtk_object_set_data_full( GTK_OBJECT( PlayList ),"frame5",frame5,(GtkDestroyNotify)gtk_widget_unref ); | |
481 gtk_widget_show( frame5 ); | |
482 gtk_box_pack_start( GTK_BOX( hbox1 ),frame5,TRUE,TRUE,0 ); | |
483 gtk_frame_set_shadow_type( GTK_FRAME( frame5 ),GTK_SHADOW_ETCHED_OUT ); | |
2901 | 484 |
6713 | 485 scrolledwindow1=gtk_scrolled_window_new( NULL,NULL ); |
486 gtk_widget_ref( scrolledwindow1 ); | |
487 gtk_object_set_data_full( GTK_OBJECT( PlayList ),"scrolledwindow1",scrolledwindow1,(GtkDestroyNotify)gtk_widget_unref ); | |
488 gtk_widget_show( scrolledwindow1 ); | |
489 gtk_container_add( GTK_CONTAINER( frame5 ),scrolledwindow1 ); | |
490 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow1 ),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC ); | |
2901 | 491 |
6713 | 492 CTDirTree=gtk_ctree_new( 1,0 ); |
493 gtk_widget_ref( CTDirTree ); | |
494 gtk_object_set_data_full( GTK_OBJECT( PlayList ),"CTDirTree",CTDirTree,(GtkDestroyNotify)gtk_widget_unref ); | |
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 ); | |
2901 | 504 |
6713 | 505 gtk_widget_realize( PlayList ); |
506 | |
507 if ( !pxOpenedBook ) pxOpenedBook=gdk_pixmap_create_from_xpm_d( PlayList->window,&msOpenedBook,&transparent,book_closed_xpm ); | |
508 if ( !pxClosedBook ) pxClosedBook=gdk_pixmap_create_from_xpm_d( PlayList->window,&msClosedBook,&transparent,book_open_xpm ); | |
2901 | 509 |
6713 | 510 parent=gtk_ctree_insert_node( GTK_CTREE( CTDirTree ),NULL,NULL,&root,4,pxOpenedBook,msOpenedBook,pxClosedBook,msClosedBook,FALSE,FALSE ); |
511 DirNode=malloc( sizeof( DirNodeType ) ); | |
512 DirNode->scaned=0; DirNode->path=strdup( root ); | |
513 gtk_ctree_node_set_row_data_full(GTK_CTREE( CTDirTree ),parent,DirNode,NULL ); | |
514 sibling=gtk_ctree_insert_node( GTK_CTREE( CTDirTree ),parent,NULL,&dummy,4,NULL,NULL,NULL,NULL,TRUE,TRUE ); | |
515 gtk_ctree_expand( GTK_CTREE( CTDirTree ),parent ); | |
516 gtk_widget_show( CTDirTree ); | |
517 | |
518 label2=gtk_label_new( MSGTR_PLAYLIST_DirectoryTree ); | |
519 gtk_widget_ref( label2 ); | |
520 gtk_object_set_data_full( GTK_OBJECT( PlayList ),"label2",label2,(GtkDestroyNotify)gtk_widget_unref ); | |
521 gtk_widget_show( label2 ); | |
522 gtk_clist_set_column_widget( GTK_CLIST( CTDirTree ),0,label2 ); | |
523 gtk_misc_set_alignment( GTK_MISC( label2 ),0.02,0.5 ); | |
2901 | 524 |
6713 | 525 frame6=gtk_frame_new( NULL ); |
526 gtk_widget_ref( frame6 ); | |
527 gtk_object_set_data_full( GTK_OBJECT( PlayList ),"frame6",frame6,(GtkDestroyNotify)gtk_widget_unref ); | |
528 gtk_widget_show( frame6 ); | |
529 gtk_box_pack_start( GTK_BOX( hbox1 ),frame6,TRUE,TRUE,0 ); | |
530 gtk_widget_set_usize( frame6,170,-2 ); | |
531 gtk_frame_set_shadow_type( GTK_FRAME( frame6 ),GTK_SHADOW_ETCHED_OUT ); | |
2901 | 532 |
6713 | 533 vbox2=gtk_vbox_new( FALSE,0 ); |
534 gtk_widget_ref( vbox2 ); | |
535 gtk_object_set_data_full( GTK_OBJECT( PlayList ),"vbox2",vbox2,(GtkDestroyNotify)gtk_widget_unref ); | |
536 gtk_widget_show( vbox2 ); | |
537 gtk_container_add( GTK_CONTAINER( frame6 ),vbox2 ); | |
538 | |
539 scrolledwindow2=gtk_scrolled_window_new( NULL,NULL ); | |
540 gtk_widget_ref( scrolledwindow2 ); | |
541 gtk_object_set_data_full( GTK_OBJECT( PlayList ),"scrolledwindow2",scrolledwindow2,(GtkDestroyNotify)gtk_widget_unref ); | |
542 gtk_widget_show( scrolledwindow2 ); | |
543 gtk_box_pack_start( GTK_BOX( vbox2 ),scrolledwindow2,TRUE,TRUE,0 ); | |
544 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow2 ),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC ); | |
2901 | 545 |
6713 | 546 CLFiles=gtk_clist_new( 1 ); |
547 gtk_widget_ref( CLFiles ); | |
548 gtk_object_set_data_full( GTK_OBJECT( PlayList ),"CLFiles",CLFiles,(GtkDestroyNotify)gtk_widget_unref ); | |
549 gtk_widget_show( CLFiles ); | |
550 gtk_container_add( GTK_CONTAINER( scrolledwindow2 ),CLFiles ); | |
551 gtk_clist_set_column_width( GTK_CLIST( CLFiles ),0,80 ); | |
6905 | 552 gtk_clist_set_selection_mode( GTK_CLIST( CLFiles ),GTK_SELECTION_EXTENDED ); |
6713 | 553 gtk_clist_column_titles_show( GTK_CLIST( CLFiles ) ); |
554 gtk_clist_set_shadow_type( GTK_CLIST( CLFiles ),GTK_SHADOW_NONE ); | |
555 | |
556 label3=gtk_label_new( MSGTR_PLAYLIST_Files ); | |
557 gtk_widget_ref( label3 ); | |
558 gtk_object_set_data_full( GTK_OBJECT( PlayList ),"label3",label3,(GtkDestroyNotify)gtk_widget_unref ); | |
559 gtk_widget_show( label3 ); | |
560 gtk_clist_set_column_widget( GTK_CLIST( CLFiles ),0,label3 ); | |
561 gtk_misc_set_alignment( GTK_MISC( label3 ),0.02,0.5 ); | |
2901 | 562 |
6713 | 563 hseparator2=gtk_hseparator_new(); |
564 gtk_widget_ref( hseparator2 ); | |
565 gtk_object_set_data_full( GTK_OBJECT( PlayList ),"hseparator2",hseparator2,(GtkDestroyNotify)gtk_widget_unref ); | |
566 gtk_widget_show( hseparator2 ); | |
567 gtk_box_pack_start( GTK_BOX( vbox2 ),hseparator2,FALSE,FALSE,0 ); | |
568 gtk_widget_set_usize( hseparator2,-2,3 ); | |
569 | |
570 scrolledwindow3=gtk_scrolled_window_new( NULL,NULL ); | |
571 gtk_widget_ref( scrolledwindow3 ); | |
572 gtk_object_set_data_full( GTK_OBJECT( PlayList ),"scrolledwindow3",scrolledwindow3,(GtkDestroyNotify)gtk_widget_unref ); | |
573 gtk_widget_show( scrolledwindow3 ); | |
574 gtk_box_pack_start( GTK_BOX( vbox2 ),scrolledwindow3,TRUE,TRUE,0 ); | |
575 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow3 ),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC ); | |
576 | |
577 CLSelected=gtk_clist_new( 2 ); | |
578 gtk_widget_ref( CLSelected ); | |
579 gtk_object_set_data_full( GTK_OBJECT( PlayList ),"CLSelected",CLSelected,(GtkDestroyNotify)gtk_widget_unref ); | |
580 gtk_widget_show( CLSelected ); | |
581 gtk_container_add( GTK_CONTAINER( scrolledwindow3 ),CLSelected ); | |
582 gtk_clist_set_column_width( GTK_CLIST( CLSelected ),0,295 ); | |
583 gtk_clist_set_column_width( GTK_CLIST( CLSelected ),1,295 ); | |
584 gtk_clist_set_selection_mode( GTK_CLIST( CLSelected ),GTK_SELECTION_MULTIPLE ); | |
585 gtk_clist_column_titles_show( GTK_CLIST( CLSelected ) ); | |
586 gtk_clist_set_shadow_type( GTK_CLIST( CLSelected ),GTK_SHADOW_NONE ); | |
2901 | 587 |
6713 | 588 label5=gtk_label_new( MSGTR_PLAYLIST_Selected ); |
589 gtk_widget_ref( label5 ); | |
590 gtk_object_set_data_full( GTK_OBJECT( PlayList ),"label5",label5,(GtkDestroyNotify)gtk_widget_unref ); | |
591 gtk_widget_show( label5 ); | |
592 gtk_clist_set_column_widget( GTK_CLIST( CLSelected ),0,label5 ); | |
593 gtk_misc_set_alignment( GTK_MISC( label5 ),0.02,0.5 ); | |
594 | |
595 label5=gtk_label_new( MSGTR_PLAYLIST_Path ); | |
596 gtk_widget_ref( label5 ); | |
597 gtk_object_set_data_full( GTK_OBJECT( PlayList ),"label5",label5,(GtkDestroyNotify)gtk_widget_unref ); | |
598 gtk_widget_show( label5 ); | |
599 gtk_clist_set_column_widget( GTK_CLIST( CLSelected ),1,label5 ); | |
600 gtk_misc_set_alignment( GTK_MISC( label5 ),0.02,0.5 ); | |
2901 | 601 |
6713 | 602 hseparator1=gtk_hseparator_new(); |
603 gtk_widget_ref( hseparator1 ); | |
604 gtk_object_set_data_full( GTK_OBJECT( PlayList ),"hseparator1",hseparator1,(GtkDestroyNotify)gtk_widget_unref ); | |
605 gtk_widget_show( hseparator1 ); | |
606 gtk_box_pack_start( GTK_BOX( vbox1 ),hseparator1,FALSE,FALSE,0 ); | |
607 gtk_widget_set_usize( hseparator1,-2,6 ); | |
608 | |
609 hbuttonbox1=gtk_hbutton_box_new(); | |
610 gtk_widget_ref( hbuttonbox1 ); | |
611 gtk_object_set_data_full( GTK_OBJECT( PlayList ),"hbuttonbox1",hbuttonbox1,(GtkDestroyNotify)gtk_widget_unref ); | |
612 gtk_widget_show( hbuttonbox1 ); | |
613 gtk_box_pack_start( GTK_BOX( vbox1 ),hbuttonbox1,FALSE,FALSE,0 ); | |
614 gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox1 ),GTK_BUTTONBOX_END ); | |
615 gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox1 ),10 ); | |
616 gtk_button_box_set_child_size( GTK_BUTTON_BOX( hbuttonbox1 ),-1,20 ); | |
617 gtk_button_box_set_child_ipadding( GTK_BUTTON_BOX( hbuttonbox1 ),0,-1 ); | |
618 | |
619 Add=gtk_button_new_with_label( MSGTR_Add ); | |
2901 | 620 gtk_widget_ref( Add ); |
6713 | 621 gtk_object_set_data_full( GTK_OBJECT( PlayList ),"Add",Add,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 622 gtk_widget_show( Add ); |
6713 | 623 gtk_container_add( GTK_CONTAINER( hbuttonbox1 ),Add ); |
624 GTK_WIDGET_UNSET_FLAGS( Add,GTK_CAN_FOCUS ); | |
2901 | 625 |
6713 | 626 Remove=gtk_button_new_with_label( MSGTR_Remove ); |
2901 | 627 gtk_widget_ref( Remove ); |
6713 | 628 gtk_object_set_data_full( GTK_OBJECT( PlayList ),"Remove",Remove,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 629 gtk_widget_show( Remove ); |
6713 | 630 gtk_container_add( GTK_CONTAINER( hbuttonbox1 ),Remove ); |
631 GTK_WIDGET_UNSET_FLAGS( Remove,GTK_CAN_FOCUS ); | |
2901 | 632 |
6713 | 633 Ok=gtk_button_new_with_label( MSGTR_Ok ); |
2901 | 634 gtk_widget_ref( Ok ); |
6713 | 635 gtk_object_set_data_full( GTK_OBJECT( PlayList ),"Ok",Ok,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 636 gtk_widget_show( Ok ); |
6713 | 637 gtk_container_add( GTK_CONTAINER( hbuttonbox1 ),Ok ); |
638 GTK_WIDGET_UNSET_FLAGS( Ok,GTK_CAN_FOCUS ); | |
639 // gtk_widget_add_accelerator( Ok,"released",accel_group,GDK_Return,0,GTK_ACCEL_VISIBLE ); | |
2901 | 640 |
7169 | 641 Cancel=gtk_button_new_with_label( MSGTR_Cancel ); |
2901 | 642 gtk_widget_ref( Cancel ); |
6713 | 643 gtk_object_set_data_full( GTK_OBJECT( PlayList ),"Cancel",Cancel,(GtkDestroyNotify)gtk_widget_unref ); |
2901 | 644 gtk_widget_show( Cancel ); |
6713 | 645 gtk_container_add( GTK_CONTAINER( hbuttonbox1 ),Cancel ); |
646 GTK_WIDGET_UNSET_FLAGS( Cancel,GTK_CAN_FOCUS ); | |
647 gtk_widget_add_accelerator( Cancel,"released",accel_group,GDK_Escape,0,GTK_ACCEL_VISIBLE ); | |
2901 | 648 |
6713 | 649 gtk_signal_connect( GTK_OBJECT( PlayList ),"destroy",GTK_SIGNAL_FUNC( plDestroy ),NULL ); |
650 gtk_signal_connect( GTK_OBJECT( PlayList ),"show",GTK_SIGNAL_FUNC( plShow ),(void *)1 ); | |
651 gtk_signal_connect( GTK_OBJECT( PlayList ),"hide",GTK_SIGNAL_FUNC( plShow ),(void *)0 ); | |
652 | |
653 gtk_signal_connect( GTK_OBJECT( CLFiles ),"select_row",GTK_SIGNAL_FUNC( plRowSelect ),(void *)0 ); | |
654 gtk_signal_connect( GTK_OBJECT( CLFiles ),"unselect_row",GTK_SIGNAL_FUNC( plUnRowSelect ),(void *)0 ); | |
655 sigSel=gtk_signal_connect( GTK_OBJECT( CLSelected ),"select_row",GTK_SIGNAL_FUNC( plRowSelect ),(void*)1 ); | |
656 sigUnsel=gtk_signal_connect( GTK_OBJECT( CLSelected ),"unselect_row",GTK_SIGNAL_FUNC( plUnRowSelect ),(void*)1 ); | |
657 | |
658 gtk_signal_connect( GTK_OBJECT( Add ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)3 ); | |
659 gtk_signal_connect( GTK_OBJECT( Remove ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)2 ); | |
660 gtk_signal_connect( GTK_OBJECT( Ok ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)1 ); | |
661 gtk_signal_connect( GTK_OBJECT( Cancel ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)0 ); | |
662 | |
663 gtk_window_add_accel_group( GTK_WINDOW( PlayList ),accel_group ); | |
2901 | 664 |
665 return PlayList; | |
666 } | |
667 |