/** * \fn void show_score(BrailleMusicEditor *editor) * \brief This function create a scoreviewer in a widget. * \param editor The GUI structure. */ void show_score(BrailleMusicEditor *editor) { GError *err = NULL; GFile *file; gchar *filename = "score.pdf"; 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_warning ("Trying to read the score pdf file %s gave an error: %s", uri, err->message); if(err) g_error_free (err); err = NULL; } else { EvDocumentModel *docmodel = ev_document_model_new_with_document(EV_DOCUMENT(doc)); ev_view_set_model(EV_VIEW(editor->score_view), EV_DOCUMENT_MODEL(docmodel)); g_signal_connect(editor->score_view, "external-link", G_CALLBACK(external_link_catch), editor); } }
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; } }