comparison audacious/ui_fileinfo.c @ 1262:186f774fa30b trunk

[svn] - ui_fileinfo goodness (not hooked up yet)
author nenolod
date Thu, 15 Jun 2006 21:54:44 -0700
parents
children ccf616f86fb4
comparison
equal deleted inserted replaced
1261:a1bd63b7b24f 1262:186f774fa30b
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
92 void
93 create_fileinfo_window(void)
94 {
95 const gchar *glade_file = DATA_DIR "/glade/fileinfo.xml";
96 GladeXML *xml;
97 GtkWidget *widget;
98
99 xml = glade_xml_new_or_die(_("Track Information Window"), glade_file, NULL, NULL);
100
101 glade_xml_signal_autoconnect(xml);
102
103 fileinfo_win = glade_xml_get_widget(xml, "fileinfo_win");
104 g_object_set_data(G_OBJECT(fileinfo_win), "glade-xml", xml);
105 gtk_window_set_transient_for(GTK_WINDOW(fileinfo_win), GTK_WINDOW(mainwin));
106
107 widget = glade_xml_get_widget(xml, "image_artwork");
108 gtk_image_set_from_file(GTK_IMAGE(widget), DATA_DIR "/images/audio.png");
109 }
110
111 void
112 fileinfo_show_for_tuple(TitleInput *tuple)
113 {
114 if (tuple == NULL)
115 return;
116
117 gtk_widget_realize(fileinfo_win);
118
119 fileinfo_entry_set_text("entry_title", tuple->track_name);
120 fileinfo_entry_set_text("entry_artist", tuple->performer);
121 fileinfo_entry_set_text("entry_album", tuple->album_name);
122 fileinfo_entry_set_text("entry_comment", tuple->comment);
123 fileinfo_entry_set_text("entry_genre", tuple->genre);
124
125 if (tuple->year != 0)
126 fileinfo_entry_set_text_free("entry_year", g_strdup_printf("%d", tuple->year));
127
128 if (tuple->track_number != 0)
129 fileinfo_entry_set_text_free("entry_track", g_strdup_printf("%d", tuple->track_number));
130
131 gtk_widget_show(fileinfo_win);
132 }