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