int main(int argc, char **argv) { BrailleMusicEditor *editor; // allocate the memory needed by our BrailleMusicEditor struct editor = g_slice_new (BrailleMusicEditor); //initialize GTK+ libraries gtk_init(&argc, &argv); ev_init(); // Creation of the main window create_window("BMC",600,400, editor); editor->vbox = gtk_vbox_new(FALSE, 2); gtk_container_add(GTK_CONTAINER(editor->window), editor->vbox); //Creation of the menubar create_menubar(editor); gtk_box_pack_start(GTK_BOX(editor->vbox), editor->menubar, FALSE, FALSE, 0); // Creation of the toolbar create_toolbar(editor); gtk_box_pack_start(GTK_BOX(editor->vbox), editor->toolbar, FALSE, FALSE, 2); //Creation of the two text views with scrollbars editor->hbox = gtk_hbox_new(FALSE, 0); gtk_container_add(GTK_CONTAINER(editor->vbox), editor->hbox); editor->edit_scrollbar = gtk_scrolled_window_new(NULL, NULL); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(editor->edit_scrollbar), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); gtk_box_pack_start(GTK_BOX(editor->hbox),editor->edit_scrollbar, TRUE, TRUE, 5); editor->textview=gtk_source_view_new(); //show line number gtk_source_view_set_show_line_numbers(GTK_SOURCE_VIEW(editor->textview), TRUE); g_signal_connect(gtk_text_view_get_buffer(GTK_TEXT_VIEW(editor->textview)), "changed", G_CALLBACK(on_text_changed), editor); gtk_container_add(GTK_CONTAINER(editor->edit_scrollbar), editor->textview); //lexical coloration auto update g_signal_connect(gtk_text_view_get_buffer(GTK_TEXT_VIEW(editor->textview)), "changed", G_CALLBACK(coloration_update), editor); //score view editor->score_scrollbar = gtk_scrolled_window_new(NULL, NULL); gtk_box_pack_start(GTK_BOX(editor->hbox),editor->score_scrollbar, TRUE, TRUE, 5); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(editor->score_scrollbar), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); editor->score_view = ev_view_new(); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(editor->score_scrollbar), editor->score_view); show_score(editor); gtk_widget_grab_focus(editor->textview); //Creation of the message error views with scrollbar editor->error_scrollbar = gtk_scrolled_window_new(NULL, NULL); gtk_box_pack_start(GTK_BOX(editor->vbox),editor->error_scrollbar, FALSE, TRUE, 0); gtk_widget_set_size_request (editor->error_scrollbar, -1, 100); gtk_container_set_border_width(GTK_CONTAINER(editor->error_scrollbar), 5); editor->error_view = gtk_text_view_new(); gtk_text_view_set_editable(GTK_TEXT_VIEW(editor->error_view), FALSE); gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(editor->error_scrollbar), editor->error_view); gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(editor->error_scrollbar), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); // show the window gtk_widget_show_all(editor->window); // enter GTK+ main loop gtk_main(); // free memory we allocated for BrailleMusicEditor struct g_slice_free (BrailleMusicEditor, editor); return EXIT_SUCCESS; }
static EvView * get_view (gchar * filename) { GFile *file; GError *err = NULL; EvView *view = NULL; GList *g; help_text = _("For each annotation on the page click on the (nearby) notehead or rest etc that the annotation refers to. This will insert a comment in the score. Transfer all the annotations in this way before editing the score, otherwise the locations will not match. You can use the EditSimilar (Ctrl-e,e and Ctrl-e,r) command to move from one comment to the next, stopping and editing the score as suggested by the comment."); filename = locate_file (filename); file = g_file_new_for_commandline_arg (filename); gchar *uri = g_file_get_uri (file); g_object_unref (file); EvDocument *doc = ev_document_factory_get_document (uri, &err); if (err) { g_critical("Error creating view from URI <%s> : message was %s", uri, err->message); return NULL; } if (annotated_pages) { gtk_widget_destroy (top_window); top_window = NULL; g_list_free (annotated_pages); current_page = annotated_pages = NULL; } view = (EvView *) ev_view_new (); EvDocumentModel *model = ev_document_model_new_with_document (doc); #ifndef EV_SIZING_FIT_PAGE #define EV_SIZING_FIT_PAGE EV_SIZING_BEST_FIT #endif ev_document_model_set_sizing_mode (model, EV_SIZING_FIT_PAGE); ev_document_model_set_continuous (model, FALSE); ev_view_set_model (view, model); if (find_annotated_pages (model)) { current_page = annotated_pages; ev_document_model_set_page (model, GPOINTER_TO_INT(current_page->data)); top_window = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_set_tooltip_text (top_window, help_text); gtk_window_set_title (GTK_WINDOW (top_window), g_strdup_printf ("Denemo - Proof-Read File: %s", filename)); gtk_window_set_default_size (GTK_WINDOW (top_window), 600, 750); GtkWidget *main_vbox = gtk_vbox_new (FALSE, 1); GtkWidget *main_hbox = gtk_hbox_new (FALSE, 1); gtk_container_add (GTK_CONTAINER (top_window), main_vbox); gtk_box_pack_start (GTK_BOX (main_vbox), main_hbox, FALSE, TRUE, 0); GtkWidget *button = gtk_button_new_with_label (_("Next Annotated Page")); g_signal_connect (button, "clicked", G_CALLBACK (next_page), (gpointer) model); gtk_box_pack_start (GTK_BOX (main_hbox), button, FALSE, TRUE, 0); button = gtk_button_new_with_label (_("Previous Annotated Page")); g_signal_connect (button, "clicked", G_CALLBACK (prev_page), (gpointer) model); gtk_box_pack_start (GTK_BOX (main_hbox), button, FALSE, TRUE, 0); g_signal_connect (G_OBJECT (view), "external-link", G_CALLBACK (action_for_link), (gpointer)model); g_signal_connect (G_OBJECT (view), "button-press-event", G_CALLBACK (press), (gpointer)model); GtkWidget *score_and_scroll_hbox = gtk_scrolled_window_new (gtk_adjustment_new (1.0, 1.0, 2.0, 1.0, 4.0, 1.0), gtk_adjustment_new (1.0, 1.0, 2.0, 1.0, 4.0, 1.0)); gtk_box_pack_start (GTK_BOX (main_vbox), score_and_scroll_hbox, TRUE, TRUE, 0); gtk_container_add (GTK_CONTAINER (score_and_scroll_hbox), GTK_WIDGET (view)); gtk_widget_show_all (top_window); gtk_window_present (GTK_WINDOW (top_window)); //this doesn't appear to work... return view; } else { warningdialog (_("This PDF file contains no annotations. It has to be a PDF file generated by Denemo for the current score to which annotations have been added.")); return NULL; } }