Mercurial > mplayer.hg
annotate gui/dialog/url.c @ 36026:f96f37b4f5a1
Remove unnecessary #includes.
Put #includes where they are needed.
author | ib |
---|---|
date | Sun, 31 Mar 2013 22:13:32 +0000 |
parents | a04e8798227b |
children | c667e34fb941 |
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 | |
36018 | 19 #include <stdio.h> |
33572 | 20 #include <stdlib.h> |
21 #include <string.h> | |
22 | |
23 #include "url.h" | |
36018 | 24 #include "dialog.h" |
33572 | 25 #include "tools.h" |
36018 | 26 #include "gui/app/app.h" |
33572 | 27 #include "gui/interface.h" |
35772 | 28 #include "gui/ui/actions.h" |
33742
e1539e14d60f
Move purely list related parts of gtkSet() from interface.c to list.c.
ib
parents:
33740
diff
changeset
|
29 #include "gui/util/list.h" |
33737 | 30 #include "gui/util/string.h" |
36018 | 31 |
33572 | 32 #include "help_mp.h" |
36018 | 33 #include "stream/stream.h" |
33572 | 34 |
36017 | 35 GtkWidget *URLDialog = NULL; |
33572 | 36 |
36017 | 37 static GtkWidget *URLCombo; |
38 static GtkWidget *URLEntry; | |
39 static GList *URLComboEntrys = NULL; | |
33572 | 40 |
36017 | 41 static void on_Button_pressed(GtkButton *button, gpointer user_data) |
33572 | 42 { |
36017 | 43 urlItem *item; |
36010 | 44 |
36017 | 45 (void)button; |
46 | |
47 if ((int)user_data) { | |
48 gchar *str = strdup(gtk_entry_get_text(GTK_ENTRY(URLEntry))); | |
33572 | 49 |
36017 | 50 if (str) { |
51 if (!strstr(str, "://")) { | |
52 gchar *tmp; | |
53 tmp = malloc(strlen(str) + 8); | |
54 sprintf(tmp, "http://%s", str); | |
55 free(str); | |
56 str = tmp; | |
57 } | |
58 | |
59 URLComboEntrys = g_list_prepend(URLComboEntrys, (gchar *)str); | |
33572 | 60 |
36017 | 61 item = calloc(1, sizeof(urlItem)); |
62 item->url = gstrdup(str); | |
63 listMgr(URLLIST_ITEM_ADD, item); | |
33572 | 64 |
36017 | 65 uiSetFile(NULL, str, STREAMTYPE_STREAM); |
66 guiInfo.NewPlay = GUI_FILE_NEW; | |
67 listMgr(PLAYLIST_DELETE, 0); | |
68 add_to_gui_playlist(str, PLAYLIST_ITEM_APPEND); | |
69 uiEvent(evPlay, 0); | |
70 } | |
33572 | 71 } |
36017 | 72 |
73 gtk_widget_destroy(URLDialog); | |
33572 | 74 } |
75 | |
36017 | 76 static GtkWidget *CreateURLDialog(void) |
33572 | 77 { |
36017 | 78 GtkWidget *vbox1; |
79 GtkWidget *hbox1; | |
80 GtkWidget *hbuttonbox1; | |
81 GtkWidget *Ok; | |
82 GtkWidget *Cancel; | |
83 GtkAccelGroup *accel_group; | |
33572 | 84 |
36017 | 85 accel_group = gtk_accel_group_new(); |
33572 | 86 |
36017 | 87 URLDialog = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
88 gtk_widget_set_name(URLDialog, "URL"); | |
89 gtk_object_set_data(GTK_OBJECT(URLDialog), "URL", URLDialog); | |
90 gtk_widget_set_usize(URLDialog, 384, 70); | |
91 GTK_WIDGET_SET_FLAGS(URLDialog, GTK_CAN_DEFAULT); | |
92 gtk_window_set_title(GTK_WINDOW(URLDialog), MSGTR_Network); | |
93 gtk_window_set_position(GTK_WINDOW(URLDialog), GTK_WIN_POS_CENTER); | |
94 gtk_window_set_policy(GTK_WINDOW(URLDialog), TRUE, TRUE, FALSE); | |
95 gtk_window_set_wmclass(GTK_WINDOW(URLDialog), "Network", "MPlayer"); | |
33572 | 96 |
36017 | 97 gtk_widget_realize(URLDialog); |
98 gtkAddIcon(URLDialog); | |
33572 | 99 |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36019
diff
changeset
|
100 vbox1 = gtkAddVBox(gtkAddDialogFrame(URLDialog), 0); |
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36019
diff
changeset
|
101 hbox1 = gtkAddHBox(vbox1, 1); |
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36019
diff
changeset
|
102 gtkAddLabel("URL: ", hbox1); |
33572 | 103 |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36019
diff
changeset
|
104 URLCombo = gtkAddCombo(hbox1); |
33572 | 105 /* |
36017 | 106 * gtk_combo_new(); |
107 * gtk_widget_set_name( URLCombo,"URLCombo" ); | |
108 * gtk_widget_show( URLCombo ); | |
109 * gtk_box_pack_start( GTK_BOX( hbox1 ),URLCombo,TRUE,TRUE,0 ); | |
110 */ | |
111 URLEntry = GTK_COMBO(URLCombo)->entry; | |
112 gtk_widget_set_name(URLEntry, "URLEntry"); | |
113 gtk_widget_show(URLEntry); | |
33572 | 114 |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36019
diff
changeset
|
115 gtkAddHSeparator(vbox1); |
33572 | 116 |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36019
diff
changeset
|
117 hbuttonbox1 = gtkAddHButtonBox(vbox1); |
36017 | 118 gtk_button_box_set_layout(GTK_BUTTON_BOX(hbuttonbox1), GTK_BUTTONBOX_END); |
119 gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbuttonbox1), 10); | |
33572 | 120 |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36019
diff
changeset
|
121 Ok = gtkAddButton(MSGTR_Ok, hbuttonbox1); |
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36019
diff
changeset
|
122 Cancel = gtkAddButton(MSGTR_Cancel, hbuttonbox1); |
33572 | 123 |
36017 | 124 gtk_widget_add_accelerator(Ok, "clicked", accel_group, GDK_Return, 0, GTK_ACCEL_VISIBLE); |
125 gtk_widget_add_accelerator(Cancel, "clicked", accel_group, GDK_Escape, 0, GTK_ACCEL_VISIBLE); | |
33572 | 126 |
36017 | 127 gtk_signal_connect(GTK_OBJECT(URLDialog), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &URLDialog); |
128 gtk_signal_connect(GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(on_Button_pressed), (void *)1); | |
129 gtk_signal_connect(GTK_OBJECT(Cancel), "clicked", GTK_SIGNAL_FUNC(on_Button_pressed), NULL); | |
33572 | 130 |
36017 | 131 gtk_widget_grab_focus(URLEntry); |
132 gtk_window_add_accel_group(GTK_WINDOW(URLDialog), accel_group); | |
33572 | 133 |
36017 | 134 return URLDialog; |
33572 | 135 } |
35988 | 136 |
36017 | 137 void ShowURLDialog(void) |
35988 | 138 { |
36017 | 139 urlItem *item; |
35988 | 140 |
36017 | 141 if (URLDialog) |
36019 | 142 gtkRaise(URLDialog); |
36017 | 143 else |
144 URLDialog = CreateURLDialog(); | |
35988 | 145 |
36017 | 146 item = listMgr(URLLIST_GET, 0); |
35988 | 147 |
36017 | 148 if (item) { |
149 g_list_free(URLComboEntrys); | |
150 URLComboEntrys = NULL; | |
151 | |
152 while (item) { | |
153 URLComboEntrys = g_list_append(URLComboEntrys, (gchar *)item->url); | |
154 item = item->next; | |
155 } | |
35988 | 156 } |
157 | |
36017 | 158 if (URLComboEntrys) { |
159 gtk_entry_set_text(GTK_ENTRY(URLEntry), URLComboEntrys->data); | |
160 gtk_combo_set_popdown_strings(GTK_COMBO(URLCombo), URLComboEntrys); | |
161 } | |
35988 | 162 |
36017 | 163 gtk_widget_show(URLDialog); |
35988 | 164 } |