Mercurial > audlegacy
annotate src/audacious/ui_fileinfo.c @ 3621:2d6106656276
Notify playlist manager of more changes
author | Kieran Clancy <clancy.kieran+audacious@gmail.com> |
---|---|
date | Tue, 25 Sep 2007 20:38:40 +0930 |
parents | 602ec8c40d0d |
children | a77a1b3f493f |
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 <glade/glade.h> | |
30 #include <string.h> | |
31 #include <stddef.h> | |
32 #include <stdio.h> | |
33 #include <sys/types.h> | |
34 #include <dirent.h> | |
35 #include <unistd.h> | |
36 #include <errno.h> | |
37 #include <sys/types.h> | |
38 #include <sys/stat.h> | |
39 | |
40 #include "glade.h" | |
41 | |
42 #include "plugin.h" | |
43 #include "pluginenum.h" | |
44 #include "input.h" | |
45 #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
|
46 #include "strings.h" |
2313 | 47 #include "general.h" |
48 #include "output.h" | |
49 #include "visualization.h" | |
50 | |
51 #include "main.h" | |
52 #include "util.h" | |
53 #include "dnd.h" | |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
54 #include "tuple.h" |
2313 | 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 | |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
174 fileinfo_show_for_tuple(Tuple *tuple) |
2313 | 175 { |
176 gchar *tmp = NULL; | |
177 | |
178 if (tuple == NULL) | |
179 return; | |
180 | |
181 gtk_widget_realize(fileinfo_win); | |
182 | |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3298
diff
changeset
|
183 fileinfo_entry_set_text("entry_title", tuple_get_string(tuple, FIELD_TITLE, NULL)); |
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3298
diff
changeset
|
184 fileinfo_entry_set_text("entry_artist", tuple_get_string(tuple, FIELD_ARTIST, NULL)); |
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3298
diff
changeset
|
185 fileinfo_entry_set_text("entry_album", tuple_get_string(tuple, FIELD_ALBUM, NULL)); |
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3298
diff
changeset
|
186 fileinfo_entry_set_text("entry_comment", tuple_get_string(tuple, FIELD_COMMENT, NULL)); |
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3298
diff
changeset
|
187 fileinfo_entry_set_text("entry_genre", tuple_get_string(tuple, FIELD_GENRE, NULL)); |
2313 | 188 |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3298
diff
changeset
|
189 tmp = g_strdup_printf("%s/%s", |
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3298
diff
changeset
|
190 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
|
191 tuple_get_string(tuple, FIELD_FILE_NAME, NULL)); |
2313 | 192 if(tmp){ |
193 fileinfo_entry_set_text_free("entry_location", str_to_utf8(tmp)); | |
194 g_free(tmp); | |
195 tmp = NULL; | |
196 } | |
197 | |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3298
diff
changeset
|
198 if (tuple_get_int(tuple, FIELD_YEAR, NULL)) |
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3298
diff
changeset
|
199 fileinfo_entry_set_text_free("entry_year", |
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3298
diff
changeset
|
200 g_strdup_printf("%d", tuple_get_int(tuple, FIELD_YEAR, NULL))); |
2313 | 201 |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3298
diff
changeset
|
202 if (tuple_get_int(tuple, FIELD_TRACK_NUMBER, NULL)) |
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3298
diff
changeset
|
203 fileinfo_entry_set_text_free("entry_track", |
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3298
diff
changeset
|
204 g_strdup_printf("%d", tuple_get_int(tuple, FIELD_TRACK_NUMBER, NULL))); |
2313 | 205 |
3490
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3298
diff
changeset
|
206 tmp = fileinfo_recursive_get_image( |
602ec8c40d0d
Fixed to comply with the Tuple API changes.
Matti Hamalainen <ccr@tnsp.org>
parents:
3298
diff
changeset
|
207 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
|
208 tuple_get_string(tuple, FIELD_FILE_NAME, NULL), 0); |
2313 | 209 |
210 if(tmp) | |
211 { | |
212 fileinfo_entry_set_image("image_artwork", tmp); | |
213 g_free(tmp); | |
214 } | |
215 | |
216 gtk_widget_show(fileinfo_win); | |
217 } | |
218 | |
219 void | |
220 fileinfo_show_for_path(gchar *path) | |
221 { | |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
222 Tuple *tuple = input_get_song_tuple(path); |
2313 | 223 |
224 if (tuple == NULL) | |
225 return input_file_info_box(path); | |
226 | |
227 fileinfo_show_for_tuple(tuple); | |
228 | |
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
229 mowgli_object_unref(tuple); |
2313 | 230 } |