Mercurial > audlegacy
annotate src/audacious/ui_urlopener.c @ 3395:df609e7e7bcf
updated romanian translation
| author | Cristi Magherusan <majeru@atheme-project.org> |
|---|---|
| date | Sun, 26 Aug 2007 03:06:40 +0300 |
| parents | 5939941ba48b |
| children | 8d8699eb659d |
| 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 | |
|
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3033
diff
changeset
|
12 * the Free Software Foundation; under version 3 of the License. |
| 2422 | 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 | |
|
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3033
diff
changeset
|
20 * along with this program. If not, see <http://www.gnu.org/licenses>. |
|
3123
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
21 * |
|
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
22 * The Audacious team does not consider modular code linking to |
|
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
23 * Audacious or using our public API to be a derived work. |
| 2422 | 24 */ |
| 25 | |
| 26 #ifdef HAVE_CONFIG_H | |
| 27 # include "config.h" | |
| 28 #endif | |
| 29 | |
| 30 #define NEED_GLADE | |
| 31 #include "util.h" | |
| 32 | |
| 33 #include <glib.h> | |
| 34 #include <glib/gi18n.h> | |
| 35 #include <glade/glade.h> | |
| 36 #include <gtk/gtk.h> | |
| 37 #include <stdlib.h> | |
| 38 #include <string.h> | |
| 39 #include <ctype.h> | |
| 40 | |
| 41 #include "platform/smartinclude.h" | |
| 42 #include <errno.h> | |
| 43 | |
| 44 #include "glade.h" | |
| 45 #include "input.h" | |
| 46 #include "main.h" | |
| 47 #include "playback.h" | |
| 48 #include "strings.h" | |
| 49 #include "ui_playlist.h" | |
| 50 | |
| 51 #ifdef USE_CHARDET | |
|
3210
5939941ba48b
More librcd removal.
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
52 #include "../libguess/libguess.h" |
| 2422 | 53 #ifdef HAVE_UDET |
|
2807
26755684c0dc
[svn] - Fixed naming inconsistencies in search dialog
mf0102
parents:
2422
diff
changeset
|
54 #include <libudet_c.h> |
| 2422 | 55 #endif |
| 56 #endif | |
| 57 | |
| 58 #define URL_HISTORY_MAX_SIZE 30 | |
| 59 | |
| 60 static void | |
| 61 util_add_url_callback(GtkWidget * widget, | |
| 62 GtkEntry * entry) | |
| 63 { | |
| 64 const gchar *text; | |
| 65 | |
| 66 text = gtk_entry_get_text(entry); | |
| 67 if (g_list_find_custom(cfg.url_history, text, (GCompareFunc) strcasecmp)) | |
| 68 return; | |
| 69 | |
| 70 cfg.url_history = g_list_prepend(cfg.url_history, g_strdup(text)); | |
| 71 | |
| 72 while (g_list_length(cfg.url_history) > URL_HISTORY_MAX_SIZE) { | |
| 73 GList *node = g_list_last(cfg.url_history); | |
| 74 g_free(node->data); | |
| 75 cfg.url_history = g_list_delete_link(cfg.url_history, node); | |
| 76 } | |
| 77 } | |
| 78 | |
| 79 GtkWidget * | |
| 80 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
|
81 GCallback enqueue_func) |
| 2422 | 82 { |
|
2807
26755684c0dc
[svn] - Fixed naming inconsistencies in search dialog
mf0102
parents:
2422
diff
changeset
|
83 GtkWidget *win, *vbox, *bbox, *cancel, *enqueue, *ok, *combo, *entry, |
|
26755684c0dc
[svn] - Fixed naming inconsistencies in search dialog
mf0102
parents:
2422
diff
changeset
|
84 *label; |
| 2422 | 85 GList *url; |
| 86 | |
| 87 win = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
| 88 gtk_window_set_title(GTK_WINDOW(win), _("Add/Open URL Dialog")); | |
| 89 gtk_window_set_type_hint(GTK_WINDOW(win), GDK_WINDOW_TYPE_HINT_DIALOG); | |
| 90 gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_CENTER); | |
| 91 gtk_window_set_default_size(GTK_WINDOW(win), 400, -1); | |
| 92 gtk_container_set_border_width(GTK_CONTAINER(win), 12); | |
| 93 | |
| 94 vbox = gtk_vbox_new(FALSE, 10); | |
| 95 gtk_container_add(GTK_CONTAINER(win), vbox); | |
| 96 | |
| 97 label = gtk_label_new(caption); | |
| 98 gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5); | |
| 99 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
| 100 | |
| 101 combo = gtk_combo_box_entry_new_text(); | |
| 102 gtk_box_pack_start(GTK_BOX(vbox), combo, FALSE, FALSE, 0); | |
| 103 | |
| 104 entry = gtk_bin_get_child(GTK_BIN(combo)); | |
| 105 gtk_window_set_focus(GTK_WINDOW(win), entry); | |
| 106 gtk_entry_set_text(GTK_ENTRY(entry), ""); | |
| 107 | |
| 108 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
|
109 gtk_combo_box_append_text(GTK_COMBO_BOX(combo), |
|
26755684c0dc
[svn] - Fixed naming inconsistencies in search dialog
mf0102
parents:
2422
diff
changeset
|
110 (const gchar *) url->data); |
| 2422 | 111 |
| 112 g_signal_connect(entry, "activate", | |
| 113 G_CALLBACK(util_add_url_callback), | |
| 114 entry); | |
| 115 g_signal_connect(entry, "activate", | |
| 116 G_CALLBACK(ok_func), | |
| 117 entry); | |
| 118 g_signal_connect_swapped(entry, "activate", | |
| 119 G_CALLBACK(gtk_widget_destroy), | |
| 120 win); | |
| 121 | |
| 122 bbox = gtk_hbutton_box_new(); | |
| 123 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox), GTK_BUTTONBOX_END); | |
| 124 gtk_button_box_set_spacing(GTK_BUTTON_BOX(bbox), 5); | |
| 125 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 0); | |
| 126 | |
|
2807
26755684c0dc
[svn] - Fixed naming inconsistencies in search dialog
mf0102
parents:
2422
diff
changeset
|
127 cancel = gtk_button_new_from_stock(GTK_STOCK_CLOSE); |
|
26755684c0dc
[svn] - Fixed naming inconsistencies in search dialog
mf0102
parents:
2422
diff
changeset
|
128 gtk_box_pack_start(GTK_BOX(bbox), cancel, FALSE, FALSE, 0); |
| 2809 | 129 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
|
130 |
|
26755684c0dc
[svn] - Fixed naming inconsistencies in search dialog
mf0102
parents:
2422
diff
changeset
|
131 g_signal_connect_swapped(cancel, "clicked", |
| 2422 | 132 G_CALLBACK(gtk_widget_destroy), |
| 133 win); | |
| 134 | |
| 135 enqueue = gtk_button_new_from_stock(GTK_STOCK_ADD); | |
| 136 gtk_box_pack_start(GTK_BOX(bbox), enqueue, FALSE, FALSE, 0); | |
| 137 | |
| 138 g_signal_connect(enqueue, "clicked", | |
| 139 G_CALLBACK(util_add_url_callback), | |
| 140 entry); | |
| 141 g_signal_connect(enqueue, "clicked", | |
| 142 G_CALLBACK(enqueue_func), | |
| 143 entry); | |
| 144 g_signal_connect_swapped(enqueue, "clicked", | |
| 145 G_CALLBACK(gtk_widget_destroy), | |
| 146 win); | |
| 147 | |
|
2807
26755684c0dc
[svn] - Fixed naming inconsistencies in search dialog
mf0102
parents:
2422
diff
changeset
|
148 ok = gtk_button_new_from_stock(GTK_STOCK_OPEN); |
|
26755684c0dc
[svn] - Fixed naming inconsistencies in search dialog
mf0102
parents:
2422
diff
changeset
|
149 g_signal_connect(ok, "clicked", |
|
26755684c0dc
[svn] - Fixed naming inconsistencies in search dialog
mf0102
parents:
2422
diff
changeset
|
150 G_CALLBACK(util_add_url_callback), entry); |
|
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(ok_func), entry); |
|
26755684c0dc
[svn] - Fixed naming inconsistencies in search dialog
mf0102
parents:
2422
diff
changeset
|
153 g_signal_connect_swapped(ok, "clicked", |
| 2422 | 154 G_CALLBACK(gtk_widget_destroy), |
| 155 win); | |
|
2807
26755684c0dc
[svn] - Fixed naming inconsistencies in search dialog
mf0102
parents:
2422
diff
changeset
|
156 gtk_box_pack_start(GTK_BOX(bbox), ok, FALSE, FALSE, 0); |
| 2422 | 157 |
| 158 gtk_widget_show_all(vbox); | |
| 159 | |
| 160 return win; | |
| 161 } |
