annotate gui/dialog/url.c @ 35529:8ad4d2fb46e8

Rebuild GUI directory structure. Rename and move ui/widgets.* to dialog/dialog.*.
author ib
date Thu, 06 Dec 2012 15:16:38 +0000
parents ab07b17fddfb
children 51a8ea7542a0
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"
35528
ab07b17fddfb Rebuild GUI directory structure.
ib
parents: 35526
diff changeset
33 #include "gui/ui/ui.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
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
39 GtkWidget * URL = NULL;
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 void ShowURLDialogBox( void )
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
46 {
34668
00e8aecfa7ff Remove global variable pointing to top of URL list.
ib
parents: 34663
diff changeset
47 urlItem * item;
00e8aecfa7ff Remove global variable pointing to top of URL list.
ib
parents: 34663
diff changeset
48
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
49 if ( URL ) gtkActive( URL );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
50 else URL=create_URL();
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
51
34668
00e8aecfa7ff Remove global variable pointing to top of URL list.
ib
parents: 34663
diff changeset
52 item = listMgr( URLLIST_GET,0 );
00e8aecfa7ff Remove global variable pointing to top of URL list.
ib
parents: 34663
diff changeset
53
00e8aecfa7ff Remove global variable pointing to top of URL list.
ib
parents: 34663
diff changeset
54 if ( item )
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
55 {
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
56 g_list_free( URLComboEntrys );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
57 URLComboEntrys=NULL;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
58 while( item )
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
59 {
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
60 URLComboEntrys=g_list_append( URLComboEntrys,(gchar *)item->url );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
61 item=item->next;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
62 }
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
63 }
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
64
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
65 if ( URLComboEntrys )
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
66 {
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
67 gtk_entry_set_text( GTK_ENTRY( URLEntry ),URLComboEntrys->data );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
68 gtk_combo_set_popdown_strings( GTK_COMBO( URLCombo ),URLComboEntrys );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
69 }
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
70
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
71 gtk_widget_show( URL );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
72 }
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
73
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
74 static void HideURLDialogBox( void )
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
75 {
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
76 if ( !URL ) return;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
77 gtk_widget_hide( URL );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
78 gtk_widget_destroy( URL );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
79 URL=0;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
80 }
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
81
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
82 static void on_Button_pressed( GtkButton * button,gpointer user_data )
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
83 {
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
84 urlItem * item;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
85
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
86 if ( (int)user_data )
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
87 {
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
88 gchar * str= strdup( gtk_entry_get_text( GTK_ENTRY( URLEntry ) ) );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
89
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
90 if ( str )
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
91 {
34959
ae29467e3294 Allow more liberal URL handling.
ib
parents: 34668
diff changeset
92 if ( !strstr( str,"://" ) )
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
93 {
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
94 gchar * tmp;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
95 tmp=malloc( strlen( str ) + 8 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
96 sprintf( tmp,"http://%s",str );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
97 free( str ); str=tmp;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
98 }
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
99 URLComboEntrys=g_list_prepend( URLComboEntrys,(gchar *)str );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
100
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
101 item=calloc( 1,sizeof( urlItem ) );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
102 item->url=gstrdup( str );
34663
73a5ecb53ee2 Replace symbolic constants by enums.
ib
parents: 34610
diff changeset
103 listMgr( URLLIST_ITEM_ADD,item );
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
104
35452
f42cc2361ee4 Cosmetic: Rename uiSetFileName().
ib
parents: 35352
diff changeset
105 uiSetFile( NULL,str,STREAMTYPE_STREAM ); guiInfo.NewPlay=GUI_FILE_NEW;
35352
96cda43fe250 Don't unconditionally delete the old playlist.
ib
parents: 35350
diff changeset
106 listMgr(PLAYLIST_DELETE, 0);
35350
ee265b18d653 Rename import_file_into_gui() add_to_gui_playlist().
ib
parents: 35349
diff changeset
107 add_to_gui_playlist(str, PLAYLIST_ITEM_APPEND);
34067
eb6344ee99ac Set an URL guiInfo.Filename by using uiSetFileName().
ib
parents: 33894
diff changeset
108 uiEventHandling( evPlay,0 );
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
109 }
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
110 }
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
111 HideURLDialogBox();
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
112 }
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
113
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
114 GtkWidget * create_URL( void )
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
115 {
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
116 GtkWidget * vbox1;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
117 GtkWidget * hbox1;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
118 GtkWidget * hbuttonbox1;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
119 GtkWidget * Ok;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
120 GtkWidget * Cancel;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
121 GtkAccelGroup * accel_group;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
122
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
123 accel_group=gtk_accel_group_new();
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
124
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
125 URL=gtk_window_new( GTK_WINDOW_TOPLEVEL );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
126 gtk_widget_set_name( URL,"URL" );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
127 gtk_object_set_data( GTK_OBJECT( URL ),"URL",URL );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
128 gtk_widget_set_usize( URL,384,70 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
129 GTK_WIDGET_SET_FLAGS( URL,GTK_CAN_DEFAULT );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
130 gtk_window_set_title( GTK_WINDOW( URL ),MSGTR_Network );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
131 gtk_window_set_position( GTK_WINDOW( URL ),GTK_WIN_POS_CENTER );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
132 gtk_window_set_policy( GTK_WINDOW( URL ),TRUE,TRUE,FALSE );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
133 gtk_window_set_wmclass( GTK_WINDOW( URL ),"Network","MPlayer" );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
134
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
135 gtk_widget_realize( URL );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
136 gtkAddIcon( URL );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
137
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
138 vbox1=AddVBox( AddDialogFrame( URL ),0 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
139 hbox1=AddHBox( vbox1,1 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
140 AddLabel( "URL: ",hbox1 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
141
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
142 URLCombo=AddComboBox( hbox1 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
143 /*
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
144 gtk_combo_new();
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
145 gtk_widget_set_name( URLCombo,"URLCombo" );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
146 gtk_widget_show( URLCombo );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
147 gtk_box_pack_start( GTK_BOX( hbox1 ),URLCombo,TRUE,TRUE,0 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
148 */
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
149 URLEntry=GTK_COMBO( URLCombo )->entry;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
150 gtk_widget_set_name( URLEntry,"URLEntry" );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
151 gtk_widget_show( URLEntry );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
152
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
153 AddHSeparator( vbox1 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
154
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
155 hbuttonbox1=AddHButtonBox( vbox1 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
156 gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox1 ),GTK_BUTTONBOX_END );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
157 gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox1 ),10 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
158
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
159 Ok=AddButton( MSGTR_Ok,hbuttonbox1 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
160 Cancel=AddButton( MSGTR_Cancel,hbuttonbox1 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
161
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
162 gtk_widget_add_accelerator( Ok,"clicked",accel_group,GDK_Return,0,GTK_ACCEL_VISIBLE );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
163 gtk_widget_add_accelerator( Cancel,"clicked",accel_group,GDK_Escape,0,GTK_ACCEL_VISIBLE );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
164
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
165 gtk_signal_connect( GTK_OBJECT( URL ),"destroy",GTK_SIGNAL_FUNC( WidgetDestroy ),&URL );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
166 gtk_signal_connect( GTK_OBJECT( Ok ),"clicked",GTK_SIGNAL_FUNC( on_Button_pressed ),(void *)1 );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
167 gtk_signal_connect( GTK_OBJECT( Cancel ),"clicked",GTK_SIGNAL_FUNC( on_Button_pressed ),NULL );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
168
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
169 gtk_widget_grab_focus( URLEntry );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
170 gtk_window_add_accel_group( GTK_WINDOW( URL ),accel_group );
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
171
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
172 return URL;
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
173 }