Mercurial > audlegacy
annotate src/audacious/ui_fileinfo.c @ 2540:6b2743b54fd7 trunk
[svn] - update options printout
author | nenolod |
---|---|
date | Sat, 17 Feb 2007 02:30:32 -0800 |
parents | 44df6c17411b |
children | 6884a2144a01 |
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" | |
2416
0fd7f4f969ad
[svn] integrated urldecode.* from libaudacious into audacious directory, made separate ui_fileopener.*
mf0102
parents:
2385
diff
changeset
|
51 #include "urldecode.h" |
2313 | 52 #include "util.h" |
53 #include "dnd.h" | |
54 #include "titlestring.h" | |
55 | |
56 #include "libaudacious/configdb.h" | |
57 | |
58 #include "playlist.h" | |
59 | |
60 #include "ui_main.h" | |
61 #include "ui_playlist.h" | |
62 #include "build_stamp.h" | |
63 #include "ui_fileinfo.h" | |
64 #include "ui_playlist.h" | |
65 | |
66 GtkWidget *fileinfo_win; | |
67 | |
68 static void | |
69 fileinfo_entry_set_text(const char *entry, const char *text) | |
70 { | |
71 GladeXML *xml = g_object_get_data(G_OBJECT(fileinfo_win), "glade-xml"); | |
72 GtkWidget *widget = glade_xml_get_widget(xml, entry); | |
73 | |
74 if (xml == NULL || widget == NULL) | |
75 return; | |
76 | |
77 gtk_entry_set_text(GTK_ENTRY(widget), text); | |
78 } | |
79 | |
80 static void | |
81 fileinfo_entry_set_text_free(const char *entry, char *text) | |
82 { | |
83 GladeXML *xml = g_object_get_data(G_OBJECT(fileinfo_win), "glade-xml"); | |
84 GtkWidget *widget = glade_xml_get_widget(xml, entry); | |
85 | |
86 if (xml == NULL || widget == NULL) | |
87 return; | |
88 | |
89 gtk_entry_set_text(GTK_ENTRY(widget), text); | |
90 | |
91 g_free(text); | |
92 } | |
93 | |
94 static void | |
95 fileinfo_entry_set_image(const char *entry, const char *text) | |
96 { | |
97 GladeXML *xml = g_object_get_data(G_OBJECT(fileinfo_win), "glade-xml"); | |
98 GtkWidget *widget = glade_xml_get_widget(xml, entry); | |
99 GdkPixbuf *pixbuf; | |
100 int width, height; | |
101 double aspect; | |
102 GdkPixbuf *pixbuf2; | |
103 | |
104 if (xml == NULL || widget == NULL) | |
105 return; | |
106 | |
107 pixbuf = gdk_pixbuf_new_from_file(text, NULL); | |
108 | |
109 if (pixbuf == NULL) | |
110 return; | |
111 | |
112 width = gdk_pixbuf_get_width(GDK_PIXBUF(pixbuf)); | |
113 height = gdk_pixbuf_get_height(GDK_PIXBUF(pixbuf)); | |
114 | |
115 if(strcmp(DATA_DIR "/images/audio.png", text)) | |
116 { | |
117 if(width == 0) | |
118 width = 1; | |
119 aspect = (double)height / (double)width; | |
120 if(aspect > 1.0) { | |
121 height = (int)(cfg.filepopup_pixelsize * aspect); | |
122 width = cfg.filepopup_pixelsize; | |
123 } else { | |
124 height = cfg.filepopup_pixelsize; | |
125 width = (int)(cfg.filepopup_pixelsize / aspect); | |
126 } | |
127 pixbuf2 = gdk_pixbuf_scale_simple(GDK_PIXBUF(pixbuf), width, height, GDK_INTERP_BILINEAR); | |
128 g_object_unref(G_OBJECT(pixbuf)); | |
129 pixbuf = pixbuf2; | |
130 } | |
131 | |
132 gtk_image_set_from_pixbuf(GTK_IMAGE(widget), GDK_PIXBUF(pixbuf)); | |
133 g_object_unref(G_OBJECT(pixbuf)); | |
134 } | |
135 | |
136 void fileinfo_hide(gpointer unused) | |
137 { | |
138 gtk_widget_hide(fileinfo_win); | |
139 | |
140 /* Clear it out. */ | |
141 fileinfo_entry_set_text("entry_title", ""); | |
142 fileinfo_entry_set_text("entry_artist", ""); | |
143 fileinfo_entry_set_text("entry_album", ""); | |
144 fileinfo_entry_set_text("entry_comment", ""); | |
145 fileinfo_entry_set_text("entry_genre", ""); | |
146 fileinfo_entry_set_text("entry_year", ""); | |
147 fileinfo_entry_set_text("entry_track", ""); | |
148 fileinfo_entry_set_text("entry_location", ""); | |
149 | |
150 fileinfo_entry_set_image("image_artwork", DATA_DIR "/images/audio.png"); | |
151 } | |
152 | |
153 void | |
154 create_fileinfo_window(void) | |
155 { | |
156 const gchar *glade_file = DATA_DIR "/glade/fileinfo.glade"; | |
157 GladeXML *xml; | |
158 GtkWidget *widget; | |
159 | |
160 xml = glade_xml_new_or_die(_("Track Information Window"), glade_file, NULL, NULL); | |
161 | |
162 glade_xml_signal_autoconnect(xml); | |
163 | |
164 fileinfo_win = glade_xml_get_widget(xml, "fileinfo_win"); | |
165 g_object_set_data(G_OBJECT(fileinfo_win), "glade-xml", xml); | |
166 gtk_window_set_transient_for(GTK_WINDOW(fileinfo_win), GTK_WINDOW(mainwin)); | |
167 | |
168 widget = glade_xml_get_widget(xml, "image_artwork"); | |
169 gtk_image_set_from_file(GTK_IMAGE(widget), DATA_DIR "/images/audio.png"); | |
170 | |
171 widget = glade_xml_get_widget(xml, "btn_close"); | |
172 g_signal_connect(G_OBJECT(widget), "clicked", (GCallback) fileinfo_hide, NULL); | |
173 } | |
174 | |
175 void | |
176 fileinfo_show_for_tuple(TitleInput *tuple) | |
177 { | |
178 gchar *tmp = NULL; | |
179 | |
180 if (tuple == NULL) | |
181 return; | |
182 | |
183 gtk_widget_realize(fileinfo_win); | |
184 | |
185 if (tuple->track_name) | |
186 fileinfo_entry_set_text("entry_title", tuple->track_name); | |
187 if (tuple->performer) | |
188 fileinfo_entry_set_text("entry_artist", tuple->performer); | |
189 if (tuple->album_name) | |
190 fileinfo_entry_set_text("entry_album", tuple->album_name); | |
191 if (tuple->comment) | |
192 fileinfo_entry_set_text("entry_comment", tuple->comment); | |
193 if (tuple->genre) | |
194 fileinfo_entry_set_text("entry_genre", tuple->genre); | |
195 | |
196 tmp = g_strdup_printf("%s/%s", tuple->file_path, tuple->file_name); | |
197 if(tmp){ | |
198 fileinfo_entry_set_text_free("entry_location", str_to_utf8(tmp)); | |
199 g_free(tmp); | |
200 tmp = NULL; | |
201 } | |
202 | |
203 if (tuple->year != 0) | |
204 fileinfo_entry_set_text_free("entry_year", g_strdup_printf("%d", tuple->year)); | |
205 | |
206 if (tuple->track_number != 0) | |
207 fileinfo_entry_set_text_free("entry_track", g_strdup_printf("%d", tuple->track_number)); | |
208 | |
209 tmp = fileinfo_recursive_get_image(tuple->file_path, tuple->file_name, 0); | |
210 | |
211 if(tmp) | |
212 { | |
213 fileinfo_entry_set_image("image_artwork", tmp); | |
214 g_free(tmp); | |
215 } | |
216 | |
217 gtk_widget_show(fileinfo_win); | |
218 } | |
219 | |
220 void | |
221 fileinfo_show_for_path(gchar *path) | |
222 { | |
223 TitleInput *tuple = input_get_song_tuple(path); | |
224 | |
225 if (tuple == NULL) | |
226 return input_file_info_box(path); | |
227 | |
228 fileinfo_show_for_tuple(tuple); | |
229 | |
230 bmp_title_input_free(tuple); | |
231 tuple = NULL; | |
232 } |