annotate gui/mplayer/gtk/pl.c @ 26458:b0a7b35b78d2

Add standard GPL header to individual files.
author diego
date Tue, 22 Apr 2008 09:33:39 +0000
parents b2f4abcf20ed
children 0f1b5b68af32
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
26458
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
1 /*
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
2 * This file is part of MPlayer.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
3 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
5 * it under the terms of the GNU General Public License as published by
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
7 * (at your option) any later version.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
8 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
12 * GNU General Public License for more details.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
13 *
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
14 * You should have received a copy of the GNU General Public License along
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
b0a7b35b78d2 Add standard GPL header to individual files.
diego
parents: 26382
diff changeset
17 */
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
18
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
19 #include <sys/types.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
20 #include <sys/stat.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
21 #include <string.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
22 #include <dirent.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
23 #include <unistd.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
24 #include <stdio.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
25 #include <stdlib.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
26
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
27 #include <gdk/gdkkeysyms.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
28 #include <gtk/gtk.h>
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
29
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
30 #include "config.h"
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
31 #include "help_mp.h"
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
32 #include "stream/stream.h"
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
33
26365
10dfbc523184 Add gui/ prefix to some #include paths so that compilation from the
diego
parents: 25601
diff changeset
34 #include "gui/interface.h"
26382
b2f4abcf20ed Make include paths consistent; do not use ../ in them.
diego
parents: 26365
diff changeset
35 #include "gui/mplayer/widgets.h"
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
36 #include "pl.h"
25601
8a0adeba5910 Rename common.[ch] to gtk_common.[ch], there are too many files by that name.
diego
parents: 23077
diff changeset
37 #include "gtk_common.h"
23077
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
38
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
39 static char * book_open_xpm[] = {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
40 "16 16 4 1",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
41 " c None s None",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
42 ". c black",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
43 "X c #808080",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
44 "o c white",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
45 " ",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
46 " .. ",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
47 " .Xo. ... ",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
48 " .Xoo. ..oo. ",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
49 " .Xooo.Xooo... ",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
50 " .Xooo.oooo.X. ",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
51 " .Xooo.Xooo.X. ",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
52 " .Xooo.oooo.X. ",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
53 " .Xooo.Xooo.X. ",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
54 " .Xooo.oooo.X. ",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
55 " .Xoo.Xoo..X. ",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
56 " .Xo.o..ooX. ",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
57 " .X..XXXXX. ",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
58 " ..X....... ",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
59 " .. ",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
60 " "};
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
61
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
62 static char * book_closed_xpm[] = {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
63 "16 16 6 1",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
64 " c None s None",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
65 ". c black",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
66 "X c blue",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
67 "o c yellow",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
68 "O c #007FEA",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
69 "# c white",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
70 " ",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
71 " .. ",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
72 " ..XX. ",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
73 " ..XXXXX. ",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
74 " ..XXXXXXXX. ",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
75 ".ooXXXXXXXXX. ",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
76 "..ooXXXXXXXXX. ",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
77 ".X.ooXXXXXXXXX. ",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
78 ".XX.ooXXXXXX.. ",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
79 " .XX.ooXXX..#O ",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
80 " .XX.oo..##OO. ",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
81 " .XX..##OO.. ",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
82 " .X.#OO.. ",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
83 " ..O.. ",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
84 " .. ",
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
85 " "};
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
86
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
87 GtkWidget * PlayList = NULL;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
88 static GtkWidget * CTDirTree;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
89 static GtkWidget * CLFiles;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
90 static GtkWidget * CLSelected;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
91 static GtkWidget * Add;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
92 static GtkWidget * Remove;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
93 static GtkWidget * Ok;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
94 static GtkWidget * Cancel;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
95 static GdkPixmap * pxOpenedBook;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
96 static GdkPixmap * pxClosedBook;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
97 static GdkBitmap * msOpenedBook;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
98 static GdkBitmap * msClosedBook;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
99
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
100 static int NrOfEntrys = 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
101 static int NrOfSelected = 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
102 static int * CLFileSelected = NULL;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
103 static int * CLListSelected = NULL;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
104
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
105 static int sigSel;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
106 static int sigUnsel;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
107
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
108 typedef struct
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
109 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
110 int scaned;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
111 char * path;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
112 } DirNodeType;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
113
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
114 static GtkCTreeNode * sibling;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
115 static GtkCTreeNode * parent;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
116 static gchar * current_path;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
117 static gchar * old_path = NULL;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
118
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
119 static int compare_func(const void *a, const void *b)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
120 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
121 char * tmp;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
122 int i;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
123 if ( !a || !b || !( (DirNodeType *)a )->path ) return -1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
124 tmp=strdup( (char *)b ); tmp[strlen( tmp )-1]=0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
125 i=strcmp( ( (DirNodeType *)a )->path,tmp );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
126 free( tmp );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
127 return i;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
128 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
129
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
130 static void scan_dir( char * path );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
131
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
132 void ShowPlayList( void )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
133 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
134 if ( PlayList ) gtkActive( PlayList );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
135 else PlayList=create_PlayList();
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
136
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
137 if ( old_path && *old_path )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
138 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
139 char * currentdir = strdup( old_path );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
140 char * tpath,* pos;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
141 GtkCTreeNode * node,* nextnode;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
142 gboolean leaf;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
143 tpath=strdup( "/" );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
144 pos=strtok( currentdir,"/" );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
145 node=gtk_ctree_find_by_row_data_custom( GTK_CTREE( CTDirTree ),NULL,"/",compare_func );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
146 do
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
147 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
148 char * tpathnew = g_strconcat( tpath,pos,"/",NULL );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
149 free( tpath ); tpath=tpathnew;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
150 nextnode=gtk_ctree_find_by_row_data_custom( GTK_CTREE( CTDirTree ),node,tpath,compare_func );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
151 if ( !nextnode ) break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
152 node=nextnode;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
153 pos=strtok( NULL,"/" );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
154 gtk_ctree_get_node_info( GTK_CTREE( CTDirTree ),node,NULL,NULL,NULL,NULL,NULL,NULL,&leaf,NULL );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
155 if ( !leaf && pos ) gtk_ctree_expand( GTK_CTREE( CTDirTree ),node );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
156 else
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
157 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
158 DirNodeType * DirNode;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
159 gtk_ctree_select( GTK_CTREE( CTDirTree ),node );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
160 DirNode=gtk_ctree_node_get_row_data( GTK_CTREE( CTDirTree ),node );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
161 current_path=DirNode->path;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
162 scan_dir( DirNode->path );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
163 if ( CLFileSelected ) free( CLFileSelected ); CLFileSelected=calloc( 1,NrOfEntrys * sizeof( int ) );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
164 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
165 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
166 } while( pos );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
167 free( tpath );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
168 free( currentdir );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
169 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
170 else gtk_ctree_select( GTK_CTREE( CTDirTree ),parent );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
171
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
172 gtk_clist_freeze( GTK_CLIST( CLSelected ) );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
173 gtk_clist_clear( GTK_CLIST( CLSelected ) );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
174 if ( plList )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
175 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
176 plItem * next = plList;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
177 while ( next || next->next )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
178 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
179 char * text[1][3]; text[0][2]="";
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
180 text[0][0]=next->name;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
181 text[0][1]=next->path;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
182 gtk_clist_append( GTK_CLIST( CLSelected ),text[0] );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
183 NrOfSelected++;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
184 if ( next->next ) next=next->next; else break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
185 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
186 CLListSelected=calloc( 1,NrOfSelected * sizeof( int ) );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
187 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
188 gtk_clist_thaw( GTK_CLIST( CLSelected ) );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
189
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
190 gtk_widget_show( PlayList );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
191 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
192
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
193 void HidePlayList( void )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
194 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
195 if ( !PlayList ) return;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
196 NrOfSelected=NrOfEntrys=0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
197 gfree( (void **)&CLListSelected ); gfree( (void **)&CLFileSelected );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
198 if ( old_path ) free( old_path ); old_path=strdup( current_path );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
199 gtk_widget_hide( PlayList );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
200 gtk_widget_destroy( PlayList );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
201 PlayList=NULL;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
202 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
203
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
204 static void plRowSelect( GtkCList * clist,gint row,gint column,GdkEvent * event,gpointer user_data )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
205 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
206 switch ( (int) user_data )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
207 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
208 case 0: CLFileSelected[row]=1; break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
209 case 1: CLListSelected[row]=1; break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
210 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
211 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
212
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
213 static void plUnRowSelect( GtkCList * clist,gint row,gint column,GdkEvent * event,gpointer user_data )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
214 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
215 switch ( (int) user_data )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
216 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
217 case 0: CLFileSelected[row]=0; break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
218 case 1: CLListSelected[row]=0; break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
219 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
220 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
221
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
222 static void plButtonReleased( GtkButton * button,gpointer user_data )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
223 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
224 switch ( (int) user_data )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
225 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
226 case 1: // ok
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
227 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
228 int i;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
229 if ( plList ) gtkSet( gtkDelPl,0,NULL );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
230 for ( i=0;i<NrOfSelected;i++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
231 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
232 plItem * item;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
233 char * text[3];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
234 item=calloc( 1,sizeof( plItem ) );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
235 gtk_clist_get_text( GTK_CLIST( CLSelected ),i,0,&text[0] );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
236 gtk_clist_get_text( GTK_CLIST( CLSelected ),i,1,&text[1] );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
237 item->name=strdup( text[0] );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
238 item->path=strdup( text[1] );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
239 gtkSet( gtkAddPlItem,0,(void*)item );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
240 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
241 if ( plCurrent )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
242 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
243 mplSetFileName( plCurrent->path,plCurrent->name,STREAMTYPE_FILE );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
244 // guiSetDF( guiIntfStruct.Filename,plCurrent->path,plCurrent->name );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
245 // guiIntfStruct.FilenameChanged=1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
246 // guiIntfStruct.StreamType=STREAMTYPE_FILE;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
247 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
248 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
249 case 0: // cancel
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
250 HidePlayList();
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
251 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
252 case 2: // remove
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
253 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
254 int i; int j; int c=0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
255
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
256 gtk_signal_handler_block( GTK_OBJECT( CLSelected ),sigSel );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
257 gtk_signal_handler_block( GTK_OBJECT( CLSelected ),sigUnsel );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
258
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
259 gtk_clist_freeze( GTK_CLIST( CLSelected ) );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
260 for ( i=0;i<NrOfSelected-c;i++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
261 if ( CLListSelected[i] )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
262 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
263 gtk_clist_remove( GTK_CLIST( CLSelected ),i - c );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
264 c++;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
265 for ( j=i;j<NrOfSelected-c;j++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
266 CLListSelected[i] = CLListSelected[i+1];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
267 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
268 NrOfSelected-=c;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
269 gtk_clist_thaw( GTK_CLIST( CLSelected ) );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
270
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
271 gtk_signal_handler_unblock( GTK_OBJECT( CLSelected ),sigSel );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
272 gtk_signal_handler_unblock( GTK_OBJECT( CLSelected ),sigUnsel );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
273
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
274 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
275 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
276 case 3: // add
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
277 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
278 int i;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
279 char * itext[1][2];
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
280 char * text[1][3]; text[0][2]="";
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
281 gtk_clist_freeze( GTK_CLIST( CLSelected ) );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
282 for ( i=0;i<NrOfEntrys;i++ )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
283 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
284 if ( CLFileSelected[i] )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
285 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
286 gtk_clist_get_text( GTK_CLIST( CLFiles ),i,0,(char **)&itext );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
287 text[0][0]=itext[0][0]; text[0][1]=current_path;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
288 gtk_clist_append( GTK_CLIST( CLSelected ),text[0] );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
289 NrOfSelected++;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
290 CLListSelected=realloc( CLListSelected,NrOfSelected * sizeof( int ) );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
291 CLListSelected[NrOfSelected - 1]=0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
292 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
293 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
294 gtk_clist_thaw( GTK_CLIST( CLSelected ) );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
295 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
296 break;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
297 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
298 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
299
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
300 static int check_for_subdir( gchar * path )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
301 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
302 DIR * dir;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
303 struct dirent * dirent;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
304 struct stat statbuf;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
305 gchar * npath;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
306
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
307 if ( (dir=opendir( path )) )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
308 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
309 while ( (dirent=readdir( dir )) )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
310 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
311 if ( dirent->d_name[0] != '.' )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
312 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
313 npath=calloc( 1,strlen( path ) + strlen( dirent->d_name ) + 3 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
314 sprintf( npath,"%s/%s",path,dirent->d_name );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
315 if ( stat( npath,&statbuf ) != -1 && S_ISDIR( statbuf.st_mode ) )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
316 { free( npath ); closedir( dir ); return 1; }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
317 free( npath );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
318 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
319 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
320 closedir( dir );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
321 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
322 return 0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
323 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
324
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
325 static void plCTree( GtkCTree * ctree,GtkCTreeNode * parent_node,gpointer user_data )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
326 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
327 GtkCTreeNode * node;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
328 DirNodeType * DirNode;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
329 gchar * text;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
330 gchar * dummy = "dummy";
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
331 int subdir = 1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
332 DIR * dir = NULL;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
333 struct dirent * dirent;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
334 gchar * path;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
335 struct stat statbuf;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
336
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
337 DirNode=gtk_ctree_node_get_row_data( ctree,parent_node );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
338 if ( !DirNode->scaned )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
339 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
340 DirNode->scaned=1; current_path=DirNode->path;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
341 gtk_clist_freeze( GTK_CLIST( ctree ) );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
342 node=gtk_ctree_find_by_row_data( ctree,parent_node,NULL );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
343 gtk_ctree_remove_node( ctree,node );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
344
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
345 if ( (dir=opendir( DirNode->path ) ) )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
346 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
347 while( (dirent=readdir( dir )) )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
348 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
349 path=calloc( 1,strlen( DirNode->path ) + strlen( dirent->d_name ) + 2 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
350 if ( !strcmp( current_path,"/" ) ) sprintf( path,"/%s",dirent->d_name );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
351 else sprintf( path,"%s/%s",current_path,dirent->d_name );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
352 text=dirent->d_name;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
353
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
354 if ( stat( path,&statbuf ) != -1 && S_ISDIR( statbuf.st_mode ) && dirent->d_name[0] != '.' )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
355 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
356 DirNode=malloc( sizeof( DirNodeType ) ); DirNode->scaned=0; DirNode->path=strdup( path );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
357 subdir=check_for_subdir( path );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
358 node=gtk_ctree_insert_node( ctree,parent_node,NULL,&text,4,pxOpenedBook,msOpenedBook,pxClosedBook,msClosedBook,!subdir,FALSE );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
359 gtk_ctree_node_set_row_data_full( ctree,node,DirNode,NULL );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
360 if ( subdir ) node=gtk_ctree_insert_node( ctree,node,NULL,&dummy,4,NULL,NULL,NULL,NULL,FALSE,FALSE );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
361 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
362 free( path ); path=NULL;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
363 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
364 closedir( dir );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
365 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
366
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
367 gtk_ctree_sort_node( ctree,parent_node );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
368 gtk_clist_thaw( GTK_CLIST( ctree ) );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
369 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
370 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
371
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
372 static void scan_dir( char * path )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
373 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
374 DIR * dir = NULL;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
375 char * curr;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
376 struct dirent * dirent;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
377 struct stat statbuf;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
378 char * text[1][2]; text[0][1]="";
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
379
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
380 gtk_clist_clear( GTK_CLIST( CLFiles ) );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
381 if ( (dir=opendir( path )) )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
382 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
383 NrOfEntrys=0;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
384 while( (dirent=readdir( dir )) )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
385 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
386 curr=calloc( 1,strlen( path ) + strlen( dirent->d_name ) + 3 ); sprintf( curr,"%s/%s",path,dirent->d_name );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
387 if ( stat( curr,&statbuf ) != -1 && ( S_ISREG( statbuf.st_mode ) || S_ISLNK( statbuf.st_mode ) ) )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
388 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
389 text[0][0]=dirent->d_name;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
390 gtk_clist_append( GTK_CLIST( CLFiles ),text[0] );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
391 NrOfEntrys++;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
392 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
393 free( curr );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
394 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
395 closedir( dir );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
396 gtk_clist_sort( GTK_CLIST( CLFiles ) );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
397 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
398 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
399
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
400 static void plCTRow(GtkWidget * widget, gint row, gint column, GdkEventButton * bevent, gpointer data)
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
401 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
402 DirNodeType * DirNode;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
403 GtkCTreeNode * node;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
404 node=gtk_ctree_node_nth( GTK_CTREE( widget ),row );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
405 DirNode=gtk_ctree_node_get_row_data( GTK_CTREE( widget ),node );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
406 current_path=DirNode->path;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
407 gtk_ctree_expand( GTK_CTREE( widget ),node );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
408 scan_dir( DirNode->path );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
409 if ( CLFileSelected ) free( CLFileSelected ); CLFileSelected=calloc( 1,NrOfEntrys * sizeof( int ) );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
410 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
411
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
412 GtkWidget * create_PlayList( void )
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
413 {
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
414 GtkWidget * vbox1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
415 GtkWidget * hbox1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
416 GtkWidget * scrolledwindow1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
417 GtkWidget * vbox2;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
418 GtkWidget * scrolledwindow2;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
419 GtkWidget * scrolledwindow3;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
420 GtkWidget * hbuttonbox1;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
421 GtkAccelGroup * accel_group;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
422 GdkColor transparent = { 0,0,0,0 };
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
423 gchar * root = "/";
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
424 gchar * dummy = "dummy";
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
425 DirNodeType * DirNode;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
426
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
427 accel_group=gtk_accel_group_new();
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
428
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
429 PlayList=gtk_window_new( GTK_WINDOW_TOPLEVEL );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
430 gtk_object_set_data( GTK_OBJECT( PlayList ),"PlayList",PlayList );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
431 gtk_widget_set_usize( PlayList,512,384 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
432 gtk_window_set_title( GTK_WINDOW( PlayList ),MSGTR_PlayList );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
433 gtk_window_set_position( GTK_WINDOW( PlayList ),GTK_WIN_POS_CENTER );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
434 // gtk_window_set_policy( GTK_WINDOW( PlayList ),FALSE,FALSE,FALSE );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
435 gtk_window_set_wmclass( GTK_WINDOW( PlayList ),"Playlist","MPlayer" );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
436
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
437 gtk_widget_realize( PlayList );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
438 gtkAddIcon( PlayList );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
439
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
440 vbox1=AddVBox( AddDialogFrame( PlayList ),0 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
441 hbox1=AddHBox( NULL,1 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
442 gtk_box_pack_start( GTK_BOX( vbox1 ),hbox1,TRUE,TRUE,0 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
443
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
444 scrolledwindow1=gtk_scrolled_window_new( NULL,NULL );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
445 gtk_widget_show( scrolledwindow1 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
446 gtk_container_add( GTK_CONTAINER(
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
447 AddFrame( NULL,0,hbox1,1 ) ),scrolledwindow1 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
448 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow1 ),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
449
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
450 CTDirTree=gtk_ctree_new( 1,0 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
451 gtk_signal_connect( GTK_OBJECT( CTDirTree ),"tree_expand",GTK_SIGNAL_FUNC( plCTree ),(void*)0 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
452 gtk_signal_connect( GTK_OBJECT( CTDirTree ),"select_row",GTK_SIGNAL_FUNC( plCTRow ),(void *)0 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
453 gtk_container_add( GTK_CONTAINER( scrolledwindow1 ),CTDirTree );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
454 gtk_clist_set_column_auto_resize( GTK_CLIST( CTDirTree ),0,TRUE );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
455 gtk_clist_set_column_width( GTK_CLIST( CTDirTree ),0,80 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
456 gtk_clist_set_selection_mode( GTK_CLIST( CTDirTree ),GTK_SELECTION_SINGLE );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
457 gtk_ctree_set_line_style( GTK_CTREE( CTDirTree ),GTK_CTREE_LINES_SOLID );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
458 gtk_clist_column_titles_show( GTK_CLIST( CTDirTree ) );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
459 gtk_clist_set_shadow_type( GTK_CLIST( CTDirTree ),GTK_SHADOW_NONE );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
460
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
461 if ( !pxOpenedBook ) pxOpenedBook=gdk_pixmap_create_from_xpm_d( PlayList->window,&msOpenedBook,&transparent,book_closed_xpm );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
462 if ( !pxClosedBook ) pxClosedBook=gdk_pixmap_create_from_xpm_d( PlayList->window,&msClosedBook,&transparent,book_open_xpm );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
463
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
464 parent=gtk_ctree_insert_node( GTK_CTREE( CTDirTree ),NULL,NULL,&root,4,pxOpenedBook,msOpenedBook,pxClosedBook,msClosedBook,FALSE,FALSE );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
465 DirNode=malloc( sizeof( DirNodeType ) );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
466 DirNode->scaned=0; DirNode->path=strdup( root );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
467 gtk_ctree_node_set_row_data_full(GTK_CTREE( CTDirTree ),parent,DirNode,NULL );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
468 sibling=gtk_ctree_insert_node( GTK_CTREE( CTDirTree ),parent,NULL,&dummy,4,NULL,NULL,NULL,NULL,TRUE,TRUE );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
469 gtk_ctree_expand( GTK_CTREE( CTDirTree ),parent );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
470 gtk_widget_show( CTDirTree );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
471
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
472
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
473 gtk_clist_set_column_widget( GTK_CLIST( CTDirTree ),0,
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
474 AddLabel( MSGTR_PLAYLIST_DirectoryTree,NULL ) );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
475
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
476 vbox2=AddVBox(
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
477 AddFrame( NULL,1,hbox1,1 ),0 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
478
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
479 scrolledwindow2=gtk_scrolled_window_new( NULL,NULL );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
480 gtk_widget_show( scrolledwindow2 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
481 gtk_box_pack_start( GTK_BOX( vbox2 ),scrolledwindow2,TRUE,TRUE,0 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
482 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow2 ),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
483
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
484 CLFiles=gtk_clist_new( 1 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
485 gtk_widget_show( CLFiles );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
486 gtk_container_add( GTK_CONTAINER( scrolledwindow2 ),CLFiles );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
487 gtk_clist_set_column_width( GTK_CLIST( CLFiles ),0,80 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
488 gtk_clist_set_selection_mode( GTK_CLIST( CLFiles ),GTK_SELECTION_EXTENDED );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
489 gtk_clist_column_titles_show( GTK_CLIST( CLFiles ) );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
490 gtk_clist_set_shadow_type( GTK_CLIST( CLFiles ),GTK_SHADOW_NONE );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
491
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
492 gtk_clist_set_column_widget( GTK_CLIST( CLFiles ),0,
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
493 AddLabel( MSGTR_PLAYLIST_Files,NULL ) );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
494
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
495 AddHSeparator( vbox2 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
496
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
497 scrolledwindow3=gtk_scrolled_window_new( NULL,NULL );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
498 gtk_widget_show( scrolledwindow3 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
499 gtk_box_pack_start( GTK_BOX( vbox2 ),scrolledwindow3,TRUE,TRUE,0 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
500 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW( scrolledwindow3 ),GTK_POLICY_AUTOMATIC,GTK_POLICY_AUTOMATIC );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
501
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
502 CLSelected=gtk_clist_new( 2 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
503 gtk_widget_show( CLSelected );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
504 gtk_container_add( GTK_CONTAINER( scrolledwindow3 ),CLSelected );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
505 gtk_clist_set_column_width( GTK_CLIST( CLSelected ),0,295 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
506 gtk_clist_set_column_width( GTK_CLIST( CLSelected ),1,295 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
507 gtk_clist_set_selection_mode( GTK_CLIST( CLSelected ),GTK_SELECTION_MULTIPLE );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
508 gtk_clist_column_titles_show( GTK_CLIST( CLSelected ) );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
509 gtk_clist_set_shadow_type( GTK_CLIST( CLSelected ),GTK_SHADOW_NONE );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
510
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
511 gtk_clist_set_column_widget( GTK_CLIST( CLSelected ),0,
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
512 AddLabel( MSGTR_PLAYLIST_Selected,NULL ) );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
513
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
514 gtk_clist_set_column_widget( GTK_CLIST( CLSelected ),1,
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
515 AddLabel( MSGTR_PLAYLIST_Path,NULL ) );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
516
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
517 AddHSeparator( vbox1 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
518
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
519 hbuttonbox1=AddHButtonBox( vbox1 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
520 gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox1 ),GTK_BUTTONBOX_END );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
521 gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox1 ),10 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
522
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
523 Add=AddButton( MSGTR_Add,hbuttonbox1 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
524 Remove=AddButton( MSGTR_Remove,hbuttonbox1 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
525 Ok=AddButton( MSGTR_Ok,hbuttonbox1 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
526 Cancel=AddButton( MSGTR_Cancel,hbuttonbox1 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
527
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
528 gtk_widget_add_accelerator( Cancel,"clicked",accel_group,GDK_Escape,0,GTK_ACCEL_VISIBLE );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
529
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
530 gtk_signal_connect( GTK_OBJECT( PlayList ),"destroy",GTK_SIGNAL_FUNC( WidgetDestroy ),&PlayList );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
531
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
532 gtk_signal_connect( GTK_OBJECT( CLFiles ),"select_row",GTK_SIGNAL_FUNC( plRowSelect ),(void *)0 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
533 gtk_signal_connect( GTK_OBJECT( CLFiles ),"unselect_row",GTK_SIGNAL_FUNC( plUnRowSelect ),(void *)0 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
534 sigSel=gtk_signal_connect( GTK_OBJECT( CLSelected ),"select_row",GTK_SIGNAL_FUNC( plRowSelect ),(void*)1 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
535 sigUnsel=gtk_signal_connect( GTK_OBJECT( CLSelected ),"unselect_row",GTK_SIGNAL_FUNC( plUnRowSelect ),(void*)1 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
536
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
537 gtk_signal_connect( GTK_OBJECT( Add ),"clicked",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)3 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
538 gtk_signal_connect( GTK_OBJECT( Remove ),"clicked",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)2 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
539 gtk_signal_connect( GTK_OBJECT( Ok ),"clicked",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)1 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
540 gtk_signal_connect( GTK_OBJECT( Cancel ),"clicked",GTK_SIGNAL_FUNC( plButtonReleased ),(void*)0 );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
541
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
542 gtk_window_add_accel_group( GTK_WINDOW( PlayList ),accel_group );
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
543
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
544 return PlayList;
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
545 }
17bf4f4b0715 Gui --> gui
diego
parents:
diff changeset
546