Mercurial > audlegacy
annotate src/audacious/ui_fileinfo.c @ 3121:3b6d316f8b09 trunk
GPL3 relicensing.
author | William Pitcock <nenolod@atheme-project.org> |
---|---|
date | Fri, 20 Jul 2007 08:59:47 -0500 |
parents | 2520e8b6cf5e |
children | f1c756f39e6c |
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 | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3113
diff
changeset
|
8 * the Free Software Foundation; under version 3 of the License. |
2313 | 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 | |
3121
3b6d316f8b09
GPL3 relicensing.
William Pitcock <nenolod@atheme-project.org>
parents:
3113
diff
changeset
|
16 * along with this program. If not, see <http://www.gnu.org/licenses>. |
2313 | 17 */ |
18 | |
19 #ifdef HAVE_CONFIG_H | |
20 # include "config.h" | |
21 #endif | |
22 | |
23 #include <glib.h> | |
24 #include <glib/gi18n.h> | |
25 #include <gtk/gtk.h> | |
26 #include <glade/glade.h> | |
27 #include <string.h> | |
28 #include <stddef.h> | |
29 #include <stdio.h> | |
30 #include <sys/types.h> | |
31 #include <dirent.h> | |
32 #include <unistd.h> | |
33 #include <errno.h> | |
34 #include <sys/types.h> | |
35 #include <sys/stat.h> | |
36 | |
37 #include "glade.h" | |
38 | |
39 #include "plugin.h" | |
40 #include "pluginenum.h" | |
41 #include "input.h" | |
42 #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
|
43 #include "strings.h" |
2313 | 44 #include "general.h" |
45 #include "output.h" | |
46 #include "visualization.h" | |
47 | |
48 #include "main.h" | |
49 #include "util.h" | |
50 #include "dnd.h" | |
51 #include "titlestring.h" | |
52 | |
53 #include "playlist.h" | |
54 | |
55 #include "ui_main.h" | |
56 #include "ui_playlist.h" | |
57 #include "build_stamp.h" | |
58 #include "ui_fileinfo.h" | |
59 #include "ui_playlist.h" | |
60 | |
61 GtkWidget *fileinfo_win; | |
62 | |
63 static void | |
64 fileinfo_entry_set_text(const char *entry, const char *text) | |
65 { | |
66 GladeXML *xml = g_object_get_data(G_OBJECT(fileinfo_win), "glade-xml"); | |
67 GtkWidget *widget = glade_xml_get_widget(xml, entry); | |
68 | |
69 if (xml == NULL || widget == NULL) | |
70 return; | |
71 | |
72 gtk_entry_set_text(GTK_ENTRY(widget), text); | |
73 } | |
74 | |
75 static void | |
76 fileinfo_entry_set_text_free(const char *entry, char *text) | |
77 { | |
78 GladeXML *xml = g_object_get_data(G_OBJECT(fileinfo_win), "glade-xml"); | |
79 GtkWidget *widget = glade_xml_get_widget(xml, entry); | |
80 | |
81 if (xml == NULL || widget == NULL) | |
82 return; | |
83 | |
84 gtk_entry_set_text(GTK_ENTRY(widget), text); | |
85 | |
86 g_free(text); | |
87 } | |
88 | |
89 static void | |
90 fileinfo_entry_set_image(const char *entry, const char *text) | |
91 { | |
92 GladeXML *xml = g_object_get_data(G_OBJECT(fileinfo_win), "glade-xml"); | |
93 GtkWidget *widget = glade_xml_get_widget(xml, entry); | |
94 GdkPixbuf *pixbuf; | |
95 int width, height; | |
96 double aspect; | |
97 GdkPixbuf *pixbuf2; | |
98 | |
99 if (xml == NULL || widget == NULL) | |
100 return; | |
101 | |
102 pixbuf = gdk_pixbuf_new_from_file(text, NULL); | |
103 | |
104 if (pixbuf == NULL) | |
105 return; | |
106 | |
107 width = gdk_pixbuf_get_width(GDK_PIXBUF(pixbuf)); | |
108 height = gdk_pixbuf_get_height(GDK_PIXBUF(pixbuf)); | |
109 | |
110 if(strcmp(DATA_DIR "/images/audio.png", text)) | |
111 { | |
112 if(width == 0) | |
113 width = 1; | |
114 aspect = (double)height / (double)width; | |
115 if(aspect > 1.0) { | |
116 height = (int)(cfg.filepopup_pixelsize * aspect); | |
117 width = cfg.filepopup_pixelsize; | |
118 } else { | |
119 height = cfg.filepopup_pixelsize; | |
120 width = (int)(cfg.filepopup_pixelsize / aspect); | |
121 } | |
122 pixbuf2 = gdk_pixbuf_scale_simple(GDK_PIXBUF(pixbuf), width, height, GDK_INTERP_BILINEAR); | |
123 g_object_unref(G_OBJECT(pixbuf)); | |
124 pixbuf = pixbuf2; | |
125 } | |
126 | |
127 gtk_image_set_from_pixbuf(GTK_IMAGE(widget), GDK_PIXBUF(pixbuf)); | |
128 g_object_unref(G_OBJECT(pixbuf)); | |
129 } | |
130 | |
131 void fileinfo_hide(gpointer unused) | |
132 { | |
133 gtk_widget_hide(fileinfo_win); | |
134 | |
135 /* Clear it out. */ | |
136 fileinfo_entry_set_text("entry_title", ""); | |
137 fileinfo_entry_set_text("entry_artist", ""); | |
138 fileinfo_entry_set_text("entry_album", ""); | |
139 fileinfo_entry_set_text("entry_comment", ""); | |
140 fileinfo_entry_set_text("entry_genre", ""); | |
141 fileinfo_entry_set_text("entry_year", ""); | |
142 fileinfo_entry_set_text("entry_track", ""); | |
143 fileinfo_entry_set_text("entry_location", ""); | |
144 | |
145 fileinfo_entry_set_image("image_artwork", DATA_DIR "/images/audio.png"); | |
146 } | |
147 | |
148 void | |
149 create_fileinfo_window(void) | |
150 { | |
151 const gchar *glade_file = DATA_DIR "/glade/fileinfo.glade"; | |
152 GladeXML *xml; | |
153 GtkWidget *widget; | |
154 | |
155 xml = glade_xml_new_or_die(_("Track Information Window"), glade_file, NULL, NULL); | |
156 | |
157 glade_xml_signal_autoconnect(xml); | |
158 | |
159 fileinfo_win = glade_xml_get_widget(xml, "fileinfo_win"); | |
160 g_object_set_data(G_OBJECT(fileinfo_win), "glade-xml", xml); | |
161 gtk_window_set_transient_for(GTK_WINDOW(fileinfo_win), GTK_WINDOW(mainwin)); | |
162 | |
163 widget = glade_xml_get_widget(xml, "image_artwork"); | |
164 gtk_image_set_from_file(GTK_IMAGE(widget), DATA_DIR "/images/audio.png"); | |
165 | |
166 widget = glade_xml_get_widget(xml, "btn_close"); | |
167 g_signal_connect(G_OBJECT(widget), "clicked", (GCallback) fileinfo_hide, NULL); | |
168 } | |
169 | |
170 void | |
171 fileinfo_show_for_tuple(TitleInput *tuple) | |
172 { | |
173 gchar *tmp = NULL; | |
174 | |
175 if (tuple == NULL) | |
176 return; | |
177 | |
178 gtk_widget_realize(fileinfo_win); | |
179 | |
180 if (tuple->track_name) | |
181 fileinfo_entry_set_text("entry_title", tuple->track_name); | |
182 if (tuple->performer) | |
183 fileinfo_entry_set_text("entry_artist", tuple->performer); | |
184 if (tuple->album_name) | |
185 fileinfo_entry_set_text("entry_album", tuple->album_name); | |
186 if (tuple->comment) | |
187 fileinfo_entry_set_text("entry_comment", tuple->comment); | |
188 if (tuple->genre) | |
189 fileinfo_entry_set_text("entry_genre", tuple->genre); | |
190 | |
191 tmp = g_strdup_printf("%s/%s", tuple->file_path, tuple->file_name); | |
192 if(tmp){ | |
193 fileinfo_entry_set_text_free("entry_location", str_to_utf8(tmp)); | |
194 g_free(tmp); | |
195 tmp = NULL; | |
196 } | |
197 | |
198 if (tuple->year != 0) | |
199 fileinfo_entry_set_text_free("entry_year", g_strdup_printf("%d", tuple->year)); | |
200 | |
201 if (tuple->track_number != 0) | |
202 fileinfo_entry_set_text_free("entry_track", g_strdup_printf("%d", tuple->track_number)); | |
203 | |
204 tmp = fileinfo_recursive_get_image(tuple->file_path, tuple->file_name, 0); | |
205 | |
206 if(tmp) | |
207 { | |
208 fileinfo_entry_set_image("image_artwork", tmp); | |
209 g_free(tmp); | |
210 } | |
211 | |
212 gtk_widget_show(fileinfo_win); | |
213 } | |
214 | |
215 void | |
216 fileinfo_show_for_path(gchar *path) | |
217 { | |
218 TitleInput *tuple = input_get_song_tuple(path); | |
219 | |
220 if (tuple == NULL) | |
221 return input_file_info_box(path); | |
222 | |
223 fileinfo_show_for_tuple(tuple); | |
224 | |
225 bmp_title_input_free(tuple); | |
226 tuple = NULL; | |
227 } |