comparison src/xs_fileinfo.c @ 636:ea06356d792b

Show tags ("[!]" and "[*]") in fileinfo selector, if there is additional information for the subtune; Only list subtunes that have _some_ STIL information.
author Matti Hamalainen <ccr@tnsp.org>
date Tue, 04 Sep 2007 00:21:03 +0000
parents 248aa59cb6a3
children 0fb760355283
comparison
equal deleted inserted replaced
635:dcd9d179e217 636:ea06356d792b
120 120
121 static void xs_fileinfo_subtune(GtkWidget * widget, void *data) 121 static void xs_fileinfo_subtune(GtkWidget * widget, void *data)
122 { 122 {
123 t_xs_stil_subnode *tmpNode; 123 t_xs_stil_subnode *tmpNode;
124 GtkWidget *tmpText; 124 GtkWidget *tmpText;
125 gint tmpIndex;
126 gchar *subName, *subAuthor, *subInfo; 125 gchar *subName, *subAuthor, *subInfo;
127 126
128 (void) widget; 127 (void) widget;
129 (void) data; 128 (void) data;
130 129
135 gtk_text_set_point(GTK_TEXT(tmpText), 0); 134 gtk_text_set_point(GTK_TEXT(tmpText), 0);
136 gtk_text_forward_delete(GTK_TEXT(tmpText), gtk_text_get_length(GTK_TEXT(tmpText))); 135 gtk_text_forward_delete(GTK_TEXT(tmpText), gtk_text_get_length(GTK_TEXT(tmpText)));
137 #endif 136 #endif
138 137
139 /* Get subtune information */ 138 /* Get subtune information */
140 tmpIndex = g_list_index(GTK_MENU_SHELL(data)->children, gtk_menu_get_active(GTK_MENU(data))); 139 tmpNode = (t_xs_stil_subnode *) data;
141 140 if (!tmpNode && xs_fileinfostil)
142 if (xs_fileinfostil && tmpIndex <= xs_fileinfostil->nsubTunes) 141 tmpNode = xs_fileinfostil->subTunes[0];
143 tmpNode = xs_fileinfostil->subTunes[tmpIndex];
144 else
145 tmpNode = NULL;
146 142
147 if (tmpNode) { 143 if (tmpNode) {
148 subName = tmpNode->pName; 144 if (tmpNode->pName)
145 subName = tmpNode->pName;
146 else
147 subName = tmpNode->pTitle;
149 subAuthor = tmpNode->pAuthor; 148 subAuthor = tmpNode->pAuthor;
150 subInfo = tmpNode->pInfo; 149 subInfo = tmpNode->pInfo;
151 } else { 150 } else {
152 subName = NULL; 151 subName = NULL;
153 subAuthor = NULL; 152 subAuthor = NULL;
173 172
174 void xs_fileinfo(gchar * pcFilename) 173 void xs_fileinfo(gchar * pcFilename)
175 { 174 {
176 GtkWidget *tmpMenuItem, *tmpMenu, *tmpOptionMenu; 175 GtkWidget *tmpMenuItem, *tmpMenu, *tmpOptionMenu;
177 t_xs_tuneinfo *tmpInfo; 176 t_xs_tuneinfo *tmpInfo;
177 t_xs_stil_subnode *tmpNode;
178 gchar tmpStr[256], *tmpFilename; 178 gchar tmpStr[256], *tmpFilename;
179 gint n; 179 gint n;
180 180
181 /* Current implementation leaves old fileinfo window untouched if 181 /* Current implementation leaves old fileinfo window untouched if
182 * no information can be found for the new file. Hmm... 182 * no information can be found for the new file. Hmm...
183 */ 183 */
184 #ifdef AUDACIOUS_PLUGIN
185 xs_get_trackinfo(pcFilename, &tmpFilename, &n);
186 #else
187 tmpFilename = pcFilename;
188 #endif
184 189
185 /* Get new tune information */ 190 /* Get new tune information */
186 XS_MUTEX_LOCK(xs_fileinfowin); 191 XS_MUTEX_LOCK(xs_fileinfowin);
187 XS_MUTEX_LOCK(xs_status); 192 XS_MUTEX_LOCK(xs_status);
188 if ((tmpInfo = xs_status.sidPlayer->plrGetSIDInfo(pcFilename)) == NULL) { 193 if ((tmpInfo = xs_status.sidPlayer->plrGetSIDInfo(tmpFilename)) == NULL) {
189 XS_MUTEX_UNLOCK(xs_fileinfowin); 194 XS_MUTEX_UNLOCK(xs_fileinfowin);
190 XS_MUTEX_UNLOCK(xs_status); 195 XS_MUTEX_UNLOCK(xs_status);
191 return; 196 return;
192 } 197 }
193 XS_MUTEX_UNLOCK(xs_status); 198 XS_MUTEX_UNLOCK(xs_status);
194 199
195 xs_fileinfostil = xs_stil_get(pcFilename); 200 xs_fileinfostil = xs_stil_get(tmpFilename);
201
202 #ifdef AUDACIOUS_PLUGIN
203 g_free(tmpFilename);
204 #endif
196 205
197 /* Check if there already is an open fileinfo window */ 206 /* Check if there already is an open fileinfo window */
198 if (xs_fileinfowin) 207 if (xs_fileinfowin)
199 gdk_window_raise(xs_fileinfowin->window); 208 gdk_window_raise(xs_fileinfowin->window);
200 else { 209 else {
224 233
225 /* Main tune - the pseudo tune */ 234 /* Main tune - the pseudo tune */
226 tmpMenuItem = gtk_menu_item_new_with_label(_("General info")); 235 tmpMenuItem = gtk_menu_item_new_with_label(_("General info"));
227 gtk_widget_show(tmpMenuItem); 236 gtk_widget_show(tmpMenuItem);
228 gtk_menu_append(GTK_MENU(tmpMenu), tmpMenuItem); 237 gtk_menu_append(GTK_MENU(tmpMenu), tmpMenuItem);
229 XS_SIGNAL_CONNECT(tmpMenuItem, "activate", xs_fileinfo_subtune, tmpMenu); 238 if (xs_fileinfostil)
239 tmpNode = xs_fileinfostil->subTunes[0];
240 else
241 tmpNode = NULL;
242 XS_SIGNAL_CONNECT(tmpMenuItem, "activate", xs_fileinfo_subtune, tmpNode);
230 243
231 /* Other menu items */ 244 /* Other menu items */
232 for (n = 1; n <= tmpInfo->nsubTunes; n++) { 245 for (n = 1; n <= tmpInfo->nsubTunes; n++) {
233 if (xs_fileinfostil && n <= xs_fileinfostil->nsubTunes && xs_fileinfostil->subTunes[n]) { 246 if (xs_fileinfostil && n <= xs_fileinfostil->nsubTunes && xs_fileinfostil->subTunes[n]) {
234 t_xs_stil_subnode *tmpNode = xs_fileinfostil->subTunes[n]; 247 gboolean isSet = FALSE;
248 tmpNode = xs_fileinfostil->subTunes[n];
235 249
236 g_snprintf(tmpStr, sizeof(tmpStr), _("Tune #%i: "), n); 250 g_snprintf(tmpStr, sizeof(tmpStr), _("Tune #%i: "), n);
237 251
238 if (tmpNode->pName) 252 if (tmpNode->pName) {
239 xs_pnstrcat(tmpStr, sizeof(tmpStr), tmpNode->pName); 253 xs_pnstrcat(tmpStr, sizeof(tmpStr), tmpNode->pName);
240 else if (tmpNode->pTitle) 254 isSet = TRUE;
241 xs_pnstrcat(tmpStr, sizeof(tmpStr), tmpNode->pTitle); 255 }
242 else if (tmpNode->pInfo) 256
243 xs_pnstrcat(tmpStr, sizeof(tmpStr), tmpNode->pInfo); 257 if (tmpNode->pTitle) {
244 else 258 xs_pnstrcat(tmpStr, sizeof(tmpStr),
259 isSet ? " [*]" : tmpNode->pTitle);
260 isSet = TRUE;
261 }
262
263 if (tmpNode->pInfo) {
264 xs_pnstrcat(tmpStr, sizeof(tmpStr),
265 isSet ? " [!]" : tmpNode->pInfo);
266 isSet = TRUE;
267 }
268
269 if (!isSet)
245 xs_pnstrcat(tmpStr, sizeof(tmpStr), "---"); 270 xs_pnstrcat(tmpStr, sizeof(tmpStr), "---");
246 } else { 271
247 g_snprintf(tmpStr, sizeof(tmpStr), _("Tune #%i"), n); 272 tmpMenuItem = gtk_menu_item_new_with_label(tmpStr);
273 gtk_widget_show(tmpMenuItem);
274 gtk_menu_append(GTK_MENU(tmpMenu), tmpMenuItem);
275 XS_SIGNAL_CONNECT(tmpMenuItem, "activate", xs_fileinfo_subtune, tmpNode);
248 } 276 }
249 277
250 tmpMenuItem = gtk_menu_item_new_with_label(tmpStr);
251 gtk_widget_show(tmpMenuItem);
252 gtk_menu_append(GTK_MENU(tmpMenu), tmpMenuItem);
253 XS_SIGNAL_CONNECT(tmpMenuItem, "activate", xs_fileinfo_subtune, tmpMenu);
254 } 278 }
255 279
256 gtk_option_menu_set_menu(GTK_OPTION_MENU(tmpOptionMenu), tmpMenu); 280 gtk_option_menu_set_menu(GTK_OPTION_MENU(tmpOptionMenu), tmpMenu);
257 gtk_widget_show(tmpOptionMenu); 281 gtk_widget_show(tmpOptionMenu);
258 282
259 /* Set the subtune information */ 283 /* Set the subtune information */
260 xs_fileinfo_subtune(NULL, tmpMenu); 284 xs_fileinfo_subtune(tmpOptionMenu, NULL);
261 285
262 /* Free temporary tuneinfo */ 286 /* Free temporary tuneinfo */
263 xs_tuneinfo_free(tmpInfo); 287 xs_tuneinfo_free(tmpInfo);
264 288
265 /* Show the window */ 289 /* Show the window */