Mercurial > audlegacy
annotate src/audacious/ui_urlopener.c @ 2814:77a012c3b521 trunk
[svn] - give default values to audacious_remote_* functions. if dbus call fails, default value will be returned.
- now audacious_rc_song_filename() calls str_to_utf8() to ensure that the string to return is in utf-8.
author | yaz |
---|---|
date | Mon, 28 May 2007 10:28:41 -0700 |
parents | 490638dcef74 |
children | 2c17b008a532 |
rev | line source |
---|---|
2422 | 1 /* Audacious - Cross-platform multimedia player |
2 * Copyright (C) 2005-2007 Audacious development team | |
3 * | |
4 * Based on BMP: | |
5 * Copyright (C) 2003-2004 BMP development team. | |
6 * | |
7 * Based on XMMS: | |
8 * Copyright (C) 1998-2003 XMMS development team. | |
9 * | |
10 * This program is free software; you can redistribute it and/or modify | |
11 * it under the terms of the GNU General Public License as published by | |
12 * the Free Software Foundation; under version 2 of the License. | |
13 * | |
14 * This program is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program; if not, write to the Free Software | |
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
22 */ | |
23 | |
24 #ifdef HAVE_CONFIG_H | |
25 # include "config.h" | |
26 #endif | |
27 | |
28 #define NEED_GLADE | |
29 #include "util.h" | |
30 | |
31 #include <glib.h> | |
32 #include <glib/gi18n.h> | |
33 #include <glade/glade.h> | |
34 #include <gtk/gtk.h> | |
35 #include <stdlib.h> | |
36 #include <string.h> | |
37 #include <ctype.h> | |
38 | |
39 #include "platform/smartinclude.h" | |
40 #include <errno.h> | |
41 | |
42 #ifdef HAVE_FTS_H | |
43 # include <fts.h> | |
44 #endif | |
45 | |
46 #include "glade.h" | |
47 #include "input.h" | |
48 #include "main.h" | |
49 #include "playback.h" | |
50 #include "strings.h" | |
51 #include "ui_playlist.h" | |
52 | |
53 #ifdef USE_CHARDET | |
2807
26755684c0dc
[svn] - Fixed naming inconsistencies in search dialog
mf0102
parents:
2422
diff
changeset
|
54 #include "../librcd/librcd.h" |
2422 | 55 #ifdef HAVE_UDET |
2807
26755684c0dc
[svn] - Fixed naming inconsistencies in search dialog
mf0102
parents:
2422
diff
changeset
|
56 #include <libudet_c.h> |
2422 | 57 #endif |
58 #endif | |
59 | |
60 #define URL_HISTORY_MAX_SIZE 30 | |
61 | |
62 static void | |
63 util_add_url_callback(GtkWidget * widget, | |
64 GtkEntry * entry) | |
65 { | |
66 const gchar *text; | |
67 | |
68 text = gtk_entry_get_text(entry); | |
69 if (g_list_find_custom(cfg.url_history, text, (GCompareFunc) strcasecmp)) | |
70 return; | |
71 | |
72 cfg.url_history = g_list_prepend(cfg.url_history, g_strdup(text)); | |
73 | |
74 while (g_list_length(cfg.url_history) > URL_HISTORY_MAX_SIZE) { | |
75 GList *node = g_list_last(cfg.url_history); | |
76 g_free(node->data); | |
77 cfg.url_history = g_list_delete_link(cfg.url_history, node); | |
78 } | |
79 } | |
80 | |
81 GtkWidget * | |
82 util_add_url_dialog_new(const gchar * caption, GCallback ok_func, | |
2807
26755684c0dc
[svn] - Fixed naming inconsistencies in search dialog
mf0102
parents:
2422
diff
changeset
|
83 GCallback enqueue_func) |
2422 | 84 { |
2807
26755684c0dc
[svn] - Fixed naming inconsistencies in search dialog
mf0102
parents:
2422
diff
changeset
|
85 GtkWidget *win, *vbox, *bbox, *cancel, *enqueue, *ok, *combo, *entry, |
26755684c0dc
[svn] - Fixed naming inconsistencies in search dialog
mf0102
parents:
2422
diff
changeset
|
86 *label; |
2422 | 87 GList *url; |
88 | |
89 win = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
90 gtk_window_set_title(GTK_WINDOW(win), _("Add/Open URL Dialog")); | |
91 gtk_window_set_type_hint(GTK_WINDOW(win), GDK_WINDOW_TYPE_HINT_DIALOG); | |
92 gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_CENTER); | |
93 gtk_window_set_default_size(GTK_WINDOW(win), 400, -1); | |
94 gtk_container_set_border_width(GTK_CONTAINER(win), 12); | |
95 | |
96 vbox = gtk_vbox_new(FALSE, 10); | |
97 gtk_container_add(GTK_CONTAINER(win), vbox); | |
98 | |
99 label = gtk_label_new(caption); | |
100 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
101 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
102 | |
103 combo = gtk_combo_box_entry_new_text(); | |
104 gtk_box_pack_start(GTK_BOX(vbox), combo, FALSE, FALSE, 0); | |
105 | |
106 entry = gtk_bin_get_child(GTK_BIN(combo)); | |
107 gtk_window_set_focus(GTK_WINDOW(win), entry); | |
108 gtk_entry_set_text(GTK_ENTRY(entry), ""); | |
109 | |
110 for (url = cfg.url_history; url; url = g_list_next(url)) | |
2807
26755684c0dc
[svn] - Fixed naming inconsistencies in search dialog
mf0102
parents:
2422
diff
changeset
|
111 gtk_combo_box_append_text(GTK_COMBO_BOX(combo), |
26755684c0dc
[svn] - Fixed naming inconsistencies in search dialog
mf0102
parents:
2422
diff
changeset
|
112 (const gchar *) url->data); |
2422 | 113 |
114 g_signal_connect(entry, "activate", | |
115 G_CALLBACK(util_add_url_callback), | |
116 entry); | |
117 g_signal_connect(entry, "activate", | |
118 G_CALLBACK(ok_func), | |
119 entry); | |
120 g_signal_connect_swapped(entry, "activate", | |
121 G_CALLBACK(gtk_widget_destroy), | |
122 win); | |
123 | |
124 bbox = gtk_hbutton_box_new(); | |
125 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
126 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); | |
127 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); | |
128 | |
2807
26755684c0dc
[svn] - Fixed naming inconsistencies in search dialog
mf0102
parents:
2422
diff
changeset
|
129 cancel = gtk_button_new_from_stock(GTK_STOCK_CLOSE); |
26755684c0dc
[svn] - Fixed naming inconsistencies in search dialog
mf0102
parents:
2422
diff
changeset
|
130 gtk_box_pack_start(GTK_BOX(bbox), cancel, FALSE, FALSE, 0); |
2809 | 131 gtk_button_box_set_child_secondary(GTK_BUTTON_BOX(bbox), cancel, TRUE); |
2807
26755684c0dc
[svn] - Fixed naming inconsistencies in search dialog
mf0102
parents:
2422
diff
changeset
|
132 |
26755684c0dc
[svn] - Fixed naming inconsistencies in search dialog
mf0102
parents:
2422
diff
changeset
|
133 g_signal_connect_swapped(cancel, "clicked", |
2422 | 134 G_CALLBACK(gtk_widget_destroy), |
135 win); | |
136 | |
137 enqueue = gtk_button_new_from_stock(GTK_STOCK_ADD); | |
138 gtk_box_pack_start(GTK_BOX(bbox), enqueue, FALSE, FALSE, 0); | |
139 | |
140 g_signal_connect(enqueue, "clicked", | |
141 G_CALLBACK(util_add_url_callback), | |
142 entry); | |
143 g_signal_connect(enqueue, "clicked", | |
144 G_CALLBACK(enqueue_func), | |
145 entry); | |
146 g_signal_connect_swapped(enqueue, "clicked", | |
147 G_CALLBACK(gtk_widget_destroy), | |
148 win); | |
149 | |
2807
26755684c0dc
[svn] - Fixed naming inconsistencies in search dialog
mf0102
parents:
2422
diff
changeset
|
150 ok = gtk_button_new_from_stock(GTK_STOCK_OPEN); |
26755684c0dc
[svn] - Fixed naming inconsistencies in search dialog
mf0102
parents:
2422
diff
changeset
|
151 g_signal_connect(ok, "clicked", |
26755684c0dc
[svn] - Fixed naming inconsistencies in search dialog
mf0102
parents:
2422
diff
changeset
|
152 G_CALLBACK(util_add_url_callback), entry); |
26755684c0dc
[svn] - Fixed naming inconsistencies in search dialog
mf0102
parents:
2422
diff
changeset
|
153 g_signal_connect(ok, "clicked", |
26755684c0dc
[svn] - Fixed naming inconsistencies in search dialog
mf0102
parents:
2422
diff
changeset
|
154 G_CALLBACK(ok_func), entry); |
26755684c0dc
[svn] - Fixed naming inconsistencies in search dialog
mf0102
parents:
2422
diff
changeset
|
155 g_signal_connect_swapped(ok, "clicked", |
2422 | 156 G_CALLBACK(gtk_widget_destroy), |
157 win); | |
2807
26755684c0dc
[svn] - Fixed naming inconsistencies in search dialog
mf0102
parents:
2422
diff
changeset
|
158 gtk_box_pack_start(GTK_BOX(bbox), ok, FALSE, FALSE, 0); |
2422 | 159 |
160 gtk_widget_show_all(vbox); | |
161 | |
162 return win; | |
163 } |