Mercurial > mplayer.hg
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 |
rev | line source |
---|---|
33572 | 1 /* |
2 * This file is part of MPlayer. | |
3 * | |
4 * MPlayer is free software; you can redistribute it and/or modify | |
5 * it under the terms of the GNU General Public License as published by | |
6 * the Free Software Foundation; either version 2 of the License, or | |
7 * (at your option) any later version. | |
8 * | |
9 * MPlayer is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
12 * GNU General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU General Public License along | |
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
17 */ | |
18 | |
19 #include <sys/types.h> | |
20 #include <sys/stat.h> | |
21 #include <unistd.h> | |
22 #include <stdlib.h> | |
23 #include <stdio.h> | |
24 #include <string.h> | |
25 | |
26 #include <gdk/gdkkeysyms.h> | |
27 #include <gtk/gtk.h> | |
28 | |
29 #include "url.h" | |
30 #include "tools.h" | |
31 #include "gui/interface.h" | |
35525 | 32 #include "gui/app/app.h" |
35528 | 33 #include "gui/ui/ui.h" |
35529 | 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 | 36 #include "gui/util/string.h" |
33572 | 37 #include "help_mp.h" |
38 | |
39 GtkWidget * URL = NULL; | |
40 | |
41 static GtkWidget * URLCombo; | |
42 static GtkWidget * URLEntry; | |
43 static GList * URLComboEntrys = NULL; | |
44 | |
45 void ShowURLDialogBox( void ) | |
46 { | |
34668 | 47 urlItem * item; |
48 | |
33572 | 49 if ( URL ) gtkActive( URL ); |
50 else URL=create_URL(); | |
51 | |
34668 | 52 item = listMgr( URLLIST_GET,0 ); |
53 | |
54 if ( item ) | |
33572 | 55 { |
56 g_list_free( URLComboEntrys ); | |
57 URLComboEntrys=NULL; | |
58 while( item ) | |
59 { | |
60 URLComboEntrys=g_list_append( URLComboEntrys,(gchar *)item->url ); | |
61 item=item->next; | |
62 } | |
63 } | |
64 | |
65 if ( URLComboEntrys ) | |
66 { | |
67 gtk_entry_set_text( GTK_ENTRY( URLEntry ),URLComboEntrys->data ); | |
68 gtk_combo_set_popdown_strings( GTK_COMBO( URLCombo ),URLComboEntrys ); | |
69 } | |
70 | |
71 gtk_widget_show( URL ); | |
72 } | |
73 | |
74 static void HideURLDialogBox( void ) | |
75 { | |
76 if ( !URL ) return; | |
77 gtk_widget_hide( URL ); | |
78 gtk_widget_destroy( URL ); | |
79 URL=0; | |
80 } | |
81 | |
82 static void on_Button_pressed( GtkButton * button,gpointer user_data ) | |
83 { | |
84 urlItem * item; | |
85 | |
86 if ( (int)user_data ) | |
87 { | |
88 gchar * str= strdup( gtk_entry_get_text( GTK_ENTRY( URLEntry ) ) ); | |
89 | |
90 if ( str ) | |
91 { | |
34959 | 92 if ( !strstr( str,"://" ) ) |
33572 | 93 { |
94 gchar * tmp; | |
95 tmp=malloc( strlen( str ) + 8 ); | |
96 sprintf( tmp,"http://%s",str ); | |
97 free( str ); str=tmp; | |
98 } | |
99 URLComboEntrys=g_list_prepend( URLComboEntrys,(gchar *)str ); | |
100 | |
101 item=calloc( 1,sizeof( urlItem ) ); | |
102 item->url=gstrdup( str ); | |
34663 | 103 listMgr( URLLIST_ITEM_ADD,item ); |
33572 | 104 |
35452 | 105 uiSetFile( NULL,str,STREAMTYPE_STREAM ); guiInfo.NewPlay=GUI_FILE_NEW; |
35352 | 106 listMgr(PLAYLIST_DELETE, 0); |
35350 | 107 add_to_gui_playlist(str, PLAYLIST_ITEM_APPEND); |
34067 | 108 uiEventHandling( evPlay,0 ); |
33572 | 109 } |
110 } | |
111 HideURLDialogBox(); | |
112 } | |
113 | |
114 GtkWidget * create_URL( void ) | |
115 { | |
116 GtkWidget * vbox1; | |
117 GtkWidget * hbox1; | |
118 GtkWidget * hbuttonbox1; | |
119 GtkWidget * Ok; | |
120 GtkWidget * Cancel; | |
121 GtkAccelGroup * accel_group; | |
122 | |
123 accel_group=gtk_accel_group_new(); | |
124 | |
125 URL=gtk_window_new( GTK_WINDOW_TOPLEVEL ); | |
126 gtk_widget_set_name( URL,"URL" ); | |
127 gtk_object_set_data( GTK_OBJECT( URL ),"URL",URL ); | |
128 gtk_widget_set_usize( URL,384,70 ); | |
129 GTK_WIDGET_SET_FLAGS( URL,GTK_CAN_DEFAULT ); | |
130 gtk_window_set_title( GTK_WINDOW( URL ),MSGTR_Network ); | |
131 gtk_window_set_position( GTK_WINDOW( URL ),GTK_WIN_POS_CENTER ); | |
132 gtk_window_set_policy( GTK_WINDOW( URL ),TRUE,TRUE,FALSE ); | |
133 gtk_window_set_wmclass( GTK_WINDOW( URL ),"Network","MPlayer" ); | |
134 | |
135 gtk_widget_realize( URL ); | |
136 gtkAddIcon( URL ); | |
137 | |
138 vbox1=AddVBox( AddDialogFrame( URL ),0 ); | |
139 hbox1=AddHBox( vbox1,1 ); | |
140 AddLabel( "URL: ",hbox1 ); | |
141 | |
142 URLCombo=AddComboBox( hbox1 ); | |
143 /* | |
144 gtk_combo_new(); | |
145 gtk_widget_set_name( URLCombo,"URLCombo" ); | |
146 gtk_widget_show( URLCombo ); | |
147 gtk_box_pack_start( GTK_BOX( hbox1 ),URLCombo,TRUE,TRUE,0 ); | |
148 */ | |
149 URLEntry=GTK_COMBO( URLCombo )->entry; | |
150 gtk_widget_set_name( URLEntry,"URLEntry" ); | |
151 gtk_widget_show( URLEntry ); | |
152 | |
153 AddHSeparator( vbox1 ); | |
154 | |
155 hbuttonbox1=AddHButtonBox( vbox1 ); | |
156 gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox1 ),GTK_BUTTONBOX_END ); | |
157 gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox1 ),10 ); | |
158 | |
159 Ok=AddButton( MSGTR_Ok,hbuttonbox1 ); | |
160 Cancel=AddButton( MSGTR_Cancel,hbuttonbox1 ); | |
161 | |
162 gtk_widget_add_accelerator( Ok,"clicked",accel_group,GDK_Return,0,GTK_ACCEL_VISIBLE ); | |
163 gtk_widget_add_accelerator( Cancel,"clicked",accel_group,GDK_Escape,0,GTK_ACCEL_VISIBLE ); | |
164 | |
165 gtk_signal_connect( GTK_OBJECT( URL ),"destroy",GTK_SIGNAL_FUNC( WidgetDestroy ),&URL ); | |
166 gtk_signal_connect( GTK_OBJECT( Ok ),"clicked",GTK_SIGNAL_FUNC( on_Button_pressed ),(void *)1 ); | |
167 gtk_signal_connect( GTK_OBJECT( Cancel ),"clicked",GTK_SIGNAL_FUNC( on_Button_pressed ),NULL ); | |
168 | |
169 gtk_widget_grab_focus( URLEntry ); | |
170 gtk_window_add_accel_group( GTK_WINDOW( URL ),accel_group ); | |
171 | |
172 return URL; | |
173 } |