Mercurial > mplayer.hg
annotate gui/ui/gtk/url.c @ 35350:ee265b18d653
Rename import_file_into_gui() add_to_gui_playlist().
This seems to be a more appropriate name.
Additionally, use self-explanatory enum constants instead of numeric
ones, change the parameter names and a declaration to const, check the
parameters and print the debug message only if the item will really be
added.
(For the sake of consistency, adjust the Win32 code as well.)
author | ib |
---|---|
date | Thu, 22 Nov 2012 13:57:40 +0000 |
parents | 60930e7347c6 |
children | 96cda43fe250 |
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" | |
32 #include "gui/app.h" | |
33 #include "gui/ui/gmplayer.h" | |
34 #include "gui/ui/widgets.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 |
34067 | 105 uiSetFileName( NULL,str,STREAMTYPE_STREAM ); guiInfo.NewPlay=GUI_FILE_NEW; |
35350 | 106 add_to_gui_playlist(str, PLAYLIST_ITEM_APPEND); |
34067 | 107 uiEventHandling( evPlay,0 ); |
33572 | 108 } |
109 } | |
110 HideURLDialogBox(); | |
111 } | |
112 | |
113 GtkWidget * create_URL( void ) | |
114 { | |
115 GtkWidget * vbox1; | |
116 GtkWidget * hbox1; | |
117 GtkWidget * hbuttonbox1; | |
118 GtkWidget * Ok; | |
119 GtkWidget * Cancel; | |
120 GtkAccelGroup * accel_group; | |
121 | |
122 accel_group=gtk_accel_group_new(); | |
123 | |
124 URL=gtk_window_new( GTK_WINDOW_TOPLEVEL ); | |
125 gtk_widget_set_name( URL,"URL" ); | |
126 gtk_object_set_data( GTK_OBJECT( URL ),"URL",URL ); | |
127 gtk_widget_set_usize( URL,384,70 ); | |
128 GTK_WIDGET_SET_FLAGS( URL,GTK_CAN_DEFAULT ); | |
129 gtk_window_set_title( GTK_WINDOW( URL ),MSGTR_Network ); | |
130 gtk_window_set_position( GTK_WINDOW( URL ),GTK_WIN_POS_CENTER ); | |
131 gtk_window_set_policy( GTK_WINDOW( URL ),TRUE,TRUE,FALSE ); | |
132 gtk_window_set_wmclass( GTK_WINDOW( URL ),"Network","MPlayer" ); | |
133 | |
134 gtk_widget_realize( URL ); | |
135 gtkAddIcon( URL ); | |
136 | |
137 vbox1=AddVBox( AddDialogFrame( URL ),0 ); | |
138 hbox1=AddHBox( vbox1,1 ); | |
139 AddLabel( "URL: ",hbox1 ); | |
140 | |
141 URLCombo=AddComboBox( hbox1 ); | |
142 /* | |
143 gtk_combo_new(); | |
144 gtk_widget_set_name( URLCombo,"URLCombo" ); | |
145 gtk_widget_show( URLCombo ); | |
146 gtk_box_pack_start( GTK_BOX( hbox1 ),URLCombo,TRUE,TRUE,0 ); | |
147 */ | |
148 URLEntry=GTK_COMBO( URLCombo )->entry; | |
149 gtk_widget_set_name( URLEntry,"URLEntry" ); | |
150 gtk_widget_show( URLEntry ); | |
151 | |
152 AddHSeparator( vbox1 ); | |
153 | |
154 hbuttonbox1=AddHButtonBox( vbox1 ); | |
155 gtk_button_box_set_layout( GTK_BUTTON_BOX( hbuttonbox1 ),GTK_BUTTONBOX_END ); | |
156 gtk_button_box_set_spacing( GTK_BUTTON_BOX( hbuttonbox1 ),10 ); | |
157 | |
158 Ok=AddButton( MSGTR_Ok,hbuttonbox1 ); | |
159 Cancel=AddButton( MSGTR_Cancel,hbuttonbox1 ); | |
160 | |
161 gtk_widget_add_accelerator( Ok,"clicked",accel_group,GDK_Return,0,GTK_ACCEL_VISIBLE ); | |
162 gtk_widget_add_accelerator( Cancel,"clicked",accel_group,GDK_Escape,0,GTK_ACCEL_VISIBLE ); | |
163 | |
164 gtk_signal_connect( GTK_OBJECT( URL ),"destroy",GTK_SIGNAL_FUNC( WidgetDestroy ),&URL ); | |
165 gtk_signal_connect( GTK_OBJECT( Ok ),"clicked",GTK_SIGNAL_FUNC( on_Button_pressed ),(void *)1 ); | |
166 gtk_signal_connect( GTK_OBJECT( Cancel ),"clicked",GTK_SIGNAL_FUNC( on_Button_pressed ),NULL ); | |
167 | |
168 gtk_widget_grab_focus( URLEntry ); | |
169 gtk_window_add_accel_group( GTK_WINDOW( URL ),accel_group ); | |
170 | |
171 return URL; | |
172 } |