comparison src/audacious/ui_fileinfo.c @ 4021:d79fd54de4fa

added mini statusbar to fileinfo dialog. looks like version string in prefs dialog
author Eugene Zagidullin <e.asphyx@gmail.com>
date Tue, 27 Nov 2007 22:52:32 +0300
parents 66529edae49d
children 85315c67252d
comparison
equal deleted inserted replaced
4020:66529edae49d 4021:d79fd54de4fa
59 #include "build_stamp.h" 59 #include "build_stamp.h"
60 #include "ui_fileinfo.h" 60 #include "ui_fileinfo.h"
61 #include "ui_playlist.h" 61 #include "ui_playlist.h"
62 62
63 #define G_FREE_CLEAR(a) { if(a != NULL) { g_free(a); a = NULL; } } 63 #define G_FREE_CLEAR(a) { if(a != NULL) { g_free(a); a = NULL; } }
64 #define STATUS_TIMEOUT 3*1000
64 65
65 GtkWidget *fileinfo_win; 66 GtkWidget *fileinfo_win;
66 67
67 GtkWidget *entry_location; 68 GtkWidget *entry_location;
68 GtkWidget *entry_title; 69 GtkWidget *entry_title;
77 78
78 GtkWidget *image_fileicon; 79 GtkWidget *image_fileicon;
79 GtkWidget *label_format_name; 80 GtkWidget *label_format_name;
80 GtkWidget *label_quality; 81 GtkWidget *label_quality;
81 GtkWidget *btn_apply; 82 GtkWidget *btn_apply;
83 GtkWidget *label_mini_status;
82 84
83 static gchar *current_file = NULL; 85 static gchar *current_file = NULL;
84 static InputPlugin *current_ip = NULL; 86 static InputPlugin *current_ip = NULL;
85 87
86 static void 88 static void
206 fileinfo_entry_set_text(entry_track, ""); 208 fileinfo_entry_set_text(entry_track, "");
207 fileinfo_entry_set_text(entry_location, ""); 209 fileinfo_entry_set_text(entry_location, "");
208 210
209 fileinfo_label_set_text(label_format_name, NULL); 211 fileinfo_label_set_text(label_format_name, NULL);
210 fileinfo_label_set_text(label_quality, NULL); 212 fileinfo_label_set_text(label_quality, NULL);
213
214 if (label_mini_status != NULL) {
215 gtk_label_set_text(GTK_LABEL(label_mini_status), "<span size=\"small\"></span>");
216 gtk_label_set_use_markup(GTK_LABEL(label_mini_status), TRUE);
217 }
211 218
212 current_ip = NULL; 219 current_ip = NULL;
213 G_FREE_CLEAR(current_file); 220 G_FREE_CLEAR(current_file);
214 221
215 fileinfo_entry_set_image(image_artwork, DATA_DIR "/images/audio.png"); 222 fileinfo_entry_set_image(image_artwork, DATA_DIR "/images/audio.png");
216 } 223 }
217 224
218 static void fileinfo_update_tuple(gpointer data) 225 static gboolean
226 ministatus_timeout_proc (gpointer data)
227 {
228 GtkLabel *status = GTK_LABEL(data);
229 gtk_label_set_text(status, "<span size=\"small\"></span>");
230 gtk_label_set_use_markup(status, TRUE);
231
232 return FALSE;
233 }
234
235 static void
236 ministatus_display_message(gchar *text)
237 {
238 if(label_mini_status != NULL) {
239 gchar *tmp = g_strdup_printf("<span size=\"small\">%s</span>", text);
240 gtk_label_set_text(GTK_LABEL(label_mini_status), tmp);
241 g_free(tmp);
242 gtk_label_set_use_markup(GTK_LABEL(label_mini_status), TRUE);
243 g_timeout_add (STATUS_TIMEOUT, (GSourceFunc) ministatus_timeout_proc, (gpointer) label_mini_status);
244 }
245 }
246
247 static void
248 message_update_successfull()
249 {
250 ministatus_display_message(_("Metadata updated successfully"));
251 }
252
253 static void
254 message_update_failed()
255 {
256 ministatus_display_message(_("Metadata updating failed"));
257 }
258
259 static void
260 fileinfo_update_tuple(gpointer data)
219 { 261 {
220 Tuple *tuple; 262 Tuple *tuple;
221 VFSFile *fd; 263 VFSFile *fd;
222 if(current_file != NULL && current_ip != NULL && current_ip->update_song_tuple != NULL) { /* TODO only if changed*/ 264 if(current_file != NULL && current_ip != NULL && current_ip->update_song_tuple != NULL) { /* TODO only if changed*/
223 265
233 275
234 set_field_int_from_entry(tuple, FIELD_YEAR, entry_year); 276 set_field_int_from_entry(tuple, FIELD_YEAR, entry_year);
235 set_field_int_from_entry(tuple, FIELD_TRACK_NUMBER, entry_track); 277 set_field_int_from_entry(tuple, FIELD_TRACK_NUMBER, entry_track);
236 278
237 if(current_ip->update_song_tuple(tuple, fd)) { 279 if(current_ip->update_song_tuple(tuple, fd)) {
238 /* TODO display ok */ 280 message_update_successfull();
239 fprintf(stderr, "fileinfo_update_tuple(): updated\n");
240 } else { 281 } else {
241 /* TODO error message */ 282 message_update_failed();
242 fprintf(stderr, "fileinfo_update_tuple(): failed\n");
243 } 283 }
244 284
245 vfs_fclose(fd); 285 vfs_fclose(fd);
246 286
247 } else { 287 } else {
248 /* TODO: error message */ 288 message_update_failed();
249 fprintf(stderr, "fileinfo_update_tuple(): can't open file %s\n", current_file);
250 } 289 }
251 290
252 mowgli_object_unref(tuple); 291 mowgli_object_unref(tuple);
253 } 292 }
254 } 293 }
317 356
318 void 357 void
319 create_fileinfo_window(void) 358 create_fileinfo_window(void)
320 { 359 {
321 GtkWidget *hbox; 360 GtkWidget *hbox;
361 GtkWidget *hbox_status_and_bbox;
362 GtkWidget *vbox0;
322 GtkWidget *vbox1; 363 GtkWidget *vbox1;
323 GtkWidget *vbox2; 364 GtkWidget *vbox2;
324 GtkWidget *label_title; 365 GtkWidget *label_title;
325 GtkWidget *label_artist; 366 GtkWidget *label_artist;
326 GtkWidget *label_album; 367 GtkWidget *label_album;
346 gtk_window_set_position(GTK_WINDOW(fileinfo_win), GTK_WIN_POS_CENTER); 387 gtk_window_set_position(GTK_WINDOW(fileinfo_win), GTK_WIN_POS_CENTER);
347 gtk_window_set_resizable(GTK_WINDOW(fileinfo_win), FALSE); 388 gtk_window_set_resizable(GTK_WINDOW(fileinfo_win), FALSE);
348 gtk_window_set_type_hint(GTK_WINDOW(fileinfo_win), GDK_WINDOW_TYPE_HINT_DIALOG); 389 gtk_window_set_type_hint(GTK_WINDOW(fileinfo_win), GDK_WINDOW_TYPE_HINT_DIALOG);
349 gtk_window_set_transient_for(GTK_WINDOW(fileinfo_win), GTK_WINDOW(mainwin)); 390 gtk_window_set_transient_for(GTK_WINDOW(fileinfo_win), GTK_WINDOW(mainwin));
350 391
392 vbox0 = gtk_vbox_new(FALSE, 0);
393 gtk_container_add(GTK_CONTAINER(fileinfo_win), vbox0);
394
351 hbox = gtk_hbox_new(FALSE, 6); 395 hbox = gtk_hbox_new(FALSE, 6);
352 gtk_container_add(GTK_CONTAINER(fileinfo_win), hbox); 396 gtk_box_pack_start(GTK_BOX(vbox0), hbox, TRUE, TRUE, 0);
353 397
354 image_artwork = gtk_image_new(); 398 image_artwork = gtk_image_new();
355 gtk_box_pack_start(GTK_BOX(hbox), image_artwork, FALSE, FALSE, 0); 399 gtk_box_pack_start(GTK_BOX(hbox), image_artwork, FALSE, FALSE, 0);
356 gtk_misc_set_alignment(GTK_MISC(image_artwork), 0.5, 0); 400 gtk_misc_set_alignment(GTK_MISC(image_artwork), 0.5, 0);
357 gtk_image_set_from_file(GTK_IMAGE(image_artwork), DATA_DIR "/images/audio.png"); 401 gtk_image_set_from_file(GTK_IMAGE(image_artwork), DATA_DIR "/images/audio.png");
509 gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 6, 0, 0); 553 gtk_alignment_set_padding (GTK_ALIGNMENT (alignment), 0, 6, 0, 0);
510 554
511 entry_location = gtk_entry_new(); 555 entry_location = gtk_entry_new();
512 gtk_container_add(GTK_CONTAINER(alignment), entry_location); 556 gtk_container_add(GTK_CONTAINER(alignment), entry_location);
513 557
558 hbox_status_and_bbox = gtk_hbox_new(FALSE, 0);
559 gtk_box_pack_start (GTK_BOX (vbox0), hbox_status_and_bbox, FALSE, FALSE, 0);
560
561 label_mini_status = gtk_label_new("<span size=\"small\"></span>");
562 gtk_label_set_use_markup(GTK_LABEL(label_mini_status), TRUE);
563 gtk_misc_set_alignment(GTK_MISC(label_mini_status), 0, 0.5);
564 gtk_box_pack_start (GTK_BOX (hbox_status_and_bbox), label_mini_status, TRUE, TRUE, 0);
565
514 bbox_close = gtk_hbutton_box_new(); 566 bbox_close = gtk_hbutton_box_new();
515 gtk_box_set_spacing(GTK_BOX(bbox_close), 6); 567 gtk_box_set_spacing(GTK_BOX(bbox_close), 6);
516 gtk_box_pack_start(GTK_BOX(vbox1), bbox_close, FALSE, FALSE, 0); 568 gtk_box_pack_start(GTK_BOX(hbox_status_and_bbox), bbox_close, FALSE, FALSE, 0);
517 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox_close), GTK_BUTTONBOX_END); 569 gtk_button_box_set_layout(GTK_BUTTON_BOX(bbox_close), GTK_BUTTONBOX_END);
518 570
519 btn_apply = gtk_button_new_from_stock("gtk-apply"); 571 btn_apply = gtk_button_new_from_stock("gtk-apply");
520 gtk_container_add(GTK_CONTAINER(bbox_close), btn_apply); 572 gtk_container_add(GTK_CONTAINER(bbox_close), btn_apply);
521 g_signal_connect(G_OBJECT(btn_apply), "clicked", (GCallback) fileinfo_update_tuple, NULL); 573 g_signal_connect(G_OBJECT(btn_apply), "clicked", (GCallback) fileinfo_update_tuple, NULL);
524 btn_close = gtk_button_new_from_stock("gtk-close"); 576 btn_close = gtk_button_new_from_stock("gtk-close");
525 gtk_container_add(GTK_CONTAINER(bbox_close), btn_close); 577 gtk_container_add(GTK_CONTAINER(bbox_close), btn_close);
526 GTK_WIDGET_SET_FLAGS(btn_close, GTK_CAN_DEFAULT); 578 GTK_WIDGET_SET_FLAGS(btn_close, GTK_CAN_DEFAULT);
527 g_signal_connect(G_OBJECT(btn_close), "clicked", (GCallback) fileinfo_hide, NULL); 579 g_signal_connect(G_OBJECT(btn_close), "clicked", (GCallback) fileinfo_hide, NULL);
528 580
529 gtk_widget_show_all (hbox); 581 gtk_widget_show_all (vbox0);
530 } 582 }
531 583
532 void 584 void
533 fileinfo_show_for_tuple(Tuple *tuple, gboolean updating_enabled) 585 fileinfo_show_for_tuple(Tuple *tuple, gboolean updating_enabled)
534 { 586 {
588 640
589 if(updating_enabled && current_file != NULL && current_ip != NULL && current_ip->update_song_tuple != NULL) 641 if(updating_enabled && current_file != NULL && current_ip != NULL && current_ip->update_song_tuple != NULL)
590 gtk_widget_set_sensitive(btn_apply, TRUE); 642 gtk_widget_set_sensitive(btn_apply, TRUE);
591 else 643 else
592 gtk_widget_set_sensitive(btn_apply, FALSE); 644 gtk_widget_set_sensitive(btn_apply, FALSE);
645
646 if (label_mini_status != NULL) {
647 gtk_label_set_text(GTK_LABEL(label_mini_status), "<span size=\"small\"></span>");
648 gtk_label_set_use_markup(GTK_LABEL(label_mini_status), TRUE);
649 }
593 650
594 if(! GTK_WIDGET_VISIBLE(fileinfo_win)) gtk_widget_show(fileinfo_win); 651 if(! GTK_WIDGET_VISIBLE(fileinfo_win)) gtk_widget_show(fileinfo_win);
595 } 652 }
596 653
597 void 654 void