annotate gui/dialog/url.c @ 36016:7ee29db149cd

Cosmetic: Rearrange code.
author ib
date Sun, 31 Mar 2013 12:10:42 +0000
parents 5c720c434d56
children b3764c930d0c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
1 /*
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
2 * This file is part of MPlayer.
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
3 *
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
4 * MPlayer is free software; you can redistribute it and/or modify
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
5 * it under the terms of the GNU General Public License as published by
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
6 * the Free Software Foundation; either version 2 of the License, or
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
7 * (at your option) any later version.
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
8 *
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
9 * MPlayer is distributed in the hope that it will be useful,
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
12 * GNU General Public License for more details.
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
13 *
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
14 * You should have received a copy of the GNU General Public License along
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
15 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
17 */
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
18
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
19 #include <sys/types.h>
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
20 #include <sys/stat.h>
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
21 #include <unistd.h>
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
22 #include <stdlib.h>
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
23 #include <stdio.h>
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
24 #include <string.h>
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
25
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
26 #include <gdk/gdkkeysyms.h>
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
27 #include <gtk/gtk.h>
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
28
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
29 #include "url.h"
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
30 #include "tools.h"
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
31 #include "gui/interface.h"
35525
e27855a45128 Rebuild GUI directory structure.
ib
parents: 35452
diff changeset
32 #include "gui/app/app.h"
35772
3fec1d4b2736 Relocate uiMainEvent() prototype.
ib
parents: 35768
diff changeset
33 #include "gui/ui/actions.h"
35529
8ad4d2fb46e8 Rebuild GUI directory structure.
ib
parents: 35528
diff changeset
34 #include "dialog.h"
33742
e1539e14d60f Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents: 33740
diff changeset
35 #include "gui/util/list.h"
33737
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33572
diff changeset
36 #include "gui/util/string.h"
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
37 #include "help_mp.h"
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
38
35978
6dfdebfa72b7 Cosmetic: Rename ShowURLDialogBox() ShowURLDialog().
ib
parents: 35773
diff changeset
39 GtkWidget * URLDialog = NULL;
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
40
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
41 static GtkWidget * URLCombo;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
42 static GtkWidget * URLEntry;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
43 static GList * URLComboEntrys = NULL;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
44
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
45 static void on_Button_pressed( GtkButton * button,gpointer user_data )
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
46 {
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
47 urlItem * item;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
48
36010
5c720c434d56 Silence "warning: unused parameter".
ib
parents: 36008
diff changeset
49 (void) button;
5c720c434d56 Silence "warning: unused parameter".
ib
parents: 36008
diff changeset
50
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
51 if ( (int)user_data )
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
52 {
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
53 gchar * str= strdup( gtk_entry_get_text( GTK_ENTRY( URLEntry ) ) );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
54
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
55 if ( str )
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
56 {
34959
ae29467e3294 Allow more liberal URL handling.
ib
parents: 34668
diff changeset
57 if ( !strstr( str,"://" ) )
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
58 {
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
59 gchar * tmp;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
60 tmp=malloc( strlen( str ) + 8 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
61 sprintf( tmp,"http://%s",str );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
62 free( str ); str=tmp;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
63 }
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
64 URLComboEntrys=g_list_prepend( URLComboEntrys,(gchar *)str );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
65
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
66 item=calloc( 1,sizeof( urlItem ) );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
67 item->url=gstrdup( str );
34663
73a5ecb53ee2 Replace symbolic constants by enums.
ib
parents: 34610
diff changeset
68 listMgr( URLLIST_ITEM_ADD,item );
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
69
35452
f42cc2361ee4 Cosmetic: Rename uiSetFileName().
ib
parents: 35352
diff changeset
70 uiSetFile( NULL,str,STREAMTYPE_STREAM ); guiInfo.NewPlay=GUI_FILE_NEW;
35352
96cda43fe250 Don't unconditionally delete the old playlist.
ib
parents: 35350
diff changeset
71 listMgr(PLAYLIST_DELETE, 0);
35350
ee265b18d653 Rename import_file_into_gui() add_to_gui_playlist().
ib
parents: 35349
diff changeset
72 add_to_gui_playlist(str, PLAYLIST_ITEM_APPEND);
35773
c688b0dcbe66 Cosmetic: Rename uiMainEvent() uiEvent().
ib
parents: 35772
diff changeset
73 uiEvent( evPlay,0 );
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
74 }
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
75 }
35997
7d749e44a9e5 Remove HideURLDialog().
ib
parents: 35996
diff changeset
76 gtk_widget_destroy( URLDialog );
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
77 }
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
78
35996
6c891a0e3fea Cosmetic: Rename the functions creating the dialogs.
ib
parents: 35988
diff changeset
79 static GtkWidget * CreateURLDialog( void )
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
80 {
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
81 GtkWidget * vbox1;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
82 GtkWidget * hbox1;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
83 GtkWidget * hbuttonbox1;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
84 GtkWidget * Ok;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
85 GtkWidget * Cancel;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
86 GtkAccelGroup * accel_group;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
87
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
88 accel_group=gtk_accel_group_new();
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
89
35978
6dfdebfa72b7 Cosmetic: Rename ShowURLDialogBox() ShowURLDialog().
ib
parents: 35773
diff changeset
90 URLDialog=gtk_window_new( GTK_WINDOW_TOPLEVEL );
6dfdebfa72b7 Cosmetic: Rename ShowURLDialogBox() ShowURLDialog().
ib
parents: 35773
diff changeset
91 gtk_widget_set_name( URLDialog,"URL" );
6dfdebfa72b7 Cosmetic: Rename ShowURLDialogBox() ShowURLDialog().
ib
parents: 35773
diff changeset
92 gtk_object_set_data( GTK_OBJECT( URLDialog ),"URL",URLDialog );
6dfdebfa72b7 Cosmetic: Rename ShowURLDialogBox() ShowURLDialog().
ib
parents: 35773
diff changeset
93 gtk_widget_set_usize( URLDialog,384,70 );
6dfdebfa72b7 Cosmetic: Rename ShowURLDialogBox() ShowURLDialog().
ib
parents: 35773
diff changeset
94 GTK_WIDGET_SET_FLAGS( URLDialog,GTK_CAN_DEFAULT );
6dfdebfa72b7 Cosmetic: Rename ShowURLDialogBox() ShowURLDialog().
ib
parents: 35773
diff changeset
95 gtk_window_set_title( GTK_WINDOW( URLDialog ),MSGTR_Network );
6dfdebfa72b7 Cosmetic: Rename ShowURLDialogBox() ShowURLDialog().
ib
parents: 35773
diff changeset
96 gtk_window_set_position( GTK_WINDOW( URLDialog ),GTK_WIN_POS_CENTER );
6dfdebfa72b7 Cosmetic: Rename ShowURLDialogBox() ShowURLDialog().
ib
parents: 35773
diff changeset
97 gtk_window_set_policy( GTK_WINDOW( URLDialog ),TRUE,TRUE,FALSE );
6dfdebfa72b7 Cosmetic: Rename ShowURLDialogBox() ShowURLDialog().
ib
parents: 35773
diff changeset
98 gtk_window_set_wmclass( GTK_WINDOW( URLDialog ),"Network","MPlayer" );
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
99
35978
6dfdebfa72b7 Cosmetic: Rename ShowURLDialogBox() ShowURLDialog().
ib
parents: 35773
diff changeset
100 gtk_widget_realize( URLDialog );
6dfdebfa72b7 Cosmetic: Rename ShowURLDialogBox() ShowURLDialog().
ib
parents: 35773
diff changeset
101 gtkAddIcon( URLDialog );
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
102
35978
6dfdebfa72b7 Cosmetic: Rename ShowURLDialogBox() ShowURLDialog().
ib
parents: 35773
diff changeset
103 vbox1=AddVBox( AddDialogFrame( URLDialog ),0 );
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
104 hbox1=AddHBox( vbox1,1 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
105 AddLabel( "URL: ",hbox1 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
106
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
107 URLCombo=AddComboBox( hbox1 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
108 /*
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
109 gtk_combo_new();
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
110 gtk_widget_set_name( URLCombo,"URLCombo" );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
111 gtk_widget_show( URLCombo );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
112 gtk_box_pack_start( GTK_BOX( hbox1 ),URLCombo,TRUE,TRUE,0 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
113 */
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
114 URLEntry=GTK_COMBO( URLCombo )->entry;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
115 gtk_widget_set_name( URLEntry,"URLEntry" );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
116 gtk_widget_show( URLEntry );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
117
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
118 AddHSeparator( vbox1 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
119
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
120 hbuttonbox1=AddHButtonBox( vbox1 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
121 gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox1 ),GTK_BUTTONBOX_END );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
122 gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox1 ),10 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
123
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
124 Ok=AddButton( MSGTR_Ok,hbuttonbox1 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
125 Cancel=AddButton( MSGTR_Cancel,hbuttonbox1 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
126
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
127 gtk_widget_add_accelerator( Ok,"clicked",accel_group,GDK_Return,0,GTK_ACCEL_VISIBLE );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
128 gtk_widget_add_accelerator( Cancel,"clicked",accel_group,GDK_Escape,0,GTK_ACCEL_VISIBLE );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
129
36008
d154d0035cb0 Don't use WidgetDestroy().
ib
parents: 35997
diff changeset
130 gtk_signal_connect( GTK_OBJECT( URLDialog ),"destroy",GTK_SIGNAL_FUNC( gtk_widget_destroyed ),&URLDialog );
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
131 gtk_signal_connect( GTK_OBJECT( Ok ),"clicked",GTK_SIGNAL_FUNC( on_Button_pressed ),(void *)1 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
132 gtk_signal_connect( GTK_OBJECT( Cancel ),"clicked",GTK_SIGNAL_FUNC( on_Button_pressed ),NULL );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
133
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
134 gtk_widget_grab_focus( URLEntry );
35978
6dfdebfa72b7 Cosmetic: Rename ShowURLDialogBox() ShowURLDialog().
ib
parents: 35773
diff changeset
135 gtk_window_add_accel_group( GTK_WINDOW( URLDialog ),accel_group );
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
136
35978
6dfdebfa72b7 Cosmetic: Rename ShowURLDialogBox() ShowURLDialog().
ib
parents: 35773
diff changeset
137 return URLDialog;
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
138 }
35988
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
139
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
140 void ShowURLDialog( void )
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
141 {
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
142 urlItem * item;
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
143
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
144 if ( URLDialog ) gtkActive( URLDialog );
35996
6c891a0e3fea Cosmetic: Rename the functions creating the dialogs.
ib
parents: 35988
diff changeset
145 else URLDialog=CreateURLDialog();
35988
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
146
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
147 item = listMgr( URLLIST_GET,0 );
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
148
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
149 if ( item )
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
150 {
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
151 g_list_free( URLComboEntrys );
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
152 URLComboEntrys=NULL;
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
153 while( item )
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
154 {
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
155 URLComboEntrys=g_list_append( URLComboEntrys,(gchar *)item->url );
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
156 item=item->next;
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
157 }
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
158 }
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
159
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
160 if ( URLComboEntrys )
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
161 {
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
162 gtk_entry_set_text( GTK_ENTRY( URLEntry ),URLComboEntrys->data );
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
163 gtk_combo_set_popdown_strings( GTK_COMBO( URLCombo ),URLComboEntrys );
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
164 }
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
165
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
166 gtk_widget_show( URLDialog );
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
167 }