Mercurial > mplayer.hg
annotate gui/dialog/url.c @ 36093:22ac72559523
Move declaration into scope where variable is used.
author | ib |
---|---|
date | Mon, 29 Apr 2013 12:26:37 +0000 |
parents | e16833799bae |
children | 0fade14b5df1 |
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 |
36050 | 41 static void button_clicked(GtkButton *button, gpointer user_data) |
33572 | 42 { |
36017 | 43 (void)button; |
44 | |
36056 | 45 if (user_data) { |
36083 | 46 char *str = strdup(gtk_entry_get_text(GTK_ENTRY(urlEntry))); |
33572 | 47 |
36017 | 48 if (str) { |
49 if (!strstr(str, "://")) { | |
36092 | 50 char *tmp = malloc(strlen(str) + 8); |
36085 | 51 |
52 if (tmp) | |
53 sprintf(tmp, "http://%s", str); | |
54 | |
36017 | 55 free(str); |
56 str = tmp; | |
57 } | |
58 | |
36085 | 59 if (str) { |
36093 | 60 urlItem *item; |
61 | |
36089 | 62 uiSetFile(NULL, str, STREAMTYPE_STREAM); |
63 listMgr(PLAYLIST_DELETE, 0); | |
64 add_to_gui_playlist(str, PLAYLIST_ITEM_APPEND); | |
65 | |
36091 | 66 item = calloc(1, sizeof(urlItem)); |
36090 | 67 |
68 if (item) { | |
36091 | 69 item->url = str; |
70 listMgr(URLLIST_ITEM_ADD, item); | |
36090 | 71 } |
33572 | 72 |
36087 | 73 guiInfo.NewPlay = GUI_FILE_NEW; |
74 uiEvent(evPlay, 0); | |
36085 | 75 } |
36017 | 76 } |
33572 | 77 } |
36017 | 78 |
79 gtk_widget_destroy(URLDialog); | |
33572 | 80 } |
81 | |
36017 | 82 static GtkWidget *CreateURLDialog(void) |
33572 | 83 { |
36017 | 84 GtkWidget *vbox1; |
85 GtkWidget *hbox1; | |
86 GtkWidget *hbuttonbox1; | |
87 GtkWidget *Ok; | |
88 GtkWidget *Cancel; | |
89 GtkAccelGroup *accel_group; | |
36066
2c0e238bc070
Don't allow the URL dialog to be vertically user-resizable.
ib
parents:
36065
diff
changeset
|
90 GdkGeometry geometry; |
33572 | 91 |
36017 | 92 accel_group = gtk_accel_group_new(); |
33572 | 93 |
36017 | 94 URLDialog = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
36057 | 95 gtk_widget_set_usize(URLDialog, 384, -1); |
36017 | 96 gtk_window_set_title(GTK_WINDOW(URLDialog), MSGTR_Network); |
97 gtk_window_set_position(GTK_WINDOW(URLDialog), GTK_WIN_POS_CENTER); | |
36053 | 98 gtk_window_set_wmclass(GTK_WINDOW(URLDialog), "Network", MPlayer); |
33572 | 99 |
36017 | 100 gtk_widget_realize(URLDialog); |
101 gtkAddIcon(URLDialog); | |
33572 | 102 |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36019
diff
changeset
|
103 vbox1 = gtkAddVBox(gtkAddDialogFrame(URLDialog), 0); |
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36019
diff
changeset
|
104 hbox1 = gtkAddHBox(vbox1, 1); |
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36019
diff
changeset
|
105 gtkAddLabel("URL: ", hbox1); |
33572 | 106 |
36049 | 107 urlCombo = gtkAddCombo(hbox1); |
33572 | 108 /* |
36017 | 109 * gtk_combo_new(); |
36049 | 110 * gtk_widget_show( urlCombo ); |
111 * gtk_box_pack_start( GTK_BOX( hbox1 ),urlCombo,TRUE,TRUE,0 ); | |
36017 | 112 */ |
36049 | 113 urlEntry = GTK_COMBO(urlCombo)->entry; |
114 gtk_widget_show(urlEntry); | |
33572 | 115 |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36019
diff
changeset
|
116 gtkAddHSeparator(vbox1); |
33572 | 117 |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36019
diff
changeset
|
118 hbuttonbox1 = gtkAddHButtonBox(vbox1); |
36017 | 119 gtk_button_box_set_layout(GTK_BUTTON_BOX(hbuttonbox1), GTK_BUTTONBOX_END); |
120 gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbuttonbox1), 10); | |
33572 | 121 |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36019
diff
changeset
|
122 Ok = gtkAddButton(MSGTR_Ok, hbuttonbox1); |
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36019
diff
changeset
|
123 Cancel = gtkAddButton(MSGTR_Cancel, hbuttonbox1); |
33572 | 124 |
36066
2c0e238bc070
Don't allow the URL dialog to be vertically user-resizable.
ib
parents:
36065
diff
changeset
|
125 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
|
126 geometry.max_height = -1; |
2c0e238bc070
Don't allow the URL dialog to be vertically user-resizable.
ib
parents:
36065
diff
changeset
|
127 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
|
128 |
36017 | 129 gtk_widget_add_accelerator(Ok, "clicked", accel_group, GDK_Return, 0, GTK_ACCEL_VISIBLE); |
130 gtk_widget_add_accelerator(Cancel, "clicked", accel_group, GDK_Escape, 0, GTK_ACCEL_VISIBLE); | |
33572 | 131 |
36017 | 132 gtk_signal_connect(GTK_OBJECT(URLDialog), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &URLDialog); |
36056 | 133 gtk_signal_connect(GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(button_clicked), Ok); |
36050 | 134 gtk_signal_connect(GTK_OBJECT(Cancel), "clicked", GTK_SIGNAL_FUNC(button_clicked), NULL); |
33572 | 135 |
36049 | 136 gtk_widget_grab_focus(urlEntry); |
36017 | 137 gtk_window_add_accel_group(GTK_WINDOW(URLDialog), accel_group); |
33572 | 138 |
36017 | 139 return URLDialog; |
33572 | 140 } |
35988 | 141 |
36017 | 142 void ShowURLDialog(void) |
35988 | 143 { |
36017 | 144 urlItem *item; |
35988 | 145 |
36017 | 146 if (URLDialog) |
36019 | 147 gtkRaise(URLDialog); |
36017 | 148 else |
149 URLDialog = CreateURLDialog(); | |
35988 | 150 |
36017 | 151 item = listMgr(URLLIST_GET, 0); |
35988 | 152 |
36017 | 153 if (item) { |
36049 | 154 g_list_free(urlEntries); |
155 urlEntries = NULL; | |
36017 | 156 |
157 while (item) { | |
36088 | 158 urlEntries = g_list_append(urlEntries, item->url); |
36047 | 159 item = item->next; |
36017 | 160 } |
35988 | 161 } |
162 | |
36049 | 163 if (urlEntries) { |
164 gtk_entry_set_text(GTK_ENTRY(urlEntry), urlEntries->data); | |
165 gtk_combo_set_popdown_strings(GTK_COMBO(urlCombo), urlEntries); | |
36017 | 166 } |
35988 | 167 |
36017 | 168 gtk_widget_show(URLDialog); |
35988 | 169 } |