Mercurial > audlegacy
annotate src/audacious/ui_fileinfo.c @ 3986:a77a1b3f493f
drop glade on fileinfo
author | Tomasz Mon <desowin@gmail.com> |
---|---|
date | Fri, 23 Nov 2007 20:32:25 +0100 |
parents | 602ec8c40d0d |
children | ce1ce0a6cc74 |
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>. |
3123
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
17 * |
f1c756f39e6c
Invoke "Plugins are not derived work" clause provided by GPL3.
William Pitcock <nenolod@atheme-project.org>
parents:
3121
diff
changeset
|
18 * 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
|
19 * Audacious or using our public API to be a derived work. |
2313 | 20 */ |
21 | |
22 #ifdef HAVE_CONFIG_H | |
23 # include "config.h" | |
24 #endif | |
25 | |
26 #include <glib.h> | |
27 #include <glib/gi18n.h> | |
28 #include <gtk/gtk.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 "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" | |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
51 #include "tuple.h" |
2313 | 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 | |
3986 | 63 GtkWidget *entry_location; |
64 GtkWidget *entry_title; | |
65 GtkWidget *entry_artist; | |
66 GtkWidget *entry_album; | |
67 GtkWidget *entry_comment; | |
68 GtkWidget *entry_year; | |
69 GtkWidget *entry_track; | |
70 GtkWidget *entry_genre; | |
71 | |
72 GtkWidget *image_artwork; | |
73 | |
2313 | 74 static void |
3986 | 75 fileinfo_entry_set_text(GtkWidget *widget, const char *text) |
2313 | 76 { |
3986 | 77 if (widget == NULL) |
78 return; | |
2313 | 79 |
3986 | 80 gtk_entry_set_text(GTK_ENTRY(widget), text); |
2313 | 81 } |
82 | |
83 static void | |
3986 | 84 fileinfo_entry_set_text_free(GtkWidget *widget, char *text) |
2313 | 85 { |
3986 | 86 if (widget == NULL) |
87 return; | |
2313 | 88 |
3986 | 89 gtk_entry_set_text(GTK_ENTRY(widget), text); |
2313 | 90 |
3986 | 91 g_free(text); |
2313 | 92 } |
93 | |
94 static void | |
3986 | 95 fileinfo_entry_set_image(GtkWidget *widget, const char *text) |
2313 | 96 { |
97 GdkPixbuf *pixbuf; | |
98 int width, height; | |
99 double aspect; | |
100 GdkPixbuf *pixbuf2; | |
101 | |
3986 | 102 if (widget == NULL) |
2313 | 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 { | |
3986 | 136 gtk_widget_hide(fileinfo_win); |
2313 | 137 |
3986 | 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, ""); | |
2313 | 147 |
3986 | 148 fileinfo_entry_set_image(image_artwork, DATA_DIR "/images/audio.png"); |
2313 | 149 } |
150 | |
151 void | |
152 create_fileinfo_window(void) | |
153 { | |
3986 | 154 GtkWidget *hbox; |
155 GtkWidget *vbox1; | |
156 GtkWidget *vbox2; | |
157 GtkWidget *label_title; | |
158 GtkWidget *label_artist; | |
159 GtkWidget *label_album; | |
160 GtkWidget *label_comment; | |
161 GtkWidget *label_genre; | |
162 GtkWidget *label_year; | |
163 GtkWidget *label_track; | |
164 GtkWidget *label_location; | |
165 GtkWidget *table1; | |
166 GtkWidget *bbox_close; | |
167 GtkWidget *btn_close; | |
168 | |
169 fileinfo_win = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
170 gtk_container_set_border_width(GTK_CONTAINER(fileinfo_win), 6); | |
171 gtk_window_set_title(GTK_WINDOW(fileinfo_win), _("Track Information")); | |
172 gtk_window_set_position(GTK_WINDOW(fileinfo_win), GTK_WIN_POS_CENTER); | |
173 gtk_window_set_resizable(GTK_WINDOW(fileinfo_win), FALSE); | |
174 gtk_window_set_type_hint(GTK_WINDOW(fileinfo_win), GDK_WINDOW_TYPE_HINT_DIALOG); | |
175 gtk_window_set_transient_for(GTK_WINDOW(fileinfo_win), GTK_WINDOW(mainwin)); | |
176 | |
177 hbox = gtk_hbox_new(FALSE, 0); | |
178 gtk_container_add(GTK_CONTAINER(fileinfo_win), hbox); | |
2313 | 179 |
3986 | 180 image_artwork = gtk_image_new(); |
181 gtk_box_pack_start(GTK_BOX(hbox), image_artwork, FALSE, FALSE, 0); | |
182 gtk_misc_set_alignment(GTK_MISC(image_artwork), 0.5, 0); | |
183 gtk_image_set_from_file(GTK_IMAGE(image_artwork), DATA_DIR "/images/audio.png"); | |
184 | |
185 vbox1 = gtk_vbox_new(FALSE, 0); | |
186 gtk_box_pack_start(GTK_BOX(hbox), vbox1, TRUE, TRUE, 0); | |
187 | |
188 vbox2 = gtk_vbox_new(FALSE, 0); | |
189 gtk_container_add(GTK_CONTAINER(vbox1), vbox2); | |
190 | |
191 label_title = gtk_label_new(_("<span size=\"small\">Title</span>")); | |
192 gtk_box_pack_start(GTK_BOX(vbox2), label_title, FALSE, FALSE, 0); | |
193 gtk_label_set_use_markup(GTK_LABEL(label_title), TRUE); | |
194 gtk_misc_set_alignment(GTK_MISC(label_title), 0, 0); | |
2313 | 195 |
3986 | 196 entry_title = gtk_entry_new(); |
197 gtk_container_add(GTK_CONTAINER(vbox2), entry_title); | |
198 | |
199 label_artist = gtk_label_new(_("<span size=\"small\">Artist</span>")); | |
200 gtk_box_pack_start(GTK_BOX(vbox2), label_artist, FALSE, FALSE, 0); | |
201 gtk_label_set_use_markup(GTK_LABEL(label_artist), TRUE); | |
202 gtk_misc_set_alignment(GTK_MISC(label_artist), 0, 0.5); | |
203 | |
204 entry_artist = gtk_entry_new(); | |
205 gtk_container_add(GTK_CONTAINER(vbox2), entry_artist); | |
206 | |
207 label_album = gtk_label_new(_("<span size=\"small\">Album</span>")); | |
208 gtk_box_pack_start(GTK_BOX(vbox2), label_album, FALSE, FALSE, 0); | |
209 gtk_label_set_use_markup(GTK_LABEL(label_album), TRUE); | |
210 gtk_misc_set_alignment(GTK_MISC(label_album), 0, 0.5); | |
211 | |
212 entry_album = gtk_entry_new(); | |
213 gtk_container_add(GTK_CONTAINER(vbox2), entry_album); | |
2313 | 214 |
3986 | 215 label_comment = gtk_label_new(_("<span size=\"small\">Comment</span>")); |
216 gtk_box_pack_start(GTK_BOX(vbox2), label_comment, FALSE, FALSE, 0); | |
217 gtk_label_set_use_markup(GTK_LABEL(label_comment), TRUE); | |
218 gtk_misc_set_alignment(GTK_MISC(label_comment), 0, 0.5); | |
219 | |
220 entry_comment = gtk_entry_new(); | |
221 gtk_container_add (GTK_CONTAINER(vbox2), entry_comment); | |
222 | |
223 label_genre = gtk_label_new(_("<span size=\"small\">Genre</span>")); | |
224 gtk_box_pack_start(GTK_BOX(vbox2), label_genre, FALSE, FALSE, 0); | |
225 gtk_label_set_use_markup(GTK_LABEL(label_genre), TRUE); | |
226 gtk_misc_set_alignment(GTK_MISC(label_genre), 0, 0.5); | |
227 | |
228 entry_genre = gtk_entry_new(); | |
229 gtk_container_add(GTK_CONTAINER(vbox2), entry_genre); | |
230 | |
231 table1 = gtk_table_new(2, 2, FALSE); | |
232 gtk_container_add(GTK_CONTAINER(vbox2), table1); | |
233 gtk_table_set_col_spacings(GTK_TABLE(table1), 6); | |
234 | |
235 label_year = gtk_label_new(_("<span size=\"small\">Year</span>")); | |
236 gtk_table_attach(GTK_TABLE(table1), label_year, 0, 1, 0, 1, | |
237 (GtkAttachOptions) (GTK_FILL), | |
238 (GtkAttachOptions) (0), 0, 0); | |
239 gtk_label_set_use_markup(GTK_LABEL(label_year), TRUE); | |
240 gtk_misc_set_alignment(GTK_MISC(label_year), 0, 0.5); | |
2313 | 241 |
3986 | 242 entry_year = gtk_entry_new(); |
243 gtk_table_attach(GTK_TABLE(table1), entry_year, 0, 1, 1, 2, | |
244 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), | |
245 (GtkAttachOptions) (0), 0, 0); | |
246 | |
247 label_track = gtk_label_new(_("<span size=\"small\">Track Number</span>")); | |
248 gtk_table_attach(GTK_TABLE(table1), label_track, 1, 2, 0, 1, | |
249 (GtkAttachOptions) (GTK_FILL), | |
250 (GtkAttachOptions) (0), 0, 0); | |
251 gtk_label_set_use_markup(GTK_LABEL(label_track), TRUE); | |
252 gtk_misc_set_alignment(GTK_MISC(label_track), 0, 0.5); | |
253 | |
254 entry_track = gtk_entry_new(); | |
255 gtk_table_attach(GTK_TABLE(table1), entry_track, 1, 2, 1, 2, | |
256 (GtkAttachOptions) (GTK_EXPAND | GTK_FILL), | |
257 (GtkAttachOptions) (0), 0, 0); | |
2313 | 258 |
3986 | 259 label_location = gtk_label_new(_("<span size=\"small\">Location</span>")); |
260 gtk_box_pack_start(GTK_BOX(vbox2), label_location, FALSE, FALSE, 0); | |
261 gtk_label_set_use_markup(GTK_LABEL(label_location), TRUE); | |
262 gtk_misc_set_alignment(GTK_MISC(label_location), 0, 0.5); | |
263 | |
264 entry_location = gtk_entry_new(); | |
265 gtk_container_add(GTK_CONTAINER(vbox2), entry_location); | |
266 | |
267 bbox_close = gtk_hbutton_box_new(); | |
268 gtk_box_pack_start(GTK_BOX(vbox1), bbox_close, FALSE, FALSE, 0); | |
269 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox_close), GTK_BUTTONBOX_END); | |
270 | |
271 btn_close = gtk_button_new_from_stock("gtk-close"); | |
272 gtk_container_add(GTK_CONTAINER(bbox_close), btn_close); | |
273 GTK_WIDGET_SET_FLAGS(btn_close, GTK_CAN_DEFAULT); | |
274 g_signal_connect(G_OBJECT(btn_close), "clicked", (GCallback) fileinfo_hide, NULL); | |
275 | |
276 gtk_widget_show_all (hbox); | |
2313 | 277 } |
278 | |
279 void | |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
280 fileinfo_show_for_tuple(Tuple *tuple) |
2313 | 281 { |
282 gchar *tmp = NULL; | |
283 | |
284 if (tuple == NULL) | |
285 return; | |
286 | |
287 gtk_widget_realize(fileinfo_win); | |
288 | |
3986 | 289 fileinfo_entry_set_text(entry_title, tuple_get_string(tuple, FIELD_TITLE, NULL)); |
290 fileinfo_entry_set_text(entry_artist, tuple_get_string(tuple, FIELD_ARTIST, NULL)); | |
291 fileinfo_entry_set_text(entry_album, tuple_get_string(tuple, FIELD_ALBUM, NULL)); | |
292 fileinfo_entry_set_text(entry_comment, tuple_get_string(tuple, FIELD_COMMENT, NULL)); | |
293 fileinfo_entry_set_text(entry_genre, tuple_get_string(tuple, FIELD_GENRE, NULL)); | |
2313 | 294 |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3298
diff
changeset
|
295 tmp = g_strdup_printf("%s/%s", |
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3298
diff
changeset
|
296 tuple_get_string(tuple, FIELD_FILE_PATH, NULL), |
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3298
diff
changeset
|
297 tuple_get_string(tuple, FIELD_FILE_NAME, NULL)); |
2313 | 298 if(tmp){ |
3986 | 299 fileinfo_entry_set_text_free(entry_location, str_to_utf8(tmp)); |
2313 | 300 g_free(tmp); |
301 tmp = NULL; | |
302 } | |
303 | |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3298
diff
changeset
|
304 if (tuple_get_int(tuple, FIELD_YEAR, NULL)) |
3986 | 305 fileinfo_entry_set_text_free(entry_year, |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3298
diff
changeset
|
306 g_strdup_printf("%d", tuple_get_int(tuple, FIELD_YEAR, NULL))); |
2313 | 307 |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3298
diff
changeset
|
308 if (tuple_get_int(tuple, FIELD_TRACK_NUMBER, NULL)) |
3986 | 309 fileinfo_entry_set_text_free(entry_track, |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3298
diff
changeset
|
310 g_strdup_printf("%d", tuple_get_int(tuple, FIELD_TRACK_NUMBER, NULL))); |
2313 | 311 |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3298
diff
changeset
|
312 tmp = fileinfo_recursive_get_image( |
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3298
diff
changeset
|
313 tuple_get_string(tuple, FIELD_FILE_PATH, NULL), |
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3298
diff
changeset
|
314 tuple_get_string(tuple, FIELD_FILE_NAME, NULL), 0); |
2313 | 315 |
316 if(tmp) | |
317 { | |
3986 | 318 fileinfo_entry_set_image(image_artwork, tmp); |
2313 | 319 g_free(tmp); |
320 } | |
321 | |
322 gtk_widget_show(fileinfo_win); | |
323 } | |
324 | |
325 void | |
326 fileinfo_show_for_path(gchar *path) | |
327 { | |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
328 Tuple *tuple = input_get_song_tuple(path); |
2313 | 329 |
330 if (tuple == NULL) | |
331 return input_file_info_box(path); | |
332 | |
333 fileinfo_show_for_tuple(tuple); | |
334 | |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
335 mowgli_object_unref(tuple); |
2313 | 336 } |