Mercurial > mplayer.hg
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 |
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" |
35772 | 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 | 30 #include "gui/util/string.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 urlItem *item; |
36010 | 44 |
36017 | 45 (void)button; |
46 | |
47 if ((int)user_data) { | |
36049 | 48 gchar *str = strdup(gtk_entry_get_text(GTK_ENTRY(urlEntry))); |
33572 | 49 |
36017 | 50 if (str) { |
51 if (!strstr(str, "://")) { | |
52 gchar *tmp; | |
53 tmp = malloc(strlen(str) + 8); | |
54 sprintf(tmp, "http://%s", str); | |
55 free(str); | |
56 str = tmp; | |
57 } | |
58 | |
36049 | 59 urlEntries = g_list_prepend(urlEntries, (gchar *)str); |
33572 | 60 |
36017 | 61 item = calloc(1, sizeof(urlItem)); |
62 item->url = gstrdup(str); | |
63 listMgr(URLLIST_ITEM_ADD, item); | |
33572 | 64 |
36017 | 65 uiSetFile(NULL, str, STREAMTYPE_STREAM); |
66 guiInfo.NewPlay = GUI_FILE_NEW; | |
67 listMgr(PLAYLIST_DELETE, 0); | |
68 add_to_gui_playlist(str, PLAYLIST_ITEM_APPEND); | |
69 uiEvent(evPlay, 0); | |
70 } | |
33572 | 71 } |
36017 | 72 |
73 gtk_widget_destroy(URLDialog); | |
33572 | 74 } |
75 | |
36017 | 76 static GtkWidget *CreateURLDialog(void) |
33572 | 77 { |
36017 | 78 GtkWidget *vbox1; |
79 GtkWidget *hbox1; | |
80 GtkWidget *hbuttonbox1; | |
81 GtkWidget *Ok; | |
82 GtkWidget *Cancel; | |
83 GtkAccelGroup *accel_group; | |
33572 | 84 |
36017 | 85 accel_group = gtk_accel_group_new(); |
33572 | 86 |
36017 | 87 URLDialog = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
88 gtk_widget_set_name(URLDialog, "URL"); | |
89 gtk_object_set_data(GTK_OBJECT(URLDialog), "URL", URLDialog); | |
90 gtk_widget_set_usize(URLDialog, 384, 70); | |
91 GTK_WIDGET_SET_FLAGS(URLDialog, GTK_CAN_DEFAULT); | |
92 gtk_window_set_title(GTK_WINDOW(URLDialog), MSGTR_Network); | |
93 gtk_window_set_position(GTK_WINDOW(URLDialog), GTK_WIN_POS_CENTER); | |
94 gtk_window_set_policy(GTK_WINDOW(URLDialog), TRUE, TRUE, FALSE); | |
95 gtk_window_set_wmclass(GTK_WINDOW(URLDialog), "Network", "MPlayer"); | |
33572 | 96 |
36017 | 97 gtk_widget_realize(URLDialog); |
98 gtkAddIcon(URLDialog); | |
33572 | 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 | 103 |
36049 | 104 urlCombo = gtkAddCombo(hbox1); |
33572 | 105 /* |
36017 | 106 * gtk_combo_new(); |
36049 | 107 * gtk_widget_set_name( urlCombo,"urlCombo" ); |
108 * gtk_widget_show( urlCombo ); | |
109 * gtk_box_pack_start( GTK_BOX( hbox1 ),urlCombo,TRUE,TRUE,0 ); | |
36017 | 110 */ |
36049 | 111 urlEntry = GTK_COMBO(urlCombo)->entry; |
112 gtk_widget_set_name(urlEntry, "URLEntry"); | |
113 gtk_widget_show(urlEntry); | |
33572 | 114 |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36019
diff
changeset
|
115 gtkAddHSeparator(vbox1); |
33572 | 116 |
36023
a04e8798227b
Cosmetic: Prefix all functions in dialog/tools.c with gtk.
ib
parents:
36019
diff
changeset
|
117 hbuttonbox1 = gtkAddHButtonBox(vbox1); |
36017 | 118 gtk_button_box_set_layout(GTK_BUTTON_BOX(hbuttonbox1), GTK_BUTTONBOX_END); |
119 gtk_button_box_set_spacing(GTK_BUTTON_BOX(hbuttonbox1), 10); | |
33572 | 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 | 123 |
36017 | 124 gtk_widget_add_accelerator(Ok, "clicked", accel_group, GDK_Return, 0, GTK_ACCEL_VISIBLE); |
125 gtk_widget_add_accelerator(Cancel, "clicked", accel_group, GDK_Escape, 0, GTK_ACCEL_VISIBLE); | |
33572 | 126 |
36017 | 127 gtk_signal_connect(GTK_OBJECT(URLDialog), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &URLDialog); |
36050 | 128 gtk_signal_connect(GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(button_clicked), (void *)1); |
129 gtk_signal_connect(GTK_OBJECT(Cancel), "clicked", GTK_SIGNAL_FUNC(button_clicked), NULL); | |
33572 | 130 |
36049 | 131 gtk_widget_grab_focus(urlEntry); |
36017 | 132 gtk_window_add_accel_group(GTK_WINDOW(URLDialog), accel_group); |
33572 | 133 |
36017 | 134 return URLDialog; |
33572 | 135 } |
35988 | 136 |
36017 | 137 void ShowURLDialog(void) |
35988 | 138 { |
36017 | 139 urlItem *item; |
35988 | 140 |
36017 | 141 if (URLDialog) |
36019 | 142 gtkRaise(URLDialog); |
36017 | 143 else |
144 URLDialog = CreateURLDialog(); | |
35988 | 145 |
36017 | 146 item = listMgr(URLLIST_GET, 0); |
35988 | 147 |
36017 | 148 if (item) { |
36049 | 149 g_list_free(urlEntries); |
150 urlEntries = NULL; | |
36017 | 151 |
152 while (item) { | |
36049 | 153 urlEntries = g_list_append(urlEntries, (gchar *)item->url); |
36047 | 154 item = item->next; |
36017 | 155 } |
35988 | 156 } |
157 | |
36049 | 158 if (urlEntries) { |
159 gtk_entry_set_text(GTK_ENTRY(urlEntry), urlEntries->data); | |
160 gtk_combo_set_popdown_strings(GTK_COMBO(urlCombo), urlEntries); | |
36017 | 161 } |
35988 | 162 |
36017 | 163 gtk_widget_show(URLDialog); |
35988 | 164 } |