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
|
|
8 * the Free Software Foundation; either version 2 of the License, or
|
|
9 * (at your option) any later version.
|
|
10 *
|
|
11 * This program is distributed in the hope that it will be useful,
|
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 * GNU General Public License for more details.
|
|
15 *
|
|
16 * You should have received a copy of the GNU General Public License
|
|
17 * along with this program; if not, write to the Free Software
|
|
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, 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"
|
|
45 #include "general.h"
|
|
46 #include "output.h"
|
|
47 #include "visualization.h"
|
|
48
|
|
49 #include "main.h"
|
|
50 #include "skin.h"
|
|
51 #include "urldecode.h"
|
|
52 #include "util.h"
|
|
53 #include "dnd.h"
|
|
54 #include "libaudacious/configdb.h"
|
|
55 #include "libaudacious/titlestring.h"
|
|
56
|
|
57 #include "mainwin.h"
|
|
58 #include "ui_playlist.h"
|
|
59 #include "skinwin.h"
|
|
60 #include "playlist_list.h"
|
|
61 #include "build_stamp.h"
|
|
62 #include "ui_fileinfo.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
|
1267
|
92 void fileinfo_hide(gpointer unused)
|
|
93 {
|
|
94 gtk_widget_hide(fileinfo_win);
|
|
95
|
|
96 /* Clear it out. */
|
|
97 fileinfo_entry_set_text("entry_title", "");
|
|
98 fileinfo_entry_set_text("entry_artist", "");
|
|
99 fileinfo_entry_set_text("entry_album", "");
|
|
100 fileinfo_entry_set_text("entry_comment", "");
|
|
101 fileinfo_entry_set_text("entry_genre", "");
|
|
102 fileinfo_entry_set_text("entry_year", "");
|
|
103 fileinfo_entry_set_text("entry_track", "");
|
|
104 fileinfo_entry_set_text("entry_location", "");
|
|
105 }
|
|
106
|
1262
|
107 void
|
|
108 create_fileinfo_window(void)
|
|
109 {
|
1263
|
110 const gchar *glade_file = DATA_DIR "/glade/fileinfo.glade";
|
1262
|
111 GladeXML *xml;
|
|
112 GtkWidget *widget;
|
|
113
|
|
114 xml = glade_xml_new_or_die(_("Track Information Window"), glade_file, NULL, NULL);
|
|
115
|
|
116 glade_xml_signal_autoconnect(xml);
|
|
117
|
|
118 fileinfo_win = glade_xml_get_widget(xml, "fileinfo_win");
|
|
119 g_object_set_data(G_OBJECT(fileinfo_win), "glade-xml", xml);
|
|
120 gtk_window_set_transient_for(GTK_WINDOW(fileinfo_win), GTK_WINDOW(mainwin));
|
|
121
|
|
122 widget = glade_xml_get_widget(xml, "image_artwork");
|
|
123 gtk_image_set_from_file(GTK_IMAGE(widget), DATA_DIR "/images/audio.png");
|
1267
|
124
|
|
125 widget = glade_xml_get_widget(xml, "btn_close");
|
|
126 g_signal_connect(G_OBJECT(widget), "clicked", (GCallback) fileinfo_hide, NULL);
|
1262
|
127 }
|
|
128
|
|
129 void
|
|
130 fileinfo_show_for_tuple(TitleInput *tuple)
|
|
131 {
|
|
132 if (tuple == NULL)
|
|
133 return;
|
|
134
|
|
135 gtk_widget_realize(fileinfo_win);
|
|
136
|
|
137 fileinfo_entry_set_text("entry_title", tuple->track_name);
|
|
138 fileinfo_entry_set_text("entry_artist", tuple->performer);
|
|
139 fileinfo_entry_set_text("entry_album", tuple->album_name);
|
|
140 fileinfo_entry_set_text("entry_comment", tuple->comment);
|
|
141 fileinfo_entry_set_text("entry_genre", tuple->genre);
|
1270
|
142 fileinfo_entry_set_text_free("entry_location", g_strdup_printf("%s/%s", tuple->file_path, tuple->file_name));
|
1262
|
143
|
|
144 if (tuple->year != 0)
|
|
145 fileinfo_entry_set_text_free("entry_year", g_strdup_printf("%d", tuple->year));
|
|
146
|
|
147 if (tuple->track_number != 0)
|
|
148 fileinfo_entry_set_text_free("entry_track", g_strdup_printf("%d", tuple->track_number));
|
|
149
|
|
150 gtk_widget_show(fileinfo_win);
|
|
151 }
|
1267
|
152
|
|
153 void
|
1269
|
154 fileinfo_show_for_path(gchar *path)
|
1267
|
155 {
|
|
156 TitleInput *tuple = input_get_song_tuple(path);
|
|
157
|
|
158 if (tuple == NULL)
|
1268
|
159 return input_file_info_box(path);
|
1267
|
160
|
|
161 fileinfo_show_for_tuple(tuple);
|
|
162
|
|
163 bmp_title_input_free(tuple);
|
|
164 }
|