Mercurial > mplayer.hg
annotate Gui/mplayer/gtk/url.c @ 6996:163f78ece9c2
add uri2filename converter
author | pontscho |
---|---|
date | Wed, 14 Aug 2002 12:17:04 +0000 |
parents | c2d4100c964e |
children | 8e9607c5897e |
rev | line source |
---|---|
6298 | 1 |
2 #include <sys/types.h> | |
3 #include <sys/stat.h> | |
4 #include <unistd.h> | |
5 #include <stdlib.h> | |
6 #include <stdio.h> | |
7 #include <string.h> | |
8 | |
9 #include <gdk/gdkkeysyms.h> | |
10 #include <gtk/gtk.h> | |
11 | |
12 #include "url.h" | |
13 #include "../../interface.h" | |
14 #include "../../events.h" | |
6335
e9bd97d5c5cc
warning & newline fixes by Dominik Mierzejewski <dominik@rangers.eu.org>
arpi
parents:
6298
diff
changeset
|
15 #include "../widgets.h" |
6651 | 16 #include "../../help_mp.h" |
6298 | 17 |
18 GtkWidget * URL; | |
19 int gtkVURLDialogBox = 0; | |
20 | |
21 static GtkWidget * URLCombo; | |
22 static GtkWidget * URLEntry; | |
23 static GList * URLComboEntrys = NULL; | |
24 | |
25 void ShowURLDialogBox( void ) | |
26 { | |
27 if ( gtkVURLDialogBox ) gtkActive( URL ); | |
28 else URL=create_URL(); | |
29 | |
30 if ( URLComboEntrys ) | |
31 { | |
32 gtk_entry_set_text( GTK_ENTRY( URLEntry ),URLComboEntrys->data ); | |
33 gtk_combo_set_popdown_strings( GTK_COMBO( URLCombo ),URLComboEntrys ); | |
34 } | |
35 | |
36 gtk_widget_show( URL ); | |
6903 | 37 gtkVURLDialogBox=1; |
6298 | 38 } |
39 | |
40 void HideURLDialogBox( void ) | |
41 { | |
6755 | 42 if ( !gtkVURLDialogBox ) return; |
6298 | 43 gtk_widget_hide( URL ); |
44 gtk_widget_destroy( URL ); | |
6903 | 45 gtkVURLDialogBox=0; |
6298 | 46 } |
47 | |
48 static gboolean on_URL_destroy_event( GtkWidget * widget,GdkEvent * event,gpointer user_data ) | |
49 { | |
50 HideURLDialogBox(); | |
51 return FALSE; | |
52 } | |
53 | |
54 static void on_Button_pressed( GtkButton * button,gpointer user_data ) | |
55 { | |
56 if ( (int)user_data ) | |
57 { | |
58 gchar * str= strdup( gtk_entry_get_text( GTK_ENTRY( URLEntry ) ) ); | |
59 | |
60 if ( str ) | |
61 { | |
62 if ( strncmp( str,"http://",7 ) && strncmp( str,"ftp://",6 ) && !strncmp( str,"mms://",6 ) ) | |
63 { | |
64 gchar * tmp; | |
65 tmp=malloc( strlen( str ) + 8 ); | |
66 sprintf( tmp,"http://%s",str ); | |
67 free( str ); str=tmp; | |
68 } | |
69 URLComboEntrys=g_list_prepend( URLComboEntrys,(gchar *)str ); | |
70 | |
71 guiSetFilename( guiIntfStruct.Filename,str ); guiIntfStruct.FilenameChanged=1; | |
6651 | 72 mplEventHandling( evPlayNetwork,0 ); |
6298 | 73 } |
74 } | |
75 HideURLDialogBox(); | |
76 } | |
77 | |
78 static void ab_URL_show( GtkButton * button,gpointer user_data ) | |
79 { gtkVURLDialogBox=(int)user_data; } | |
80 | |
81 GtkWidget * create_URL( void ) | |
82 { | |
83 GtkWidget * frame1; | |
84 GtkWidget * frame2; | |
85 GtkWidget * frame3; | |
86 GtkWidget * frame4; | |
87 GtkWidget * vbox1; | |
88 GtkWidget * hbox1; | |
89 GtkWidget * label1; | |
6651 | 90 GtkWidget * hsep; |
6298 | 91 GtkWidget * hbuttonbox1; |
92 GtkWidget * Ok; | |
93 GtkWidget * Cancel; | |
94 GtkAccelGroup * accel_group; | |
95 | |
96 accel_group=gtk_accel_group_new(); | |
97 | |
98 URL=gtk_window_new( GTK_WINDOW_DIALOG ); | |
99 gtk_widget_set_name( URL,"URL" ); | |
100 gtk_object_set_data( GTK_OBJECT( URL ),"URL",URL ); | |
6651 | 101 gtk_widget_set_usize( URL,384,70 ); |
6298 | 102 GTK_WIDGET_SET_FLAGS( URL,GTK_CAN_DEFAULT ); |
6651 | 103 gtk_window_set_title( GTK_WINDOW( URL ),MSGTR_Network ); |
6298 | 104 gtk_window_set_position( GTK_WINDOW( URL ),GTK_WIN_POS_CENTER ); |
105 gtk_window_set_policy( GTK_WINDOW( URL ),TRUE,TRUE,FALSE ); | |
6651 | 106 gtk_window_set_wmclass( GTK_WINDOW( URL ),MSGTR_Network,"MPlayer" ); |
107 | |
108 gtk_widget_realize( URL ); | |
109 gtkAddIcon( URL ); | |
6298 | 110 |
111 frame1=gtk_frame_new( NULL ); | |
112 gtk_widget_set_name( frame1,"frame1" ); | |
113 gtk_widget_ref( frame1 ); | |
114 gtk_object_set_data_full( GTK_OBJECT( URL ),"frame1",frame1,(GtkDestroyNotify)gtk_widget_unref ); | |
115 gtk_widget_show( frame1 ); | |
116 gtk_container_add( GTK_CONTAINER( URL ),frame1 ); | |
117 gtk_container_set_border_width( GTK_CONTAINER( frame1 ),1 ); | |
118 gtk_frame_set_shadow_type( GTK_FRAME( frame1 ),GTK_SHADOW_IN ); | |
119 | |
120 frame2=gtk_frame_new( NULL ); | |
121 gtk_widget_set_name( frame2,"frame2" ); | |
122 gtk_widget_ref( frame2 ); | |
123 gtk_object_set_data_full( GTK_OBJECT( URL ),"frame2",frame2,(GtkDestroyNotify)gtk_widget_unref ); | |
124 gtk_widget_show( frame2 ); | |
125 gtk_container_add( GTK_CONTAINER( frame1 ),frame2 ); | |
126 gtk_container_set_border_width( GTK_CONTAINER( frame2 ),1 ); | |
127 gtk_frame_set_shadow_type( GTK_FRAME( frame2 ),GTK_SHADOW_NONE ); | |
128 | |
129 frame3=gtk_frame_new( NULL ); | |
130 gtk_widget_set_name( frame3,"frame3" ); | |
131 gtk_widget_ref( frame3 ); | |
132 gtk_object_set_data_full( GTK_OBJECT( URL ),"frame3",frame3,(GtkDestroyNotify)gtk_widget_unref ); | |
133 gtk_widget_show( frame3 ); | |
134 gtk_container_add( GTK_CONTAINER( frame2 ),frame3 ); | |
135 gtk_frame_set_shadow_type( GTK_FRAME( frame3 ),GTK_SHADOW_ETCHED_OUT ); | |
136 | |
137 frame4=gtk_frame_new( NULL ); | |
138 gtk_widget_set_name( frame4,"frame4" ); | |
139 gtk_widget_ref( frame4 ); | |
140 gtk_object_set_data_full( GTK_OBJECT( URL ),"frame4",frame4,(GtkDestroyNotify)gtk_widget_unref ); | |
141 gtk_widget_show( frame4 ); | |
142 gtk_container_add( GTK_CONTAINER( frame3 ),frame4 ); | |
143 gtk_frame_set_shadow_type( GTK_FRAME( frame4 ),GTK_SHADOW_NONE ); | |
144 | |
145 vbox1=gtk_vbox_new( FALSE,0 ); | |
146 gtk_widget_set_name( vbox1,"vbox1" ); | |
147 gtk_widget_ref( vbox1 ); | |
148 gtk_object_set_data_full( GTK_OBJECT( URL ),"vbox1",vbox1,(GtkDestroyNotify)gtk_widget_unref ); | |
149 gtk_widget_show( vbox1 ); | |
150 gtk_container_add( GTK_CONTAINER( frame4 ),vbox1 ); | |
151 | |
152 hbox1=gtk_hbox_new( FALSE,0 ); | |
153 gtk_widget_set_name( hbox1,"hbox1" ); | |
154 gtk_widget_ref( hbox1 ); | |
155 gtk_object_set_data_full( GTK_OBJECT( URL ),"hbox1",hbox1,(GtkDestroyNotify)gtk_widget_unref ); | |
156 gtk_widget_show( hbox1 ); | |
157 gtk_box_pack_start( GTK_BOX( vbox1 ),hbox1,TRUE,TRUE,0 ); | |
158 | |
159 label1=gtk_label_new( "URL: " ); | |
160 gtk_widget_set_name( label1,"label1" ); | |
161 gtk_widget_ref( label1 ); | |
162 gtk_object_set_data_full( GTK_OBJECT( URL ),"label1",label1,(GtkDestroyNotify)gtk_widget_unref ); | |
163 gtk_widget_show( label1 ); | |
164 gtk_box_pack_start( GTK_BOX( hbox1 ),label1,FALSE,FALSE,0 ); | |
165 gtk_widget_set_usize( label1,38,-2 ); | |
166 gtk_label_set_justify( GTK_LABEL( label1 ),GTK_JUSTIFY_FILL ); | |
167 gtk_misc_set_alignment( GTK_MISC( label1 ),0.5,0.49 ); | |
168 | |
169 URLCombo=gtk_combo_new(); | |
170 gtk_widget_set_name( URLCombo,"URLCombo" ); | |
171 gtk_widget_ref( URLCombo ); | |
172 gtk_object_set_data_full( GTK_OBJECT( URL ),"URLCombo",URLCombo,(GtkDestroyNotify)gtk_widget_unref ); | |
173 gtk_widget_show( URLCombo ); | |
174 gtk_box_pack_start( GTK_BOX( hbox1 ),URLCombo,TRUE,TRUE,0 ); | |
175 | |
176 URLEntry=GTK_COMBO( URLCombo )->entry; | |
177 gtk_widget_set_name( URLEntry,"URLEntry" ); | |
178 gtk_widget_ref( URLEntry ); | |
179 gtk_object_set_data_full( GTK_OBJECT( URL ),"URLEntry",URLEntry,(GtkDestroyNotify)gtk_widget_unref ); | |
180 gtk_widget_show( URLEntry ); | |
181 | |
6651 | 182 hsep=gtk_hseparator_new(); |
183 gtk_widget_set_name( hsep,"hsep" ); | |
184 gtk_widget_ref( hsep ); | |
185 gtk_object_set_data_full( GTK_OBJECT( URL ),"hsep",hsep,(GtkDestroyNotify)gtk_widget_unref ); | |
186 gtk_widget_show( hsep ); | |
187 gtk_box_pack_start( GTK_BOX( vbox1 ),hsep,FALSE,TRUE,0 ); | |
188 gtk_widget_set_usize( hsep,-2,8 ); | |
6298 | 189 |
190 hbuttonbox1=gtk_hbutton_box_new(); | |
191 gtk_widget_set_name( hbuttonbox1,"hbuttonbox1" ); | |
192 gtk_widget_ref( hbuttonbox1 ); | |
193 gtk_object_set_data_full( GTK_OBJECT( URL ),"hbuttonbox1",hbuttonbox1,(GtkDestroyNotify)gtk_widget_unref ); | |
194 gtk_widget_show( hbuttonbox1 ); | |
195 gtk_box_pack_start( GTK_BOX( vbox1 ),hbuttonbox1,FALSE,FALSE,0 ); | |
196 gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox1 ),GTK_BUTTONBOX_END ); | |
6651 | 197 gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox1 ),10 ); |
198 gtk_button_box_set_child_size( GTK_BUTTON_BOX( hbuttonbox1 ),85,20 ); | |
199 gtk_button_box_set_child_ipadding( GTK_BUTTON_BOX( hbuttonbox1 ),0,0 ); | |
6298 | 200 |
6651 | 201 Ok=gtk_button_new_with_label( MSGTR_Ok ); |
6298 | 202 gtk_widget_set_name( Ok,"Ok" ); |
203 gtk_widget_ref( Ok ); | |
204 gtk_object_set_data_full( GTK_OBJECT( URL ),"Ok",Ok,(GtkDestroyNotify)gtk_widget_unref ); | |
205 gtk_widget_show( Ok ); | |
206 gtk_container_add( GTK_CONTAINER( hbuttonbox1 ),Ok ); | |
207 | |
6651 | 208 Cancel=gtk_button_new_with_label( MSGTR_Cancel ); |
6298 | 209 gtk_widget_set_name( Cancel,"Cancel" ); |
210 gtk_widget_ref( Cancel ); | |
211 gtk_object_set_data_full( GTK_OBJECT( URL ),"Cancel",Cancel,(GtkDestroyNotify)gtk_widget_unref ); | |
212 gtk_widget_show( Cancel ); | |
213 gtk_container_add( GTK_CONTAINER( hbuttonbox1 ),Cancel ); | |
214 | |
215 gtk_widget_add_accelerator( Ok,"pressed",accel_group,GDK_Return,0,GTK_ACCEL_VISIBLE ); | |
216 // gtk_widget_add_accelerator( Ok,"pressed",accel_group,GDK_O,GDK_MOD1_MASK,GTK_ACCEL_VISIBLE ); | |
217 // gtk_widget_add_accelerator( Ok,"pressed",accel_group,GDK_o,GDK_MOD1_MASK,GTK_ACCEL_VISIBLE ); | |
218 gtk_widget_add_accelerator( Cancel,"pressed",accel_group,GDK_Escape,0,GTK_ACCEL_VISIBLE ); | |
219 // gtk_widget_add_accelerator( Cancel,"pressed",accel_group,GDK_C,GDK_MOD1_MASK,GTK_ACCEL_VISIBLE ); | |
220 // gtk_widget_add_accelerator( Cancel,"pressed",accel_group,GDK_c,GDK_MOD1_MASK,GTK_ACCEL_VISIBLE ); | |
221 | |
222 gtk_signal_connect( GTK_OBJECT( URL ),"destroy",GTK_SIGNAL_FUNC( on_URL_destroy_event ),NULL ); | |
223 gtk_signal_connect( GTK_OBJECT( URL ),"show",GTK_SIGNAL_FUNC( ab_URL_show ),(void *)1 ); | |
224 gtk_signal_connect( GTK_OBJECT( URL ),"hide",GTK_SIGNAL_FUNC( ab_URL_show ),0 ); | |
225 | |
226 gtk_signal_connect( GTK_OBJECT( Ok ),"pressed",GTK_SIGNAL_FUNC( on_Button_pressed ),(void *)1 ); | |
227 gtk_signal_connect( GTK_OBJECT( Cancel ),"pressed",GTK_SIGNAL_FUNC( on_Button_pressed ),NULL ); | |
228 | |
6651 | 229 gtk_widget_grab_focus( URLEntry ); |
6298 | 230 gtk_window_add_accel_group( GTK_WINDOW( URL ),accel_group ); |
231 | |
232 return URL; | |
233 } | |
234 |