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"
|
1884
|
22 #include "../../help_mp.h"
|
1693
|
23 #include "../error.h"
|
|
24
|
|
25 GtkWidget * SkinBrowser;
|
|
26 GtkWidget * PlayList;
|
|
27 GtkWidget * FileSelect;
|
|
28 GtkWidget * AboutBox;
|
|
29 GtkWidget * Options;
|
2901
|
30 GtkWidget * PopUpMenu;
|
1693
|
31
|
1925
|
32 GtkWidget * MessageBox;
|
|
33
|
|
34 GtkWidget * WarningPixmap;
|
|
35 GtkWidget * ErrorPixmap;
|
|
36
|
1693
|
37 int gtkVisibleSkinBrowser = 0;
|
|
38 int gtkVisiblePlayList = 0;
|
|
39 int gtkVisibleFileSelect = 0;
|
|
40 int gtkVisibleMessageBox = 0;
|
|
41 int gtkVisibleAboutBox = 0;
|
|
42 int gtkVisibleOptions = 0;
|
|
43
|
|
44 gtkCommStruct * gtkShMem;
|
|
45
|
|
46 #include "gtk/sb.h"
|
|
47 #include "gtk/pl.h"
|
|
48 #include "gtk/fs.h"
|
|
49 #include "gtk/mb.h"
|
|
50 #include "gtk/about.h"
|
|
51 #include "gtk/opts.h"
|
2901
|
52 #include "gtk/menu.h"
|
1693
|
53
|
|
54 void widgetsCreate( void )
|
|
55 {
|
|
56 AboutBox=create_About();
|
|
57 SkinBrowser=create_SkinBrowser();
|
|
58 PlayList=create_PlayList();
|
|
59 FileSelect=create_FileSelect();
|
1907
|
60 MessageBox=create_MessageBox(0);
|
1693
|
61 Options=create_Options();
|
2980
|
62 // PopUpMenu=create_PopUpMenu();
|
1693
|
63 }
|
|
64
|
|
65 // --- forked function
|
|
66
|
|
67 static void gtkThreadProc( int argc,char * argv[] )
|
|
68 {
|
1850
|
69 struct sigaction sa;
|
|
70
|
3474
|
71 #ifdef HAVE_RTC
|
|
72 setuid( getuid() ); // strongly test, please check this.
|
|
73 #endif
|
|
74
|
1693
|
75 gtk_set_locale();
|
|
76 gtk_init( &argc,&argv );
|
|
77 gdk_set_use_xshm( TRUE );
|
|
78
|
|
79 widgetsCreate();
|
|
80
|
1742
|
81 gtkPID=getppid();
|
1693
|
82
|
1850
|
83 memset(&sa, 0, sizeof(sa));
|
|
84 sa.sa_handler = gtkSigHandler;
|
|
85 sigaction( SIGTYPE, &sa, NULL );
|
1693
|
86
|
|
87 gtkIsOk=True;
|
|
88 gtkSendMessage( evGtkIsOk );
|
|
89
|
|
90 gtk_main();
|
1700
|
91 printf( "[gtk] exit.\n" );
|
1693
|
92 exit( 0 );
|
|
93 }
|
|
94
|
|
95 // --- init & close gtk
|
|
96
|
|
97 void gtkInit( int argc,char* argv[], char *envp[] )
|
|
98 {
|
1825
|
99 gtkShMem=shmem_alloc( sizeof( gtkCommStruct ) );
|
1742
|
100 if ( ( gtkPID = fork() ) == 0 ) gtkThreadProc( argc,argv );
|
1693
|
101 }
|
|
102
|
1700
|
103 void gtkDone( void ){
|
|
104 int status;
|
|
105 gtkSendMessage(evExit);
|
|
106 usleep(50000); // 50ms should be enough!
|
|
107 printf("gtk killed...\n");
|
1742
|
108 kill( gtkPID,SIGKILL );
|
1693
|
109 }
|
|
110
|
1907
|
111 void gtkMessageBox( int type,gchar * str )
|
1693
|
112 {
|
3586
|
113 if ( !gtkIsOk ) return;
|
1907
|
114 gtkShMem->mb.type=type;
|
1693
|
115 strcpy( gtkShMem->mb.str,str );
|
|
116 gtkSendMessage( evMessageBox );
|
|
117 }
|
|
118
|
|
119 void gtkClearList( GtkWidget * list )
|
|
120 { gtk_clist_clear( GTK_CLIST( list ) ); }
|
|
121
|
|
122 int gtkFindCList( GtkWidget * list,char * item )
|
|
123 {
|
|
124 gint j,t;
|
|
125 gchar * tmpstr;
|
|
126 for( t=0,j=0;j<GTK_CLIST( list )->rows;j++ )
|
|
127 {
|
|
128 gtk_clist_get_text( GTK_CLIST( list ),j,0,&tmpstr );
|
|
129 if ( !strcmp( tmpstr,item ) ) return j;
|
|
130 }
|
|
131 return -1;
|
|
132 }
|
|
133
|
|
134 void gtkSetDefaultToCList( GtkWidget * list,char * item )
|
|
135 {
|
|
136 gint i;
|
|
137 if ( ( i=gtkFindCList( list,item ) ) > -1 ) gtk_clist_select_row( GTK_CLIST( list ),i,0 );
|
|
138 }
|
|
139
|