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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
1
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
2 #include <stdlib.h>
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
3 #include <stdio.h>
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
4
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
5 #include <sys/types.h>
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
6 #include <sys/stat.h>
1700
a0f28ba7c34a gtk exit cleanup
arpi
parents: 1698
diff changeset
7 #include <sys/wait.h>
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
8 #include <unistd.h>
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
9 #include <string.h>
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
10 #include <signal.h>
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
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
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
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
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
15 #include <gtk/gtk.h>
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
16
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
17 #include "widgets.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
18
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
19 #include "./mplayer.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
20 #include "psignal.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
21 #include "../events.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
22
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
23 #include "../../config.h"
1884
d21f8afc7680 add to multi lang support
pontscho
parents: 1883
diff changeset
24 #include "../../help_mp.h"
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
25 #include "../error.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
26
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
27 GtkWidget * SkinBrowser;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
28 GtkWidget * PlayList;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
29 GtkWidget * FileSelect;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
30 GtkWidget * AboutBox;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
31 GtkWidget * Options;
2901
f77f8379f28f rewrite ...
pontscho
parents: 1925
diff changeset
32 GtkWidget * PopUpMenu;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
33
1925
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1907
diff changeset
34 GtkWidget * MessageBox;
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1907
diff changeset
35
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1907
diff changeset
36 GtkWidget * WarningPixmap;
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1907
diff changeset
37 GtkWidget * ErrorPixmap;
633a7f0d72a4 add gui error handling jol.
pontscho
parents: 1907
diff changeset
38
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
39 int gtkVisibleSkinBrowser = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
40 int gtkVisiblePlayList = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
41 int gtkVisibleFileSelect = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
42 int gtkVisibleMessageBox = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
43 int gtkVisibleAboutBox = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
44 int gtkVisibleOptions = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
45
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
46 gtkCommStruct * gtkShMem;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
47
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
48 #include "gtk/sb.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
49 #include "gtk/pl.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
50 #include "gtk/fs.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
51 #include "gtk/mb.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
52 #include "gtk/about.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
53 #include "gtk/opts.h"
2901
f77f8379f28f rewrite ...
pontscho
parents: 1925
diff changeset
54 #include "gtk/menu.h"
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
55
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
56 void widgetsCreate( void )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
57 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
58 AboutBox=create_About();
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
59 SkinBrowser=create_SkinBrowser();
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
60 PlayList=create_PlayList();
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
61 FileSelect=create_FileSelect();
1907
83291fafe66c add new features. and fix skin error loop.
pontscho
parents: 1884
diff changeset
62 MessageBox=create_MessageBox(0);
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
63 Options=create_Options();
2980
c4b6dc8bb554 fix middle menu hideing bug
pontscho
parents: 2940
diff changeset
64 // PopUpMenu=create_PopUpMenu();
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
65 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
66
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
67 // --- forked function
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
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
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
71 static void gtkThreadProc( int argc,char * argv[] )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
72 {
1850
62b8e85865a2 Some changes to compile the GUI on solaris
jkeil
parents: 1825
diff changeset
73 struct sigaction sa;
62b8e85865a2 Some changes to compile the GUI on solaris
jkeil
parents: 1825
diff changeset
74
3474
47983b6a042d gtk suid bug fix(?)
pontscho
parents: 2980
diff changeset
75 #ifdef HAVE_RTC
47983b6a042d gtk suid bug fix(?)
pontscho
parents: 2980
diff changeset
76 setuid( getuid() ); // strongly test, please check this.
47983b6a042d gtk suid bug fix(?)
pontscho
parents: 2980
diff changeset
77 #endif
47983b6a042d gtk suid bug fix(?)
pontscho
parents: 2980
diff changeset
78
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
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
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
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
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
88
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
89 widgetsCreate();
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
90
1742
0880718750d5 fix signalhandling
pontscho
parents: 1700
diff changeset
91 gtkPID=getppid();
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
92
1850
62b8e85865a2 Some changes to compile the GUI on solaris
jkeil
parents: 1825
diff changeset
93 memset(&sa, 0, sizeof(sa));
62b8e85865a2 Some changes to compile the GUI on solaris
jkeil
parents: 1825
diff changeset
94 sa.sa_handler = gtkSigHandler;
62b8e85865a2 Some changes to compile the GUI on solaris
jkeil
parents: 1825
diff changeset
95 sigaction( SIGTYPE, &sa, NULL );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
96
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
97 gtkIsOk=True;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
98 gtkSendMessage( evGtkIsOk );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
99
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
100 gtk_main();
1700
a0f28ba7c34a gtk exit cleanup
arpi
parents: 1698
diff changeset
101 printf( "[gtk] exit.\n" );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
102 exit( 0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
103 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
104
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
105 // --- init & close gtk
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
106
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
107 void gtkInit( int argc,char* argv[], char *envp[] )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
108 {
1825
1791c7930776 fix sizeof :))))
pontscho
parents: 1742
diff changeset
109 gtkShMem=shmem_alloc( sizeof( gtkCommStruct ) );
1742
0880718750d5 fix signalhandling
pontscho
parents: 1700
diff changeset
110 if ( ( gtkPID = fork() ) == 0 ) gtkThreadProc( argc,argv );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
111 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
112
1700
a0f28ba7c34a gtk exit cleanup
arpi
parents: 1698
diff changeset
113 void gtkDone( void ){
a0f28ba7c34a gtk exit cleanup
arpi
parents: 1698
diff changeset
114 gtkSendMessage(evExit);
a0f28ba7c34a gtk exit cleanup
arpi
parents: 1698
diff changeset
115 usleep(50000); // 50ms should be enough!
a0f28ba7c34a gtk exit cleanup
arpi
parents: 1698
diff changeset
116 printf("gtk killed...\n");
1742
0880718750d5 fix signalhandling
pontscho
parents: 1700
diff changeset
117 kill( gtkPID,SIGKILL );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
118 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
119
1907
83291fafe66c add new features. and fix skin error loop.
pontscho
parents: 1884
diff changeset
120 void gtkMessageBox( int type,gchar * str )
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
121 {
3586
a0009a534428 itt a skin nem van hibauzenet igy.
pontscho
parents: 3474
diff changeset
122 if ( !gtkIsOk ) return;
1907
83291fafe66c add new features. and fix skin error loop.
pontscho
parents: 1884
diff changeset
123 gtkShMem->mb.type=type;
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
124 strcpy( gtkShMem->mb.str,str );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
125 gtkSendMessage( evMessageBox );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
126 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
127
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
128 void gtkClearList( GtkWidget * list )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
129 { gtk_clist_clear( GTK_CLIST( list ) ); }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
130
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
131 int gtkFindCList( GtkWidget * list,char * item )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
132 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
133 gint j,t;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
134 gchar * tmpstr;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
135 for( t=0,j=0;j<GTK_CLIST( list )->rows;j++ )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
136 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
137 gtk_clist_get_text( GTK_CLIST( list ),j,0,&tmpstr );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
138 if ( !strcmp( tmpstr,item ) ) return j;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
139 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
140 return -1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
141 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
142
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
143 void gtkSetDefaultToCList( GtkWidget * list,char * item )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
144 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
145 gint i;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
146 if ( ( i=gtkFindCList( list,item ) ) > -1 ) gtk_clist_select_row( GTK_CLIST( list ),i,0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
147 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
148