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