annotate src/audlegacy/ui_urlopener.c @ 4877:ab60d53dd965

Use g_filename_to_uri on command line items that do not contain "://" (bug #51)
author John Lindgren <john.lindgren@tds.net>
date Fri, 01 May 2009 19:35:44 -0400
parents 7bf7f83a217e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4700
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
1 /* Audacious - Cross-platform multimedia player
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
2 * Copyright (C) 2005-2007 Audacious development team
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
3 *
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
4 * Based on BMP:
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
5 * Copyright (C) 2003-2004 BMP development team.
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
6 *
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
7 * Based on XMMS:
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
8 * Copyright (C) 1998-2003 XMMS development team.
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
9 *
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
10 * This program is free software; you can redistribute it and/or modify
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
12 * the Free Software Foundation; under version 3 of the License.
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
13 *
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
14 * This program is distributed in the hope that it will be useful,
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
17 * GNU General Public License for more details.
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
18 *
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
19 * You should have received a copy of the GNU General Public License
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
20 * along with this program. If not, see <http://www.gnu.org/licenses>.
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
21 *
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
22 * The Audacious team does not consider modular code linking to
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
23 * Audacious or using our public API to be a derived work.
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
24 */
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
25
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
26 #ifdef HAVE_CONFIG_H
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
27 # include "config.h"
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
28 #endif
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
29
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
30 #define NEED_GLADE
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
31 #include "util.h"
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
32
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
33 #include <glib.h>
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
34 #include <glib/gi18n.h>
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
35 #include <gtk/gtk.h>
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
36 #include <stdlib.h>
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
37 #include <string.h>
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
38 #include <ctype.h>
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
39
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
40 #include "platform/smartinclude.h"
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
41 #include <errno.h>
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
42
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
43 #include "input.h"
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
44 #include "main.h"
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
45 #include "playback.h"
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
46 #include "strings.h"
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
47
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
48 #ifdef USE_CHARDET
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
49 #include "../libguess/libguess.h"
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
50 # ifdef HAVE_UDET
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
51 # include <libudet_c.h>
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
52 # endif
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
53 #endif
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
54
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
55 #define URL_HISTORY_MAX_SIZE 30
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
56
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
57 static void
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
58 util_add_url_callback(GtkWidget * widget,
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
59 GtkEntry * entry)
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
60 {
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
61 const gchar *text;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
62
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
63 text = gtk_entry_get_text(entry);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
64 if (g_list_find_custom(cfg.url_history, text, (GCompareFunc) strcasecmp))
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
65 return;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
66
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
67 cfg.url_history = g_list_prepend(cfg.url_history, g_strdup(text));
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
68
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
69 while (g_list_length(cfg.url_history) > URL_HISTORY_MAX_SIZE) {
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
70 GList *node = g_list_last(cfg.url_history);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
71 g_free(node->data);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
72 cfg.url_history = g_list_delete_link(cfg.url_history, node);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
73 }
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
74 }
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
75
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
76 GtkWidget *
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
77 util_add_url_dialog_new(const gchar * caption, GCallback ok_func,
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
78 GCallback enqueue_func)
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
79 {
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
80 GtkWidget *win, *vbox, *bbox, *cancel, *enqueue, *ok, *combo, *entry,
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
81 *label;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
82 GList *url;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
83
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
84 win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
85 gtk_window_set_title(GTK_WINDOW(win), _("Add/Open URL Dialog"));
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
86 gtk_window_set_type_hint(GTK_WINDOW(win), GDK_WINDOW_TYPE_HINT_DIALOG);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
87 gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_CENTER);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
88 gtk_window_set_default_size(GTK_WINDOW(win), 400, -1);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
89 gtk_container_set_border_width(GTK_CONTAINER(win), 12);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
90
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
91 vbox = gtk_vbox_new(FALSE, 10);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
92 gtk_container_add(GTK_CONTAINER(win), vbox);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
93
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
94 label = gtk_label_new(caption);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
95 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
96 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
97
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
98 combo = gtk_combo_box_entry_new_text();
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
99 gtk_box_pack_start(GTK_BOX(vbox), combo, FALSE, FALSE, 0);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
100
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
101 entry = gtk_bin_get_child(GTK_BIN(combo));
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
102 gtk_window_set_focus(GTK_WINDOW(win), entry);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
103 gtk_entry_set_text(GTK_ENTRY(entry), "");
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
104
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
105 for (url = cfg.url_history; url; url = g_list_next(url))
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
106 gtk_combo_box_append_text(GTK_COMBO_BOX(combo),
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
107 (const gchar *) url->data);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
108
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
109 g_signal_connect(entry, "activate",
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
110 G_CALLBACK(util_add_url_callback),
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
111 entry);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
112 g_signal_connect(entry, "activate",
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
113 G_CALLBACK(ok_func),
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
114 entry);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
115 g_signal_connect_swapped(entry, "activate",
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
116 G_CALLBACK(gtk_widget_destroy),
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
117 win);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
118
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
119 bbox = gtk_hbutton_box_new();
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
120 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
121 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
122 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
123
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
124 cancel = gtk_button_new_from_stock(GTK_STOCK_CLOSE);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
125 gtk_box_pack_start(GTK_BOX(bbox), cancel, FALSE, FALSE, 0);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
126 gtk_button_box_set_child_secondary(GTK_BUTTON_BOX(bbox), cancel, TRUE);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
127
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
128 g_signal_connect_swapped(cancel, "clicked",
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
129 G_CALLBACK(gtk_widget_destroy),
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
130 win);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
131
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
132 enqueue = gtk_button_new_from_stock(GTK_STOCK_ADD);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
133 gtk_box_pack_start(GTK_BOX(bbox), enqueue, FALSE, FALSE, 0);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
134
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
135 g_signal_connect(enqueue, "clicked",
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
136 G_CALLBACK(util_add_url_callback),
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
137 entry);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
138 g_signal_connect(enqueue, "clicked",
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
139 G_CALLBACK(enqueue_func),
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
140 entry);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
141 g_signal_connect_swapped(enqueue, "clicked",
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
142 G_CALLBACK(gtk_widget_destroy),
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
143 win);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
144
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
145 ok = gtk_button_new_from_stock(GTK_STOCK_OPEN);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
146 g_signal_connect(ok, "clicked",
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
147 G_CALLBACK(util_add_url_callback), entry);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
148 g_signal_connect(ok, "clicked",
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
149 G_CALLBACK(ok_func), entry);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
150 g_signal_connect_swapped(ok, "clicked",
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
151 G_CALLBACK(gtk_widget_destroy),
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
152 win);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
153 gtk_box_pack_start(GTK_BOX(bbox), ok, FALSE, FALSE, 0);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
154
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
155 gtk_widget_show_all(vbox);
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
156
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
157 return win;
3a56d2786063 move all files belonging to the legacy UI to legacy/
mf0102 <0102@gmx.at>
parents:
diff changeset
158 }
4717
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
159
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
160 static void
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
161 on_add_url_add_clicked(GtkWidget * widget,
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
162 GtkWidget * entry)
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
163 {
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
164 const gchar *text = gtk_entry_get_text(GTK_ENTRY(entry));
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
165 if (text && *text)
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
166 playlist_add_url(playlist_get_active(), text);
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
167 }
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
168
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
169 static void
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
170 on_add_url_ok_clicked(GtkWidget * widget,
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
171 GtkWidget * entry)
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
172 {
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
173 Playlist *playlist = playlist_get_active();
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
174
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
175 const gchar *text = gtk_entry_get_text(GTK_ENTRY(entry));
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
176 if (text && *text)
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
177 {
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
178 playlist_clear(playlist);
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
179 playlist_add_url(playlist, text);
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
180 playback_initiate();
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
181 }
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
182 }
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
183
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
184 void
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
185 show_add_url_window(void)
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
186 {
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
187 static GtkWidget *url_window = NULL;
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
188
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
189 if (!url_window) {
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
190 url_window =
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
191 util_add_url_dialog_new(_("Enter location to play:"),
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
192 G_CALLBACK(on_add_url_ok_clicked),
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
193 G_CALLBACK(on_add_url_add_clicked));
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
194
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
195 g_signal_connect(url_window, "destroy",
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
196 G_CALLBACK(gtk_widget_destroyed),
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
197 &url_window);
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
198 }
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
199
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
200 gtk_window_present(GTK_WINDOW(url_window));
d59d0c490a61 hookify urlopener
Tomasz Mon <desowin@gmail.com>
parents: 4712
diff changeset
201 }