1 2 //#include "gui_event_list.h" 3 4 5 enum toolbar_pos 6 { 7 TOOLBAR_LEFT, 8 TOOLBAR_RIGHT, 9 TOOLBAR_TOP, 10 TOOLBAR_BOTTOM, 11 TOOLBAR_NONE 12 }; 13 14 enum ui_mode 15 { 16 UI_MODE_SSA, 17 UI_MODE_ASS, 18 UI_MODE_SRT, 19 UI_MODE_KARAOKE, 20 UI_MODE_NONE 21 }; 22 23 enum karaoke_mode 24 { 25 KARAOKE_MODE_OFF, 26 KARAOKE_MODE_BOX, 27 KARAOKE_MODE_LINE 28 }; 29 30 enum notebook_page 31 { 32 NOTEBOOK_PAGE_AUDIO, 33 NOTEBOOK_PAGE_VIDEO 34 }; 35 36 enum status_bar_colors 37 { 38 STATUS_COLOR_SUCCESS, 39 STATUS_COLOR_ERROR, 40 STATUS_COLOR_UNSAVED, 41 STATUS_COLOR_COUNT 42 }; 43 44 enum control_widget_type 45 { 46 CONTROLS_TABLE, 47 CONTROLS_HBOX, 48 CONTROLS_VBOX 49 }; 50 51 GdkPixbuf *gui_main_load_image(int identifier); 52 void gui_main_create(); 53 char *gui_main_open_file(char *title, char **filters); 54 char *gui_main_save_file(char *title, char **filters, char *default_extension, char *filename = NULL); 55 void gui_main_title_update(); 56 void gui_main_update_sensitivity(); 57 void gui_main_error_sound(); 58 GtkToolbar *gui_main_create_list_toolbar(gboolean horizontal); 59 GtkToolbar *gui_main_create_wave_toolbar(gboolean horizontal); 60 void gui_main_disable_seek(); 61 void gui_main_enable_seek(gboolean enable); 62 void gui_main_register_extensions(GtkWidget *widget, int callback_action); 63 void gui_warning(char *format, ...); 64 void gui_main_marker_changed_cb(KryMarker *marker, long position); 65 gboolean gui_main_key_press(GtkWidget *widget, GdkEventKey *event, gpointer button); 66 gboolean gui_main_scroll_press(GtkWidget *widget, GdkEvent *event, gpointer button); 67 int gui_main_select_font(struct fontsel_info * fontsel_info); 68 void gui_main_hbox_color_map_cb(GtkWidget *widget, GtkWidget *w2); 69 void gui_error(char *format, ...); 70 void gui_error(GtkWindow *parent, char *format, ...); 71 gboolean gui_question_yes_no(char *format, ...); 72 gboolean gui_question_yes_no(GtkWindow *window, char *format, ...); 73 void gui_main_sync_point_set(GtkWidget *widget, int action, gpointer data); 74 void gui_main_sync_point_sync(GtkWidget *widget, int action, gpointer data); 75 gboolean gui_warning_yes_no(char *format, ...); 76 double gui_spin_button_get_value(GtkSpinButton *button); 77 gboolean gui_main_error_dialog_show(char *header, char *footer, kryList<kryTextParseError *> *error_list); 78 GtkWidget *gui_main_create_text_editor(); 79 GtkWidget *gui_main_create_event_editor(); 80 void gui_main_focus_on_wave(); 81 void gui_main_notebook_page_changed(GtkNotebook *notebook, GtkNotebookPage *page_unused, enum notebook_page page, gpointer data_unused); 82 void gui_main_sync_event_to_wave(GtkWidget *widget, int action, gpointer data); 83 void gui_karaoke_set_selected_event(kryEvent *event_generic); 84 void gui_main_color_fill(GtkDrawingArea *area, kryColor *color, gboolean border); 85 void gui_main_disable(); 86 void gui_main_enable(); 87 GtkWidget *gui_main_create_control_toolbar(control_widget_type type); 88 void gui_main_entry_style_changed_cb(GtkWidget *widget, gpointer data); 89 gboolean gui_main_is_enabled();; 90 unsigned int update_crc(unsigned int crc_accum, char *data_blk_ptr, int data_blk_size); 91 void gen_crc_table(); 92 #ifdef _WINDOWS 93 void gui_win32_print_last_error(LPTSTR lpszFunction); 94 #endif 95 96 97 struct recent_info 98 { 99 GtkMenuItem *parent; 100 GList **list; 101 }; 102 103 104 struct gui_main_style_editor 105 { 106 GtkComboBox *combo_style; 107 //GtkCombo *combo_align; 108 109 GtkRadioButton *button_align[9]; 110 111 GtkSpinButton *spin_font_size; 112 113 GtkEntry *entry_font_name; 114 GtkToggleButton *button_font_bold; 115 GtkToggleButton *button_font_italic; 116 GtkToggleButton *button_font_underline; 117 GtkToggleButton *button_font_strikethrough; 118 119 GtkSpinButton *spin_margin_left; 120 GtkSpinButton *spin_margin_right; 121 GtkSpinButton *spin_margin_vertical; 122 123 GtkSpinButton *spin_angle; 124 125 GtkComboBox *combo_border; 126 GtkSpinButton *spin_border_size; 127 GtkSpinButton *spin_shadow_size; 128 GtkSpinButton *spin_scalex; 129 GtkSpinButton *spin_scaley; 130 GtkSpinButton *spin_spacing; 131 132 GtkLabel *label_tertiary; 133 GtkLabel *label_outline; 134 GtkLabel *label_shadow; 135 GtkLabel *label_back; 136 137 GtkButton *button_tertiary; 138 GtkButton *button_outline; 139 GtkButton *button_shadow; 140 GtkButton *button_back; 141 142 GtkDrawingArea *draw_primary; 143 GtkDrawingArea *draw_secondary; 144 GtkDrawingArea *draw_tertiary; 145 GtkDrawingArea *draw_outline; 146 GtkDrawingArea *draw_shadow; 147 GtkDrawingArea *draw_back; 148 149 GtkFrame *frame_style_font; 150 151 kryStyle *current; 152 }; 153 154 struct gui_main_tab_options_color 155 { 156 GtkLabel *label_no_color; 157 GtkHBox *hbox_editor; 158 GtkDrawingArea *area; 159 kryColor *active_color; 160 GtkTreeView *color_view; 161 }; 162 163 struct gui_main_tab_video 164 { 165 struct video_ffmpeg *video; 166 AVPicture pict; 167 168 KryMarker *marker_start; 169 KryMarker *marker_start_prev; 170 /*long mark_start_mili; 171 long mark_start_mili_prev; /// *only* used for video*/ 172 173 int posx; 174 int posy; 175 176 int orgx; 177 int orgy; 178 179 GdkRectangle subRect; 180 gboolean doMove; 181 gboolean doUpdate; 182 gboolean showGrid; 183 int grid_interval_x; 184 int grid_interval_y; 185 int grid_snap_distance; 186 187 GtkEntry *entry_time; 188 GtkProgressBar *progress_bar; 189 gboolean sync_audio; 190 191 GtkButton *button_back1; 192 GtkButton *button_forward1; 193 GtkButton *button_back10; 194 GtkButton *button_forward10; 195 196 GtkButton *button_lock; 197 GtkButton *button_video; 198 GtkButton *button_solid; 199 200 GtkButton *button_jump_start; 201 GtkButton *button_jump_end; 202 203 GtkWidget *vbox_notebook; 204 205 GtkToggleButton *button_hide; 206 207 unsigned int color_solid; 208 209 double zoomf; 210 }; 211 212 struct sabbu_options 213 { 214 gboolean format_script; 215 gboolean join_2spaces; 216 gboolean two_button_mode; 217 gboolean enable_logging; 218 gboolean disable_collisions; 219 gboolean text_editor_top; 220 gboolean video_disabled; 221 gboolean enable_drag_selection; 222 gboolean disable_automatic_wave_jump; 223 gboolean play_selection_stop; 224 gboolean theme_warning_shown; 225 gboolean peak_files; 226 gboolean enable_marker_dragging; 227 gboolean save_utf16; 228 gboolean advanced_waveform_ui; 229 gboolean controls_as_toolbar; 230 gboolean show_only_first_channel; 231 232 double default_zoom; 233 int time_advance; 234 235 int leadin; 236 int leadout; 237 }; 238 239 struct gui_menu_script 240 { 241 GtkMenuItem *open_recent; 242 GtkMenuItem *save_as_utf16; 243 GtkMenuItem *close; 244 245 GtkMenuItem *open_recent_workspace; 246 GtkMenuItem *save_workspace_as; 247 GtkMenuItem *close_workspace; 248 }; 249 250 struct gui_menu_audio 251 { 252 GtkMenuItem *open_recent; 253 GtkMenuItem *close; 254 GtkMenuItem *grab_times; 255 GtkMenuItem *play_from_start_marker; 256 GtkMenuItem *play_previous_row; 257 GtkMenuItem *play_current_row; 258 GtkMenuItem *play_next_row; 259 GtkMenuItem *advance_selection; 260 GtkMenuItem *save_selection_as_wav; 261 }; 262 263 struct gui_menu_video 264 { 265 GtkMenuItem *open_recent; 266 GtkMenuItem *close; 267 }; 268 269 struct gui_menu_event 270 { 271 GtkMenuItem *me; 272 GtkMenuItem *type; 273 GtkMenuItem *add_blank_above; 274 GtkMenuItem *add_blank_below; 275 GtkMenuItem *add_separator_above; 276 GtkMenuItem *add_separator_below; 277 GtkMenuItem *event_delete; 278 GtkMenuItem *find_spelling_mistake; 279 GtkMenuItem *spellcheck_language; 280 GtkMenuItem *join; 281 GtkMenuItem *shift_times; 282 GtkMenuItem *split_at_cursor; 283 GtkMenuItem *split; 284 GtkMenuItem *copy; 285 GtkMenuItem *cut; 286 GtkMenuItem *paste_above; 287 GtkMenuItem *paste_below; 288 GtkMenuItem *number_events; 289 }; 290 291 struct gui_menu_karaoke 292 { 293 GtkMenuItem *me; 294 GtkMenuItem *box_mode; 295 GtkMenuItem *script_mode; 296 GtkMenuItem *save_changes; 297 GtkMenuItem *turn_off; 298 //GtkMenuItem *add_silence_before; 299 //GtkMenuItem *add_silence_after; 300 GtkMenuItem *split_part; 301 GtkMenuItem *previous_part; 302 GtkMenuItem *next_part; 303 }; 304 305 struct gui_menu_sync 306 { 307 GtkMenuItem *me; 308 }; 309 310 struct gui_menu 311 { 312 GtkMenuBar *me; 313 struct gui_menu_script script; 314 struct gui_menu_audio audio; 315 struct gui_menu_video video; 316 struct gui_menu_event event; 317 struct gui_menu_karaoke karaoke; 318 struct gui_menu_sync sync; 319 }; 320 321 struct gui_pixbufs 322 { 323 GdkPixbuf *show; 324 GdkPixbuf *hide; 325 GdkPixbuf *gear; 326 GdkPixbuf *syntax; 327 GdkPixbuf *syntax_off; 328 GdkPixbuf *karaoke_box; 329 GdkPixbuf *karaoke_line; 330 GdkPixbuf *search_indicator; 331 GdkPixbuf *margin_left; 332 GdkPixbuf *margin_right; 333 GdkPixbuf *margin_vertical; 334 GdkPixbuf *angle; 335 GdkPixbuf *scalex; 336 GdkPixbuf *scaley; 337 GdkPixbuf *spacing; 338 339 GdkPixbuf *time_left; 340 GdkPixbuf *time_left2; 341 GdkPixbuf *time_right; 342 GdkPixbuf *time_right2; 343 344 GdkPixbuf *sarrow_up_left; 345 GdkPixbuf *sarrow_up; 346 GdkPixbuf *sarrow_up_right; 347 GdkPixbuf *sarrow_left; 348 GdkPixbuf *sarrow_center; 349 GdkPixbuf *sarrow_right; 350 GdkPixbuf *sarrow_down_left; 351 GdkPixbuf *sarrow_down; 352 GdkPixbuf *sarrow_down_right; 353 354 GdkPixbuf *sync_scroll; 355 GdkPixbuf *sync_zoom; 356 GdkPixbuf *sync_scale; 357 358 GdkPixbuf *play; 359 GdkPixbuf *play_last; 360 GdkPixbuf *play_selection; 361 GdkPixbuf *play_stop; 362 363 GdkPixbuf *grab_times; 364 365 GdkPixbuf *focus_selected; 366 367 GdkPixbuf *show_time; 368 GdkPixbuf *show_keyframes; 369 370 GdkPixbuf *leadin; 371 GdkPixbuf *leadout; 372 GdkPixbuf *leadboth; 373 }; 374 375 struct gui_main_struct 376 { 377 struct gui_menu menu; 378 struct gui_main_tab_video tab_video; 379 struct gui_main_tab_options_color tab_options_color; 380 struct gui_pixbufs pixbufs; 381 struct gui_main_style_editor style_editor; 382 383 struct AspellSpeller *speller; 384 385 GtkAccelGroup *menu_accel_group; 386 387 388 krySignal signal_progress; 389 390 GtkListStore *name_store; 391 GtkTreeModel *name_store_sorted; 392 int name_store_rows; 393 394 GtkListStore *style_store; 395 396 struct KryEventList *event_list; 397 struct KryTextEditor *text_editor; 398 399 GtkCellRenderer *renderer_text; 400 GtkWindow *window; 401 GtkWindow *window_focus; 402 403 GtkLabel *label_zoom; 404 GtkSpinButton *spin_zoom; 405 GtkLabel *label_scale; 406 GtkSpinButton *spin_scale; 407 408 GtkTable *table_event_editor; 409 GtkToolbar *play_toolbar; 410 GtkHBox *hbox_play_toolbar; 411 GList *list_play_toolbar; 412 GtkButton *wave_grab_times; 413 GtkButton *wave_play_selected; 414 415 GtkWidget *search_indicator_style; 416 GtkWidget *search_indicator_name; 417 GtkWidget *search_indicator_text; 418 419 GtkWidget *time_start; 420 GtkWidget *time_end; 421 GtkWidget *time_dur; 422 423 GtkWidget *box_time_start; 424 GtkWidget *box_time_end; 425 GdkColor box_orig_color; 426 427 GtkTooltips *tooltips; 428 GtkPaned *wave_pane; 429 430 struct KryStatusBar *status_bar; 431 GtkNotebook *notebook; 432 433 GtkWidget *tab_audio_widget; 434 GtkWidget *tab_video_widget; 435 436 GtkLabel *tab_audio_label; 437 GtkLabel *tab_video_label; 438 439 GtkHBox *hbox_hide_channels; 440 GtkHBox *hbox_wave; 441 GtkVBox *vbox_sub_wave; 442 GtkWidget *toolbar_wave; 443 444 GtkHBox *hbox_list; 445 GtkVBox *vbox_sub_list; 446 GtkToolbar *toolbar_list; 447 448 GtkButton *tool_play_start; 449 GtkButton *tool_play_stop; 450 451 enum toolbar_pos toolbar_location; 452 enum ui_mode ui_mode; 453 454 struct sound_info *sound_info; 455 456 /*** RECENT FILES RELATED ***/ 457 GList *list_recent_scripts; 458 GList *list_recent_workspaces; 459 GList *list_recent_audio; 460 GList *list_recent_videos; 461 462 GCallback cb_recent_scripts; 463 GCallback cb_recent_workspaces; 464 GCallback cb_recent_audio; 465 GCallback cb_recent_videos; 466 /*** RECENT FILES RELATED ***/ 467 468 // marker for the entire event 469 KryMarker *marker_event_start; 470 KryMarker *marker_event_end; 471 472 KryMarker *marker_current; 473 474 // marker for the active event. 475 // will either be set to the event markers for normal mode 476 // or to the current karaoke part for the karaoke mode 477 KryMarker *marker_active_start; 478 KryMarker *marker_active_end; 479 480 enum karaoke_mode karaoke_mode; 481 kryEvent *karaoke_parent_event; 482 kryEventKaraokeText *karaoke_selection; 483 kryEventKaraokeText *karaoke_start; 484 kryEventKaraokeText *karaoke_end; 485 kryList<kryEvent *> *karaoke_parts; 486 487 KryMarker *marker_karaoke_start; 488 KryMarker *marker_karaoke_end; 489 GtkComboBox *karaoke_type_combo; 490 491 KryRegionFixedList *region_list; 492 KryWaveformGroup *waveform_group; 493 GtkVBox *vbox_waves; 494 495 enum sound_play_status sound_play_status; 496 //gboolean is_playing; // only used for 'Play from Start Marker' command 497 498 499 GtkDrawingArea *video_area; 500 501 502 GtkLabel *label_name; 503 GtkComboBox *combo_name; 504 505 GtkLabel *label_style; 506 GtkComboBox *combo_style; 507 508 GtkLabel *label_layer; 509 GtkSpinButton *spin_layer; 510 511 gboolean autosave; 512 513 GtkHBox *hbox_start_1; 514 GtkHBox *hbox_end_1; 515 516 GtkButton *button_start_less_10; 517 GtkButton *button_start_more_10; 518 GtkButton *button_start_less_1; 519 GtkButton *button_start_more_1; 520 521 kryList<kryEventDetailed *> clipboard_events; 522 //kryScript *line_copy; 523 524 gboolean time_modified; 525 526 //enum text_highlight_mode text_highlight_mode; 527 528 //GtkVBox *karaoke_vbox_separator; 529 GtkHBox *karaoke_hbox_switch; 530 GtkVBox *karaoke_vbox_switch; 531 GtkVBox *karaoke_vbox_toolbar; 532 GtkButton *karaoke_button_box; 533 GtkButton *karaoke_button_line; 534 GtkWidget *karaoke_toolbar_split; 535 GtkHBox *hbox_karaoke; 536 GtkLayout *karaoke_container; 537 GtkWidget *event_editor; 538 GtkFrame *frame_controls; 539 540 GtkVBox *vbox_event_edit; 541 GtkVBox *vbox_list_super; 542 GtkPaned *paned_notebook; 543 GtkPaned *paned_list; 544 545 GtkWidget *hbox_color; 546 547 GdkColor color_bg; 548 549 GdkColor colors_waveform[WAVEFORM_COLOR_COUNT]; 550 KryWaveform *wave_preview; 551 552 kryColorTable *waveform_color_table; 553 kryColorTable *list_color_table; 554 kryColorTable *style_color_table; 555 kryColorTable *status_bar_color_table; 556 kryColorTable *highlight_color_table; 557 558 struct hold_button_callback_info *info_start_less1; 559 struct hold_button_callback_info *info_start_less10; 560 struct hold_button_callback_info *info_start_more1; 561 struct hold_button_callback_info *info_start_more10; 562 563 struct hold_button_callback_info *info_end_less1; 564 struct hold_button_callback_info *info_end_less10; 565 struct hold_button_callback_info *info_end_more1; 566 struct hold_button_callback_info *info_end_more10; 567 568 gboolean video_drawing; 569 570 int pane_video_pos; 571 int pane_other_pos; 572 573 int play_speed; 574 575 //GList *event_list_columns; 576 577 GList *rc_files; 578 }; 579 580 581 582 typedef void (*kryButtonCallback)(GdkEventButton *, gpointer); 583 584 struct hold_button_callback_info 585 { 586 GtkWidget *widget; 587 kryButtonCallback func; 588 gpointer data; 589 gboolean released; 590 int running; 591 int id; 592 593 GdkEventButton event; 594 }; 595 596 enum recent_id 597 { 598 RECENT_SCRIPTS, 599 RECENT_WORKSPACES, 600 RECENT_AUDIO, 601 RECENT_VIDEOS 602 }; 603 604 static char *file_filter_audio[] = 605 { 606 "WAV (*.wav)", "*.wav", 607 _("FileFilter|All Files (*.*)"), "*.*", NULL 608 }; 609 610 static char *file_filter_script_ssa[] = 611 { 612 _("FileFilter|All Supported Formats (*.ssa; *.ass)"), "*.ass;*.ssa;", 613 "SubStation Alpha (*.ssa)", "*.ssa", 614 "Advanced SubStation (*.ass)", "*.ass", 615 _("FileFilter|All Files (*.*)"), "*.*", 616 NULL 617 }; 618 619 static char *file_filter_script[] = 620 { 621 _("FileFilter|All Supported Formats (*.ssa; *.ass; *.srt; *.txt)"), "*.ass;*.ssa;*.txt;*.srt;", 622 "SubStation Alpha (*.ssa)", "*.ssa", 623 "Advanced SubStation (*.ass)", "*.ass", 624 "SubRip (*.srt)", "*.srt", 625 _("FileFilter|Text File (*.txt)"), "*.txt", 626 _("FileFilter|All Files (*.*)"), "*.*", 627 NULL 628 }; 629 630 static char *file_filter_workspace[] = 631 { 632 _("FileFilter|Sabbu Workspace (*.sabbu)"), "*.sabbu", 633 _("FileFilter|All Files (*.*)"), "*.*", 634 NULL 635 }; 636 637 static char *file_filter_keyframe[] = 638 { 639 _("FileFilter|Keyframes (*.keyframes)"), "*.keyframes", 640 _("FileFilter|All Files (*.*)"), "*.*", 641 NULL 642 }; 643 644 static char *file_filter_video[] = 645 { 646 "AVI (*.avi)", "*.avi", 647 _("FileFilter|All Files (*.*)"), "*.*", 648 NULL 649 }; 650 651 static char *file_filter_export_txt[] = 652 { 653 _("FileFilter|Text File (*.txt)"), "*.txt", 654 _("FileFilter|All Files (*.*)"), "*.*", 655 NULL 656 }; 657 658 static char *file_filter_export_encore[] = 659 { 660 "Adobe Encore File (*.txt)", "*.txt", 661 _("FileFilter|All Files (*.*)"), "*.*", 662 NULL 663 }; 664 665 static char *file_filter_script_s_ass[] = 666 { 667 "Advanced SubStation (*.ass)", "*.ass", 668 "SubStation Alpha (*.ssa)", "*.ssa", 669 "SubRip (*.srt)", "*.srt", 670 _("FileFilter|All Files (*.*)"), "*.*", 671 NULL 672 }; 673 674 static char *file_filter_script_s_ssa[] = 675 { 676 "SubStation Alpha (*.ssa)", "*.ssa", 677 "Advanced SubStation (*.ass)", "*.ass", 678 "SubRip (*.srt)", "*.srt", 679 _("FileFilter|All Files (*.*)"), "*.*", 680 NULL 681 }; 682 683 static char *file_filter_script_s_srt[] = 684 { 685 "SubRip (*.srt)", "*.srt", 686 "SubStation Alpha (*.ssa)", "*.ssa", 687 "Advanced SubStation (*.ass)", "*.ass", 688 _("FileFilter|All Files (*.*)"), "*.*", 689 NULL 690 }; 691 692 void gui_main_entry_name_changed_cb(GtkWidget *widget, GtkComboBox *combo); 693 gboolean gui_main_hold_button_press(GtkWidget *widget, GdkEventButton *event, struct hold_button_callback_info *info); 694 gboolean gui_main_hold_button_release(GtkWidget *widget, struct hold_button_callback_info *info); 695 void gui_main_layer_style_changed_cb(GtkWidget *widget, gpointer data); 696 gboolean gui_combo_box_set_text(GtkComboBox *combo, char *text, gboolean numeric = FALSE); 697 void gui_combo_box_add_text(GtkComboBox *combo, char *text, gboolean numeric = FALSE); 698 void gui_main_script_modified(gboolean modified); 699 void gui_main_recent_list_add(GtkMenuItem *parent, GList **list, GCallback cb, char *filename); 700 void gui_main_recent_list_save(GList *list, char *key); 701 void gui_main_menu_script_openrecent(GtkWidget *widget, gpointer callback_data); 702 void gui_main_update_pane_position(int page); 703 void gui_main_set_ui_mode(enum ui_mode ui_mode); 704 void gui_main_check_theme(); 705 void gui_main_set_time_modified(gboolean val); 706 GtkComboBoxEntry *gui_combo_box_fps_new(gboolean ntsc_pal_only = FALSE); 707 void gui_main_text_paned_move_cb(GtkPaned *paned, GParamSpec *spec, gpointer data); 708 void gui_main_waveform_toolbar_advanced(struct waveform_info *info); 709 void gui_main_advanced_waveform_ui_switch(gboolean val); 710 gboolean gui_main_time_box_key_press_cb(GtkWidget *widget, GdkEventKey *key, gpointer data); 711 void gui_main_focus(); 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744