comparison src/sid/xs_fileinfo.c @ 1592:ff902c317ecf

Merged fileinfo improvements from XMMS-SID: sub-tunes info selector menu now only shows subtunes that have some STIL information. Also, the menu entries are tagged with [!] and [*] if they have certain STIL fields.
author Matti Hamalainen <ccr@tnsp.org>
date Wed, 05 Sep 2007 02:09:02 +0300
parents 8581eb9d574a
children 9ad9b3479b38
comparison
equal deleted inserted replaced
1591:fccf78344cab 1592:ff902c317ecf
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 if (tmpNode->pName) 144 if (tmpNode->pName)
149 subName = tmpNode->pName; 145 subName = tmpNode->pName;
150 else 146 else
176 172
177 void xs_fileinfo(gchar * pcFilename) 173 void xs_fileinfo(gchar * pcFilename)
178 { 174 {
179 GtkWidget *tmpMenuItem, *tmpMenu, *tmpOptionMenu; 175 GtkWidget *tmpMenuItem, *tmpMenu, *tmpOptionMenu;
180 t_xs_tuneinfo *tmpInfo; 176 t_xs_tuneinfo *tmpInfo;
177 t_xs_stil_subnode *tmpNode;
181 gchar tmpStr[256], *tmpFilename; 178 gchar tmpStr[256], *tmpFilename;
182 gint n; 179 gint n;
183 180
184 /* Current implementation leaves old fileinfo window untouched if 181 /* Current implementation leaves old fileinfo window untouched if
185 * no information can be found for the new file. Hmm... 182 * no information can be found for the new file. Hmm...
236 233
237 /* Main tune - the pseudo tune */ 234 /* Main tune - the pseudo tune */
238 tmpMenuItem = gtk_menu_item_new_with_label(_("General info")); 235 tmpMenuItem = gtk_menu_item_new_with_label(_("General info"));
239 gtk_widget_show(tmpMenuItem); 236 gtk_widget_show(tmpMenuItem);
240 gtk_menu_append(GTK_MENU(tmpMenu), tmpMenuItem); 237 gtk_menu_append(GTK_MENU(tmpMenu), tmpMenuItem);
241 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);
242 243
243 /* Other menu items */ 244 /* Other menu items */
244 for (n = 1; n <= tmpInfo->nsubTunes; n++) { 245 for (n = 1; n <= tmpInfo->nsubTunes; n++) {
245 if (xs_fileinfostil && n <= xs_fileinfostil->nsubTunes && xs_fileinfostil->subTunes[n]) { 246 if (xs_fileinfostil && n <= xs_fileinfostil->nsubTunes && xs_fileinfostil->subTunes[n]) {
246 t_xs_stil_subnode *tmpNode = xs_fileinfostil->subTunes[n]; 247 gboolean isSet = FALSE;
248 tmpNode = xs_fileinfostil->subTunes[n];
247 249
248 g_snprintf(tmpStr, sizeof(tmpStr), _("Tune #%i: "), n); 250 g_snprintf(tmpStr, sizeof(tmpStr), _("Tune #%i: "), n);
249 251
250 if (tmpNode->pName) 252 if (tmpNode->pName) {
251 xs_pnstrcat(tmpStr, sizeof(tmpStr), tmpNode->pName); 253 xs_pnstrcat(tmpStr, sizeof(tmpStr), tmpNode->pName);
252 else if (tmpNode->pTitle) 254 isSet = TRUE;
253 xs_pnstrcat(tmpStr, sizeof(tmpStr), tmpNode->pTitle); 255 }
254 else if (tmpNode->pInfo) 256
255 xs_pnstrcat(tmpStr, sizeof(tmpStr), tmpNode->pInfo); 257 if (tmpNode->pTitle) {
256 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)
257 xs_pnstrcat(tmpStr, sizeof(tmpStr), "---"); 270 xs_pnstrcat(tmpStr, sizeof(tmpStr), "---");
258 } else { 271
259 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);
260 } 276 }
261 277
262 tmpMenuItem = gtk_menu_item_new_with_label(tmpStr);
263 gtk_widget_show(tmpMenuItem);
264 gtk_menu_append(GTK_MENU(tmpMenu), tmpMenuItem);
265 XS_SIGNAL_CONNECT(tmpMenuItem, "activate", xs_fileinfo_subtune, tmpMenu);
266 } 278 }
267 279
268 gtk_option_menu_set_menu(GTK_OPTION_MENU(tmpOptionMenu), tmpMenu); 280 gtk_option_menu_set_menu(GTK_OPTION_MENU(tmpOptionMenu), tmpMenu);
269 gtk_widget_show(tmpOptionMenu); 281 gtk_widget_show(tmpOptionMenu);
270 282
271 /* Set the subtune information */ 283 /* Set the subtune information */
272 xs_fileinfo_subtune(tmpOptionMenu, tmpMenu); 284 xs_fileinfo_subtune(tmpOptionMenu, NULL);
273 285
274 /* Free temporary tuneinfo */ 286 /* Free temporary tuneinfo */
275 xs_tuneinfo_free(tmpInfo); 287 xs_tuneinfo_free(tmpInfo);
276 288
277 /* Show the window */ 289 /* Show the window */