Mercurial > mplayer.hg
annotate gui/mplayer/gtk/url.c @ 25992:a9e86b2def64
Merge the two conditional definitions of get_current_dir_name.
author | diego |
---|---|
date | Mon, 18 Feb 2008 19:37:59 +0000 |
parents | 8a0adeba5910 |
children |
rev | line source |
---|---|
23077 | 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" | |
25601
8a0adeba5910
Rename common.[ch] to gtk_common.[ch], there are too many files by that name.
diego
parents:
23154
diff
changeset
|
13 #include "gtk_common.h" |
23077 | 14 #include "interface.h" |
15 #include "app.h" | |
16 #include "../widgets.h" | |
23154
e564b9cd7290
Fix several implicit declarations of functions warnings.
diego
parents:
23077
diff
changeset
|
17 #include "../gmplayer.h" |
23077 | 18 #include "help_mp.h" |
19 | |
20 GtkWidget * URL = NULL; | |
21 | |
22 static GtkWidget * URLCombo; | |
23 static GtkWidget * URLEntry; | |
24 static GList * URLComboEntrys = NULL; | |
25 | |
26 void ShowURLDialogBox( void ) | |
27 { | |
28 if ( URL ) gtkActive( URL ); | |
29 else URL=create_URL(); | |
30 | |
31 if ( URLList ) | |
32 { | |
33 URLItem * item = URLList; | |
34 g_list_free( URLComboEntrys ); | |
35 URLComboEntrys=NULL; | |
36 while( item ) | |
37 { | |
38 URLComboEntrys=g_list_append( URLComboEntrys,(gchar *)item->url ); | |
39 item=item->next; | |
40 } | |
41 } | |
42 | |
43 if ( URLComboEntrys ) | |
44 { | |
45 gtk_entry_set_text( GTK_ENTRY( URLEntry ),URLComboEntrys->data ); | |
46 gtk_combo_set_popdown_strings( GTK_COMBO( URLCombo ),URLComboEntrys ); | |
47 } | |
48 | |
49 gtk_widget_show( URL ); | |
50 } | |
51 | |
52 void HideURLDialogBox( void ) | |
53 { | |
54 if ( !URL ) return; | |
55 gtk_widget_hide( URL ); | |
56 gtk_widget_destroy( URL ); | |
57 URL=0; | |
58 } | |
59 | |
60 static void on_Button_pressed( GtkButton * button,gpointer user_data ) | |
61 { | |
62 URLItem * item; | |
63 | |
64 if ( (int)user_data ) | |
65 { | |
66 gchar * str= strdup( gtk_entry_get_text( GTK_ENTRY( URLEntry ) ) ); | |
67 | |
68 if ( str ) | |
69 { | |
70 if ( strncmp( str,"http://",7 ) | |
71 && strncmp( str,"ftp://",6 ) | |
72 && strncmp( str,"mms://",6 ) | |
73 && strncmp( str,"pnm://",6 ) | |
74 && strncmp( str,"rtsp://",7 ) ) | |
75 { | |
76 gchar * tmp; | |
77 tmp=malloc( strlen( str ) + 8 ); | |
78 sprintf( tmp,"http://%s",str ); | |
79 free( str ); str=tmp; | |
80 } | |
81 URLComboEntrys=g_list_prepend( URLComboEntrys,(gchar *)str ); | |
82 | |
83 item=calloc( 1,sizeof( URLItem ) ); | |
84 item->url=gstrdup( str ); | |
85 gtkSet( gtkAddURLItem,0,(void *)item ); | |
86 | |
87 guiSetFilename( guiIntfStruct.Filename,str ); guiIntfStruct.FilenameChanged=1; | |
88 mplEventHandling( evPlayNetwork,0 ); | |
89 } | |
90 } | |
91 HideURLDialogBox(); | |
92 } | |
93 | |
94 GtkWidget * create_URL( void ) | |
95 { | |
96 GtkWidget * vbox1; | |
97 GtkWidget * hbox1; | |
98 GtkWidget * hbuttonbox1; | |
99 GtkWidget * Ok; | |
100 GtkWidget * Cancel; | |
101 GtkAccelGroup * accel_group; | |
102 | |
103 accel_group=gtk_accel_group_new(); | |
104 | |
105 URL=gtk_window_new( GTK_WINDOW_TOPLEVEL ); | |
106 gtk_widget_set_name( URL,"URL" ); | |
107 gtk_object_set_data( GTK_OBJECT( URL ),"URL",URL ); | |
108 gtk_widget_set_usize( URL,384,70 ); | |
109 GTK_WIDGET_SET_FLAGS( URL,GTK_CAN_DEFAULT ); | |
110 gtk_window_set_title( GTK_WINDOW( URL ),MSGTR_Network ); | |
111 gtk_window_set_position( GTK_WINDOW( URL ),GTK_WIN_POS_CENTER ); | |
112 gtk_window_set_policy( GTK_WINDOW( URL ),TRUE,TRUE,FALSE ); | |
113 gtk_window_set_wmclass( GTK_WINDOW( URL ),"Network","MPlayer" ); | |
114 | |
115 gtk_widget_realize( URL ); | |
116 gtkAddIcon( URL ); | |
117 | |
118 vbox1=AddVBox( AddDialogFrame( URL ),0 ); | |
119 hbox1=AddHBox( vbox1,1 ); | |
120 AddLabel( "URL: ",hbox1 ); | |
121 | |
122 URLCombo=AddComboBox( hbox1 ); | |
123 /* | |
124 gtk_combo_new(); | |
125 gtk_widget_set_name( URLCombo,"URLCombo" ); | |
126 gtk_widget_show( URLCombo ); | |
127 gtk_box_pack_start( GTK_BOX( hbox1 ),URLCombo,TRUE,TRUE,0 ); | |
128 */ | |
129 URLEntry=GTK_COMBO( URLCombo )->entry; | |
130 gtk_widget_set_name( URLEntry,"URLEntry" ); | |
131 gtk_widget_show( URLEntry ); | |
132 | |
133 AddHSeparator( vbox1 ); | |
134 | |
135 hbuttonbox1=AddHButtonBox( vbox1 ); | |
136 gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox1 ),GTK_BUTTONBOX_END ); | |
137 gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox1 ),10 ); | |
138 | |
139 Ok=AddButton( MSGTR_Ok,hbuttonbox1 ); | |
140 Cancel=AddButton( MSGTR_Cancel,hbuttonbox1 ); | |
141 | |
142 gtk_widget_add_accelerator( Ok,"clicked",accel_group,GDK_Return,0,GTK_ACCEL_VISIBLE ); | |
143 gtk_widget_add_accelerator( Cancel,"clicked",accel_group,GDK_Escape,0,GTK_ACCEL_VISIBLE ); | |
144 | |
145 gtk_signal_connect( GTK_OBJECT( URL ),"destroy",GTK_SIGNAL_FUNC( WidgetDestroy ),&URL ); | |
146 gtk_signal_connect( GTK_OBJECT( Ok ),"clicked",GTK_SIGNAL_FUNC( on_Button_pressed ),(void *)1 ); | |
147 gtk_signal_connect( GTK_OBJECT( Cancel ),"clicked",GTK_SIGNAL_FUNC( on_Button_pressed ),NULL ); | |
148 | |
149 gtk_widget_grab_focus( URLEntry ); | |
150 gtk_window_add_accel_group( GTK_WINDOW( URL ),accel_group ); | |
151 | |
152 return URL; | |
153 } | |
154 |