Mercurial > mplayer.hg
annotate gui/dialog/url.c @ 36895:5616bd62fa26
Fix bug with hpotmeter/vpotmeter in the Win32 GUI.
Allow a hpotmeter/vpotmeter without button.
(The rendering should be fixed, actually, because
it only renders the button but not the phases image.)
author | ib |
---|---|
date | Tue, 11 Mar 2014 12:48:59 +0000 |
parents | eed2fb870f43 |
children | 9afababf229e |
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" |
36032 | 26 #include "gui/interface.h" |
36018 | 27 #include "gui/app/app.h" |
36053 | 28 #include "gui/app/gui.h" |
35772 | 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" |
36018 | 31 |
33572 | 32 #include "help_mp.h" |
36018 | 33 #include "stream/stream.h" |
33572 | 34 |
36045 | 35 GtkWidget *URLDialog; |
33572 | 36 |
36049 | 37 static GtkWidget *urlCombo; |
38 static GtkWidget *urlEntry; | |
39 static GList *urlEntries; | |
33572 | 40 |
36102 | 41 /** |
36103 | 42 * @brief Add the entered URL to the URL list and stream it, |
43 * if the button clicked is the OK button | |
44 * | |
45 * @note If the scheme is missing, http is assumed (and added). | |
36102 | 46 * |
47 * @param button object which received the signal | |
48 * @param user_data user data set when the signal handler was connected | |
36103 | 49 * |
50 * @note The button is determined by checking @a user_data. | |
36102 | 51 */ |
36050 | 52 static void button_clicked(GtkButton *button, gpointer user_data) |
33572 | 53 { |
36017 | 54 (void)button; |
55 | |
36056 | 56 if (user_data) { |
36083 | 57 char *str = strdup(gtk_entry_get_text(GTK_ENTRY(urlEntry))); |
33572 | 58 |
36017 | 59 if (str) { |
60 if (!strstr(str, "://")) { | |
36092 | 61 char *tmp = malloc(strlen(str) + 8); |
36085 | 62 |
63 if (tmp) | |
64 sprintf(tmp, "http://%s", str); | |
65 | |
36017 | 66 free(str); |
67 str = tmp; | |
68 } | |
69 | |
36085 | 70 if (str) { |
36093 | 71 urlItem *item; |
72 | |
36089 | 73 uiSetFile(NULL, str, STREAMTYPE_STREAM); |
74 listMgr(PLAYLIST_DELETE, 0); | |
75 add_to_gui_playlist(str, PLAYLIST_ITEM_APPEND); | |
76 | |
36091 | 77 item = calloc(1, sizeof(urlItem)); |
36090 | 78 |
79 if (item) { | |
36091 | 80 item->url = str; |
81 listMgr(URLLIST_ITEM_ADD, item); | |
36090 | 82 } |
33572 | 83 |
36087 | 84 guiInfo.NewPlay = GUI_FILE_NEW; |
85 uiEvent(evPlay, 0); | |
36085 | 86 } |
36017 | 87 } |
33572 | 88 } |
36017 | 89 |
90 gtk_widget_destroy(URLDialog); | |
33572 | 91 } |
92 | |
36017 | 93 static GtkWidget *CreateURLDialog(void) |
33572 | 94 { |
36017 | 95 GtkWidget *vbox1; |
96 GtkWidget *hbox1; | |
97 GtkWidget *hbuttonbox1; | |
98 GtkWidget *Ok; | |
99 GtkWidget *Cancel; | |
100 GtkAccelGroup *accel_group; | |
36066
2c0e238bc070
Don't allow the URL dialog to be vertically user-resizable.
ib
parents:
36065
diff
changeset
|
101 GdkGeometry geometry; |
33572 | 102 |
36017 | 103 accel_group = gtk_accel_group_new(); |
33572 | 104 |
36017 | 105 URLDialog = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
36057 | 106 gtk_widget_set_usize(URLDialog, 384, -1); |
36694 | 107 gtk_window_set_title(GTK_WINDOW(URLDialog), MSGTR_GUI_NetworkStreaming); |
36017 | 108 gtk_window_set_position(GTK_WINDOW(URLDialog), GTK_WIN_POS_CENTER); |
36053 | 109 gtk_window_set_wmclass(GTK_WINDOW(URLDialog), "Network", MPlayer); |
33572 | 110 |
36017 | 111 gtk_widget_realize(URLDialog); |
112 gtkAddIcon(URLDialog); | |
33572 | 113 |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36019
diff
changeset
|
114 vbox1 = gtkAddVBox(gtkAddDialogFrame(URLDialog), 0); |
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36019
diff
changeset
|
115 hbox1 = gtkAddHBox(vbox1, 1); |
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36019
diff
changeset
|
116 gtkAddLabel("URL: ", hbox1); |
33572 | 117 |
36049 | 118 urlCombo = gtkAddCombo(hbox1); |
33572 | 119 /* |
36017 | 120 * gtk_combo_new(); |
36049 | 121 * gtk_widget_show( urlCombo ); |
122 * gtk_box_pack_start( GTK_BOX( hbox1 ),urlCombo,TRUE,TRUE,0 ); | |
36017 | 123 */ |
36049 | 124 urlEntry = GTK_COMBO(urlCombo)->entry; |
125 gtk_widget_show(urlEntry); | |
33572 | 126 |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36019
diff
changeset
|
127 gtkAddHSeparator(vbox1); |
33572 | 128 |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36019
diff
changeset
|
129 hbuttonbox1 = gtkAddHButtonBox(vbox1); |
36017 | 130 gtk_button_box_set_layout(GTK_BUTTON_BOX(hbuttonbox1), GTK_BUTTONBOX_END); |
131 gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbuttonbox1), 10); | |
33572 | 132 |
36694 | 133 Ok = gtkAddButton(MSGTR_GUI_Ok, hbuttonbox1); |
134 Cancel = gtkAddButton(MSGTR_GUI_Cancel, hbuttonbox1); | |
33572 | 135 |
36066
2c0e238bc070
Don't allow the URL dialog to be vertically user-resizable.
ib
parents:
36065
diff
changeset
|
136 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
|
137 geometry.max_height = -1; |
2c0e238bc070
Don't allow the URL dialog to be vertically user-resizable.
ib
parents:
36065
diff
changeset
|
138 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
|
139 |
36017 | 140 gtk_widget_add_accelerator(Ok, "clicked", accel_group, GDK_Return, 0, GTK_ACCEL_VISIBLE); |
141 gtk_widget_add_accelerator(Cancel, "clicked", accel_group, GDK_Escape, 0, GTK_ACCEL_VISIBLE); | |
33572 | 142 |
36017 | 143 gtk_signal_connect(GTK_OBJECT(URLDialog), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &URLDialog); |
36056 | 144 gtk_signal_connect(GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(button_clicked), Ok); |
36050 | 145 gtk_signal_connect(GTK_OBJECT(Cancel), "clicked", GTK_SIGNAL_FUNC(button_clicked), NULL); |
33572 | 146 |
36049 | 147 gtk_widget_grab_focus(urlEntry); |
36017 | 148 gtk_window_add_accel_group(GTK_WINDOW(URLDialog), accel_group); |
33572 | 149 |
36017 | 150 return URLDialog; |
33572 | 151 } |
35988 | 152 |
36017 | 153 void ShowURLDialog(void) |
35988 | 154 { |
36017 | 155 urlItem *item; |
35988 | 156 |
36017 | 157 if (URLDialog) |
36019 | 158 gtkRaise(URLDialog); |
36017 | 159 else |
160 URLDialog = CreateURLDialog(); | |
35988 | 161 |
36017 | 162 item = listMgr(URLLIST_GET, 0); |
35988 | 163 |
36017 | 164 if (item) { |
36049 | 165 g_list_free(urlEntries); |
166 urlEntries = NULL; | |
36017 | 167 |
168 while (item) { | |
36088 | 169 urlEntries = g_list_append(urlEntries, item->url); |
36047 | 170 item = item->next; |
36017 | 171 } |
35988 | 172 } |
173 | |
36049 | 174 if (urlEntries) { |
175 gtk_entry_set_text(GTK_ENTRY(urlEntry), urlEntries->data); | |
176 gtk_combo_set_popdown_strings(GTK_COMBO(urlCombo), urlEntries); | |
36017 | 177 } |
35988 | 178 |
36017 | 179 gtk_widget_show(URLDialog); |
35988 | 180 } |