annotate Gui/mplayer/widgets.c @ 1718:3df3982c2c36

Fix "echo -n" problems on solaris for the new GUI stuff. Add a config.mak define for mediaLib
author jkeil
date Mon, 27 Aug 2001 16:51:10 +0000
parents a0f28ba7c34a
children 0880718750d5
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
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
12 #include <gdk/gdkkeysyms.h>
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
13 #include <gtk/gtk.h>
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
14
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
15 #include "widgets.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
16
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
17 #include "./mplayer.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
18 #include "psignal.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
19 #include "../events.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
20
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
21 #include "../../config.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
22 #include "../error.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
23
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
24 #include "pixmaps/up.xpm"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
25 #include "pixmaps/dir.xpm"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
26 #include "pixmaps/file.xpm"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
27 #include "pixmaps/logo.xpm"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
28
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
29 GtkWidget * SkinBrowser;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
30 GtkWidget * PlayList;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
31 GtkWidget * FileSelect;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
32 GtkWidget * MessageBox;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
33 GtkWidget * AboutBox;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
34 GtkWidget * Options;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
35
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
36 int gtkVisibleSkinBrowser = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
37 int gtkVisiblePlayList = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
38 int gtkVisibleFileSelect = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
39 int gtkVisibleMessageBox = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
40 int gtkVisibleAboutBox = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
41 int gtkVisibleOptions = 0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
42
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
43 gtkCommStruct * gtkShMem;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
44
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
45 #include "gtk/sb.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
46 #include "gtk/pl.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
47 #include "gtk/fs.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
48 #include "gtk/mb.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
49 #include "gtk/about.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
50 #include "gtk/opts.h"
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
51
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
52 void widgetsCreate( void )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
53 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
54 AboutBox=create_About();
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
55 SkinBrowser=create_SkinBrowser();
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
56 PlayList=create_PlayList();
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
57 FileSelect=create_FileSelect();
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
58 MessageBox=create_MessageBox();
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
59 Options=create_Options();
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
60 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
61
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
62 int gtkParent = 1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
63
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
64 // --- forked function
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
65
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
66 static void gtkThreadProc( int argc,char * argv[] )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
67 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
68 gtk_set_locale();
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
69 gtk_init( &argc,&argv );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
70 gdk_set_use_xshm( TRUE );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
71
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
72 widgetsCreate();
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
73
1698
7f8579211924 fixed ugly gtkChildPID=getppid(); bug
arpi
parents: 1693
diff changeset
74 // gtkParentPID=getppid();
7f8579211924 fixed ugly gtkChildPID=getppid(); bug
arpi
parents: 1693
diff changeset
75 // gtkChildPID=getpid();
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
76 gtkParent=0;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
77
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
78 signal( SIGTYPE,gtkSigHandler );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
79
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
80 gtkIsOk=True;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
81 gtkSendMessage( evGtkIsOk );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
82
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
83 gtk_main();
1700
a0f28ba7c34a gtk exit cleanup
arpi
parents: 1698
diff changeset
84 printf( "[gtk] exit.\n" );
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
85 exit( 0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
86 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
87
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
88 // --- init & close gtk
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
89
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
90 void gtkInit( int argc,char* argv[], char *envp[] )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
91 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
92 gtkParentPID=getpid();
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
93 gtkShMem=shmem_alloc( ShMemSize );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
94 if ( ( gtkChildPID = fork() ) == 0 ) gtkThreadProc( argc,argv );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
95 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
96
1700
a0f28ba7c34a gtk exit cleanup
arpi
parents: 1698
diff changeset
97 void gtkDone( void ){
a0f28ba7c34a gtk exit cleanup
arpi
parents: 1698
diff changeset
98 int status;
a0f28ba7c34a gtk exit cleanup
arpi
parents: 1698
diff changeset
99 gtkSendMessage(evExit);
a0f28ba7c34a gtk exit cleanup
arpi
parents: 1698
diff changeset
100 usleep(50000); // 50ms should be enough!
a0f28ba7c34a gtk exit cleanup
arpi
parents: 1698
diff changeset
101 printf("gtk killed...\n");
1693
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
102 kill( gtkChildPID,SIGKILL );
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 void gtkMessageBox( gchar * str )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
106 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
107 gtkShMem->mb.sx=420; gtkShMem->mb.sy=128;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
108 gtkShMem->mb.tsx=384; gtkShMem->mb.tsy=77;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
109 if ( strlen( str ) > 200 )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
110 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
111 gtkShMem->mb.sx=512;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
112 gtkShMem->mb.sy=128;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
113 gtkShMem->mb.tsx=476;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
114 gtkShMem->mb.tsy=77;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
115 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
116 strcpy( gtkShMem->mb.str,str );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
117 gtkSendMessage( evMessageBox );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
118 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
119
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
120 void gtkClearList( GtkWidget * list )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
121 { gtk_clist_clear( GTK_CLIST( list ) ); }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
122
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
123 int gtkFindCList( GtkWidget * list,char * item )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
124 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
125 gint j,t;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
126 gchar * tmpstr;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
127 for( t=0,j=0;j<GTK_CLIST( list )->rows;j++ )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
128 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
129 gtk_clist_get_text( GTK_CLIST( list ),j,0,&tmpstr );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
130 if ( !strcmp( tmpstr,item ) ) return j;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
131 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
132 return -1;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
133 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
134
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
135 void gtkSetDefaultToCList( GtkWidget * list,char * item )
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
136 {
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
137 gint i;
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
138 if ( ( i=gtkFindCList( list,item ) ) > -1 ) gtk_clist_select_row( GTK_CLIST( list ),i,0 );
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
139 }
d237c5d4b216 GUI version n-1
arpi
parents:
diff changeset
140