Mercurial > mplayer.hg
annotate Gui/mplayer/widgets.c @ 4438:e01ee848935f
grr, 10l. vo_x11_uninit: close display only if window not created by GUI
author | alex |
---|---|
date | Thu, 31 Jan 2002 11:26:29 +0000 |
parents | 116abdd0aed1 |
children | 3473ca9ef158 |
rev | line source |
---|---|
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 | |
4176
116abdd0aed1
small gtk bug fix (-display bug, baze gabu, miattad fogok elkarhozni:), and remove gui dependencie in mencoder
pontscho
parents:
3586
diff
changeset
|
12 #include <gdk/gdkprivate.h> |
1693 | 13 #include <gdk/gdkkeysyms.h> |
4176
116abdd0aed1
small gtk bug fix (-display bug, baze gabu, miattad fogok elkarhozni:), and remove gui dependencie in mencoder
pontscho
parents:
3586
diff
changeset
|
14 #include <gdk/gdk.h> |
1693 | 15 #include <gtk/gtk.h> |
16 | |
17 #include "widgets.h" | |
18 | |
19 #include "./mplayer.h" | |
20 #include "psignal.h" | |
21 #include "../events.h" | |
22 | |
23 #include "../../config.h" | |
1884 | 24 #include "../../help_mp.h" |
1693 | 25 #include "../error.h" |
26 | |
27 GtkWidget * SkinBrowser; | |
28 GtkWidget * PlayList; | |
29 GtkWidget * FileSelect; | |
30 GtkWidget * AboutBox; | |
31 GtkWidget * Options; | |
2901 | 32 GtkWidget * PopUpMenu; |
1693 | 33 |
1925 | 34 GtkWidget * MessageBox; |
35 | |
36 GtkWidget * WarningPixmap; | |
37 GtkWidget * ErrorPixmap; | |
38 | |
1693 | 39 int gtkVisibleSkinBrowser = 0; |
40 int gtkVisiblePlayList = 0; | |
41 int gtkVisibleFileSelect = 0; | |
42 int gtkVisibleMessageBox = 0; | |
43 int gtkVisibleAboutBox = 0; | |
44 int gtkVisibleOptions = 0; | |
45 | |
46 gtkCommStruct * gtkShMem; | |
47 | |
48 #include "gtk/sb.h" | |
49 #include "gtk/pl.h" | |
50 #include "gtk/fs.h" | |
51 #include "gtk/mb.h" | |
52 #include "gtk/about.h" | |
53 #include "gtk/opts.h" | |
2901 | 54 #include "gtk/menu.h" |
1693 | 55 |
56 void widgetsCreate( void ) | |
57 { | |
58 AboutBox=create_About(); | |
59 SkinBrowser=create_SkinBrowser(); | |
60 PlayList=create_PlayList(); | |
61 FileSelect=create_FileSelect(); | |
1907 | 62 MessageBox=create_MessageBox(0); |
1693 | 63 Options=create_Options(); |
2980 | 64 // PopUpMenu=create_PopUpMenu(); |
1693 | 65 } |
66 | |
67 // --- forked function | |
68 | |
4176
116abdd0aed1
small gtk bug fix (-display bug, baze gabu, miattad fogok elkarhozni:), and remove gui dependencie in mencoder
pontscho
parents:
3586
diff
changeset
|
69 extern char *mDisplayName; |
116abdd0aed1
small gtk bug fix (-display bug, baze gabu, miattad fogok elkarhozni:), and remove gui dependencie in mencoder
pontscho
parents:
3586
diff
changeset
|
70 |
1693 | 71 static void gtkThreadProc( int argc,char * argv[] ) |
72 { | |
1850 | 73 struct sigaction sa; |
74 | |
3474 | 75 #ifdef HAVE_RTC |
76 setuid( getuid() ); // strongly test, please check this. | |
77 #endif | |
78 | |
1693 | 79 gtk_set_locale(); |
4176
116abdd0aed1
small gtk bug fix (-display bug, baze gabu, miattad fogok elkarhozni:), and remove gui dependencie in mencoder
pontscho
parents:
3586
diff
changeset
|
80 { |
116abdd0aed1
small gtk bug fix (-display bug, baze gabu, miattad fogok elkarhozni:), and remove gui dependencie in mencoder
pontscho
parents:
3586
diff
changeset
|
81 char tmp[128]; |
116abdd0aed1
small gtk bug fix (-display bug, baze gabu, miattad fogok elkarhozni:), and remove gui dependencie in mencoder
pontscho
parents:
3586
diff
changeset
|
82 sprintf( tmp,"--display=%s",mDisplayName ); |
116abdd0aed1
small gtk bug fix (-display bug, baze gabu, miattad fogok elkarhozni:), and remove gui dependencie in mencoder
pontscho
parents:
3586
diff
changeset
|
83 argv[argc++]=strdup( tmp ); |
116abdd0aed1
small gtk bug fix (-display bug, baze gabu, miattad fogok elkarhozni:), and remove gui dependencie in mencoder
pontscho
parents:
3586
diff
changeset
|
84 gtk_init( &argc,&argv ); |
116abdd0aed1
small gtk bug fix (-display bug, baze gabu, miattad fogok elkarhozni:), and remove gui dependencie in mencoder
pontscho
parents:
3586
diff
changeset
|
85 } |
1693 | 86 gdk_set_use_xshm( TRUE ); |
4176
116abdd0aed1
small gtk bug fix (-display bug, baze gabu, miattad fogok elkarhozni:), and remove gui dependencie in mencoder
pontscho
parents:
3586
diff
changeset
|
87 printf( "[gtk] display: %s\n",gdk_get_display() ); |
1693 | 88 |
89 widgetsCreate(); | |
90 | |
1742 | 91 gtkPID=getppid(); |
1693 | 92 |
1850 | 93 memset(&sa, 0, sizeof(sa)); |
94 sa.sa_handler = gtkSigHandler; | |
95 sigaction( SIGTYPE, &sa, NULL ); | |
1693 | 96 |
97 gtkIsOk=True; | |
98 gtkSendMessage( evGtkIsOk ); | |
99 | |
100 gtk_main(); | |
1700 | 101 printf( "[gtk] exit.\n" ); |
1693 | 102 exit( 0 ); |
103 } | |
104 | |
105 // --- init & close gtk | |
106 | |
107 void gtkInit( int argc,char* argv[], char *envp[] ) | |
108 { | |
1825 | 109 gtkShMem=shmem_alloc( sizeof( gtkCommStruct ) ); |
1742 | 110 if ( ( gtkPID = fork() ) == 0 ) gtkThreadProc( argc,argv ); |
1693 | 111 } |
112 | |
1700 | 113 void gtkDone( void ){ |
114 gtkSendMessage(evExit); | |
115 usleep(50000); // 50ms should be enough! | |
116 printf("gtk killed...\n"); | |
1742 | 117 kill( gtkPID,SIGKILL ); |
1693 | 118 } |
119 | |
1907 | 120 void gtkMessageBox( int type,gchar * str ) |
1693 | 121 { |
3586 | 122 if ( !gtkIsOk ) return; |
1907 | 123 gtkShMem->mb.type=type; |
1693 | 124 strcpy( gtkShMem->mb.str,str ); |
125 gtkSendMessage( evMessageBox ); | |
126 } | |
127 | |
128 void gtkClearList( GtkWidget * list ) | |
129 { gtk_clist_clear( GTK_CLIST( list ) ); } | |
130 | |
131 int gtkFindCList( GtkWidget * list,char * item ) | |
132 { | |
133 gint j,t; | |
134 gchar * tmpstr; | |
135 for( t=0,j=0;j<GTK_CLIST( list )->rows;j++ ) | |
136 { | |
137 gtk_clist_get_text( GTK_CLIST( list ),j,0,&tmpstr ); | |
138 if ( !strcmp( tmpstr,item ) ) return j; | |
139 } | |
140 return -1; | |
141 } | |
142 | |
143 void gtkSetDefaultToCList( GtkWidget * list,char * item ) | |
144 { | |
145 gint i; | |
146 if ( ( i=gtkFindCList( list,item ) ) > -1 ) gtk_clist_select_row( GTK_CLIST( list ),i,0 ); | |
147 } | |
148 |