Mercurial > audlegacy
annotate src/audacious/ui_fileinfo.c @ 3097:bb1fa0aed8f4
add url unescape code to playlist_get_info_text().
author | Yoshiki Yazawa <yaz@cc.rim.or.jp> |
---|---|
date | Thu, 19 Jul 2007 12:49:50 +0900 |
parents | 6131bf51ee63 |
children | 2520e8b6cf5e |
rev | line source |
---|---|
2313 | 1 /* |
2 * Audacious: A cross-platform multimedia player | |
3 * Copyright (c) 2006 William Pitcock, Tony Vroon, George Averill, | |
4 * Giacomo Lozito, Derek Pomery and Yoshiki Yazawa. | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; under version 2 of the License. | |
9 * | |
10 * This program is distributed in the hope that it will be useful, | |
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 * GNU General Public License for more details. | |
14 * | |
15 * You should have received a copy of the GNU General Public License | |
16 * along with this program; if not, write to the Free Software | |
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | |
18 * 02110-1301, USA. | |
19 */ | |
20 | |
21 #ifdef HAVE_CONFIG_H | |
22 # include "config.h" | |
23 #endif | |
24 | |
25 #include <glib.h> | |
26 #include <glib/gi18n.h> | |
27 #include <gtk/gtk.h> | |
28 #include <glade/glade.h> | |
29 #include <string.h> | |
30 #include <stddef.h> | |
31 #include <stdio.h> | |
32 #include <sys/types.h> | |
33 #include <dirent.h> | |
34 #include <unistd.h> | |
35 #include <errno.h> | |
36 #include <sys/types.h> | |
37 #include <sys/stat.h> | |
38 | |
39 #include "glade.h" | |
40 | |
41 #include "plugin.h" | |
42 #include "pluginenum.h" | |
43 #include "input.h" | |
44 #include "effect.h" | |
2385
ab2b1b6f6179
[svn] - add missing inclusion of strings.h where necessary, do not export main.h and export strings.h
giacomo
parents:
2348
diff
changeset
|
45 #include "strings.h" |
2313 | 46 #include "general.h" |
47 #include "output.h" | |
48 #include "visualization.h" | |
49 | |
50 #include "main.h" | |
51 #include "util.h" | |
52 #include "dnd.h" | |
53 #include "titlestring.h" | |
54 | |
55 #include "playlist.h" | |
56 | |
57 #include "ui_main.h" | |
58 #include "ui_playlist.h" | |
59 #include "build_stamp.h" | |
60 #include "ui_fileinfo.h" | |
61 #include "ui_playlist.h" | |
62 | |
63 GtkWidget *fileinfo_win; | |
64 | |
65 static void | |
66 fileinfo_entry_set_text(const char *entry, const char *text) | |
67 { | |
68 GladeXML *xml = g_object_get_data(G_OBJECT(fileinfo_win), "glade-xml"); | |
69 GtkWidget *widget = glade_xml_get_widget(xml, entry); | |
70 | |
71 if (xml == NULL || widget == NULL) | |
72 return; | |
73 | |
74 gtk_entry_set_text(GTK_ENTRY(widget), text); | |
75 } | |
76 | |
77 static void | |
78 fileinfo_entry_set_text_free(const char *entry, char *text) | |
79 { | |
80 GladeXML *xml = g_object_get_data(G_OBJECT(fileinfo_win), "glade-xml"); | |
81 GtkWidget *widget = glade_xml_get_widget(xml, entry); | |
82 | |
83 if (xml == NULL || widget == NULL) | |
84 return; | |
85 | |
86 gtk_entry_set_text(GTK_ENTRY(widget), text); | |
87 | |
88 g_free(text); | |
89 } | |
90 | |
91 static void | |
92 fileinfo_entry_set_image(const char *entry, const char *text) | |
93 { | |
94 GladeXML *xml = g_object_get_data(G_OBJECT(fileinfo_win), "glade-xml"); | |
95 GtkWidget *widget = glade_xml_get_widget(xml, entry); | |
96 GdkPixbuf *pixbuf; | |
97 int width, height; | |
98 double aspect; | |
99 GdkPixbuf *pixbuf2; | |
100 | |
101 if (xml == NULL || widget == NULL) | |
102 return; | |
103 | |
104 pixbuf = gdk_pixbuf_new_from_file(text, NULL); | |
105 | |
106 if (pixbuf == NULL) | |
107 return; | |
108 | |
109 width = gdk_pixbuf_get_width(GDK_PIXBUF(pixbuf)); | |
110 height = gdk_pixbuf_get_height(GDK_PIXBUF(pixbuf)); | |
111 | |
112 if(strcmp(DATA_DIR "/images/audio.png", text)) | |
113 { | |
114 if(width == 0) | |
115 width = 1; | |
116 aspect = (double)height / (double)width; | |
117 if(aspect > 1.0) { | |
118 height = (int)(cfg.filepopup_pixelsize * aspect); | |
119 width = cfg.filepopup_pixelsize; | |
120 } else { | |
121 height = cfg.filepopup_pixelsize; | |
122 width = (int)(cfg.filepopup_pixelsize / aspect); | |
123 } | |
124 pixbuf2 = gdk_pixbuf_scale_simple(GDK_PIXBUF(pixbuf), width, height, GDK_INTERP_BILINEAR); | |
125 g_object_unref(G_OBJECT(pixbuf)); | |
126 pixbuf = pixbuf2; | |
127 } | |
128 | |
129 gtk_image_set_from_pixbuf(GTK_IMAGE(widget), GDK_PIXBUF(pixbuf)); | |
130 g_object_unref(G_OBJECT(pixbuf)); | |
131 } | |
132 | |
133 void fileinfo_hide(gpointer unused) | |
134 { | |
135 gtk_widget_hide(fileinfo_win); | |
136 | |
137 /* Clear it out. */ | |
138 fileinfo_entry_set_text("entry_title", ""); | |
139 fileinfo_entry_set_text("entry_artist", ""); | |
140 fileinfo_entry_set_text("entry_album", ""); | |
141 fileinfo_entry_set_text("entry_comment", ""); | |
142 fileinfo_entry_set_text("entry_genre", ""); | |
143 fileinfo_entry_set_text("entry_year", ""); | |
144 fileinfo_entry_set_text("entry_track", ""); | |
145 fileinfo_entry_set_text("entry_location", ""); | |
146 | |
147 fileinfo_entry_set_image("image_artwork", DATA_DIR "/images/audio.png"); | |
148 } | |
149 | |
150 void | |
151 create_fileinfo_window(void) | |
152 { | |
153 const gchar *glade_file = DATA_DIR "/glade/fileinfo.glade"; | |
154 GladeXML *xml; | |
155 GtkWidget *widget; | |
156 | |
157 xml = glade_xml_new_or_die(_("Track Information Window"), glade_file, NULL, NULL); | |
158 | |
159 glade_xml_signal_autoconnect(xml); | |
160 | |
161 fileinfo_win = glade_xml_get_widget(xml, "fileinfo_win"); | |
162 g_object_set_data(G_OBJECT(fileinfo_win), "glade-xml", xml); | |
163 gtk_window_set_transient_for(GTK_WINDOW(fileinfo_win), GTK_WINDOW(mainwin)); | |
164 | |
165 widget = glade_xml_get_widget(xml, "image_artwork"); | |
166 gtk_image_set_from_file(GTK_IMAGE(widget), DATA_DIR "/images/audio.png"); | |
167 | |
168 widget = glade_xml_get_widget(xml, "btn_close"); | |
169 g_signal_connect(G_OBJECT(widget), "clicked", (GCallback) fileinfo_hide, NULL); | |
170 } | |
171 | |
172 void | |
173 fileinfo_show_for_tuple(TitleInput *tuple) | |
174 { | |
175 gchar *tmp = NULL; | |
176 | |
177 if (tuple == NULL) | |
178 return; | |
179 | |
180 gtk_widget_realize(fileinfo_win); | |
181 | |
182 if (tuple->track_name) | |
183 fileinfo_entry_set_text("entry_title", tuple->track_name); | |
184 if (tuple->performer) | |
185 fileinfo_entry_set_text("entry_artist", tuple->performer); | |
186 if (tuple->album_name) | |
187 fileinfo_entry_set_text("entry_album", tuple->album_name); | |
188 if (tuple->comment) | |
189 fileinfo_entry_set_text("entry_comment", tuple->comment); | |
190 if (tuple->genre) | |
191 fileinfo_entry_set_text("entry_genre", tuple->genre); | |
192 | |
193 tmp = g_strdup_printf("%s/%s", tuple->file_path, tuple->file_name); | |
194 if(tmp){ | |
195 fileinfo_entry_set_text_free("entry_location", str_to_utf8(tmp)); | |
196 g_free(tmp); | |
197 tmp = NULL; | |
198 } | |
199 | |
200 if (tuple->year != 0) | |
201 fileinfo_entry_set_text_free("entry_year", g_strdup_printf("%d", tuple->year)); | |
202 | |
203 if (tuple->track_number != 0) | |
204 fileinfo_entry_set_text_free("entry_track", g_strdup_printf("%d", tuple->track_number)); | |
205 | |
206 tmp = fileinfo_recursive_get_image(tuple->file_path, tuple->file_name, 0); | |
207 | |
208 if(tmp) | |
209 { | |
210 fileinfo_entry_set_image("image_artwork", tmp); | |
211 g_free(tmp); | |
212 } | |
213 | |
214 gtk_widget_show(fileinfo_win); | |
215 } | |
216 | |
217 void | |
218 fileinfo_show_for_path(gchar *path) | |
219 { | |
220 TitleInput *tuple = input_get_song_tuple(path); | |
221 | |
222 if (tuple == NULL) | |
223 return input_file_info_box(path); | |
224 | |
225 fileinfo_show_for_tuple(tuple); | |
226 | |
227 bmp_title_input_free(tuple); | |
228 tuple = NULL; | |
229 } |