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