Mercurial > mplayer.hg
annotate gui/dialog/playlist.c @ 37078:7471626e943e
Relocate add_vf().
Additionally, add doxygen comment.
author | ib |
---|---|
date | Thu, 24 Apr 2014 13:31:52 +0000 |
parents | 1236a692d0c6 |
children | ae4f30c4ef02 |
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> | |
36772
0da6c7ff95d2
Revise code of listMgr() command PLAYLIST_ITEM_GET_POS.
ib
parents:
36762
diff
changeset
|
24 #include <stdint.h> |
33572 | 25 #include <stdio.h> |
26 #include <stdlib.h> | |
27 | |
28 #include <gdk/gdkkeysyms.h> | |
29 #include <gtk/gtk.h> | |
30 | |
31 #include "help_mp.h" | |
32 #include "stream/stream.h" | |
33 | |
35525 | 34 #include "gui/app/cfg.h" |
35 #include "gui/app/gui.h" | |
35381
746e2e0577b2
Without current playlist item, reset guiInfo's Filename and StreamType.
ib
parents:
34681
diff
changeset
|
36 #include "gui/interface.h" |
35529 | 37 #include "dialog.h" |
36026 | 38 #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
|
39 #include "gui/util/list.h" |
33739 | 40 #include "gui/util/mem.h" |
35461 | 41 #include "gui/util/string.h" |
33572 | 42 #include "playlist.h" |
43 #include "tools.h" | |
44 | |
35526 | 45 #include "pixmaps/open2.xpm" |
46 #include "pixmaps/dir2.xpm" | |
33572 | 47 |
36011 | 48 #define CFG_OLD_PLAYLIST |
35872
93ab56bda68a
Utilize new cfg_old_filename_from_utf8() in playlist code.
ib
parents:
35578
diff
changeset
|
49 #include "gui/app/cfg-old.c" |
93ab56bda68a
Utilize new cfg_old_filename_from_utf8() in playlist code.
ib
parents:
35578
diff
changeset
|
50 |
35981 | 51 GtkWidget * Playlist = NULL; |
33572 | 52 static GtkWidget * CTDirTree; |
53 static GtkWidget * CLFiles; | |
54 static GtkWidget * CLSelected; | |
55 static GtkWidget * Add; | |
56 static GtkWidget * Remove; | |
57 static GtkWidget * Ok; | |
58 static GtkWidget * Cancel; | |
59 static GdkPixmap * pxOpenedBook; | |
60 static GdkPixmap * pxClosedBook; | |
61 static GdkBitmap * msOpenedBook; | |
62 static GdkBitmap * msClosedBook; | |
63 | |
64 static int NrOfEntrys = 0; | |
65 static int NrOfSelected = 0; | |
66 static int * CLFileSelected = NULL; | |
67 static int * CLListSelected = NULL; | |
68 | |
69 static int sigSel; | |
70 static int sigUnsel; | |
71 static int sigEvent; | |
72 | |
73 typedef struct | |
74 { | |
75 int scaned; | |
76 char * path; | |
77 } DirNodeType; | |
78 | |
79 static GtkCTreeNode * sibling; | |
80 static GtkCTreeNode * parent; | |
81 static gchar * current_path; | |
82 static gchar * old_path = NULL; | |
83 | |
84 static int compare_func(const void *a, const void *b) | |
85 { | |
86 char * tmp; | |
87 int i; | |
88 if ( !a || !b || !( (DirNodeType *)a )->path ) return -1; | |
36842 | 89 tmp=strdup( b ); tmp[strlen( tmp )-1]=0; |
33572 | 90 i=strcmp( ( (DirNodeType *)a )->path,tmp ); |
91 free( tmp ); | |
92 return i; | |
93 } | |
94 | |
95 static void plRowSelect( GtkCList * clist,gint row,gint column,GdkEvent * event,gpointer user_data ) | |
96 { | |
36010 | 97 (void) clist; |
98 (void) column; | |
99 (void) event; | |
100 | |
36776 | 101 switch ( GPOINTER_TO_INT( user_data) ) |
33572 | 102 { |
35493 | 103 case 0: CLFileSelected[row]=True; break; |
104 case 1: CLListSelected[row]=True; break; | |
33572 | 105 } |
106 } | |
107 | |
108 static void plUnRowSelect( GtkCList * clist,gint row,gint column,GdkEvent * event,gpointer user_data ) | |
109 { | |
36010 | 110 (void) clist; |
111 (void) column; | |
112 (void) event; | |
113 | |
36776 | 114 switch ( GPOINTER_TO_INT( user_data) ) |
33572 | 115 { |
35493 | 116 case 0: CLFileSelected[row]=False; break; |
117 case 1: CLListSelected[row]=False; break; | |
33572 | 118 } |
119 } | |
120 | |
121 static void plButtonReleased( GtkButton * button,gpointer user_data ) | |
122 { | |
36010 | 123 (void) button; |
124 | |
36776 | 125 switch ( GPOINTER_TO_INT( user_data) ) |
33572 | 126 { |
127 case 1: // ok | |
128 { | |
37023 | 129 int i; |
130 plItem curr, * item, * old; | |
131 item = listMgr( PLAYLIST_ITEM_GET_CURR,0 ); | |
132 if (item) | |
133 { | |
134 curr.path = gstrdup(item->path); | |
135 curr.name = gstrdup(item->name); | |
136 } | |
137 else | |
138 { | |
139 curr.path = NULL; | |
140 curr.name = NULL; | |
141 } | |
142 listMgr( PLAYLIST_DELETE,0 ); | |
143 for ( i=0;i<NrOfSelected;i++ ) | |
144 { | |
145 char * text[2]; | |
146 item=calloc( 1,sizeof( plItem ) ); | |
147 gtk_clist_get_text( GTK_CLIST( CLSelected ),i,2,&text[0] ); | |
148 gtk_clist_get_text( GTK_CLIST( CLSelected ),i,3,&text[1] ); | |
149 item->name = strdup( text[0] ); | |
150 item->path = strdup( text[1] ); | |
151 listMgr( PLAYLIST_ITEM_APPEND,item ); | |
152 } | |
153 item = listMgr( PLAYLIST_GET,0 ); | |
154 if ( item ) | |
155 { | |
156 if ( guiInfo.Playing ) | |
157 { | |
158 old = listMgr( PLAYLIST_ITEM_FIND,&curr ); | |
159 if ( old ) | |
160 { | |
161 listMgr( PLAYLIST_ITEM_SET_CURR,old ); | |
162 guiInfo.Track = (uintptr_t) listMgr( PLAYLIST_ITEM_GET_POS,old ); | |
163 item = NULL; | |
164 } | |
165 } | |
166 if ( item ) | |
167 { | |
168 uiSetFile( item->path,item->name,STREAMTYPE_FILE ); | |
169 guiInfo.MediumChanged = GUI_MEDIUM_NEW; | |
170 guiInfo.PlaylistNext = !guiInfo.Playing; | |
171 guiInfo.Track = 1; | |
172 } | |
173 } | |
174 else if (isPlaylistStreamtype && !guiInfo.Playing) uiUnsetFile(); | |
175 guiInfo.Tracks = (uintptr_t) listMgr( PLAYLIST_ITEM_GET_POS,0 ); | |
176 free(curr.path); | |
177 free(curr.name); | |
33572 | 178 } |
179 case 0: // cancel | |
36000 | 180 NrOfSelected=NrOfEntrys=0; |
181 nfree( CLListSelected ); | |
182 nfree( CLFileSelected ); | |
183 free( old_path ); | |
184 old_path=strdup( current_path ); | |
185 gtk_widget_destroy( Playlist ); | |
33572 | 186 break; |
187 case 2: // remove | |
188 { | |
37023 | 189 int i; int j; |
33572 | 190 |
37023 | 191 gtk_signal_handler_block( GTK_OBJECT( CLSelected ),sigSel ); |
192 gtk_signal_handler_block( GTK_OBJECT( CLSelected ),sigUnsel ); | |
193 gtk_signal_handler_block( GTK_OBJECT( CLSelected ),sigEvent ); | |
33572 | 194 |
195 gtk_clist_freeze( GTK_CLIST( CLSelected ) ); | |
35522 | 196 i = 0; |
197 while ( i<NrOfSelected ) | |
198 { | |
37023 | 199 if ( CLListSelected[i] ) |
200 { | |
201 gtk_clist_remove( GTK_CLIST( CLSelected ),i ); | |
202 NrOfSelected--; | |
203 for ( j=i;j<NrOfSelected;j++ ) | |
204 CLListSelected[j] = CLListSelected[j+1]; | |
205 } | |
206 else i++; | |
35522 | 207 } |
37023 | 208 gtk_clist_thaw( GTK_CLIST( CLSelected ) ); |
33572 | 209 |
37023 | 210 gtk_signal_handler_unblock( GTK_OBJECT( CLSelected ),sigSel ); |
211 gtk_signal_handler_unblock( GTK_OBJECT( CLSelected ),sigUnsel ); | |
212 gtk_signal_handler_unblock( GTK_OBJECT( CLSelected ),sigEvent ); | |
33572 | 213 |
214 } | |
215 break; | |
216 case 3: // add | |
217 { | |
218 int i; | |
219 void *p; | |
35927 | 220 char * itext[2]; |
221 char * text[1][5]; text[0][4]=""; | |
33572 | 222 gtk_clist_freeze( GTK_CLIST( CLSelected ) ); |
223 for ( i=0;i<NrOfEntrys;i++ ) | |
224 { | |
225 if ( CLFileSelected[i] ) | |
226 { | |
37023 | 227 NrOfSelected++; |
228 p=realloc( CLListSelected,NrOfSelected * sizeof( int ) ); | |
229 if ( !p ) NrOfSelected--; | |
230 else | |
231 { | |
232 CLListSelected=p; | |
233 CLListSelected[NrOfSelected - 1]=False; | |
234 gtk_clist_get_text( GTK_CLIST( CLFiles ),i,0,&itext[0] ); | |
235 gtk_clist_get_text( GTK_CLIST( CLFiles ),i,1,&itext[1] ); | |
236 text[0][0]=itext[0]; text[0][1]=g_filename_display_name( current_path ); | |
237 text[0][2]=itext[1]; text[0][3]=current_path; | |
238 gtk_clist_append( GTK_CLIST( CLSelected ),text[0] ); | |
239 g_free( text[0][1] ); | |
240 } | |
241 } | |
242 } | |
243 gtk_clist_thaw( GTK_CLIST( CLSelected ) ); | |
33572 | 244 } |
245 break; | |
246 } | |
247 } | |
248 | |
34348 | 249 static gboolean plKeyReleased( GtkWidget * widget, |
250 GdkEventKey * event, | |
251 gpointer user_data ) | |
252 { | |
34349 | 253 if (event->keyval == GDK_Return) |
254 { | |
255 if ( GTK_WIDGET_TYPE( widget ) == GTK_TYPE_BUTTON ) plButtonReleased( NULL, user_data ); | |
256 else | |
257 { | |
36776 | 258 switch ( GPOINTER_TO_INT( user_data) ) |
34349 | 259 { |
260 case 0: | |
36776 | 261 plButtonReleased( NULL, GINT_TO_POINTER(3) ); |
34349 | 262 break; |
263 case 1: | |
36776 | 264 plButtonReleased( NULL, GINT_TO_POINTER(2) ); |
34349 | 265 break; |
266 } | |
267 } | |
268 } | |
34348 | 269 return FALSE; |
270 } | |
271 | |
33572 | 272 static gboolean plEvent ( GtkWidget * widget, |
273 GdkEvent * event, | |
274 gpointer user_data ) | |
275 { | |
276 GdkEventButton *bevent; | |
277 gint row, col; | |
278 | |
279 bevent = (GdkEventButton *) event; | |
280 | |
281 if ( event->type == GDK_BUTTON_RELEASE && bevent->button == 2 ) | |
282 { | |
283 if ( gtk_clist_get_selection_info( GTK_CLIST( widget ), bevent->x, bevent->y, &row, &col ) ) | |
284 { | |
36776 | 285 switch ( GPOINTER_TO_INT( user_data) ) |
33572 | 286 { |
287 case 0: | |
35493 | 288 CLFileSelected[row] = True; |
36776 | 289 plButtonReleased( NULL, GINT_TO_POINTER(3) ); |
35493 | 290 CLFileSelected[row] = False; |
33572 | 291 return TRUE; |
292 | |
293 case 1: | |
35493 | 294 CLListSelected[row] = True; |
36776 | 295 plButtonReleased( NULL, GINT_TO_POINTER(2) ); |
33572 | 296 return TRUE; |
297 } | |
298 } | |
299 } | |
300 | |
301 return FALSE; | |
302 } | |
303 | |
304 static int check_for_subdir( gchar * path ) | |
305 { | |
37023 | 306 DIR * dir; |
33572 | 307 struct dirent * dirent; |
308 struct stat statbuf; | |
37023 | 309 gchar * npath; |
33572 | 310 |
311 if ( (dir=opendir( path )) ) | |
312 { | |
313 while ( (dirent=readdir( dir )) ) | |
314 { | |
315 if ( dirent->d_name[0] != '.' ) | |
316 { | |
317 npath=calloc( 1,strlen( path ) + strlen( dirent->d_name ) + 3 ); | |
318 sprintf( npath,"%s/%s",path,dirent->d_name ); | |
319 if ( stat( npath,&statbuf ) != -1 && S_ISDIR( statbuf.st_mode ) ) | |
35493 | 320 { free( npath ); closedir( dir ); return True; } |
33572 | 321 free( npath ); |
322 } | |
323 } | |
324 closedir( dir ); | |
325 } | |
35493 | 326 return False; |
33572 | 327 } |
328 | |
329 static void plCTree( GtkCTree * ctree,GtkCTreeNode * parent_node,gpointer user_data ) | |
330 { | |
331 GtkCTreeNode * node; | |
332 DirNodeType * DirNode; | |
37023 | 333 gchar * text, * utf8name = NULL; |
334 gchar * dummy = "dummy"; | |
335 int subdir = True; | |
336 DIR * dir = NULL; | |
33572 | 337 struct dirent * dirent; |
37023 | 338 gchar * path; |
339 struct stat statbuf; | |
33572 | 340 |
36010 | 341 (void) user_data; |
342 | |
33572 | 343 DirNode=gtk_ctree_node_get_row_data( ctree,parent_node ); |
344 if ( !DirNode->scaned ) | |
345 { | |
35493 | 346 DirNode->scaned=True; current_path=DirNode->path; |
33572 | 347 gtk_clist_freeze( GTK_CLIST( ctree ) ); |
348 node=gtk_ctree_find_by_row_data( ctree,parent_node,NULL ); | |
349 gtk_ctree_remove_node( ctree,node ); | |
350 | |
351 if ( (dir=opendir( DirNode->path ) ) ) | |
352 { | |
353 while( (dirent=readdir( dir )) ) | |
354 { | |
355 path=calloc( 1,strlen( DirNode->path ) + strlen( dirent->d_name ) + 2 ); | |
356 if ( !strcmp( current_path,"/" ) ) sprintf( path,"/%s",dirent->d_name ); | |
37023 | 357 else sprintf( path,"%s/%s",current_path,dirent->d_name ); |
33572 | 358 text=dirent->d_name; |
35938
8515446e81c6
Cosmetic: Rename variables holding data in UTF-8 encoding.
ib
parents:
35927
diff
changeset
|
359 g_free( utf8name ); |
8515446e81c6
Cosmetic: Rename variables holding data in UTF-8 encoding.
ib
parents:
35927
diff
changeset
|
360 utf8name=g_filename_display_name( text ); |
33572 | 361 |
362 if ( stat( path,&statbuf ) != -1 && S_ISDIR( statbuf.st_mode ) && dirent->d_name[0] != '.' ) | |
37023 | 363 { |
364 DirNode=malloc( sizeof( DirNodeType ) ); DirNode->scaned=False; DirNode->path=strdup( path ); | |
365 subdir=check_for_subdir( path ); | |
366 node=gtk_ctree_insert_node( ctree,parent_node,NULL,&utf8name,4,pxOpenedBook,msOpenedBook,pxClosedBook,msClosedBook,!subdir,FALSE ); | |
367 gtk_ctree_node_set_row_data_full( ctree,node,DirNode,NULL ); | |
368 if ( subdir ) gtk_ctree_insert_node( ctree,node,NULL,&dummy,4,NULL,NULL,NULL,NULL,FALSE,FALSE ); | |
369 } | |
33572 | 370 free( path ); path=NULL; |
371 } | |
372 closedir( dir ); | |
373 } | |
374 | |
375 gtk_ctree_sort_node( ctree,parent_node ); | |
376 gtk_clist_thaw( GTK_CLIST( ctree ) ); | |
377 } | |
378 | |
35938
8515446e81c6
Cosmetic: Rename variables holding data in UTF-8 encoding.
ib
parents:
35927
diff
changeset
|
379 g_free( utf8name ); |
33572 | 380 } |
381 | |
382 static void scan_dir( char * path ) | |
383 { | |
37023 | 384 DIR * dir = NULL; |
385 char * curr; | |
33572 | 386 struct dirent * dirent; |
37023 | 387 struct stat statbuf; |
388 char * text[1][3]; text[0][2]=""; | |
33572 | 389 |
390 gtk_clist_clear( GTK_CLIST( CLFiles ) ); | |
391 if ( (dir=opendir( path )) ) | |
392 { | |
393 NrOfEntrys=0; | |
394 while( (dirent=readdir( dir )) ) | |
395 { | |
37023 | 396 curr=calloc( 1,strlen( path ) + strlen( dirent->d_name ) + 3 ); sprintf( curr,"%s/%s",path,dirent->d_name ); |
397 if ( stat( curr,&statbuf ) != -1 && ( S_ISREG( statbuf.st_mode ) || S_ISLNK( statbuf.st_mode ) ) ) | |
398 { | |
399 text[0][0]=g_filename_display_name( dirent->d_name ); | |
400 text[0][1]=dirent->d_name; | |
401 gtk_clist_append( GTK_CLIST( CLFiles ), text[0] ); | |
402 g_free( text[0][0] ); | |
403 NrOfEntrys++; | |
404 } | |
405 free( curr ); | |
406 } | |
33572 | 407 closedir( dir ); |
408 gtk_clist_sort( GTK_CLIST( CLFiles ) ); | |
409 } | |
410 } | |
411 | |
34466
a650895d50a5
Use correct data types and common variable names in GTK callback functions.
ib
parents:
34349
diff
changeset
|
412 static void plCTRow(GtkCList * clist, gint row, gint column, GdkEvent * event, gpointer user_data) |
33572 | 413 { |
414 DirNodeType * DirNode; | |
415 GtkCTreeNode * node; | |
36010 | 416 |
417 (void) column; | |
418 (void) event; | |
419 (void) user_data; | |
420 | |
34466
a650895d50a5
Use correct data types and common variable names in GTK callback functions.
ib
parents:
34349
diff
changeset
|
421 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
|
422 DirNode=gtk_ctree_node_get_row_data( GTK_CTREE( clist ),node ); |
33572 | 423 current_path=DirNode->path; |
34466
a650895d50a5
Use correct data types and common variable names in GTK callback functions.
ib
parents:
34349
diff
changeset
|
424 gtk_ctree_expand( GTK_CTREE( clist ),node ); |
33572 | 425 scan_dir( DirNode->path ); |
426 free( CLFileSelected ); | |
427 CLFileSelected=calloc( 1,NrOfEntrys * sizeof( int ) ); | |
428 } | |
429 | |
35996 | 430 static GtkWidget * CreatePlaylist( void ) |
33572 | 431 { |
37023 | 432 GtkWidget * vbox1; |
433 GtkWidget * hbox1; | |
434 GtkWidget * scrolledwindow1; | |
435 GtkWidget * vbox2; | |
436 GtkWidget * scrolledwindow2; | |
437 GtkWidget * scrolledwindow3; | |
438 GtkWidget * hbuttonbox1; | |
33572 | 439 GtkAccelGroup * accel_group; |
37023 | 440 GdkColor transparent = { 0,0,0,0 }; |
441 gchar * root = "/"; | |
442 gchar * dummy = "dummy"; | |
443 DirNodeType * DirNode; | |
35963
db72a3183d41
Preselect current playlist directory from last playlist entry.
ib
parents:
35938
diff
changeset
|
444 plItem * last; |
33572 | 445 |
446 accel_group=gtk_accel_group_new(); | |
447 | |
35981 | 448 Playlist=gtk_window_new( GTK_WINDOW_TOPLEVEL ); |
449 gtk_widget_set_usize( Playlist,512,384 ); | |
36694 | 450 gtk_window_set_title( GTK_WINDOW( Playlist ),MSGTR_GUI_Playlist ); |
35981 | 451 gtk_window_set_position( GTK_WINDOW( Playlist ),GTK_WIN_POS_CENTER ); |
36053 | 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 ); | |
36777 | 468 gtk_signal_connect( GTK_OBJECT( CTDirTree ),"tree-expand",GTK_SIGNAL_FUNC( plCTree ),NULL ); |
469 gtk_signal_connect( GTK_OBJECT( CTDirTree ),"select-row",GTK_SIGNAL_FUNC( plCTRow ),NULL ); | |
33572 | 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, | |
36694 | 495 gtkAddLabel( MSGTR_GUI_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, | |
36694 | 517 gtkAddLabel( MSGTR_GUI_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, | |
36694 | 540 gtkAddLabel( MSGTR_GUI_SelectedFiles,NULL ) ); |
33572 | 541 |
542 gtk_clist_set_column_widget( GTK_CLIST( CLSelected ),1, | |
36694 | 543 gtkAddLabel( MSGTR_GUI_Directory,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 | |
36694 | 553 Add=gtkAddButton( MSGTR_GUI_Add,hbuttonbox1 ); |
554 Remove=gtkAddButton( MSGTR_GUI_Remove,hbuttonbox1 ); | |
555 Ok=gtkAddButton( MSGTR_GUI_Ok,hbuttonbox1 ); | |
556 Cancel=gtkAddButton( MSGTR_GUI_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 |
36776 | 562 gtk_signal_connect( GTK_OBJECT( CLFiles ),"select-row",GTK_SIGNAL_FUNC( plRowSelect ),GINT_TO_POINTER(0) ); |
563 gtk_signal_connect( GTK_OBJECT( CLFiles ),"unselect-row",GTK_SIGNAL_FUNC( plUnRowSelect ),GINT_TO_POINTER(0) ); | |
564 gtk_signal_connect( GTK_OBJECT( CLFiles ),"event",GTK_SIGNAL_FUNC( plEvent ),GINT_TO_POINTER(0) ); | |
565 gtk_signal_connect( GTK_OBJECT( CLFiles ),"key-release-event",GTK_SIGNAL_FUNC( plKeyReleased ),GINT_TO_POINTER(0) ); | |
566 sigSel=gtk_signal_connect( GTK_OBJECT( CLSelected ),"select-row",GTK_SIGNAL_FUNC( plRowSelect ),GINT_TO_POINTER(1) ); | |
567 sigUnsel=gtk_signal_connect( GTK_OBJECT( CLSelected ),"unselect-row",GTK_SIGNAL_FUNC( plUnRowSelect ),GINT_TO_POINTER(1) ); | |
568 sigEvent=gtk_signal_connect( GTK_OBJECT( CLSelected ),"event",GTK_SIGNAL_FUNC( plEvent ),GINT_TO_POINTER(1) ); | |
569 gtk_signal_connect( GTK_OBJECT( CLSelected ),"key-release-event",GTK_SIGNAL_FUNC( plKeyReleased ),GINT_TO_POINTER(1) ); | |
33572 | 570 |
36776 | 571 gtk_signal_connect( GTK_OBJECT( Add ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),GINT_TO_POINTER(3) ); |
572 gtk_signal_connect( GTK_OBJECT( Add ),"key-release-event",GTK_SIGNAL_FUNC( plKeyReleased ),GINT_TO_POINTER(3) ); | |
573 gtk_signal_connect( GTK_OBJECT( Remove ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),GINT_TO_POINTER(2) ); | |
574 gtk_signal_connect( GTK_OBJECT( Remove ),"key-release-event",GTK_SIGNAL_FUNC( plKeyReleased ),GINT_TO_POINTER(2) ); | |
575 gtk_signal_connect( GTK_OBJECT( Ok ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),GINT_TO_POINTER(1) ); | |
576 gtk_signal_connect( GTK_OBJECT( Ok ),"key-release-event",GTK_SIGNAL_FUNC( plKeyReleased ),GINT_TO_POINTER(1) ); | |
577 gtk_signal_connect( GTK_OBJECT( Cancel ),"released",GTK_SIGNAL_FUNC( plButtonReleased ),GINT_TO_POINTER(0) ); | |
578 gtk_signal_connect( GTK_OBJECT( Cancel ),"key-release-event",GTK_SIGNAL_FUNC( plKeyReleased ),GINT_TO_POINTER(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 ); | |
37023 | 615 DirNode=gtk_ctree_node_get_row_data( GTK_CTREE( CTDirTree ),node ); |
616 current_path=DirNode->path; | |
35982 | 617 scan_dir( DirNode->path ); |
37023 | 618 free( CLFileSelected ); |
619 CLFileSelected=calloc( 1,NrOfEntrys * sizeof( int ) ); | |
620 break; | |
35982 | 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 } |