Mercurial > audlegacy
annotate src/audacious/ui_fileinfo.c @ 3395:df609e7e7bcf
updated romanian translation
| author | Cristi Magherusan <majeru@atheme-project.org> |
|---|---|
| date | Sun, 26 Aug 2007 03:06:40 +0300 |
| parents | f985357757e0 |
| children | 602ec8c40d0d |
| 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 | |
|
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
183 fileinfo_entry_set_text("entry_title", tuple_get_string(tuple, "title")); |
|
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
184 fileinfo_entry_set_text("entry_artist", tuple_get_string(tuple, "artist")); |
|
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
185 fileinfo_entry_set_text("entry_album", tuple_get_string(tuple, "album")); |
|
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
186 fileinfo_entry_set_text("entry_comment", tuple_get_string(tuple, "comment")); |
|
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
187 fileinfo_entry_set_text("entry_genre", tuple_get_string(tuple, "genre")); |
| 2313 | 188 |
|
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
189 tmp = g_strdup_printf("%s/%s", tuple_get_string(tuple, "file-path"), tuple_get_string(tuple, "file-name")); |
| 2313 | 190 if(tmp){ |
| 191 fileinfo_entry_set_text_free("entry_location", str_to_utf8(tmp)); | |
| 192 g_free(tmp); | |
| 193 tmp = NULL; | |
| 194 } | |
| 195 | |
|
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
196 if (tuple_get_int(tuple, "year")) |
|
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
197 fileinfo_entry_set_text_free("entry_year", g_strdup_printf("%d", tuple_get_int(tuple, "year"))); |
| 2313 | 198 |
|
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
199 if (tuple_get_int(tuple, "track-number")) |
|
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
200 fileinfo_entry_set_text_free("entry_track", g_strdup_printf("%d", tuple_get_int(tuple, "track-number"))); |
| 2313 | 201 |
|
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
202 tmp = fileinfo_recursive_get_image(tuple_get_string(tuple, "file-path"), tuple_get_string(tuple, "file-name"), 0); |
| 2313 | 203 |
| 204 if(tmp) | |
| 205 { | |
| 206 fileinfo_entry_set_image("image_artwork", tmp); | |
| 207 g_free(tmp); | |
| 208 } | |
| 209 | |
| 210 gtk_widget_show(fileinfo_win); | |
| 211 } | |
| 212 | |
| 213 void | |
| 214 fileinfo_show_for_path(gchar *path) | |
| 215 { | |
|
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
216 Tuple *tuple = input_get_song_tuple(path); |
| 2313 | 217 |
| 218 if (tuple == NULL) | |
| 219 return input_file_info_box(path); | |
| 220 | |
| 221 fileinfo_show_for_tuple(tuple); | |
| 222 | |
|
3298
f985357757e0
audacious-core: convert to tuple-ng, remove titlestring API.
William Pitcock <nenolod@atheme-project.org>
parents:
3123
diff
changeset
|
223 mowgli_object_unref(tuple); |
| 2313 | 224 } |
