Mercurial > mplayer.hg
annotate gui/dialog/url.c @ 36065:070c711825ea
Don't allow the URL dialog to be user-shrinkable.
Remove the policy and use the default.
author | ib |
---|---|
date | Thu, 04 Apr 2013 19:18:11 +0000 |
parents | ecd7b4e543bf |
children | 2c0e238bc070 |
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" |
33737 | 31 #include "gui/util/string.h" |
36018 | 32 |
33572 | 33 #include "help_mp.h" |
36018 | 34 #include "stream/stream.h" |
33572 | 35 |
36045 | 36 GtkWidget *URLDialog; |
33572 | 37 |
36049 | 38 static GtkWidget *urlCombo; |
39 static GtkWidget *urlEntry; | |
40 static GList *urlEntries; | |
33572 | 41 |
36050 | 42 static void button_clicked(GtkButton *button, gpointer user_data) |
33572 | 43 { |
36017 | 44 urlItem *item; |
36010 | 45 |
36017 | 46 (void)button; |
47 | |
36056 | 48 if (user_data) { |
36049 | 49 gchar *str = strdup(gtk_entry_get_text(GTK_ENTRY(urlEntry))); |
33572 | 50 |
36017 | 51 if (str) { |
52 if (!strstr(str, "://")) { | |
53 gchar *tmp; | |
54 tmp = malloc(strlen(str) + 8); | |
55 sprintf(tmp, "http://%s", str); | |
56 free(str); | |
57 str = tmp; | |
58 } | |
59 | |
36049 | 60 urlEntries = g_list_prepend(urlEntries, (gchar *)str); |
33572 | 61 |
36017 | 62 item = calloc(1, sizeof(urlItem)); |
63 item->url = gstrdup(str); | |
64 listMgr(URLLIST_ITEM_ADD, item); | |
33572 | 65 |
36017 | 66 uiSetFile(NULL, str, STREAMTYPE_STREAM); |
67 guiInfo.NewPlay = GUI_FILE_NEW; | |
68 listMgr(PLAYLIST_DELETE, 0); | |
69 add_to_gui_playlist(str, PLAYLIST_ITEM_APPEND); | |
70 uiEvent(evPlay, 0); | |
71 } | |
33572 | 72 } |
36017 | 73 |
74 gtk_widget_destroy(URLDialog); | |
33572 | 75 } |
76 | |
36017 | 77 static GtkWidget *CreateURLDialog(void) |
33572 | 78 { |
36017 | 79 GtkWidget *vbox1; |
80 GtkWidget *hbox1; | |
81 GtkWidget *hbuttonbox1; | |
82 GtkWidget *Ok; | |
83 GtkWidget *Cancel; | |
84 GtkAccelGroup *accel_group; | |
33572 | 85 |
36017 | 86 accel_group = gtk_accel_group_new(); |
33572 | 87 |
36017 | 88 URLDialog = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
36057 | 89 gtk_widget_set_usize(URLDialog, 384, -1); |
36017 | 90 gtk_window_set_title(GTK_WINDOW(URLDialog), MSGTR_Network); |
91 gtk_window_set_position(GTK_WINDOW(URLDialog), GTK_WIN_POS_CENTER); | |
36053 | 92 gtk_window_set_wmclass(GTK_WINDOW(URLDialog), "Network", MPlayer); |
33572 | 93 |
36017 | 94 gtk_widget_realize(URLDialog); |
95 gtkAddIcon(URLDialog); | |
33572 | 96 |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36019
diff
changeset
|
97 vbox1 = gtkAddVBox(gtkAddDialogFrame(URLDialog), 0); |
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36019
diff
changeset
|
98 hbox1 = gtkAddHBox(vbox1, 1); |
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36019
diff
changeset
|
99 gtkAddLabel("URL: ", hbox1); |
33572 | 100 |
36049 | 101 urlCombo = gtkAddCombo(hbox1); |
33572 | 102 /* |
36017 | 103 * gtk_combo_new(); |
36049 | 104 * gtk_widget_show( urlCombo ); |
105 * gtk_box_pack_start( GTK_BOX( hbox1 ),urlCombo,TRUE,TRUE,0 ); | |
36017 | 106 */ |
36049 | 107 urlEntry = GTK_COMBO(urlCombo)->entry; |
108 gtk_widget_show(urlEntry); | |
33572 | 109 |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36019
diff
changeset
|
110 gtkAddHSeparator(vbox1); |
33572 | 111 |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36019
diff
changeset
|
112 hbuttonbox1 = gtkAddHButtonBox(vbox1); |
36017 | 113 gtk_button_box_set_layout(GTK_BUTTON_BOX(hbuttonbox1), GTK_BUTTONBOX_END); |
114 gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbuttonbox1), 10); | |
33572 | 115 |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36019
diff
changeset
|
116 Ok = gtkAddButton(MSGTR_Ok, hbuttonbox1); |
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36019
diff
changeset
|
117 Cancel = gtkAddButton(MSGTR_Cancel, hbuttonbox1); |
33572 | 118 |
36017 | 119 gtk_widget_add_accelerator(Ok, "clicked", accel_group, GDK_Return, 0, GTK_ACCEL_VISIBLE); |
120 gtk_widget_add_accelerator(Cancel, "clicked", accel_group, GDK_Escape, 0, GTK_ACCEL_VISIBLE); | |
33572 | 121 |
36017 | 122 gtk_signal_connect(GTK_OBJECT(URLDialog), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &URLDialog); |
36056 | 123 gtk_signal_connect(GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(button_clicked), Ok); |
36050 | 124 gtk_signal_connect(GTK_OBJECT(Cancel), "clicked", GTK_SIGNAL_FUNC(button_clicked), NULL); |
33572 | 125 |
36049 | 126 gtk_widget_grab_focus(urlEntry); |
36017 | 127 gtk_window_add_accel_group(GTK_WINDOW(URLDialog), accel_group); |
33572 | 128 |
36017 | 129 return URLDialog; |
33572 | 130 } |
35988 | 131 |
36017 | 132 void ShowURLDialog(void) |
35988 | 133 { |
36017 | 134 urlItem *item; |
35988 | 135 |
36017 | 136 if (URLDialog) |
36019 | 137 gtkRaise(URLDialog); |
36017 | 138 else |
139 URLDialog = CreateURLDialog(); | |
35988 | 140 |
36017 | 141 item = listMgr(URLLIST_GET, 0); |
35988 | 142 |
36017 | 143 if (item) { |
36049 | 144 g_list_free(urlEntries); |
145 urlEntries = NULL; | |
36017 | 146 |
147 while (item) { | |
36049 | 148 urlEntries = g_list_append(urlEntries, (gchar *)item->url); |
36047 | 149 item = item->next; |
36017 | 150 } |
35988 | 151 } |
152 | |
36049 | 153 if (urlEntries) { |
154 gtk_entry_set_text(GTK_ENTRY(urlEntry), urlEntries->data); | |
155 gtk_combo_set_popdown_strings(GTK_COMBO(urlCombo), urlEntries); | |
36017 | 156 } |
35988 | 157 |
36017 | 158 gtk_widget_show(URLDialog); |
35988 | 159 } |