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"
|
1883
|
28 #include "pixmaps/about.xpm"
|
1907
|
29 #include "pixmaps/error.xpm"
|
|
30 #include "pixmaps/warning.xpm"
|
1693
|
31
|
|
32 GtkWidget * SkinBrowser;
|
|
33 GtkWidget * PlayList;
|
|
34 GtkWidget * FileSelect;
|
|
35 GtkWidget * AboutBox;
|
|
36 GtkWidget * Options;
|
|
37
|
1925
|
38 GtkWidget * MessageBox;
|
|
39
|
|
40 GtkWidget * WarningPixmap;
|
|
41 GtkWidget * ErrorPixmap;
|
|
42
|
1693
|
43 int gtkVisibleSkinBrowser = 0;
|
|
44 int gtkVisiblePlayList = 0;
|
|
45 int gtkVisibleFileSelect = 0;
|
|
46 int gtkVisibleMessageBox = 0;
|
|
47 int gtkVisibleAboutBox = 0;
|
|
48 int gtkVisibleOptions = 0;
|
|
49
|
|
50 gtkCommStruct * gtkShMem;
|
|
51
|
|
52 #include "gtk/sb.h"
|
|
53 #include "gtk/pl.h"
|
|
54 #include "gtk/fs.h"
|
|
55 #include "gtk/mb.h"
|
|
56 #include "gtk/about.h"
|
|
57 #include "gtk/opts.h"
|
|
58
|
|
59 void widgetsCreate( void )
|
|
60 {
|
|
61 AboutBox=create_About();
|
|
62 SkinBrowser=create_SkinBrowser();
|
|
63 PlayList=create_PlayList();
|
|
64 FileSelect=create_FileSelect();
|
1907
|
65 MessageBox=create_MessageBox(0);
|
1693
|
66 Options=create_Options();
|
|
67 }
|
|
68
|
|
69 // --- forked function
|
|
70
|
|
71 static void gtkThreadProc( int argc,char * argv[] )
|
|
72 {
|
1850
|
73 struct sigaction sa;
|
|
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 {
|
1907
|
113 gtkShMem->mb.type=type;
|
1693
|
114 strcpy( gtkShMem->mb.str,str );
|
|
115 gtkSendMessage( evMessageBox );
|
|
116 }
|
|
117
|
|
118 void gtkClearList( GtkWidget * list )
|
|
119 { gtk_clist_clear( GTK_CLIST( list ) ); }
|
|
120
|
|
121 int gtkFindCList( GtkWidget * list,char * item )
|
|
122 {
|
|
123 gint j,t;
|
|
124 gchar * tmpstr;
|
|
125 for( t=0,j=0;j<GTK_CLIST( list )->rows;j++ )
|
|
126 {
|
|
127 gtk_clist_get_text( GTK_CLIST( list ),j,0,&tmpstr );
|
|
128 if ( !strcmp( tmpstr,item ) ) return j;
|
|
129 }
|
|
130 return -1;
|
|
131 }
|
|
132
|
|
133 void gtkSetDefaultToCList( GtkWidget * list,char * item )
|
|
134 {
|
|
135 gint i;
|
|
136 if ( ( i=gtkFindCList( list,item ) ) > -1 ) gtk_clist_select_row( GTK_CLIST( list ),i,0 );
|
|
137 }
|
|
138
|