Changeset 3274
- Timestamp:
- 10/25/07 20:24:42 (6 years ago)
- Location:
- trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2
- Files:
-
- 9 edited
-
TODO (modified) (1 diff)
-
openmoko-mediaplayer.schemas (modified) (1 diff)
-
src/main_page.c (modified) (45 diffs)
-
src/main_page.h (modified) (1 diff)
-
src/persistent.c (modified) (20 diffs)
-
src/persistent.h (modified) (5 diffs)
-
src/playback.c (modified) (1 diff)
-
src/playlist.c (modified) (2 diffs)
-
src/playlist.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/TODO
r3260 r3274 25 25 Search alphabetically 26 26 Jump to track 27 Sort music by BPM 28 Dynamic playlists: 29 fetching songs from last.fm 30 audioscrobbler recommendations -
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/openmoko-mediaplayer.schemas
r3263 r3274 35 35 <short>Resume playback on startup?</short> 36 36 <long>Should the media player resume playback where it left off the last time it ran?</long> 37 </locale> 38 </schema> 39 40 <schema> 41 <key>/schemas/apps/openmoko/mediaplayer/seek_distance</key> 42 <applyto>/apps/openmoko/mediaplayer/seek_distance</applyto> 43 <owner>openmoko-mediaplayer</owner> 44 <type>int</type> 45 <default>10000</default> 46 <locale name="C"> 47 <short>Determines how many milliseconds the engine will seek when FFWD/REW'ing</short> 48 <long>Determines how many milliseconds the engine will seek when FFWD/REW'ing</long> 37 49 </locale> 38 50 </schema> -
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main_page.c
r3263 r3274 29 29 #endif 30 30 31 #include <math.h> 32 31 33 #include <glib.h> 32 34 #include <glib/gprintf.h> … … 35 37 #include <gtk/gtk.h> 36 38 39 #include "guitools.h" 37 40 #include "main_page.h" 38 41 #include "main.h" 39 #include "guitools.h"40 42 #include "playlist.h" 41 43 #include "playback.h" 42 44 #include "persistent.h" 43 45 44 45 46 #include <math.h> 46 // This is the amount the cursor must have moved in either direction to be considered moving 47 // If we don't do this then it will constantly trigger gesture recognition due to jitter on the touchscreen 48 #define OMP_MAIN_MIN_CURSOR_DELTA 3 49 50 47 51 48 52 /// Contains all main window widgets that need to be changeable … … 64 68 GtkWidget *shuffle_button_image; 65 69 GtkWidget *repeat_button_image; 66 } main_widgets;70 } omp_main_widgets; 67 71 68 72 GtkWidget *omp_main_window = NULL; … … 100 104 void omp_main_update_shuffle_state(gpointer instance, gboolean state, gpointer user_data); 101 105 void omp_main_update_repeat_mode(gpointer instance, guint mode, gpointer user_data); 106 void omp_main_update_show_cover_art(gpointer instance, gboolean flag, gpointer user_data); 102 107 void omp_main_update_status_change(gpointer instance, gpointer user_data); 103 108 void omp_main_update_track_position(gpointer instance, gpointer user_data); 104 109 void omp_main_update_volume(gpointer instance, gpointer user_data); 110 void omp_main_update_label_type(gpointer instance, guint new_type, gpointer user_data); 105 111 106 112 … … 109 115 * Self-explanatory :) 110 116 */ 111 gint min(gint a, gint b) 117 gint 118 min(gint a, gint b) 112 119 { 113 120 return (a > b) ? b : a; … … 117 124 * Self-explanatory :) 118 125 */ 119 gint max(gint a, gint b) 126 gint 127 max(gint a, gint b) 120 128 { 121 129 return (a > b) ? a : b; … … 123 131 124 132 /** 133 * Find length of vector a+ib using the alpha min + beta max approximation 134 * @param a X dimension of vector (real) 135 * @param b Y dimension of vector (imaginary) 136 * @return Length of vector a+ib 137 * @note We use this approximation because a) finger movement is never more precise than our approximation; 138 * @note b) we need speed and sqrt(a^2 + b^2) is too slow without an FPU while providing unnecessary precision 139 */ 140 guint 141 approx_radius(gint a, gint b) 142 { 143 guint a_abs, b_abs, a_max, b_min; 144 145 a_abs = abs(a); 146 b_abs = abs(b); 147 148 a_max = max(a_abs, b_abs); 149 b_min = min(a_abs, b_abs); 150 151 // Formula is |a+ib| = alpha*a_max + beta*b_min 152 // We use alpha=15/16 and beta=15/32 153 154 return ((a_max*15) >> 4) + ((b_min*15) >> 5); 155 } 156 157 /** 125 158 * Event handler for the expand button 126 159 */ … … 129 162 { 130 163 // Toggle visibility of extended controls 131 if (GTK_WIDGET_VISIBLE( main_widgets.extended_controls))132 gtk_widget_hide( main_widgets.extended_controls);164 if (GTK_WIDGET_VISIBLE(omp_main_widgets.extended_controls)) 165 gtk_widget_hide(omp_main_widgets.extended_controls); 133 166 else 134 gtk_widget_show( main_widgets.extended_controls);167 gtk_widget_show(omp_main_widgets.extended_controls); 135 168 } 136 169 … … 141 174 omp_main_fast_forward_clicked(GtkWidget *widget, gpointer data) 142 175 { 143 omp_playback_set_track_position(omp_playback_get_track_position()+ BUTTON_SEEK_DISTANCE);176 omp_playback_set_track_position(omp_playback_get_track_position()+omp_config_get_seek_distance()); 144 177 } 145 178 … … 150 183 omp_main_rewind_clicked(GtkWidget *widget, gpointer data) 151 184 { 152 omp_playback_set_track_position(omp_playback_get_track_position()- BUTTON_SEEK_DISTANCE);185 omp_playback_set_track_position(omp_playback_get_track_position()-omp_config_get_seek_distance()); 153 186 } 154 187 … … 160 193 { 161 194 if (omp_playback_get_state() != OMP_PLAYBACK_STATE_PLAYING) 162 {163 195 omp_playback_play(); 164 165 } else { 166 196 else 167 197 omp_playback_pause(); 168 }169 198 } 170 199 … … 189 218 mode = omp_config_get_repeat_mode()+1; 190 219 191 if (mode == OMP_REPEAT_COUNT) 192 { 193 mode = 0; 194 } 220 if (mode >= OMP_REPEAT_COUNT) mode = 0; 195 221 196 222 omp_config_set_repeat_mode(mode); … … 214 240 omp_main_gesture_identify(guint x, guint y) 215 241 { 216 #define MIN_RADIUS 15217 218 242 gint delta_x, delta_y, gamma; 219 243 … … 222 246 delta_y = y - main_gesture_data.y_origin; 223 247 224 main_gesture_data.radius = sqrt(delta_x * delta_x + delta_y *delta_y);248 main_gesture_data.radius = approx_radius(delta_x, delta_y); 225 249 226 250 // angle = arccos(gamma) but arccos() is too slow to compute -> range comparison … … 228 252 gamma = delta_x*1000 / main_gesture_data.radius; 229 253 230 if (main_gesture_data.radius > MIN_RADIUS)254 if (main_gesture_data.radius > omp_config_get_min_gesture_radius()) 231 255 { 232 256 … … 312 336 omp_main_gesture_check_repeat() 313 337 { 314 #define REPEAT_TIME_TRESHOLD_USEC 0750000315 #define REPEAT_INTERVAL_MSEC 1000316 317 338 GTimeVal current_time, delta_t; 318 339 … … 324 345 delta_t.tv_usec = current_time.tv_usec - main_gesture_data.start_time.tv_usec; 325 346 326 if (delta_t.tv_usec >= REPEAT_TIME_TRESHOLD_USEC)347 if (delta_t.tv_usec >= omp_config_get_gesture_repeat_tresh()*1000) 327 348 { 328 349 main_gesture_data.repeating = TRUE; 329 g_timeout_add( REPEAT_INTERVAL_MSEC, omp_main_gesture_repeat_callback, NULL);350 g_timeout_add(omp_config_get_gesture_repeat_intv(), omp_main_gesture_repeat_callback, NULL); 330 351 } 331 352 … … 339 360 omp_main_pointer_moved(GtkWidget *widget, GdkEventMotion *event, gpointer user_data) 340 361 { 341 #define MAX_DELTA_LAST 3342 362 gint delta_last_x, delta_last_y; 343 363 … … 348 368 349 369 // Did the cursor move a substantial amount? 350 if ( (delta_last_x > MAX_DELTA_LAST) && (delta_last_y > MAX_DELTA_LAST) )370 if ( (delta_last_x > OMP_MAIN_MIN_CURSOR_DELTA) && (delta_last_y > OMP_MAIN_MIN_CURSOR_DELTA) ) 351 371 { 352 372 // Yes it did, so it's most likely being moved … … 421 441 if (omp_config_get_main_ui_show_cover()) 422 442 { 423 gtk_image_set_from_stock(GTK_IMAGE( main_widgets.cover_image), "no_cover", -1);424 gtk_widget_queue_draw( main_widgets.cover_image); // Re-draw the cover as it might have been used as video display before443 gtk_image_set_from_stock(GTK_IMAGE(omp_main_widgets.cover_image), "no_cover", -1); 444 gtk_widget_queue_draw(omp_main_widgets.cover_image); // Re-draw the cover as it might have been used as video display before 425 445 } 426 446 … … 431 451 if (omp_config_get_main_ui_label2() != OMP_MAIN_LABEL_HIDDEN) 432 452 { 433 gtk_label_set_text(GTK_LABEL( main_widgets.label1), NULL);434 gtk_label_set_text(GTK_LABEL( main_widgets.label2), _("No track information"));435 gtk_label_set_text(GTK_LABEL( main_widgets.label3), NULL);453 gtk_label_set_text(GTK_LABEL(omp_main_widgets.label1), NULL); 454 gtk_label_set_text(GTK_LABEL(omp_main_widgets.label2), _("No track information")); 455 gtk_label_set_text(GTK_LABEL(omp_main_widgets.label3), NULL); 436 456 437 457 } else { … … 439 459 if (omp_config_get_main_ui_label1() != OMP_MAIN_LABEL_HIDDEN) 440 460 { 441 gtk_label_set_text(GTK_LABEL( main_widgets.label1), NULL);442 gtk_label_set_text(GTK_LABEL( main_widgets.label2), NULL);443 gtk_label_set_text(GTK_LABEL( main_widgets.label3), _("No track information"));461 gtk_label_set_text(GTK_LABEL(omp_main_widgets.label1), NULL); 462 gtk_label_set_text(GTK_LABEL(omp_main_widgets.label2), NULL); 463 gtk_label_set_text(GTK_LABEL(omp_main_widgets.label3), _("No track information")); 444 464 } else { 445 gtk_label_set_text(GTK_LABEL( main_widgets.label1), _("No track information"));446 gtk_label_set_text(GTK_LABEL( main_widgets.label2), NULL);447 gtk_label_set_text(GTK_LABEL( main_widgets.label3), NULL);465 gtk_label_set_text(GTK_LABEL(omp_main_widgets.label1), _("No track information")); 466 gtk_label_set_text(GTK_LABEL(omp_main_widgets.label2), NULL); 467 gtk_label_set_text(GTK_LABEL(omp_main_widgets.label3), NULL); 448 468 } 449 469 … … 451 471 452 472 caption = g_strdup_printf(OMP_WIDGET_CAPTION_TRACK_NUM, 0, 0); 453 gtk_label_set_text(GTK_LABEL( main_widgets.track_number_label), caption);473 gtk_label_set_text(GTK_LABEL(omp_main_widgets.track_number_label), caption); 454 474 g_free(caption); 455 475 456 476 caption = g_strdup_printf(OMP_WIDGET_CAPTION_TRACK_TIME, 0, 0, 0, 0); 457 gtk_label_set_text(GTK_LABEL( main_widgets.time_label), caption);477 gtk_label_set_text(GTK_LABEL(omp_main_widgets.time_label), caption); 458 478 g_free(caption); 459 479 460 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR( main_widgets.time_bar), 0);480 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(omp_main_widgets.time_bar), 0); 461 481 } 462 482 … … 480 500 481 501 // Pack the image into an eventbox (for video playback) and that into another frame to give it a black border 482 main_widgets.cover_eventbox = gtk_event_box_new();483 484 main_widgets.cover_image = gtk_image_new();485 gtk_widget_set_name(GTK_WIDGET( main_widgets.cover_image), "omp-main-top-cover");486 gtk_container_add(GTK_CONTAINER( main_widgets.cover_eventbox),main_widgets.cover_image);487 488 main_widgets.cover_frame = widget_wrap(main_widgets.cover_eventbox, "omp-main-top-cover");489 gtk_frame_set_shadow_type(GTK_FRAME( main_widgets.cover_frame), GTK_SHADOW_IN);490 gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET( main_widgets.cover_frame), FALSE, FALSE, 0);502 omp_main_widgets.cover_eventbox = gtk_event_box_new(); 503 504 omp_main_widgets.cover_image = gtk_image_new(); 505 gtk_widget_set_name(GTK_WIDGET(omp_main_widgets.cover_image), "omp-main-top-cover"); 506 gtk_container_add(GTK_CONTAINER(omp_main_widgets.cover_eventbox), omp_main_widgets.cover_image); 507 508 omp_main_widgets.cover_frame = widget_wrap(omp_main_widgets.cover_eventbox, "omp-main-top-cover"); 509 gtk_frame_set_shadow_type(GTK_FRAME(omp_main_widgets.cover_frame), GTK_SHADOW_IN); 510 gtk_box_pack_start(GTK_BOX(hbox), GTK_WIDGET(omp_main_widgets.cover_frame), FALSE, FALSE, 0); 491 511 492 512 // Add the placeholder that makes sure the vbox retains its height even when the cover image is hidden 513 // We do this so the background image is still present and can be used for the labels 493 514 image = gtk_image_new(); 494 515 gtk_widget_set_name(GTK_WIDGET(image), "omp-main-top-cover-placeholder"); … … 506 527 gtk_box_pack_start(GTK_BOX(vbox), alignment, FALSE, FALSE, 0); 507 528 508 main_widgets.label1 = gtk_label_new(NULL);509 gtk_widget_set_name(GTK_WIDGET( main_widgets.label1), "omp-main-top-label1");510 gtk_label_set_ellipsize(GTK_LABEL( main_widgets.label1), PANGO_ELLIPSIZE_END);511 gtk_misc_set_alignment(GTK_MISC( main_widgets.label1), 0, 0);512 main_widgets.label1_frame = widget_wrap(main_widgets.label1, NULL);513 gtk_box_pack_start(GTK_BOX(vbox), main_widgets.label1_frame, FALSE, FALSE, 0);514 515 main_widgets.label2 = gtk_label_new(NULL);516 gtk_widget_set_name(GTK_WIDGET( main_widgets.label2), "omp-main-top-label2");517 gtk_label_set_ellipsize(GTK_LABEL( main_widgets.label2), PANGO_ELLIPSIZE_END);518 gtk_misc_set_alignment(GTK_MISC( main_widgets.label2), 0, 0);519 label = widget_wrap( main_widgets.label2, NULL);529 omp_main_widgets.label1 = gtk_label_new(NULL); 530 gtk_widget_set_name(GTK_WIDGET(omp_main_widgets.label1), "omp-main-top-label1"); 531 gtk_label_set_ellipsize(GTK_LABEL(omp_main_widgets.label1), PANGO_ELLIPSIZE_END); 532 gtk_misc_set_alignment(GTK_MISC(omp_main_widgets.label1), 0, 0); 533 omp_main_widgets.label1_frame = widget_wrap(omp_main_widgets.label1, NULL); 534 gtk_box_pack_start(GTK_BOX(vbox), omp_main_widgets.label1_frame, FALSE, FALSE, 0); 535 536 omp_main_widgets.label2 = gtk_label_new(NULL); 537 gtk_widget_set_name(GTK_WIDGET(omp_main_widgets.label2), "omp-main-top-label2"); 538 gtk_label_set_ellipsize(GTK_LABEL(omp_main_widgets.label2), PANGO_ELLIPSIZE_END); 539 gtk_misc_set_alignment(GTK_MISC(omp_main_widgets.label2), 0, 0); 540 label = widget_wrap(omp_main_widgets.label2, NULL); 520 541 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); 521 542 … … 525 546 526 547 // Title label 527 main_widgets.label3 = gtk_label_new(NULL);528 gtk_widget_set_name(GTK_WIDGET( main_widgets.label3), "omp-main-top-label3");529 gtk_label_set_ellipsize(GTK_LABEL( main_widgets.label3), PANGO_ELLIPSIZE_END);530 label3 = widget_wrap( main_widgets.label3, NULL);548 omp_main_widgets.label3 = gtk_label_new(NULL); 549 gtk_widget_set_name(GTK_WIDGET(omp_main_widgets.label3), "omp-main-top-label3"); 550 gtk_label_set_ellipsize(GTK_LABEL(omp_main_widgets.label3), PANGO_ELLIPSIZE_END); 551 label3 = widget_wrap(omp_main_widgets.label3, NULL); 531 552 gtk_box_pack_start(GTK_BOX(parent), label3, FALSE, FALSE, 0); 532 553 … … 535 556 gtk_widget_show_all(GTK_WIDGET(frame)); 536 557 537 if (omp_config_get_main_ui_label1() == OMP_MAIN_LABEL_HIDDEN) gtk_widget_hide( main_widgets.label1_frame);538 if (omp_config_get_main_ui_label2() == OMP_MAIN_LABEL_HIDDEN) gtk_widget_hide( main_widgets.label2);558 if (omp_config_get_main_ui_label1() == OMP_MAIN_LABEL_HIDDEN) gtk_widget_hide(omp_main_widgets.label1_frame); 559 if (omp_config_get_main_ui_label2() == OMP_MAIN_LABEL_HIDDEN) gtk_widget_hide(omp_main_widgets.label2); 539 560 540 561 if (omp_config_get_main_ui_label3() != OMP_MAIN_LABEL_HIDDEN) gtk_widget_show_all(label3); 541 562 542 563 if (!omp_config_get_main_ui_show_cover()) 543 gtk_widget_hide( main_widgets.cover_frame);564 gtk_widget_hide(omp_main_widgets.cover_frame); 544 565 } 545 566 … … 566 587 567 588 // Playlist counter label 568 main_widgets.track_number_label = gtk_label_new(NULL);569 gtk_widget_set_name( main_widgets.track_number_label, "omp-main-btm-info-bar");570 label = widget_wrap( main_widgets.track_number_label, NULL);589 omp_main_widgets.track_number_label = gtk_label_new(NULL); 590 gtk_widget_set_name(omp_main_widgets.track_number_label, "omp-main-btm-info-bar"); 591 label = widget_wrap(omp_main_widgets.track_number_label, NULL); 571 592 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); 572 593 573 594 // Track time label 574 main_widgets.time_label = gtk_label_new(NULL);575 gtk_widget_set_name( main_widgets.time_label, "omp-main-btm-info-bar");576 label = widget_wrap( main_widgets.time_label, NULL);595 omp_main_widgets.time_label = gtk_label_new(NULL); 596 gtk_widget_set_name(omp_main_widgets.time_label, "omp-main-btm-info-bar"); 597 label = widget_wrap(omp_main_widgets.time_label, NULL); 577 598 gtk_box_pack_end(GTK_BOX(hbox), label, FALSE, FALSE, 0); 578 599 … … 586 607 587 608 // Progress bar 588 main_widgets.time_bar = gtk_progress_bar_new();589 gtk_widget_set_name( main_widgets.time_bar, "omp-main-btm-progressbar");590 gtk_box_pack_start(GTK_BOX(main_vbox), main_widgets.time_bar, FALSE, FALSE, 0);609 omp_main_widgets.time_bar = gtk_progress_bar_new(); 610 gtk_widget_set_name(omp_main_widgets.time_bar, "omp-main-btm-progressbar"); 611 gtk_box_pack_start(GTK_BOX(main_vbox), omp_main_widgets.time_bar, FALSE, FALSE, 0); 591 612 592 613 … … 616 637 // Play/pause button 617 638 button = button_create_with_image("omp-main-btm-buttons", "play", 618 & main_widgets.play_pause_button_image,639 &omp_main_widgets.play_pause_button_image, 619 640 G_CALLBACK(omp_main_play_pause_clicked)); 620 641 button = widget_wrap(button, "omp-main-btm-button-padding-xy"); … … 629 650 630 651 // Volume indicator 631 main_widgets.volume_image = gtk_image_new();632 gtk_widget_set_name( main_widgets.volume_image, "omp-main-btm-volume");633 icon = widget_wrap( main_widgets.volume_image, NULL);652 omp_main_widgets.volume_image = gtk_image_new(); 653 gtk_widget_set_name(omp_main_widgets.volume_image, "omp-main-btm-volume"); 654 icon = widget_wrap(omp_main_widgets.volume_image, NULL); 634 655 gtk_box_pack_start(GTK_BOX(hbox), icon, FALSE, FALSE, 0); 635 656 636 657 637 658 // Button container - second row 638 main_widgets.extended_controls = gtk_event_box_new();639 gtk_widget_set_name( main_widgets.extended_controls, "omp-main-btm-button-box2");640 gtk_box_pack_start(GTK_BOX(main_vbox), main_widgets.extended_controls, FALSE, FALSE, 0);659 omp_main_widgets.extended_controls = gtk_event_box_new(); 660 gtk_widget_set_name(omp_main_widgets.extended_controls, "omp-main-btm-button-box2"); 661 gtk_box_pack_start(GTK_BOX(main_vbox), omp_main_widgets.extended_controls, FALSE, FALSE, 0); 641 662 642 663 hbox = gtk_hbox_new(FALSE, 0); 643 664 btn_box = widget_wrap(hbox, "omp-main-btm-button-box2"); 644 gtk_container_add(GTK_CONTAINER( main_widgets.extended_controls), btn_box);665 gtk_container_add(GTK_CONTAINER(omp_main_widgets.extended_controls), btn_box); 645 666 646 667 // Expand button placeholder … … 653 674 // Shuffle button 654 675 button = button_create_with_image("omp-main-btm-buttons", "shuffle_off", 655 & main_widgets.shuffle_button_image,676 &omp_main_widgets.shuffle_button_image, 656 677 G_CALLBACK(omp_main_shuffle_clicked)); 657 678 button = widget_wrap(button, "omp-main-btm-button-padding-xy"); … … 660 681 // Play/pause button 661 682 button = button_create_with_image("omp-main-btm-buttons", "repeat_off", 662 & main_widgets.repeat_button_image,683 &omp_main_widgets.repeat_button_image, 663 684 G_CALLBACK(omp_main_repeat_clicked)); 664 685 button = widget_wrap(button, "omp-main-btm-button-padding-xy"); … … 682 703 // Show all widgets except the extended controls 683 704 gtk_widget_show_all(main_vbox); 684 gtk_widget_hide( main_widgets.extended_controls);705 gtk_widget_hide(omp_main_widgets.extended_controls); 685 706 } 686 707 … … 724 745 g_signal_connect(G_OBJECT(omp_window), OMP_EVENT_CONFIG_REPEAT_MODE_CHANGED, 725 746 G_CALLBACK(omp_main_update_repeat_mode), NULL); 747 748 g_signal_connect(G_OBJECT(omp_window), OMP_EVENT_CONFIG_MAIN_UI_SHOW_COVER_CHANGED, 749 G_CALLBACK(omp_main_update_show_cover_art), NULL); 750 751 g_signal_connect(G_OBJECT(omp_window), OMP_EVENT_CONFIG_MAIN_LABEL1_TYPE_CHANGED, 752 G_CALLBACK(omp_main_update_label_type), (gpointer)1); 753 754 g_signal_connect(G_OBJECT(omp_window), OMP_EVENT_CONFIG_MAIN_LABEL2_TYPE_CHANGED, 755 G_CALLBACK(omp_main_update_label_type), (gpointer)2); 756 757 g_signal_connect(G_OBJECT(omp_window), OMP_EVENT_CONFIG_MAIN_LABEL3_TYPE_CHANGED, 758 G_CALLBACK(omp_main_update_label_type), (gpointer)3); 726 759 727 760 // Set up playback signal handlers … … 769 802 { 770 803 if (omp_config_get_main_ui_label1() == label_type) 771 gtk_label_set_text(GTK_LABEL( main_widgets.label1), caption);804 gtk_label_set_text(GTK_LABEL(omp_main_widgets.label1), caption); 772 805 773 806 if (omp_config_get_main_ui_label2() == label_type) 774 gtk_label_set_text(GTK_LABEL( main_widgets.label2), caption);807 gtk_label_set_text(GTK_LABEL(omp_main_widgets.label2), caption); 775 808 776 809 if (omp_config_get_main_ui_label3() == label_type) 777 gtk_label_set_text(GTK_LABEL( main_widgets.label3), caption);810 gtk_label_set_text(GTK_LABEL(omp_main_widgets.label3), caption); 778 811 } 779 812 … … 784 817 omp_main_get_video_window() 785 818 { 786 if (GTK_WIDGET_NO_WINDOW( main_widgets.cover_eventbox))819 if (GTK_WIDGET_NO_WINDOW(omp_main_widgets.cover_eventbox)) 787 820 g_error(_("Video display widget has no window!\n")); 788 821 789 return GDK_WINDOW_XWINDOW( main_widgets.cover_eventbox->window);822 return GDK_WINDOW_XWINDOW(omp_main_widgets.cover_eventbox->window); 790 823 } 791 824 … … 821 854 if (omp_config_get_main_ui_show_cover()) 822 855 { 823 gtk_image_set_from_stock(GTK_IMAGE( main_widgets.cover_image), "no_cover", -1);824 gtk_widget_queue_draw( main_widgets.cover_image); // Re-draw the default cover856 gtk_image_set_from_stock(GTK_IMAGE(omp_main_widgets.cover_image), "no_cover", -1); 857 gtk_widget_queue_draw(omp_main_widgets.cover_image); // Re-draw the default cover 825 858 } 826 859 827 860 // Set preliminary artist/title strings (updated on incoming metadata) 828 omp_playlist_get_track_info( omp_playlist_current_track_id, &artist, &title, &track_length);861 omp_playlist_get_track_info(-1, &artist, &title, &track_length); 829 862 omp_main_set_label(OMP_MAIN_LABEL_ARTIST, artist); 830 863 omp_main_set_label(OMP_MAIN_LABEL_TITLE, title); … … 844 877 track_id = (omp_playlist_track_count) ? omp_playlist_current_track_id+1 : 0; 845 878 text = g_strdup_printf(OMP_WIDGET_CAPTION_TRACK_NUM, track_id, omp_playlist_track_count); 846 gtk_label_set_text(GTK_LABEL( main_widgets.track_number_label), text);879 gtk_label_set_text(GTK_LABEL(omp_main_widgets.track_number_label), text); 847 880 g_free(text); 848 881 } … … 858 891 (guint)(track_position / 60000), (guint)(track_position/1000) % 60, 859 892 (guint)(track_length / 60000), (guint)(track_length/1000) % 60); 860 gtk_label_set_text(GTK_LABEL(main_widgets.time_label), text); 893 894 gtk_label_set_text(GTK_LABEL(omp_main_widgets.time_label), text); 861 895 g_free(text); 862 896 863 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR( main_widgets.time_bar), (gdouble)track_position/(gdouble)track_length);897 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(omp_main_widgets.time_bar), (gdouble)track_position/(gdouble)track_length); 864 898 } 865 899 } … … 881 915 { 882 916 if (state) 883 { 884 gtk_image_set_from_stock(GTK_IMAGE(main_widgets.shuffle_button_image), "shuffle_on", -1); 885 } else { 886 gtk_image_set_from_stock(GTK_IMAGE(main_widgets.shuffle_button_image), "shuffle_off", -1); 887 } 917 gtk_image_set_from_stock(GTK_IMAGE(omp_main_widgets.shuffle_button_image), "shuffle_on", -1); 918 else 919 gtk_image_set_from_stock(GTK_IMAGE(omp_main_widgets.shuffle_button_image), "shuffle_off", -1); 888 920 } 889 921 … … 897 929 { 898 930 case OMP_REPEAT_OFF: 899 gtk_image_set_from_stock(GTK_IMAGE( main_widgets.repeat_button_image), "repeat_off", -1);931 gtk_image_set_from_stock(GTK_IMAGE(omp_main_widgets.repeat_button_image), "repeat_off", -1); 900 932 break; 901 933 902 934 case OMP_REPEAT_ONCE: 903 gtk_image_set_from_stock(GTK_IMAGE( main_widgets.repeat_button_image), "repeat_once", -1);935 gtk_image_set_from_stock(GTK_IMAGE(omp_main_widgets.repeat_button_image), "repeat_once", -1); 904 936 break; 905 937 906 938 case OMP_REPEAT_CURRENT: 907 gtk_image_set_from_stock(GTK_IMAGE( main_widgets.repeat_button_image), "repeat_current", -1);939 gtk_image_set_from_stock(GTK_IMAGE(omp_main_widgets.repeat_button_image), "repeat_current", -1); 908 940 break; 909 941 910 942 case OMP_REPEAT_ALL: 911 gtk_image_set_from_stock(GTK_IMAGE(main_widgets.repeat_button_image), "repeat_all", -1); 912 } 943 gtk_image_set_from_stock(GTK_IMAGE(omp_main_widgets.repeat_button_image), "repeat_all", -1); 944 } 945 } 946 947 /** 948 * Updates the UI after the "show cover art" flag changed 949 */ 950 void 951 omp_main_update_show_cover_art(gpointer instance, gboolean flag, gpointer user_data) 952 { 953 /* if (flag) 954 gtk_widget_show(omp_main_widgets.cover_frame); 955 else 956 gtk_widget_hide(omp_main_widgets.cover_frame); */ 913 957 } 914 958 … … 922 966 if (omp_playback_get_state() == OMP_PLAYBACK_STATE_PAUSED) 923 967 { 924 gtk_image_set_from_stock(GTK_IMAGE( main_widgets.play_pause_button_image), "play", -1);968 gtk_image_set_from_stock(GTK_IMAGE(omp_main_widgets.play_pause_button_image), "play", -1); 925 969 } else { 926 gtk_image_set_from_stock(GTK_IMAGE( main_widgets.play_pause_button_image), "pause", -1);970 gtk_image_set_from_stock(GTK_IMAGE(omp_main_widgets.play_pause_button_image), "pause", -1); 927 971 } 928 972 } … … 951 995 (guint)(track_position / 60000), (guint)(track_position/1000) % 60, 952 996 (guint)(track_length / 60000), (guint)(track_length/1000) % 60); 953 gtk_label_set_text(GTK_LABEL(main_widgets.time_label), text); 997 998 gtk_label_set_text(GTK_LABEL(omp_main_widgets.time_label), text); 954 999 g_free(text); 955 1000 956 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR( main_widgets.time_bar), (gdouble)track_position/(gdouble)track_length);1001 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(omp_main_widgets.time_bar), (gdouble)track_position/(gdouble)track_length); 957 1002 } 958 1003 … … 971 1016 972 1017 image = g_strdup_printf("volume%02d", volume/10); 973 gtk_image_set_from_stock(GTK_IMAGE( main_widgets.volume_image), image, -1);1018 gtk_image_set_from_stock(GTK_IMAGE(omp_main_widgets.volume_image), image, -1); 974 1019 g_free(image); 975 1020 } 1021 1022 /** 1023 * Updates the UI when the type of the first dynamic label changed 1024 * @param instance Unused 1025 * @param new_type The new type to set for the label 1026 * @param user_data Contains the number of the label to update (1..3) 1027 */ 1028 void 1029 omp_main_update_label_type(gpointer instance, guint new_type, gpointer user_data) 1030 { 1031 GtkWidget *label, *frame; 1032 gchar *artist = NULL; 1033 gchar *title = NULL; 1034 1035 g_return_if_fail( (user_data > 0) && (user_data < 4) ); 1036 1037 switch ((gint)user_data) 1038 { 1039 case 1: 1040 { 1041 label = omp_main_widgets.label1; 1042 frame = omp_main_widgets.label1_frame; 1043 break; 1044 } 1045 1046 case 2: 1047 { 1048 label = omp_main_widgets.label2; 1049 frame = NULL; // Can't be hidden 1050 break; 1051 } 1052 1053 case 3: 1054 { 1055 label = omp_main_widgets.label3; 1056 frame = NULL; // Can't be hidden 1057 break; 1058 } 1059 } 1060 1061 // Fetch track information if needed 1062 if ( (new_type != OMP_MAIN_LABEL_HIDDEN) && (new_type != OMP_MAIN_LABEL_EMPTY) ) 1063 omp_playlist_get_track_info(-1, &artist, &title, NULL); 1064 1065 // Update label 1066 switch ((omp_main_label_type)new_type) 1067 { 1068 case OMP_MAIN_LABEL_HIDDEN: 1069 { 1070 if (frame) gtk_widget_hide(frame); 1071 break; 1072 } 1073 1074 case OMP_MAIN_LABEL_EMPTY: 1075 { 1076 gtk_label_set_text(GTK_LABEL(label), NULL); 1077 break; 1078 } 1079 1080 case OMP_MAIN_LABEL_ARTIST: 1081 { 1082 gtk_label_set_text(GTK_LABEL(label), artist); 1083 break; 1084 } 1085 1086 case OMP_MAIN_LABEL_TITLE: 1087 { 1088 gtk_label_set_text(GTK_LABEL(label), title); 1089 break; 1090 } 1091 } 1092 1093 if (artist) g_free(artist); 1094 if (title) g_free(title); 1095 1096 // Make sure label is visible - it might have been hidden previously 1097 if ( (frame) && (new_type != OMP_MAIN_LABEL_HIDDEN) ) 1098 gtk_widget_show(frame); 1099 } 1100 -
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/main_page.h
r3263 r3274 34 34 #define OMP_WIDGET_CAPTION_VOLUME "%u%%" 35 35 36 // Determines how many milliseconds the engine will seek if the FFWD/REW buttons are clicked37 #define BUTTON_SEEK_DISTANCE 1000038 39 36 40 37 -
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/persistent.c
r3263 r3274 50 50 OMP_REPEAT_OFF, // repeat_mode 51 51 TRUE, // resume_playback 52 10000, // seek_distance 52 53 10000, // prev_track_treshold 53 54 TRUE, // show_numbers_in_pl … … 67 68 68 69 /// The GConf instance we'll use 69 GConfClient *omp_gconf_client ;70 GConfClient *omp_gconf_client = NULL; 70 71 71 72 … … 78 79 { 79 80 GConfValue *value; 80 gboolean v_bool;81 81 82 82 value = gconf_entry_get_value(entry); … … 86 86 case OMP_CONFIG_SHUFFLE: 87 87 { 88 // Update value in config struct and submit new state to the UI89 88 omp_config->shuffle = gconf_value_get_bool(value); 90 89 g_signal_emit_by_name(G_OBJECT(omp_window), OMP_EVENT_CONFIG_SHUFFLE_STATE_CHANGED, omp_config->shuffle); … … 94 93 case OMP_CONFIG_REPEAT_MODE: 95 94 { 96 // Update value in config struct and submit new state to the UI97 95 omp_config->repeat_mode = gconf_value_get_int(value); 98 96 g_signal_emit_by_name(G_OBJECT(omp_window), OMP_EVENT_CONFIG_REPEAT_MODE_CHANGED, omp_config->repeat_mode); … … 103 101 { 104 102 omp_config->resume_playback = gconf_value_get_bool(value); 103 // No notification needed, value is used on demand 104 break; 105 } 106 107 case OMP_CONFIG_SEEK_DISTANCE: 108 { 109 omp_config->seek_distance = gconf_value_get_int(value); 110 // No notification needed, value is used on demand 105 111 break; 106 112 } … … 109 115 { 110 116 omp_config->prev_track_treshold = gconf_value_get_int(value); 117 // No notification needed, value is used on demand 111 118 break; 112 119 } … … 115 122 { 116 123 omp_config->show_numbers_in_pl = gconf_value_get_bool(value); 124 g_signal_emit_by_name(G_OBJECT(omp_window), OMP_EVENT_CONFIG_SHOW_NUMBERS_IN_PL_CHANGED, omp_config->show_numbers_in_pl); 117 125 break; 118 126 } … … 121 129 { 122 130 omp_config->main_ui_show_cover = gconf_value_get_bool(value); 131 g_signal_emit_by_name(G_OBJECT(omp_window), OMP_EVENT_CONFIG_MAIN_UI_SHOW_COVER_CHANGED, omp_config->main_ui_show_cover); 123 132 break; 124 133 } … … 127 136 { 128 137 omp_config->main_ui_label1 = gconf_value_get_int(value); 138 g_signal_emit_by_name(G_OBJECT(omp_window), OMP_EVENT_CONFIG_MAIN_LABEL1_TYPE_CHANGED, omp_config->main_ui_label1); 129 139 break; 130 140 } … … 133 143 { 134 144 omp_config->main_ui_label2 = gconf_value_get_int(value); 145 g_signal_emit_by_name(G_OBJECT(omp_window), OMP_EVENT_CONFIG_MAIN_LABEL2_TYPE_CHANGED, omp_config->main_ui_label2); 135 146 break; 136 147 } … … 139 150 { 140 151 omp_config->main_ui_label3 = gconf_value_get_int(value); 152 g_signal_emit_by_name(G_OBJECT(omp_window), OMP_EVENT_CONFIG_MAIN_LABEL3_TYPE_CHANGED, omp_config->main_ui_label3); 141 153 break; 142 154 } … … 145 157 { 146 158 omp_config->min_gesture_radius = gconf_value_get_int(value); 159 // No notification needed, value is used on demand 147 160 break; 148 161 } … … 151 164 { 152 165 omp_config->gesture_repeat_tresh = gconf_value_get_int(value); 166 // No notification needed, value is used on demand 153 167 break; 154 168 } … … 157 171 { 158 172 omp_config->gesture_repeat_intv = gconf_value_get_int(value); 173 // No notification needed, value is used on demand 159 174 break; 160 175 } … … 190 205 g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT); 191 206 207 g_signal_new(OMP_EVENT_CONFIG_MAIN_UI_SHOW_COVER_CHANGED, 208 G_TYPE_OBJECT, G_SIGNAL_RUN_FIRST, 0, 0, NULL, 209 g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN); 210 211 g_signal_new(OMP_EVENT_CONFIG_SHOW_NUMBERS_IN_PL_CHANGED, 212 G_TYPE_OBJECT, G_SIGNAL_RUN_FIRST, 0, 0, NULL, 213 g_cclosure_marshal_VOID__BOOLEAN, G_TYPE_NONE, 1, G_TYPE_BOOLEAN); 214 215 g_signal_new(OMP_EVENT_CONFIG_MAIN_LABEL1_TYPE_CHANGED, 216 G_TYPE_OBJECT, G_SIGNAL_RUN_FIRST, 0, 0, NULL, 217 g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT); 218 219 g_signal_new(OMP_EVENT_CONFIG_MAIN_LABEL2_TYPE_CHANGED, 220 G_TYPE_OBJECT, G_SIGNAL_RUN_FIRST, 0, 0, NULL, 221 g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT); 222 223 g_signal_new(OMP_EVENT_CONFIG_MAIN_LABEL3_TYPE_CHANGED, 224 G_TYPE_OBJECT, G_SIGNAL_RUN_FIRST, 0, 0, NULL, 225 g_cclosure_marshal_VOID__UINT, G_TYPE_NONE, 1, G_TYPE_UINT); 226 192 227 // Set up GConf, fetch default values and attach notification handler 193 228 omp_gconf_client = gconf_client_get_default(); … … 219 254 220 255 omp_config->prev_track_treshold = 256 gconf_client_get_int(omp_gconf_client, OMP_GCONF_PATH "/seek_distance", NULL); 257 gconf_client_notify_add(omp_gconf_client, OMP_GCONF_PATH "/seek_distance", 258 omp_config_gconf_notification, (gpointer)OMP_CONFIG_SEEK_DISTANCE, NULL, NULL); 259 260 omp_config->prev_track_treshold = 221 261 gconf_client_get_int(omp_gconf_client, OMP_GCONF_PATH "/prev_track_treshold", NULL); 222 262 gconf_client_notify_add(omp_gconf_client, OMP_GCONF_PATH "/prev_track_treshold", … … 270 310 omp_config_free() 271 311 { 272 g_object_unref(G_OBJECT(omp_gconf_client));312 if (omp_gconf_client) g_object_unref(G_OBJECT(omp_gconf_client)); 273 313 g_free(omp_config); 274 314 } … … 313 353 314 354 /** 355 * Returns amount of milliseconds the playback engine should seek on FFWD/REW'ing 356 */ 357 guint 358 omp_config_get_seek_distance() 359 { 360 return omp_config->seek_distance; 361 } 362 363 /** 315 364 * Returns amount of milliseconds that determine behavior of the "prev track" event 316 365 */ … … 373 422 { 374 423 return omp_config->main_ui_label3; 424 } 425 426 /** 427 * Returns the minimum length of a gesture stroke in order to consider it a valid gesture 428 */ 429 guint 430 omp_config_get_min_gesture_radius() 431 { 432 return omp_config->min_gesture_radius; 433 } 434 435 /** 436 * Returns the time after which a gesture's action will be repeated for as long as the finger is down 437 */ 438 guint 439 omp_config_get_gesture_repeat_tresh() 440 { 441 return omp_config->gesture_repeat_tresh; 442 } 443 444 /** 445 * Returns the interval at which a gesture's action will be repeated 446 */ 447 guint 448 omp_config_get_gesture_repeat_intv() 449 { 450 return omp_config->gesture_repeat_intv; 375 451 } 376 452 -
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/persistent.h
r3263 r3274 31 31 #include "main.h" 32 32 33 // Configuratin data notification events 33 34 #define OMP_EVENT_CONFIG_SHUFFLE_STATE_CHANGED "config_shuffle_state_changed" 34 35 #define OMP_EVENT_CONFIG_REPEAT_MODE_CHANGED "config_repeat_mode_changed" 36 #define OMP_EVENT_CONFIG_SHOW_NUMBERS_IN_PL_CHANGED "config_show_numbers_in_pl_changed" 37 #define OMP_EVENT_CONFIG_MAIN_UI_SHOW_COVER_CHANGED "config_main_show_cover_changed" 38 #define OMP_EVENT_CONFIG_MAIN_LABEL1_TYPE_CHANGED "config_main_label1_type_changed" 39 #define OMP_EVENT_CONFIG_MAIN_LABEL2_TYPE_CHANGED "config_main_label2_type_changed" 40 #define OMP_EVENT_CONFIG_MAIN_LABEL3_TYPE_CHANGED "config_main_label3_type_changed" 35 41 42 // Session data notification events 36 43 #define OMP_EVENT_SESSION_FILE_CHOOSER_PATH_CHANGED "session_file_chooser_path_changed" 37 44 … … 61 68 guint repeat_mode; ///< Repeat mode @see omp_repeat_modes 62 69 gboolean resume_playback; ///< Resume playback on startup where it left off? 70 gint seek_distance; ///< Determines how many milliseconds the engine will seek when FFWD/REW'ing 63 71 guint prev_track_treshold; ///< Amount of milliseconds a track must have been playing to jump back to track beginning on "prev track" event 64 72 gboolean show_numbers_in_pl; ///< Show numbers in playlist? … … 70 78 guint main_ui_label3; ///< Contents of main UI's label #3 71 79 guint min_gesture_radius; ///< If a gesture stroke's length is shorter than this the gesture is dismissed 72 guint gesture_repeat_tresh; ///< If a gesture was madeits action will be repeated if the finger is still down after this time (msec)80 guint gesture_repeat_tresh; ///< If a gesture was recognized its action will be repeated if the finger is still down after this time (msec) 73 81 guint gesture_repeat_intv; ///< Gesture will be repeated every X milliseconds 74 82 }; … … 80 88 OMP_CONFIG_REPEAT_MODE, 81 89 OMP_CONFIG_RESUME_PLAYBACK, 90 OMP_CONFIG_SEEK_DISTANCE, 82 91 OMP_CONFIG_PREV_TRACK_TRESHOLD, 83 92 OMP_CONFIG_SHOW_NUMBERS_IN_PL, … … 116 125 guint omp_config_get_repeat_mode(); 117 126 127 guint omp_config_get_seek_distance(); 118 128 guint omp_config_get_prev_track_treshold(); 119 129 gulong omp_config_get_pulsesink_buffer_time(); 120 130 gulong omp_config_get_pulsesink_latency_time(); 131 121 132 gboolean omp_config_get_main_ui_show_cover(); 122 133 guint omp_config_get_main_ui_label1(); 123 134 guint omp_config_get_main_ui_label2(); 124 135 guint omp_config_get_main_ui_label3(); 136 137 guint omp_config_get_min_gesture_radius(); 138 guint omp_config_get_gesture_repeat_tresh(); 139 guint omp_config_get_gesture_repeat_intv(); 125 140 126 141 void omp_session_init(); -
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playback.c
r3232 r3274 419 419 if (volume > 100) 420 420 { 421 g_warning("Attempted to set invalid volume! ");421 g_warning("Attempted to set invalid volume!\n"); 422 422 volume = 100; 423 423 } -
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playlist.c
r2960 r3274 777 777 /** 778 778 * Retrieves a track's meta data if possible 779 * @param track_id Track ID to get meta data of, starting at 0 779 * @param track_id Track ID to get meta data of, starting at 0; set to -1 to use current track 780 780 * @param artist Destination for the artist string, can be NULL; must be freed after use 781 781 * @param title Destination for the title string, can be NULL; must be freed after use … … 784 784 */ 785 785 void 786 omp_playlist_get_track_info(g uint track_id, gchar **artist, gchar **title, gulong *duration)787 { 788 if ( track_id == omp_playlist_current_track_id)786 omp_playlist_get_track_info(gint track_id, gchar **artist, gchar **title, gulong *duration) 787 { 788 if ( (track_id == omp_playlist_current_track_id) || (track_id == -1) ) 789 789 { 790 790 if (!omp_playlist_current_track) return; -
trunk/src/target/OM-2007.2/applications/openmoko-mediaplayer2/src/playlist.h
r3263 r3274 84 84 gchar *omp_playlist_resolve_track(omp_spiff_track *track); 85 85 gboolean omp_playlist_load_current_track(); 86 void omp_playlist_get_track_info(g uint track_id, gchar **artist, gchar **title, gulong *duration);86 void omp_playlist_get_track_info(gint track_id, gchar **artist, gchar **title, gulong *duration); 87 87 void omp_playlist_update_track_count(); 88 88
Note: See TracChangeset
for help on using the changeset viewer.
