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
|
1693
|
71 gtk_set_locale();
|
|
72 gtk_init( &argc,&argv );
|
|
73 gdk_set_use_xshm( TRUE );
|
|
74
|
|
75 widgetsCreate();
|
|
76
|
1742
|
77 gtkPID=getppid();
|
1693
|
78
|
1850
|
79 memset(&sa, 0, sizeof(sa));
|
|
80 sa.sa_handler = gtkSigHandler;
|
|
81 sigaction( SIGTYPE, &sa, NULL );
|
1693
|
82
|
|
83 gtkIsOk=True;
|
|
84 gtkSendMessage( evGtkIsOk );
|
|
85
|
|
86 gtk_main();
|
1700
|
87 printf( "[gtk] exit.\n" );
|
1693
|
88 exit( 0 );
|
|
89 }
|
|
90
|
|
91 // --- init & close gtk
|
|
92
|
|
93 void gtkInit( int argc,char* argv[], char *envp[] )
|
|
94 {
|
1825
|
95 gtkShMem=shmem_alloc( sizeof( gtkCommStruct ) );
|
1742
|
96 if ( ( gtkPID = fork() ) == 0 ) gtkThreadProc( argc,argv );
|
1693
|
97 }
|
|
98
|
1700
|
99 void gtkDone( void ){
|
|
100 int status;
|
|
101 gtkSendMessage(evExit);
|
|
102 usleep(50000); // 50ms should be enough!
|
|
103 printf("gtk killed...\n");
|
1742
|
104 kill( gtkPID,SIGKILL );
|
1693
|
105 }
|
|
106
|
1907
|
107 void gtkMessageBox( int type,gchar * str )
|
1693
|
108 {
|
1907
|
109 gtkShMem->mb.type=type;
|
1693
|
110 strcpy( gtkShMem->mb.str,str );
|
|
111 gtkSendMessage( evMessageBox );
|
|
112 }
|
|
113
|
|
114 void gtkClearList( GtkWidget * list )
|
|
115 { gtk_clist_clear( GTK_CLIST( list ) ); }
|
|
116
|
|
117 int gtkFindCList( GtkWidget * list,char * item )
|
|
118 {
|
|
119 gint j,t;
|
|
120 gchar * tmpstr;
|
|
121 for( t=0,j=0;j<GTK_CLIST( list )->rows;j++ )
|
|
122 {
|
|
123 gtk_clist_get_text( GTK_CLIST( list ),j,0,&tmpstr );
|
|
124 if ( !strcmp( tmpstr,item ) ) return j;
|
|
125 }
|
|
126 return -1;
|
|
127 }
|
|
128
|
|
129 void gtkSetDefaultToCList( GtkWidget * list,char * item )
|
|
130 {
|
|
131 gint i;
|
|
132 if ( ( i=gtkFindCList( list,item ) ) > -1 ) gtk_clist_select_row( GTK_CLIST( list ),i,0 );
|
|
133 }
|
|
134
|