1693
|
1
|
|
2 #include <stdlib.h>
|
|
3 #include <stdio.h>
|
|
4
|
|
5 #include <sys/types.h>
|
|
6 #include <sys/stat.h>
|
1700
|
7 #include <sys/wait.h>
|
1693
|
8 #include <unistd.h>
|
|
9 #include <string.h>
|
|
10 #include <signal.h>
|
|
11
|
|
12 #include <gdk/gdkkeysyms.h>
|
|
13 #include <gtk/gtk.h>
|
|
14
|
|
15 #include "widgets.h"
|
|
16
|
|
17 #include "./mplayer.h"
|
|
18 #include "psignal.h"
|
|
19 #include "../events.h"
|
|
20
|
|
21 #include "../../config.h"
|
|
22 #include "../error.h"
|
|
23
|
|
24 #include "pixmaps/up.xpm"
|
|
25 #include "pixmaps/dir.xpm"
|
|
26 #include "pixmaps/file.xpm"
|
|
27 #include "pixmaps/logo.xpm"
|
|
28
|
|
29 GtkWidget * SkinBrowser;
|
|
30 GtkWidget * PlayList;
|
|
31 GtkWidget * FileSelect;
|
|
32 GtkWidget * MessageBox;
|
|
33 GtkWidget * AboutBox;
|
|
34 GtkWidget * Options;
|
|
35
|
|
36 int gtkVisibleSkinBrowser = 0;
|
|
37 int gtkVisiblePlayList = 0;
|
|
38 int gtkVisibleFileSelect = 0;
|
|
39 int gtkVisibleMessageBox = 0;
|
|
40 int gtkVisibleAboutBox = 0;
|
|
41 int gtkVisibleOptions = 0;
|
|
42
|
|
43 gtkCommStruct * gtkShMem;
|
|
44
|
|
45 #include "gtk/sb.h"
|
|
46 #include "gtk/pl.h"
|
|
47 #include "gtk/fs.h"
|
|
48 #include "gtk/mb.h"
|
|
49 #include "gtk/about.h"
|
|
50 #include "gtk/opts.h"
|
|
51
|
|
52 void widgetsCreate( void )
|
|
53 {
|
|
54 AboutBox=create_About();
|
|
55 SkinBrowser=create_SkinBrowser();
|
|
56 PlayList=create_PlayList();
|
|
57 FileSelect=create_FileSelect();
|
|
58 MessageBox=create_MessageBox();
|
|
59 Options=create_Options();
|
|
60 }
|
|
61
|
|
62 int gtkParent = 1;
|
|
63
|
|
64 // --- forked function
|
|
65
|
|
66 static void gtkThreadProc( int argc,char * argv[] )
|
|
67 {
|
|
68 gtk_set_locale();
|
|
69 gtk_init( &argc,&argv );
|
|
70 gdk_set_use_xshm( TRUE );
|
|
71
|
|
72 widgetsCreate();
|
|
73
|
1698
|
74 // gtkParentPID=getppid();
|
|
75 // gtkChildPID=getpid();
|
1693
|
76 gtkParent=0;
|
|
77
|
|
78 signal( SIGTYPE,gtkSigHandler );
|
|
79
|
|
80 gtkIsOk=True;
|
|
81 gtkSendMessage( evGtkIsOk );
|
|
82
|
|
83 gtk_main();
|
1700
|
84 printf( "[gtk] exit.\n" );
|
1693
|
85 exit( 0 );
|
|
86 }
|
|
87
|
|
88 // --- init & close gtk
|
|
89
|
|
90 void gtkInit( int argc,char* argv[], char *envp[] )
|
|
91 {
|
|
92 gtkParentPID=getpid();
|
|
93 gtkShMem=shmem_alloc( ShMemSize );
|
|
94 if ( ( gtkChildPID = fork() ) == 0 ) gtkThreadProc( argc,argv );
|
|
95 }
|
|
96
|
1700
|
97 void gtkDone( void ){
|
|
98 int status;
|
|
99 gtkSendMessage(evExit);
|
|
100 usleep(50000); // 50ms should be enough!
|
|
101 printf("gtk killed...\n");
|
1693
|
102 kill( gtkChildPID,SIGKILL );
|
|
103 }
|
|
104
|
|
105 void gtkMessageBox( gchar * str )
|
|
106 {
|
|
107 gtkShMem->mb.sx=420; gtkShMem->mb.sy=128;
|
|
108 gtkShMem->mb.tsx=384; gtkShMem->mb.tsy=77;
|
|
109 if ( strlen( str ) > 200 )
|
|
110 {
|
|
111 gtkShMem->mb.sx=512;
|
|
112 gtkShMem->mb.sy=128;
|
|
113 gtkShMem->mb.tsx=476;
|
|
114 gtkShMem->mb.tsy=77;
|
|
115 }
|
|
116 strcpy( gtkShMem->mb.str,str );
|
|
117 gtkSendMessage( evMessageBox );
|
|
118 }
|
|
119
|
|
120 void gtkClearList( GtkWidget * list )
|
|
121 { gtk_clist_clear( GTK_CLIST( list ) ); }
|
|
122
|
|
123 int gtkFindCList( GtkWidget * list,char * item )
|
|
124 {
|
|
125 gint j,t;
|
|
126 gchar * tmpstr;
|
|
127 for( t=0,j=0;j<GTK_CLIST( list )->rows;j++ )
|
|
128 {
|
|
129 gtk_clist_get_text( GTK_CLIST( list ),j,0,&tmpstr );
|
|
130 if ( !strcmp( tmpstr,item ) ) return j;
|
|
131 }
|
|
132 return -1;
|
|
133 }
|
|
134
|
|
135 void gtkSetDefaultToCList( GtkWidget * list,char * item )
|
|
136 {
|
|
137 gint i;
|
|
138 if ( ( i=gtkFindCList( list,item ) ) > -1 ) gtk_clist_select_row( GTK_CLIST( list ),i,0 );
|
|
139 }
|
|
140
|