annotate gui/dialog/url.c @ 36082:bb41e924fea9

Cosmetic: Insert blank line and relocate statement.
author ib
date Mon, 29 Apr 2013 10:28:18 +0000
parents 2c0e238bc070
children 3705b6e4ba07
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
36018
26836919db4e Add, group and sort #includes, remove unneeded ones.
ib
parents: 36017
diff changeset
19 #include <stdio.h>
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
20 #include <stdlib.h>
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
21 #include <string.h>
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
22
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
23 #include "url.h"
36018
26836919db4e Add, group and sort #includes, remove unneeded ones.
ib
parents: 36017
diff changeset
24 #include "dialog.h"
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
25 #include "tools.h"
36032
c667e34fb941 Cosmetic: Rearrange #includes.
ib
parents: 36023
diff changeset
26 #include "gui/interface.h"
36018
26836919db4e Add, group and sort #includes, remove unneeded ones.
ib
parents: 36017
diff changeset
27 #include "gui/app/app.h"
36053
7affacef2f88 Define "MPlayer" string.
ib
parents: 36052
diff changeset
28 #include "gui/app/gui.h"
35772
3fec1d4b2736 Relocate uiMainEvent() prototype.
ib
parents: 35768
diff changeset
29 #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
30 #include "gui/util/list.h"
33737
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33572
diff changeset
31 #include "gui/util/string.h"
36018
26836919db4e Add, group and sort #includes, remove unneeded ones.
ib
parents: 36017
diff changeset
32
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
33 #include "help_mp.h"
36018
26836919db4e Add, group and sort #includes, remove unneeded ones.
ib
parents: 36017
diff changeset
34 #include "stream/stream.h"
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
35
36045
a6f9525929a4 Remove unnecessary initialization.
ib
parents: 36032
diff changeset
36 GtkWidget *URLDialog;
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
37
36049
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
38 static GtkWidget *urlCombo;
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
39 static GtkWidget *urlEntry;
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
40 static GList *urlEntries;
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
41
36050
968e936dc898 Cosmetic: Rename signal handler function.
ib
parents: 36049
diff changeset
42 static void button_clicked(GtkButton *button, gpointer user_data)
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
43 {
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
44 urlItem *item;
36010
5c720c434d56 Silence "warning: unused parameter".
ib
parents: 36008
diff changeset
45
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
46 (void)button;
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
47
36056
94188b63e047 Avoid casts by passing an existing pointer.
ib
parents: 36053
diff changeset
48 if (user_data) {
36049
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
49 gchar *str = strdup(gtk_entry_get_text(GTK_ENTRY(urlEntry)));
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
50
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
51 if (str) {
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
52 if (!strstr(str, "://")) {
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
53 gchar *tmp;
36082
bb41e924fea9 Cosmetic: Insert blank line and relocate statement.
ib
parents: 36066
diff changeset
54
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
55 tmp = malloc(strlen(str) + 8);
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
56 sprintf(tmp, "http://%s", str);
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
57 free(str);
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
58 str = tmp;
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
59 }
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
60
36049
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
61 urlEntries = g_list_prepend(urlEntries, (gchar *)str);
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
62
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
63 item = calloc(1, sizeof(urlItem));
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
64 item->url = gstrdup(str);
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
65 listMgr(URLLIST_ITEM_ADD, item);
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
66
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
67 uiSetFile(NULL, str, STREAMTYPE_STREAM);
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
68 listMgr(PLAYLIST_DELETE, 0);
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
69 add_to_gui_playlist(str, PLAYLIST_ITEM_APPEND);
36082
bb41e924fea9 Cosmetic: Insert blank line and relocate statement.
ib
parents: 36066
diff changeset
70 guiInfo.NewPlay = GUI_FILE_NEW;
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
71 uiEvent(evPlay, 0);
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
72 }
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
73 }
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
74
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
75 gtk_widget_destroy(URLDialog);
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
76 }
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
77
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
78 static GtkWidget *CreateURLDialog(void)
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
79 {
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
80 GtkWidget *vbox1;
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
81 GtkWidget *hbox1;
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
82 GtkWidget *hbuttonbox1;
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
83 GtkWidget *Ok;
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
84 GtkWidget *Cancel;
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
85 GtkAccelGroup *accel_group;
36066
2c0e238bc070 Don't allow the URL dialog to be vertically user-resizable.
ib
parents: 36065
diff changeset
86 GdkGeometry geometry;
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
87
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
88 accel_group = gtk_accel_group_new();
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
89
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
90 URLDialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
36057
12dcd03f4e79 Don't set (too small) height.
ib
parents: 36056
diff changeset
91 gtk_widget_set_usize(URLDialog, 384, -1);
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
92 gtk_window_set_title(GTK_WINDOW(URLDialog), MSGTR_Network);
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
93 gtk_window_set_position(GTK_WINDOW(URLDialog), GTK_WIN_POS_CENTER);
36053
7affacef2f88 Define "MPlayer" string.
ib
parents: 36052
diff changeset
94 gtk_window_set_wmclass(GTK_WINDOW(URLDialog), "Network", MPlayer);
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
95
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
96 gtk_widget_realize(URLDialog);
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
97 gtkAddIcon(URLDialog);
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
98
36023
a04e8798227b Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents: 36019
diff changeset
99 vbox1 = gtkAddVBox(gtkAddDialogFrame(URLDialog), 0);
a04e8798227b Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents: 36019
diff changeset
100 hbox1 = gtkAddHBox(vbox1, 1);
a04e8798227b Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents: 36019
diff changeset
101 gtkAddLabel("URL: ", hbox1);
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
102
36049
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
103 urlCombo = gtkAddCombo(hbox1);
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
104 /*
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
105 * gtk_combo_new();
36049
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
106 * gtk_widget_show( urlCombo );
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
107 * gtk_box_pack_start( GTK_BOX( hbox1 ),urlCombo,TRUE,TRUE,0 );
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
108 */
36049
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
109 urlEntry = GTK_COMBO(urlCombo)->entry;
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
110 gtk_widget_show(urlEntry);
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
111
36023
a04e8798227b Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents: 36019
diff changeset
112 gtkAddHSeparator(vbox1);
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
113
36023
a04e8798227b Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents: 36019
diff changeset
114 hbuttonbox1 = gtkAddHButtonBox(vbox1);
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
115 gtk_button_box_set_layout(GTK_BUTTON_BOX(hbuttonbox1), GTK_BUTTONBOX_END);
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
116 gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbuttonbox1), 10);
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
117
36023
a04e8798227b Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents: 36019
diff changeset
118 Ok = gtkAddButton(MSGTR_Ok, hbuttonbox1);
a04e8798227b Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents: 36019
diff changeset
119 Cancel = gtkAddButton(MSGTR_Cancel, hbuttonbox1);
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
120
36066
2c0e238bc070 Don't allow the URL dialog to be vertically user-resizable.
ib
parents: 36065
diff changeset
121 geometry.max_width = gdk_screen_get_width(gtk_widget_get_screen(URLDialog));
2c0e238bc070 Don't allow the URL dialog to be vertically user-resizable.
ib
parents: 36065
diff changeset
122 geometry.max_height = -1;
2c0e238bc070 Don't allow the URL dialog to be vertically user-resizable.
ib
parents: 36065
diff changeset
123 gtk_window_set_geometry_hints(GTK_WINDOW(URLDialog), NULL, &geometry, GDK_HINT_MAX_SIZE);
2c0e238bc070 Don't allow the URL dialog to be vertically user-resizable.
ib
parents: 36065
diff changeset
124
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
125 gtk_widget_add_accelerator(Ok, "clicked", accel_group, GDK_Return, 0, GTK_ACCEL_VISIBLE);
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
126 gtk_widget_add_accelerator(Cancel, "clicked", accel_group, GDK_Escape, 0, GTK_ACCEL_VISIBLE);
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
127
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
128 gtk_signal_connect(GTK_OBJECT(URLDialog), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &URLDialog);
36056
94188b63e047 Avoid casts by passing an existing pointer.
ib
parents: 36053
diff changeset
129 gtk_signal_connect(GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(button_clicked), Ok);
36050
968e936dc898 Cosmetic: Rename signal handler function.
ib
parents: 36049
diff changeset
130 gtk_signal_connect(GTK_OBJECT(Cancel), "clicked", GTK_SIGNAL_FUNC(button_clicked), NULL);
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
131
36049
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
132 gtk_widget_grab_focus(urlEntry);
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
133 gtk_window_add_accel_group(GTK_WINDOW(URLDialog), accel_group);
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
134
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
135 return URLDialog;
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
136 }
35988
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
137
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
138 void ShowURLDialog(void)
35988
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
139 {
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
140 urlItem *item;
35988
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
141
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
142 if (URLDialog)
36019
d2d776c8e040 Cosmetic: Rename gtkActive() gtkRaise().
ib
parents: 36018
diff changeset
143 gtkRaise(URLDialog);
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
144 else
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
145 URLDialog = CreateURLDialog();
35988
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
146
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
147 item = listMgr(URLLIST_GET, 0);
35988
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
148
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
149 if (item) {
36049
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
150 g_list_free(urlEntries);
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
151 urlEntries = NULL;
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
152
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
153 while (item) {
36049
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
154 urlEntries = g_list_append(urlEntries, (gchar *)item->url);
36047
705ed2e9e7b1 Cosmetic: Rename variable and correct spelling.
ib
parents: 36045
diff changeset
155 item = item->next;
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
156 }
35988
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
157 }
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
158
36049
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
159 if (urlEntries) {
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
160 gtk_entry_set_text(GTK_ENTRY(urlEntry), urlEntries->data);
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
161 gtk_combo_set_popdown_strings(GTK_COMBO(urlCombo), urlEntries);
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
162 }
35988
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
163
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
164 gtk_widget_show(URLDialog);
35988
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
165 }