Mercurial > mplayer.hg
annotate Gui/mplayer/gtk/url.c @ 13074:dfd8b3c22c5b
support snow
author | alex |
---|---|
date | Sat, 21 Aug 2004 19:31:00 +0000 |
parents | ad75409ed15e |
children | 0e1471d9da74 |
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" | |
8299 | 13 #include "common.h" |
6298 | 14 #include "../../interface.h" |
8043 | 15 #include "../../app.h" |
6335
e9bd97d5c5cc
warning & newline fixes by Dominik Mierzejewski <dominik@rangers.eu.org>
arpi
parents:
6298
diff
changeset
|
16 #include "../widgets.h" |
6651 | 17 #include "../../help_mp.h" |
6298 | 18 |
8299 | 19 GtkWidget * URL = NULL; |
6298 | 20 |
21 static GtkWidget * URLCombo; | |
22 static GtkWidget * URLEntry; | |
23 static GList * URLComboEntrys = NULL; | |
24 | |
25 void ShowURLDialogBox( void ) | |
26 { | |
8299 | 27 if ( URL ) gtkActive( URL ); |
6298 | 28 else URL=create_URL(); |
29 | |
7092
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
30 if ( URLList ) |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
31 { |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
32 URLItem * item = URLList; |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
33 g_list_free( URLComboEntrys ); |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
34 URLComboEntrys=NULL; |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
35 while( item ) |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
36 { |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
37 URLComboEntrys=g_list_append( URLComboEntrys,(gchar *)item->url ); |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
38 item=item->next; |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
39 } |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
40 } |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
41 |
6298 | 42 if ( URLComboEntrys ) |
43 { | |
44 gtk_entry_set_text( GTK_ENTRY( URLEntry ),URLComboEntrys->data ); | |
45 gtk_combo_set_popdown_strings( GTK_COMBO( URLCombo ),URLComboEntrys ); | |
46 } | |
47 | |
48 gtk_widget_show( URL ); | |
49 } | |
50 | |
51 void HideURLDialogBox( void ) | |
52 { | |
8299 | 53 if ( !URL ) return; |
6298 | 54 gtk_widget_hide( URL ); |
55 gtk_widget_destroy( URL ); | |
8299 | 56 URL=0; |
6298 | 57 } |
58 | |
59 static void on_Button_pressed( GtkButton * button,gpointer user_data ) | |
60 { | |
7092
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
61 URLItem * item; |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
62 |
6298 | 63 if ( (int)user_data ) |
64 { | |
65 gchar * str= strdup( gtk_entry_get_text( GTK_ENTRY( URLEntry ) ) ); | |
66 | |
67 if ( str ) | |
68 { | |
10160
ad75409ed15e
support for pnm and rtsp stream opening with gui, patch by Ambrose Li <a.c.li@ieee.org>
alex
parents:
8719
diff
changeset
|
69 if ( strncmp( str,"http://",7 ) |
ad75409ed15e
support for pnm and rtsp stream opening with gui, patch by Ambrose Li <a.c.li@ieee.org>
alex
parents:
8719
diff
changeset
|
70 && strncmp( str,"ftp://",6 ) |
ad75409ed15e
support for pnm and rtsp stream opening with gui, patch by Ambrose Li <a.c.li@ieee.org>
alex
parents:
8719
diff
changeset
|
71 && strncmp( str,"mms://",6 ) |
ad75409ed15e
support for pnm and rtsp stream opening with gui, patch by Ambrose Li <a.c.li@ieee.org>
alex
parents:
8719
diff
changeset
|
72 && strncmp( str,"pnm://",6 ) |
ad75409ed15e
support for pnm and rtsp stream opening with gui, patch by Ambrose Li <a.c.li@ieee.org>
alex
parents:
8719
diff
changeset
|
73 && strncmp( str,"rtsp://",7 ) ) |
6298 | 74 { |
75 gchar * tmp; | |
76 tmp=malloc( strlen( str ) + 8 ); | |
77 sprintf( tmp,"http://%s",str ); | |
78 free( str ); str=tmp; | |
79 } | |
80 URLComboEntrys=g_list_prepend( URLComboEntrys,(gchar *)str ); | |
7092
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
81 |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
82 item=calloc( 1,sizeof( URLItem ) ); |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
83 item->url=gstrdup( str ); |
8e9607c5897e
- warning fixes from Dominik Mierzejewski <dominik@rangers.eu.org>
pontscho
parents:
6903
diff
changeset
|
84 gtkSet( gtkAddURLItem,0,(void *)item ); |
6298 | 85 |
86 guiSetFilename( guiIntfStruct.Filename,str ); guiIntfStruct.FilenameChanged=1; | |
6651 | 87 mplEventHandling( evPlayNetwork,0 ); |
6298 | 88 } |
89 } | |
90 HideURLDialogBox(); | |
91 } | |
92 | |
93 GtkWidget * create_URL( void ) | |
94 { | |
95 GtkWidget * vbox1; | |
96 GtkWidget * hbox1; | |
97 GtkWidget * hbuttonbox1; | |
98 GtkWidget * Ok; | |
99 GtkWidget * Cancel; | |
100 GtkAccelGroup * accel_group; | |
101 | |
102 accel_group=gtk_accel_group_new(); | |
103 | |
8043 | 104 URL=gtk_window_new( GTK_WINDOW_TOPLEVEL ); |
6298 | 105 gtk_widget_set_name( URL,"URL" ); |
106 gtk_object_set_data( GTK_OBJECT( URL ),"URL",URL ); | |
6651 | 107 gtk_widget_set_usize( URL,384,70 ); |
6298 | 108 GTK_WIDGET_SET_FLAGS( URL,GTK_CAN_DEFAULT ); |
6651 | 109 gtk_window_set_title( GTK_WINDOW( URL ),MSGTR_Network ); |
6298 | 110 gtk_window_set_position( GTK_WINDOW( URL ),GTK_WIN_POS_CENTER ); |
111 gtk_window_set_policy( GTK_WINDOW( URL ),TRUE,TRUE,FALSE ); | |
8299 | 112 gtk_window_set_wmclass( GTK_WINDOW( URL ),"Network","MPlayer" ); |
6651 | 113 |
114 gtk_widget_realize( URL ); | |
115 gtkAddIcon( URL ); | |
6298 | 116 |
8299 | 117 vbox1=AddVBox( AddDialogFrame( URL ),0 ); |
118 hbox1=AddHBox( vbox1,1 ); | |
119 AddLabel( "URL: ",hbox1 ); | |
6298 | 120 |
8299 | 121 URLCombo=AddComboBox( hbox1 ); |
122 /* | |
123 gtk_combo_new(); | |
6298 | 124 gtk_widget_set_name( URLCombo,"URLCombo" ); |
125 gtk_widget_show( URLCombo ); | |
126 gtk_box_pack_start( GTK_BOX( hbox1 ),URLCombo,TRUE,TRUE,0 ); | |
8299 | 127 */ |
6298 | 128 URLEntry=GTK_COMBO( URLCombo )->entry; |
129 gtk_widget_set_name( URLEntry,"URLEntry" ); | |
130 gtk_widget_show( URLEntry ); | |
131 | |
8299 | 132 AddHSeparator( vbox1 ); |
6298 | 133 |
8299 | 134 hbuttonbox1=AddHButtonBox( vbox1 ); |
135 gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox1 ),GTK_BUTTONBOX_END ); | |
136 gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox1 ),10 ); | |
6298 | 137 |
8299 | 138 Ok=AddButton( MSGTR_Ok,hbuttonbox1 ); |
139 Cancel=AddButton( MSGTR_Cancel,hbuttonbox1 ); | |
6298 | 140 |
8299 | 141 gtk_widget_add_accelerator( Ok,"clicked",accel_group,GDK_Return,0,GTK_ACCEL_VISIBLE ); |
142 gtk_widget_add_accelerator( Cancel,"clicked",accel_group,GDK_Escape,0,GTK_ACCEL_VISIBLE ); | |
6298 | 143 |
8719
dc27303ae528
correct widget destroy event handler (thank for D J Hawkey Jr <hawkeyd@visi.com>)
pontscho
parents:
8299
diff
changeset
|
144 gtk_signal_connect( GTK_OBJECT( URL ),"destroy",GTK_SIGNAL_FUNC( WidgetDestroy ),&URL ); |
8299 | 145 gtk_signal_connect( GTK_OBJECT( Ok ),"clicked",GTK_SIGNAL_FUNC( on_Button_pressed ),(void *)1 ); |
146 gtk_signal_connect( GTK_OBJECT( Cancel ),"clicked",GTK_SIGNAL_FUNC( on_Button_pressed ),NULL ); | |
6298 | 147 |
6651 | 148 gtk_widget_grab_focus( URLEntry ); |
6298 | 149 gtk_window_add_accel_group( GTK_WINDOW( URL ),accel_group ); |
150 | |
151 return URL; | |
152 } | |
153 |