comparison src/xs_fileinfo.c @ 615:8fe2e757fa4a

Fixed sub-tune info selection box in fileinfo window.
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 02 Sep 2007 19:57:03 +0000
parents 52a6c114e505
children d7389ea52113
comparison
equal deleted inserted replaced
614:52a6c114e505 615:8fe2e757fa4a
215 215
216 216
217 static void xs_fileinfo_subtune(GtkWidget * widget, void *data) 217 static void xs_fileinfo_subtune(GtkWidget * widget, void *data)
218 { 218 {
219 t_xs_stil_subnode *tmpNode; 219 t_xs_stil_subnode *tmpNode;
220 GtkWidget *tmpItem, *tmpText; 220 GtkWidget *tmpText;
221 gint tmpIndex; 221 gint tmpIndex;
222 gchar *subName, *subAuthor; 222 gchar *subName, *subAuthor, *subInfo;
223 223
224 (void) widget; 224 (void) widget;
225 (void) data; 225 (void) data;
226 226
227 /* Freeze text-widget and delete the old text */ 227 /* Freeze text-widget and delete the old text */
229 gtk_text_freeze(GTK_TEXT(tmpText)); 229 gtk_text_freeze(GTK_TEXT(tmpText));
230 gtk_text_set_point(GTK_TEXT(tmpText), 0); 230 gtk_text_set_point(GTK_TEXT(tmpText), 0);
231 gtk_text_forward_delete(GTK_TEXT(tmpText), gtk_text_get_length(GTK_TEXT(tmpText))); 231 gtk_text_forward_delete(GTK_TEXT(tmpText), gtk_text_get_length(GTK_TEXT(tmpText)));
232 232
233 /* Get subtune information */ 233 /* Get subtune information */
234 tmpItem = gtk_menu_get_active(GTK_MENU(data)); 234 tmpIndex = g_list_index(GTK_MENU_SHELL(data)->children, gtk_menu_get_active(GTK_MENU(data)));
235 tmpIndex = g_list_index(GTK_MENU_SHELL(data)->children, tmpItem); 235
236
237 if (xs_fileinfostil && tmpIndex <= xs_fileinfostil->nsubTunes) 236 if (xs_fileinfostil && tmpIndex <= xs_fileinfostil->nsubTunes)
238 tmpNode = xs_fileinfostil->subTunes[tmpIndex]; 237 tmpNode = xs_fileinfostil->subTunes[tmpIndex];
239 else 238 else
240 tmpNode = NULL; 239 tmpNode = NULL;
241 240
242 if (tmpNode) { 241 if (tmpNode) {
243 subName = tmpNode->pName; 242 subName = tmpNode->pName;
244 subAuthor = tmpNode->pAuthor; 243 subAuthor = tmpNode->pAuthor;
245 244 subInfo = tmpNode->pInfo;
246 if (tmpNode->pInfo) {
247 gtk_text_insert(GTK_TEXT(tmpText), NULL, NULL, NULL,
248 tmpNode->pInfo, strlen(tmpNode->pInfo));
249 }
250 } else { 245 } else {
251 subName = NULL; 246 subName = NULL;
252 subAuthor = NULL; 247 subAuthor = NULL;
248 subInfo = NULL;
253 } 249 }
254 250
255 /* Get and set subtune information */ 251 /* Get and set subtune information */
256 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_sub_name")), subName ? subName : ""); 252 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_sub_name")), subName ? subName : "");
257 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_sub_author")), subAuthor ? subAuthor : ""); 253 gtk_entry_set_text(GTK_ENTRY(LUW("fileinfo_sub_author")), subAuthor ? subAuthor : "");
254 gtk_text_insert(GTK_TEXT(tmpText), NULL, NULL, NULL,
255 subInfo ? subInfo : "", -1);
258 256
259 /* Un-freeze the widget */ 257 /* Un-freeze the widget */
260 gtk_text_thaw(GTK_TEXT(tmpText)); 258 gtk_text_thaw(GTK_TEXT(tmpText));
261 } 259 }
262 260
263 261
264 void xs_fileinfo(gchar * pcFilename) 262 void xs_fileinfo(gchar * pcFilename)
265 { 263 {
266 GtkWidget *tmpMenuItem, *tmpMenu, *tmpOptionMenu; 264 GtkWidget *tmpMenuItem, *tmpMenu, *tmpOptionMenu;
267 t_xs_tuneinfo *tmpInfo; 265 t_xs_tuneinfo *tmpInfo;
266 gchar tmpStr[256];
268 gint n; 267 gint n;
269 268
270 /* Current implementation leaves old fileinfo window untouched if 269 /* Current implementation leaves old fileinfo window untouched if
271 * no information can be found for the new file. Hmm... 270 * no information can be found for the new file. Hmm...
272 */ 271 */
286 /* Check if there already is an open fileinfo window */ 285 /* Check if there already is an open fileinfo window */
287 if (xs_fileinfowin) 286 if (xs_fileinfowin)
288 gdk_window_raise(xs_fileinfowin->window); 287 gdk_window_raise(xs_fileinfowin->window);
289 else { 288 else {
290 xs_fileinfowin = create_xs_fileinfowin(); 289 xs_fileinfowin = create_xs_fileinfowin();
291 gtk_signal_connect( 290 gtk_signal_connect(GTK_OBJECT(
292 GTK_OBJECT(gtk_range_get_adjustment(GTK_RANGE(LUW("fileinfo_subctrl_adj")))), 291 gtk_range_get_adjustment(GTK_RANGE(LUW("fileinfo_subctrl_adj")))), "value_changed",
293 "value_changed", GTK_SIGNAL_FUNC(xs_fileinfo_setsong), NULL); 292 GTK_SIGNAL_FUNC(xs_fileinfo_setsong), NULL);
294 } 293 }
295 294
296 /* Delete current items */ 295 /* Delete current items */
297 tmpOptionMenu = LUW("fileinfo_sub_tune"); 296 tmpOptionMenu = LUW("fileinfo_sub_tune");
298 tmpMenu = gtk_option_menu_get_menu(GTK_OPTION_MENU(tmpOptionMenu)); 297 tmpMenu = gtk_option_menu_get_menu(GTK_OPTION_MENU(tmpOptionMenu));
315 gtk_signal_connect(GTK_OBJECT(tmpMenuItem), "activate", 314 gtk_signal_connect(GTK_OBJECT(tmpMenuItem), "activate",
316 GTK_SIGNAL_FUNC(xs_fileinfo_subtune), tmpMenu); 315 GTK_SIGNAL_FUNC(xs_fileinfo_subtune), tmpMenu);
317 316
318 /* Other menu items */ 317 /* Other menu items */
319 for (n = 1; n <= tmpInfo->nsubTunes; n++) { 318 for (n = 1; n <= tmpInfo->nsubTunes; n++) {
320 gchar tmpStr[64];
321 if (xs_fileinfostil && n <= xs_fileinfostil->nsubTunes && xs_fileinfostil->subTunes[n]) { 319 if (xs_fileinfostil && n <= xs_fileinfostil->nsubTunes && xs_fileinfostil->subTunes[n]) {
322 t_xs_stil_subnode *tmpNode = xs_fileinfostil->subTunes[n]; 320 t_xs_stil_subnode *tmpNode = xs_fileinfostil->subTunes[n];
323 321
324 g_snprintf(tmpStr, sizeof(tmpStr), _("Tune #%i: "), n); 322 g_snprintf(tmpStr, sizeof(tmpStr), _("Tune #%i: "), n);
325 323
336 } 334 }
337 335
338 tmpMenuItem = gtk_menu_item_new_with_label(tmpStr); 336 tmpMenuItem = gtk_menu_item_new_with_label(tmpStr);
339 gtk_widget_show(tmpMenuItem); 337 gtk_widget_show(tmpMenuItem);
340 gtk_menu_append(GTK_MENU(tmpMenu), tmpMenuItem); 338 gtk_menu_append(GTK_MENU(tmpMenu), tmpMenuItem);
341
342 gtk_signal_connect(GTK_OBJECT(tmpMenuItem), "activate", 339 gtk_signal_connect(GTK_OBJECT(tmpMenuItem), "activate",
343 GTK_SIGNAL_FUNC(xs_fileinfo_subtune), tmpMenu); 340 GTK_SIGNAL_FUNC(xs_fileinfo_subtune), tmpMenu);
344 } 341 }
345 342
346 gtk_option_menu_set_menu(GTK_OPTION_MENU(tmpOptionMenu), tmpMenu); 343 gtk_option_menu_set_menu(GTK_OPTION_MENU(tmpOptionMenu), tmpMenu);