annotate gui/dialog/url.c @ 36050:968e936dc898

Cosmetic: Rename signal handler function. Consistently either use <widget name>_<signal> or <widget type>_<signal> if it's used for more than one widget.
author ib
date Thu, 04 Apr 2013 09:41:25 +0000
parents 31f6a88593b3
children aebe956868d9
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"
35772
3fec1d4b2736 Relocate uiMainEvent() prototype.
ib
parents: 35768
diff changeset
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
71c29e8ec68f Move string functions from interface.c to string.c.
ib
parents: 33572
diff changeset
30 #include "gui/util/string.h"
36018
26836919db4e Add, group and sort #includes, remove unneeded ones.
ib
parents: 36017
diff changeset
31
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
32 #include "help_mp.h"
36018
26836919db4e Add, group and sort #includes, remove unneeded ones.
ib
parents: 36017
diff changeset
33 #include "stream/stream.h"
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
34
36045
a6f9525929a4 Remove unnecessary initialization.
ib
parents: 36032
diff changeset
35 GtkWidget *URLDialog;
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
36
36049
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
37 static GtkWidget *urlCombo;
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
38 static GtkWidget *urlEntry;
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
39 static GList *urlEntries;
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
40
36050
968e936dc898 Cosmetic: Rename signal handler function.
ib
parents: 36049
diff changeset
41 static void button_clicked(GtkButton *button, gpointer user_data)
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
42 {
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
43 urlItem *item;
36010
5c720c434d56 Silence "warning: unused parameter".
ib
parents: 36008
diff changeset
44
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
45 (void)button;
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
46
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
47 if ((int)user_data) {
36049
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
48 gchar *str = strdup(gtk_entry_get_text(GTK_ENTRY(urlEntry)));
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
49
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
50 if (str) {
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
51 if (!strstr(str, "://")) {
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
52 gchar *tmp;
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
53 tmp = malloc(strlen(str) + 8);
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
54 sprintf(tmp, "http://%s", str);
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
55 free(str);
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
56 str = tmp;
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
57 }
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
58
36049
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
59 urlEntries = g_list_prepend(urlEntries, (gchar *)str);
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
60
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
61 item = calloc(1, sizeof(urlItem));
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
62 item->url = gstrdup(str);
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
63 listMgr(URLLIST_ITEM_ADD, item);
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
64
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
65 uiSetFile(NULL, str, STREAMTYPE_STREAM);
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
66 guiInfo.NewPlay = GUI_FILE_NEW;
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
67 listMgr(PLAYLIST_DELETE, 0);
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
68 add_to_gui_playlist(str, PLAYLIST_ITEM_APPEND);
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
69 uiEvent(evPlay, 0);
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
70 }
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
71 }
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
72
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
73 gtk_widget_destroy(URLDialog);
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
74 }
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
75
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
76 static GtkWidget *CreateURLDialog(void)
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
77 {
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
78 GtkWidget *vbox1;
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
79 GtkWidget *hbox1;
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
80 GtkWidget *hbuttonbox1;
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
81 GtkWidget *Ok;
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
82 GtkWidget *Cancel;
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
83 GtkAccelGroup *accel_group;
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
84
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
85 accel_group = gtk_accel_group_new();
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
86
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
87 URLDialog = gtk_window_new(GTK_WINDOW_TOPLEVEL);
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
88 gtk_widget_set_name(URLDialog, "URL");
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
89 gtk_object_set_data(GTK_OBJECT(URLDialog), "URL", URLDialog);
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
90 gtk_widget_set_usize(URLDialog, 384, 70);
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
91 GTK_WIDGET_SET_FLAGS(URLDialog, GTK_CAN_DEFAULT);
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);
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
94 gtk_window_set_policy(GTK_WINDOW(URLDialog), TRUE, TRUE, FALSE);
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
95 gtk_window_set_wmclass(GTK_WINDOW(URLDialog), "Network", "MPlayer");
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
96
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
97 gtk_widget_realize(URLDialog);
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
98 gtkAddIcon(URLDialog);
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
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
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
103
36049
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
104 urlCombo = gtkAddCombo(hbox1);
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
105 /*
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
106 * gtk_combo_new();
36049
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
107 * gtk_widget_set_name( urlCombo,"urlCombo" );
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
108 * gtk_widget_show( urlCombo );
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
109 * gtk_box_pack_start( GTK_BOX( hbox1 ),urlCombo,TRUE,TRUE,0 );
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
110 */
36049
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
111 urlEntry = GTK_COMBO(urlCombo)->entry;
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
112 gtk_widget_set_name(urlEntry, "URLEntry");
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
113 gtk_widget_show(urlEntry);
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
114
36023
a04e8798227b Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents: 36019
diff changeset
115 gtkAddHSeparator(vbox1);
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
116
36023
a04e8798227b Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents: 36019
diff changeset
117 hbuttonbox1 = gtkAddHButtonBox(vbox1);
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
118 gtk_button_box_set_layout(GTK_BUTTON_BOX(hbuttonbox1), GTK_BUTTONBOX_END);
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
119 gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbuttonbox1), 10);
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
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
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
123
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
124 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
125 gtk_widget_add_accelerator(Cancel, "clicked", accel_group, GDK_Escape, 0, GTK_ACCEL_VISIBLE);
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
126
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
127 gtk_signal_connect(GTK_OBJECT(URLDialog), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &URLDialog);
36050
968e936dc898 Cosmetic: Rename signal handler function.
ib
parents: 36049
diff changeset
128 gtk_signal_connect(GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(button_clicked), (void *)1);
968e936dc898 Cosmetic: Rename signal handler function.
ib
parents: 36049
diff changeset
129 gtk_signal_connect(GTK_OBJECT(Cancel), "clicked", GTK_SIGNAL_FUNC(button_clicked), NULL);
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
130
36049
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
131 gtk_widget_grab_focus(urlEntry);
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
132 gtk_window_add_accel_group(GTK_WINDOW(URLDialog), accel_group);
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
133
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
134 return URLDialog;
33572
d9b805602aa1 Rename some gtk files.
ib
parents:
diff changeset
135 }
35988
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
136
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
137 void ShowURLDialog(void)
35988
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
138 {
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
139 urlItem *item;
35988
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
140
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
141 if (URLDialog)
36019
d2d776c8e040 Cosmetic: Rename gtkActive() gtkRaise().
ib
parents: 36018
diff changeset
142 gtkRaise(URLDialog);
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
143 else
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
144 URLDialog = CreateURLDialog();
35988
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
145
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
146 item = listMgr(URLLIST_GET, 0);
35988
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
147
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
148 if (item) {
36049
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
149 g_list_free(urlEntries);
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
150 urlEntries = NULL;
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
151
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
152 while (item) {
36049
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
153 urlEntries = g_list_append(urlEntries, (gchar *)item->url);
36047
705ed2e9e7b1 Cosmetic: Rename variable and correct spelling.
ib
parents: 36045
diff changeset
154 item = item->next;
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
155 }
35988
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
156 }
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
157
36049
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
158 if (urlEntries) {
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
159 gtk_entry_set_text(GTK_ENTRY(urlEntry), urlEntries->data);
31f6a88593b3 Cosmetic: Rename static variables.
ib
parents: 36047
diff changeset
160 gtk_combo_set_popdown_strings(GTK_COMBO(urlCombo), urlEntries);
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
161 }
35988
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
162
36017
b3764c930d0c Cosmetic: Format to MPlayer coding style.
ib
parents: 36010
diff changeset
163 gtk_widget_show(URLDialog);
35988
ad1a5580c91d Make create_URL() static.
ib
parents: 35987
diff changeset
164 }