Mercurial > audlegacy
annotate audacious/ui_fileinfo.c @ 2270:50dea14e2fa3 trunk
[svn] Serbian language upadated
author | kustodian |
---|---|
date | Thu, 04 Jan 2007 14:55:34 -0800 |
parents | 1148bfa60fd5 |
children |
rev | line source |
---|---|
1262 | 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 | |
2105
f18a5b617c34
[svn] - move to GPLv2-only. Based on my interpretation of the license, we are
nenolod
parents:
2092
diff
changeset
|
8 * the Free Software Foundation; under version 2 of the License. |
1262 | 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 | |
1956
fb61da4f4c23
[svn] - remove unused declaration "filepopup_pixbuf".
nenolod
parents:
1889
diff
changeset
|
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
fb61da4f4c23
[svn] - remove unused declaration "filepopup_pixbuf".
nenolod
parents:
1889
diff
changeset
|
18 * 02110-1301, USA. |
1262 | 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" | |
45 #include "general.h" | |
46 #include "output.h" | |
47 #include "visualization.h" | |
48 | |
49 #include "main.h" | |
2073 | 50 #include "libaudacious/urldecode.h" |
1262 | 51 #include "util.h" |
52 #include "dnd.h" | |
1755 | 53 #include "titlestring.h" |
54 | |
1262 | 55 #include "libaudacious/configdb.h" |
56 | |
1283
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
57 #include "playlist.h" |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
58 |
2237 | 59 #include "ui_main.h" |
1262 | 60 #include "ui_playlist.h" |
61 #include "build_stamp.h" | |
62 #include "ui_fileinfo.h" | |
1284 | 63 #include "ui_playlist.h" |
1262 | 64 |
65 GtkWidget *fileinfo_win; | |
1283
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
66 GtkWidget *filepopup_win; |
1262 | 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 | |
1283
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
94 static void |
1296 | 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); | |
1299 | 99 GdkPixbuf *pixbuf; |
1710 | 100 int width, height; |
101 double aspect; | |
2055 | 102 GdkPixbuf *pixbuf2; |
1296 | 103 |
104 if (xml == NULL || widget == NULL) | |
105 return; | |
106 | |
1299 | 107 pixbuf = gdk_pixbuf_new_from_file(text, NULL); |
108 | |
109 if (pixbuf == NULL) | |
110 return; | |
111 | |
1710 | 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)) | |
1299 | 116 { |
1710 | 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 } | |
2055 | 127 pixbuf2 = gdk_pixbuf_scale_simple(GDK_PIXBUF(pixbuf), width, height, GDK_INTERP_BILINEAR); |
1299 | 128 g_object_unref(G_OBJECT(pixbuf)); |
129 pixbuf = pixbuf2; | |
130 } | |
131 | |
132 gtk_image_set_from_pixbuf(GTK_IMAGE(widget), GDK_PIXBUF(pixbuf)); | |
1326 | 133 g_object_unref(G_OBJECT(pixbuf)); |
1296 | 134 } |
135 | |
136 static void | |
1283
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
137 filepopup_entry_set_text(const char *entry, const char *text) |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
138 { |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
139 GladeXML *xml = g_object_get_data(G_OBJECT(filepopup_win), "glade-xml"); |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
140 GtkWidget *widget = glade_xml_get_widget(xml, entry); |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
141 |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
142 if (xml == NULL || widget == NULL) |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
143 return; |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
144 |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
145 gtk_label_set_text(GTK_LABEL(widget), text); |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
146 } |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
147 |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
148 static void |
1296 | 149 filepopup_entry_set_image(const char *entry, const char *text) |
150 { | |
151 GladeXML *xml = g_object_get_data(G_OBJECT(filepopup_win), "glade-xml"); | |
152 GtkWidget *widget = glade_xml_get_widget(xml, entry); | |
1299 | 153 GdkPixbuf *pixbuf; |
1710 | 154 int width, height; |
155 double aspect; | |
2055 | 156 GdkPixbuf *pixbuf2; |
1296 | 157 |
158 if (xml == NULL || widget == NULL) | |
159 return; | |
160 | |
1299 | 161 pixbuf = gdk_pixbuf_new_from_file(text, NULL); |
162 | |
163 if (pixbuf == NULL) | |
164 return; | |
165 | |
1710 | 166 width = gdk_pixbuf_get_width(GDK_PIXBUF(pixbuf)); |
167 height = gdk_pixbuf_get_height(GDK_PIXBUF(pixbuf)); | |
168 | |
169 if(strcmp(DATA_DIR "/images/audio.png", text)) | |
1299 | 170 { |
1710 | 171 if(width == 0) |
172 width = 1; | |
173 aspect = (double)height / (double)width; | |
174 if(aspect > 1.0) { | |
175 height = (int)(cfg.filepopup_pixelsize * aspect); | |
176 width = cfg.filepopup_pixelsize; | |
177 } else { | |
178 height = cfg.filepopup_pixelsize; | |
179 width = (int)(cfg.filepopup_pixelsize / aspect); | |
180 } | |
2055 | 181 pixbuf2 = gdk_pixbuf_scale_simple(GDK_PIXBUF(pixbuf), width, height, GDK_INTERP_BILINEAR); |
1299 | 182 g_object_unref(G_OBJECT(pixbuf)); |
183 pixbuf = pixbuf2; | |
184 } | |
185 | |
186 gtk_image_set_from_pixbuf(GTK_IMAGE(widget), GDK_PIXBUF(pixbuf)); | |
1326 | 187 g_object_unref(G_OBJECT(pixbuf)); |
1296 | 188 } |
189 | |
190 static void | |
1283
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
191 filepopup_entry_set_text_free(const char *entry, char *text) |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
192 { |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
193 GladeXML *xml = g_object_get_data(G_OBJECT(filepopup_win), "glade-xml"); |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
194 GtkWidget *widget = glade_xml_get_widget(xml, entry); |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
195 |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
196 if (xml == NULL || widget == NULL) |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
197 return; |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
198 |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
199 gtk_label_set_text(GTK_LABEL(widget), text); |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
200 |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
201 g_free(text); |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
202 } |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
203 |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
204 static gboolean |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
205 filepopup_pointer_check_iter(gpointer unused) |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
206 { |
1312 | 207 gint x, y, pos; |
1283
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
208 TitleInput *tuple; |
1605
ce3ce44d6814
[svn] - filepopup follows change of pointed song, i.e. it will hide while scrolling.
yaz
parents:
1588
diff
changeset
|
209 static gint prev_x = 0, prev_y = 0, ctr = 0, prev_pos = -1; |
1775 | 210 static gint shaded_pos = -1, shaded_prev_pos = -1; |
1300
a5c4e748d557
[svn] - don't call filepopup_show_for_tuple() more than once
nenolod
parents:
1299
diff
changeset
|
211 gboolean skip = FALSE; |
1605
ce3ce44d6814
[svn] - filepopup follows change of pointed song, i.e. it will hide while scrolling.
yaz
parents:
1588
diff
changeset
|
212 GdkWindow *win; |
2092 | 213 Playlist *playlist = playlist_get_active(); |
1605
ce3ce44d6814
[svn] - filepopup follows change of pointed song, i.e. it will hide while scrolling.
yaz
parents:
1588
diff
changeset
|
214 |
ce3ce44d6814
[svn] - filepopup follows change of pointed song, i.e. it will hide while scrolling.
yaz
parents:
1588
diff
changeset
|
215 win = gdk_window_at_pointer(NULL, NULL); |
ce3ce44d6814
[svn] - filepopup follows change of pointed song, i.e. it will hide while scrolling.
yaz
parents:
1588
diff
changeset
|
216 gdk_window_get_pointer(GDK_WINDOW(playlistwin->window), &x, &y, NULL); |
ce3ce44d6814
[svn] - filepopup follows change of pointed song, i.e. it will hide while scrolling.
yaz
parents:
1588
diff
changeset
|
217 pos = playlist_list_get_playlist_position(playlistwin_list, x, y); |
1283
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
218 |
1605
ce3ce44d6814
[svn] - filepopup follows change of pointed song, i.e. it will hide while scrolling.
yaz
parents:
1588
diff
changeset
|
219 if (win == NULL |
ce3ce44d6814
[svn] - filepopup follows change of pointed song, i.e. it will hide while scrolling.
yaz
parents:
1588
diff
changeset
|
220 || cfg.show_filepopup_for_tuple == FALSE |
1401
3bc53d7f9012
[svn] - now filepopup_pointer_check_iter() returns immediately if cfg.show_filepopup_for_tuple is FALSE.
yaz
parents:
1389
diff
changeset
|
221 || playlistwin_list->pl_tooltips == FALSE |
1605
ce3ce44d6814
[svn] - filepopup follows change of pointed song, i.e. it will hide while scrolling.
yaz
parents:
1588
diff
changeset
|
222 || pos != prev_pos |
1775 | 223 || win != GDK_WINDOW(playlistwin->window)) |
1284 | 224 { |
1605
ce3ce44d6814
[svn] - filepopup follows change of pointed song, i.e. it will hide while scrolling.
yaz
parents:
1588
diff
changeset
|
225 prev_pos = pos; |
1284 | 226 ctr = 0; |
1389
c19443be579d
[svn] ensure that the fileinfo popup in playlist disappears when the cursor is moved again
giacomo
parents:
1371
diff
changeset
|
227 if ( filepopup_win->window != NULL && |
c19443be579d
[svn] ensure that the fileinfo popup in playlist disappears when the cursor is moved again
giacomo
parents:
1371
diff
changeset
|
228 gdk_window_is_viewable(GDK_WINDOW(filepopup_win->window)) ) |
c19443be579d
[svn] ensure that the fileinfo popup in playlist disappears when the cursor is moved again
giacomo
parents:
1371
diff
changeset
|
229 filepopup_hide(NULL); |
1284 | 230 return TRUE; |
231 } | |
232 | |
1283
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
233 if (prev_x == x && prev_y == y) |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
234 ctr++; |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
235 else |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
236 { |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
237 ctr = 0; |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
238 prev_x = x; |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
239 prev_y = y; |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
240 filepopup_hide(NULL); |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
241 return TRUE; |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
242 } |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
243 |
1300
a5c4e748d557
[svn] - don't call filepopup_show_for_tuple() more than once
nenolod
parents:
1299
diff
changeset
|
244 if (filepopup_win->window == NULL) |
a5c4e748d557
[svn] - don't call filepopup_show_for_tuple() more than once
nenolod
parents:
1299
diff
changeset
|
245 skip = TRUE; |
a5c4e748d557
[svn] - don't call filepopup_show_for_tuple() more than once
nenolod
parents:
1299
diff
changeset
|
246 |
1775 | 247 if (playlistwin_is_shaded()) { |
2092 | 248 shaded_pos = playlist_get_position(playlist); |
1775 | 249 if (shaded_prev_pos != shaded_pos) |
250 skip = TRUE; | |
251 } | |
252 | |
253 if (ctr >= cfg.filepopup_delay && (skip == TRUE || gdk_window_is_viewable(GDK_WINDOW(filepopup_win->window)) != TRUE)) { | |
254 if (pos == -1 && !playlistwin_is_shaded()) { | |
1283
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
255 filepopup_hide(NULL); |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
256 return TRUE; |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
257 } |
1775 | 258 else { /* shaded mode */ |
2092 | 259 tuple = playlist_get_tuple(playlist, shaded_pos); |
1775 | 260 filepopup_hide(NULL); |
261 filepopup_show_for_tuple(tuple); | |
262 shaded_prev_pos = shaded_pos; | |
263 } | |
1283
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
264 |
1605
ce3ce44d6814
[svn] - filepopup follows change of pointed song, i.e. it will hide while scrolling.
yaz
parents:
1588
diff
changeset
|
265 prev_pos = pos; |
ce3ce44d6814
[svn] - filepopup follows change of pointed song, i.e. it will hide while scrolling.
yaz
parents:
1588
diff
changeset
|
266 |
2092 | 267 tuple = playlist_get_tuple(playlist, pos); |
1401
3bc53d7f9012
[svn] - now filepopup_pointer_check_iter() returns immediately if cfg.show_filepopup_for_tuple is FALSE.
yaz
parents:
1389
diff
changeset
|
268 filepopup_show_for_tuple(tuple); |
1283
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
269 } |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
270 |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
271 return TRUE; |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
272 } |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
273 |
1267 | 274 void fileinfo_hide(gpointer unused) |
275 { | |
276 gtk_widget_hide(fileinfo_win); | |
277 | |
278 /* Clear it out. */ | |
279 fileinfo_entry_set_text("entry_title", ""); | |
280 fileinfo_entry_set_text("entry_artist", ""); | |
281 fileinfo_entry_set_text("entry_album", ""); | |
282 fileinfo_entry_set_text("entry_comment", ""); | |
283 fileinfo_entry_set_text("entry_genre", ""); | |
284 fileinfo_entry_set_text("entry_year", ""); | |
285 fileinfo_entry_set_text("entry_track", ""); | |
286 fileinfo_entry_set_text("entry_location", ""); | |
1307
63d30ae1db33
[svn] - reset the album art back to the default icon
nenolod
parents:
1306
diff
changeset
|
287 |
63d30ae1db33
[svn] - reset the album art back to the default icon
nenolod
parents:
1306
diff
changeset
|
288 fileinfo_entry_set_image("image_artwork", DATA_DIR "/images/audio.png"); |
1267 | 289 } |
290 | |
1283
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
291 void filepopup_hide(gpointer unused) |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
292 { |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
293 gtk_widget_hide(filepopup_win); |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
294 |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
295 filepopup_entry_set_text("label_title", ""); |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
296 filepopup_entry_set_text("label_artist", ""); |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
297 filepopup_entry_set_text("label_album", ""); |
1296 | 298 filepopup_entry_set_text("label_genre", ""); |
299 filepopup_entry_set_text("label_track", ""); | |
300 filepopup_entry_set_text("label_year", ""); | |
301 filepopup_entry_set_text("label_length", ""); | |
1297 | 302 |
1307
63d30ae1db33
[svn] - reset the album art back to the default icon
nenolod
parents:
1306
diff
changeset
|
303 |
1297 | 304 gtk_window_resize(GTK_WINDOW(filepopup_win), 1, 1); |
1283
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
305 } |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
306 |
1262 | 307 void |
308 create_fileinfo_window(void) | |
309 { | |
1263 | 310 const gchar *glade_file = DATA_DIR "/glade/fileinfo.glade"; |
1262 | 311 GladeXML *xml; |
312 GtkWidget *widget; | |
313 | |
314 xml = glade_xml_new_or_die(_("Track Information Window"), glade_file, NULL, NULL); | |
315 | |
316 glade_xml_signal_autoconnect(xml); | |
317 | |
318 fileinfo_win = glade_xml_get_widget(xml, "fileinfo_win"); | |
319 g_object_set_data(G_OBJECT(fileinfo_win), "glade-xml", xml); | |
320 gtk_window_set_transient_for(GTK_WINDOW(fileinfo_win), GTK_WINDOW(mainwin)); | |
321 | |
322 widget = glade_xml_get_widget(xml, "image_artwork"); | |
323 gtk_image_set_from_file(GTK_IMAGE(widget), DATA_DIR "/images/audio.png"); | |
1267 | 324 |
325 widget = glade_xml_get_widget(xml, "btn_close"); | |
326 g_signal_connect(G_OBJECT(widget), "clicked", (GCallback) fileinfo_hide, NULL); | |
1262 | 327 } |
328 | |
329 void | |
1283
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
330 create_filepopup_window(void) |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
331 { |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
332 const gchar *glade_file = DATA_DIR "/glade/fileinfo_popup.glade"; |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
333 GladeXML *xml; |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
334 GtkWidget *widget; |
1287
e778f43a74fb
[svn] - make tuples more verbose (they might be a bit big though)
nenolod
parents:
1286
diff
changeset
|
335 |
1283
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
336 xml = glade_xml_new_or_die(_("Track Information Popup"), glade_file, NULL, NULL); |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
337 |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
338 glade_xml_signal_autoconnect(xml); |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
339 |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
340 filepopup_win = glade_xml_get_widget(xml, "win_pl_popup"); |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
341 g_object_set_data(G_OBJECT(filepopup_win), "glade-xml", xml); |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
342 gtk_window_set_transient_for(GTK_WINDOW(filepopup_win), GTK_WINDOW(mainwin)); |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
343 |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
344 widget = glade_xml_get_widget(xml, "image_artwork"); |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
345 gtk_image_set_from_file(GTK_IMAGE(widget), DATA_DIR "/images/audio.png"); |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
346 |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
347 g_timeout_add(50, filepopup_pointer_check_iter, NULL); |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
348 } |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
349 |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
350 void |
1262 | 351 fileinfo_show_for_tuple(TitleInput *tuple) |
352 { | |
1402
1abfc389ecc6
[svn] fileinfo_show_for_tuple() sometimes causes "Invalid UTF-8 string"
yaz
parents:
1401
diff
changeset
|
353 gchar *tmp = NULL; |
1296 | 354 |
1262 | 355 if (tuple == NULL) |
356 return; | |
357 | |
358 gtk_widget_realize(fileinfo_win); | |
359 | |
1864 | 360 if (tuple->track_name) |
361 fileinfo_entry_set_text("entry_title", tuple->track_name); | |
362 if (tuple->performer) | |
363 fileinfo_entry_set_text("entry_artist", tuple->performer); | |
364 if (tuple->album_name) | |
365 fileinfo_entry_set_text("entry_album", tuple->album_name); | |
366 if (tuple->comment) | |
367 fileinfo_entry_set_text("entry_comment", tuple->comment); | |
368 if (tuple->genre) | |
369 fileinfo_entry_set_text("entry_genre", tuple->genre); | |
1402
1abfc389ecc6
[svn] fileinfo_show_for_tuple() sometimes causes "Invalid UTF-8 string"
yaz
parents:
1401
diff
changeset
|
370 |
1abfc389ecc6
[svn] fileinfo_show_for_tuple() sometimes causes "Invalid UTF-8 string"
yaz
parents:
1401
diff
changeset
|
371 tmp = g_strdup_printf("%s/%s", tuple->file_path, tuple->file_name); |
1abfc389ecc6
[svn] fileinfo_show_for_tuple() sometimes causes "Invalid UTF-8 string"
yaz
parents:
1401
diff
changeset
|
372 if(tmp){ |
1abfc389ecc6
[svn] fileinfo_show_for_tuple() sometimes causes "Invalid UTF-8 string"
yaz
parents:
1401
diff
changeset
|
373 fileinfo_entry_set_text_free("entry_location", str_to_utf8(tmp)); |
1abfc389ecc6
[svn] fileinfo_show_for_tuple() sometimes causes "Invalid UTF-8 string"
yaz
parents:
1401
diff
changeset
|
374 g_free(tmp); |
1abfc389ecc6
[svn] fileinfo_show_for_tuple() sometimes causes "Invalid UTF-8 string"
yaz
parents:
1401
diff
changeset
|
375 tmp = NULL; |
1abfc389ecc6
[svn] fileinfo_show_for_tuple() sometimes causes "Invalid UTF-8 string"
yaz
parents:
1401
diff
changeset
|
376 } |
1262 | 377 |
378 if (tuple->year != 0) | |
379 fileinfo_entry_set_text_free("entry_year", g_strdup_printf("%d", tuple->year)); | |
380 | |
381 if (tuple->track_number != 0) | |
382 fileinfo_entry_set_text_free("entry_track", g_strdup_printf("%d", tuple->track_number)); | |
383 | |
1889
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
384 tmp = fileinfo_recursive_get_image(tuple->file_path, tuple->file_name, 0); |
1371
ca4f3115d33c
[svn] - recursively locate album art, by external contributor Oliver Lumpton.
nenolod
parents:
1358
diff
changeset
|
385 |
ca4f3115d33c
[svn] - recursively locate album art, by external contributor Oliver Lumpton.
nenolod
parents:
1358
diff
changeset
|
386 if(tmp) |
ca4f3115d33c
[svn] - recursively locate album art, by external contributor Oliver Lumpton.
nenolod
parents:
1358
diff
changeset
|
387 { |
ca4f3115d33c
[svn] - recursively locate album art, by external contributor Oliver Lumpton.
nenolod
parents:
1358
diff
changeset
|
388 fileinfo_entry_set_image("image_artwork", tmp); |
ca4f3115d33c
[svn] - recursively locate album art, by external contributor Oliver Lumpton.
nenolod
parents:
1358
diff
changeset
|
389 g_free(tmp); |
ca4f3115d33c
[svn] - recursively locate album art, by external contributor Oliver Lumpton.
nenolod
parents:
1358
diff
changeset
|
390 } |
ca4f3115d33c
[svn] - recursively locate album art, by external contributor Oliver Lumpton.
nenolod
parents:
1358
diff
changeset
|
391 |
ca4f3115d33c
[svn] - recursively locate album art, by external contributor Oliver Lumpton.
nenolod
parents:
1358
diff
changeset
|
392 gtk_widget_show(fileinfo_win); |
ca4f3115d33c
[svn] - recursively locate album art, by external contributor Oliver Lumpton.
nenolod
parents:
1358
diff
changeset
|
393 } |
ca4f3115d33c
[svn] - recursively locate album art, by external contributor Oliver Lumpton.
nenolod
parents:
1358
diff
changeset
|
394 |
1413 | 395 static gboolean |
1889
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
396 has_front_cover_extension(const gchar *name) |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
397 { |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
398 char *ext; |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
399 |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
400 ext = strrchr(name, '.'); |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
401 if (!ext) { |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
402 /* No file extension */ |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
403 return FALSE; |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
404 } |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
405 |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
406 return g_strcasecmp(ext, ".jpg") == 0 || |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
407 g_strcasecmp(ext, ".jpeg") == 0 || |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
408 g_strcasecmp(ext, ".png") == 0; |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
409 } |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
410 |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
411 static gboolean |
1413 | 412 cover_name_filter(const gchar *name, const gchar *filter, const gboolean ret_on_empty) |
413 { | |
414 gboolean result = FALSE; | |
415 gchar **splitted; | |
416 gchar *current; | |
417 gchar *lname; | |
418 gint i; | |
419 | |
420 if (!filter || strlen(filter) == 0) { | |
421 return ret_on_empty; | |
422 } | |
423 | |
424 splitted = g_strsplit(filter, ",", 0); | |
425 | |
426 lname = g_strdup(name); | |
427 g_strdown(lname); | |
428 | |
429 for (i = 0; !result && (current = splitted[i]); i++) { | |
430 gchar *stripped = g_strstrip(g_strdup(current)); | |
431 g_strdown(stripped); | |
432 | |
433 result = result || strstr(lname, stripped); | |
434 | |
435 g_free(stripped); | |
436 } | |
437 | |
438 g_free(lname); | |
439 g_strfreev(splitted); | |
440 | |
441 return result; | |
442 } | |
443 | |
444 /* Check wether it's an image we want */ | |
445 static gboolean | |
1889
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
446 is_front_cover_image(const gchar *imgfile) |
1413 | 447 { |
1889
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
448 return cover_name_filter(imgfile, cfg.cover_name_include, TRUE) && |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
449 !cover_name_filter(imgfile, cfg.cover_name_exclude, FALSE); |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
450 } |
1413 | 451 |
1889
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
452 static gboolean |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
453 is_file_image(const gchar *imgfile, const gchar *file_name) |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
454 { |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
455 char *imgfile_ext, *file_name_ext; |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
456 size_t imgfile_len, file_name_len; |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
457 gboolean matches; |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
458 |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
459 imgfile_ext = strrchr(imgfile, '.'); |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
460 if (!imgfile_ext) { |
1413 | 461 /* No file extension */ |
462 return FALSE; | |
463 } | |
464 | |
1889
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
465 file_name_ext = strrchr(file_name, '.'); |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
466 if (!file_name_ext) { |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
467 /* No file extension */ |
1413 | 468 return FALSE; |
469 } | |
470 | |
1889
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
471 imgfile_len = (imgfile_ext - imgfile); |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
472 file_name_len = (file_name_ext - file_name); |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
473 |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
474 if (imgfile_len == file_name_len) { |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
475 return (g_ascii_strncasecmp(imgfile, file_name, imgfile_len) == 0); |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
476 } else { |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
477 return FALSE; |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
478 } |
1413 | 479 } |
480 | |
1371
ca4f3115d33c
[svn] - recursively locate album art, by external contributor Oliver Lumpton.
nenolod
parents:
1358
diff
changeset
|
481 gchar* |
1889
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
482 fileinfo_recursive_get_image(const gchar* path, |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
483 const gchar* file_name, gint depth) |
1371
ca4f3115d33c
[svn] - recursively locate album art, by external contributor Oliver Lumpton.
nenolod
parents:
1358
diff
changeset
|
484 { |
ca4f3115d33c
[svn] - recursively locate album art, by external contributor Oliver Lumpton.
nenolod
parents:
1358
diff
changeset
|
485 GDir *d; |
ca4f3115d33c
[svn] - recursively locate album art, by external contributor Oliver Lumpton.
nenolod
parents:
1358
diff
changeset
|
486 |
1429
a360afd8df52
[svn] Make annoying recursion that consistently returns wrong art, optional.
nemo
parents:
1413
diff
changeset
|
487 if (cfg.recurse_for_cover && depth > cfg.recurse_for_cover_depth) |
1371
ca4f3115d33c
[svn] - recursively locate album art, by external contributor Oliver Lumpton.
nenolod
parents:
1358
diff
changeset
|
488 return NULL; |
ca4f3115d33c
[svn] - recursively locate album art, by external contributor Oliver Lumpton.
nenolod
parents:
1358
diff
changeset
|
489 |
ca4f3115d33c
[svn] - recursively locate album art, by external contributor Oliver Lumpton.
nenolod
parents:
1358
diff
changeset
|
490 d = g_dir_open(path, 0, NULL); |
ca4f3115d33c
[svn] - recursively locate album art, by external contributor Oliver Lumpton.
nenolod
parents:
1358
diff
changeset
|
491 |
1666
77baac5f7439
[svn] - make fileinfo_recursive_get_image() breadth first search.
yaz
parents:
1611
diff
changeset
|
492 if (d) { |
1889
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
493 const gchar *f; |
1413 | 494 |
1889
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
495 if (cfg.use_file_cover && file_name) { |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
496 /* Look for images matching file name */ |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
497 while(f = g_dir_read_name(d)) { |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
498 gchar *newpath = g_strconcat(path, "/", f, NULL); |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
499 |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
500 if (!g_file_test(newpath, G_FILE_TEST_IS_DIR) && |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
501 has_front_cover_extension(f) && |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
502 is_file_image(f, file_name)) { |
1666
77baac5f7439
[svn] - make fileinfo_recursive_get_image() breadth first search.
yaz
parents:
1611
diff
changeset
|
503 g_dir_close(d); |
77baac5f7439
[svn] - make fileinfo_recursive_get_image() breadth first search.
yaz
parents:
1611
diff
changeset
|
504 return newpath; |
1371
ca4f3115d33c
[svn] - recursively locate album art, by external contributor Oliver Lumpton.
nenolod
parents:
1358
diff
changeset
|
505 } |
1889
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
506 |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
507 g_free(newpath); |
1306
d44e5df149dc
[svn] - not sure what all of that cur_dir stuff was, but I think somebody was smoking crack
nenolod
parents:
1304
diff
changeset
|
508 } |
1889
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
509 g_dir_rewind(d); |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
510 } |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
511 |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
512 /* Search for files using filter */ |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
513 while (f = g_dir_read_name(d)) { |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
514 gchar *newpath = g_strconcat(path, "/", f, NULL); |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
515 |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
516 if (!g_file_test(newpath, G_FILE_TEST_IS_DIR) && |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
517 has_front_cover_extension(f) && |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
518 is_front_cover_image(f)) { |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
519 g_dir_close(d); |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
520 return newpath; |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
521 } |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
522 |
1666
77baac5f7439
[svn] - make fileinfo_recursive_get_image() breadth first search.
yaz
parents:
1611
diff
changeset
|
523 g_free(newpath); |
1303 | 524 } |
1889
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
525 g_dir_rewind(d); |
1666
77baac5f7439
[svn] - make fileinfo_recursive_get_image() breadth first search.
yaz
parents:
1611
diff
changeset
|
526 |
77baac5f7439
[svn] - make fileinfo_recursive_get_image() breadth first search.
yaz
parents:
1611
diff
changeset
|
527 /* checks whether recursive or not. */ |
1889
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
528 if (!cfg.recurse_for_cover) { |
1666
77baac5f7439
[svn] - make fileinfo_recursive_get_image() breadth first search.
yaz
parents:
1611
diff
changeset
|
529 g_dir_close(d); |
77baac5f7439
[svn] - make fileinfo_recursive_get_image() breadth first search.
yaz
parents:
1611
diff
changeset
|
530 return NULL; |
77baac5f7439
[svn] - make fileinfo_recursive_get_image() breadth first search.
yaz
parents:
1611
diff
changeset
|
531 } |
77baac5f7439
[svn] - make fileinfo_recursive_get_image() breadth first search.
yaz
parents:
1611
diff
changeset
|
532 |
1889
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
533 /* Descend into directories recursively. */ |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
534 while (f = g_dir_read_name(d)) { |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
535 gchar *newpath = g_strconcat(path, "/", f, NULL); |
1666
77baac5f7439
[svn] - make fileinfo_recursive_get_image() breadth first search.
yaz
parents:
1611
diff
changeset
|
536 |
77baac5f7439
[svn] - make fileinfo_recursive_get_image() breadth first search.
yaz
parents:
1611
diff
changeset
|
537 if(g_file_test(newpath, G_FILE_TEST_IS_DIR)) { |
1889
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
538 gchar *tmp = fileinfo_recursive_get_image(newpath, |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
539 NULL, depth + 1); |
1666
77baac5f7439
[svn] - make fileinfo_recursive_get_image() breadth first search.
yaz
parents:
1611
diff
changeset
|
540 if(tmp) { |
77baac5f7439
[svn] - make fileinfo_recursive_get_image() breadth first search.
yaz
parents:
1611
diff
changeset
|
541 g_free(newpath); |
77baac5f7439
[svn] - make fileinfo_recursive_get_image() breadth first search.
yaz
parents:
1611
diff
changeset
|
542 g_dir_close(d); |
77baac5f7439
[svn] - make fileinfo_recursive_get_image() breadth first search.
yaz
parents:
1611
diff
changeset
|
543 return tmp; |
77baac5f7439
[svn] - make fileinfo_recursive_get_image() breadth first search.
yaz
parents:
1611
diff
changeset
|
544 } |
77baac5f7439
[svn] - make fileinfo_recursive_get_image() breadth first search.
yaz
parents:
1611
diff
changeset
|
545 } |
1889
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
546 |
1666
77baac5f7439
[svn] - make fileinfo_recursive_get_image() breadth first search.
yaz
parents:
1611
diff
changeset
|
547 g_free(newpath); |
77baac5f7439
[svn] - make fileinfo_recursive_get_image() breadth first search.
yaz
parents:
1611
diff
changeset
|
548 } |
77baac5f7439
[svn] - make fileinfo_recursive_get_image() breadth first search.
yaz
parents:
1611
diff
changeset
|
549 |
1306
d44e5df149dc
[svn] - not sure what all of that cur_dir stuff was, but I think somebody was smoking crack
nenolod
parents:
1304
diff
changeset
|
550 g_dir_close(d); |
1889
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
551 } |
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
552 |
1371
ca4f3115d33c
[svn] - recursively locate album art, by external contributor Oliver Lumpton.
nenolod
parents:
1358
diff
changeset
|
553 return NULL; |
1262 | 554 } |
1267 | 555 |
556 void | |
1283
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
557 filepopup_show_for_tuple(TitleInput *tuple) |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
558 { |
2006
beaeb1990cb4
[svn] - now filepopup can find newly added images immediately.
yaz
parents:
1964
diff
changeset
|
559 gchar *tmp = NULL; |
1312 | 560 gint x, y, x_off = 3, y_off = 3, h, w; |
1296 | 561 |
1889
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
562 static gchar *last_artwork = NULL; |
2006
beaeb1990cb4
[svn] - now filepopup can find newly added images immediately.
yaz
parents:
1964
diff
changeset
|
563 const static char default_artwork[] = DATA_DIR "/images/audio.png"; |
1710 | 564 |
1283
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
565 if (tuple == NULL) |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
566 return; |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
567 |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
568 gtk_widget_realize(filepopup_win); |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
569 |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
570 filepopup_entry_set_text("label_title", tuple->track_name); |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
571 filepopup_entry_set_text("label_artist", tuple->performer); |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
572 filepopup_entry_set_text("label_album", tuple->album_name); |
1287
e778f43a74fb
[svn] - make tuples more verbose (they might be a bit big though)
nenolod
parents:
1286
diff
changeset
|
573 filepopup_entry_set_text("label_genre", tuple->genre); |
1309
816ea8bbde1c
[svn] - if tuple->length == -1 then don't show a length
nenolod
parents:
1307
diff
changeset
|
574 |
816ea8bbde1c
[svn] - if tuple->length == -1 then don't show a length
nenolod
parents:
1307
diff
changeset
|
575 if (tuple->length != -1) |
816ea8bbde1c
[svn] - if tuple->length == -1 then don't show a length
nenolod
parents:
1307
diff
changeset
|
576 filepopup_entry_set_text_free("label_length", g_strdup_printf("%d:%02d", tuple->length / 60000, (tuple->length / 1000) % 60)); |
1287
e778f43a74fb
[svn] - make tuples more verbose (they might be a bit big though)
nenolod
parents:
1286
diff
changeset
|
577 |
e778f43a74fb
[svn] - make tuples more verbose (they might be a bit big though)
nenolod
parents:
1286
diff
changeset
|
578 if (tuple->year != 0) |
e778f43a74fb
[svn] - make tuples more verbose (they might be a bit big though)
nenolod
parents:
1286
diff
changeset
|
579 filepopup_entry_set_text_free("label_year", g_strdup_printf("%d", tuple->year)); |
e778f43a74fb
[svn] - make tuples more verbose (they might be a bit big though)
nenolod
parents:
1286
diff
changeset
|
580 |
e778f43a74fb
[svn] - make tuples more verbose (they might be a bit big though)
nenolod
parents:
1286
diff
changeset
|
581 if (tuple->track_number != 0) |
e778f43a74fb
[svn] - make tuples more verbose (they might be a bit big though)
nenolod
parents:
1286
diff
changeset
|
582 filepopup_entry_set_text_free("label_track", g_strdup_printf("%d", tuple->track_number)); |
1283
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
583 |
2006
beaeb1990cb4
[svn] - now filepopup can find newly added images immediately.
yaz
parents:
1964
diff
changeset
|
584 tmp = fileinfo_recursive_get_image(tuple->file_path, tuple->file_name, 0); |
beaeb1990cb4
[svn] - now filepopup can find newly added images immediately.
yaz
parents:
1964
diff
changeset
|
585 if (tmp) { // picture found |
beaeb1990cb4
[svn] - now filepopup can find newly added images immediately.
yaz
parents:
1964
diff
changeset
|
586 if (!last_artwork || strcmp(last_artwork, tmp)) { // new picture |
beaeb1990cb4
[svn] - now filepopup can find newly added images immediately.
yaz
parents:
1964
diff
changeset
|
587 filepopup_entry_set_image("image_artwork", tmp); |
1964
f027afc2ca2e
[svn] - avoid freeing a NULL pointer in ui_fileinfo.c
nenolod
parents:
1960
diff
changeset
|
588 g_free(last_artwork); |
2006
beaeb1990cb4
[svn] - now filepopup can find newly added images immediately.
yaz
parents:
1964
diff
changeset
|
589 last_artwork = tmp; |
beaeb1990cb4
[svn] - now filepopup can find newly added images immediately.
yaz
parents:
1964
diff
changeset
|
590 } |
beaeb1990cb4
[svn] - now filepopup can find newly added images immediately.
yaz
parents:
1964
diff
changeset
|
591 else { // same picture |
1710 | 592 } |
1296 | 593 } |
2006
beaeb1990cb4
[svn] - now filepopup can find newly added images immediately.
yaz
parents:
1964
diff
changeset
|
594 else { // no picture found |
beaeb1990cb4
[svn] - now filepopup can find newly added images immediately.
yaz
parents:
1964
diff
changeset
|
595 if (!last_artwork || strcmp(last_artwork, default_artwork)) { |
beaeb1990cb4
[svn] - now filepopup can find newly added images immediately.
yaz
parents:
1964
diff
changeset
|
596 filepopup_entry_set_image("image_artwork", default_artwork); |
beaeb1990cb4
[svn] - now filepopup can find newly added images immediately.
yaz
parents:
1964
diff
changeset
|
597 g_free(last_artwork); |
beaeb1990cb4
[svn] - now filepopup can find newly added images immediately.
yaz
parents:
1964
diff
changeset
|
598 last_artwork = g_strdup(default_artwork); |
beaeb1990cb4
[svn] - now filepopup can find newly added images immediately.
yaz
parents:
1964
diff
changeset
|
599 } |
beaeb1990cb4
[svn] - now filepopup can find newly added images immediately.
yaz
parents:
1964
diff
changeset
|
600 else { |
beaeb1990cb4
[svn] - now filepopup can find newly added images immediately.
yaz
parents:
1964
diff
changeset
|
601 } |
beaeb1990cb4
[svn] - now filepopup can find newly added images immediately.
yaz
parents:
1964
diff
changeset
|
602 } |
1889
597bd579d9af
[svn] Patch by Michael Hanselmann to fetch a per-song image file.
nemo
parents:
1864
diff
changeset
|
603 |
1312 | 604 gdk_window_get_pointer(NULL, &x, &y, NULL); |
605 gtk_window_get_size(GTK_WINDOW(filepopup_win), &w, &h); | |
606 if (gdk_screen_width()-(w+3) < x) x_off = (w*-1)-3; | |
607 if (gdk_screen_height()-(h+3) < y) y_off = (h*-1)-3; | |
608 gtk_window_move(GTK_WINDOW(filepopup_win), x + x_off, y + y_off); | |
609 | |
1283
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
610 gtk_widget_show(filepopup_win); |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
611 } |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
612 |
19b1d3f22e10
[svn] - when hovering over a playlist tuple, describe the tuple via a tooltip-like popup
nenolod
parents:
1270
diff
changeset
|
613 void |
1269 | 614 fileinfo_show_for_path(gchar *path) |
1267 | 615 { |
616 TitleInput *tuple = input_get_song_tuple(path); | |
617 | |
618 if (tuple == NULL) | |
1268 | 619 return input_file_info_box(path); |
1267 | 620 |
621 fileinfo_show_for_tuple(tuple); | |
622 | |
623 bmp_title_input_free(tuple); | |
1588
15d92c51bde6
[svn] - modified time (mtime) has been introduced into tuple
yaz
parents:
1541
diff
changeset
|
624 tuple = NULL; |
1267 | 625 } |