/* Get ready to run the CBlorb compiler. This function is called from a child process watch, so the GDK lock is not held and must be acquired for any GUI calls. */ static void prepare_cblorb_compiler(CompilerData *data) { gdk_threads_enter(); i7_document_display_status_message(I7_DOCUMENT(data->story), _("Running cBlorb..."), COMPILE_OPERATIONS); gdk_threads_leave(); }
/* Set everything up for using the NI compiler. Called from the main thread. */ static void prepare_ni_compiler(CompilerData *data) { I7_STORY_USE_PRIVATE(data->story, priv); GError *err = NULL; /* Clear the previous compile output */ gtk_text_buffer_set_text(priv->progress, "", -1); html_load_blank(WEBKIT_WEB_VIEW(data->story->panel[LEFT]->results_tabs[I7_RESULTS_TAB_REPORT])); html_load_blank(WEBKIT_WEB_VIEW(data->story->panel[RIGHT]->results_tabs[I7_RESULTS_TAB_REPORT])); /* Create the UUID file if needed */ GFile *uuid_file = g_file_get_child(data->input_file, "uuid.txt"); if(!g_file_query_exists(uuid_file, NULL)) { #ifdef E2FS_UUID /* code for e2fsprogs uuid */ uuid_t uuid; gchar uuid_string[37]; uuid_generate_time(uuid); uuid_unparse(uuid, uuid_string); #else /* code for OSSP UUID */ gchar *uuid_string = NULL; /* a new buffer is allocated if NULL */ uuid_t *uuid; if(!((uuid_create(&uuid) == UUID_RC_OK) && (uuid_make(uuid, UUID_MAKE_V1) == UUID_RC_OK) && (uuid_export(uuid, UUID_FMT_STR, (void **)&uuid_string, NULL) == UUID_RC_OK) && (uuid_destroy(uuid) == UUID_RC_OK))) { error_dialog(GTK_WINDOW(data->story), NULL, _("Error creating UUID.")); g_object_unref(uuid_file); return; } #endif /* UUID conditional */ if(!g_file_replace_contents(uuid_file, uuid_string, strlen(uuid_string), NULL, FALSE, G_FILE_CREATE_NONE, NULL, NULL, &err)) { IO_ERROR_DIALOG(GTK_WINDOW(data->story), uuid_file, err, _("creating UUID file")); g_object_unref(uuid_file); return; } #ifndef E2FS_UUID /* Only OSSP UUID */ free(uuid_string); #endif /* !OSSP_UUID */ } g_object_unref(uuid_file); /* Display status message */ i7_document_display_status_message(I7_DOCUMENT(data->story), _("Compiling Inform 7 to Inform 6"), COMPILE_OPERATIONS); }
/* Callback for beginning the print operation, we give the printed pages our tab width from the preferences, and the margins from the page setup dialog. */ static void on_begin_print(GtkPrintOperation *print, GtkPrintContext *context, I7Document *document) { I7App *theapp = i7_app_get(); GSettings *prefs = i7_app_get_prefs(theapp); GtkSourcePrintCompositor *compositor = gtk_source_print_compositor_new(i7_document_get_buffer(document)); g_signal_connect(print, "draw-page", G_CALLBACK(on_draw_page), compositor); g_signal_connect(print, "end-print", G_CALLBACK(on_end_print), compositor); /* Design our printed page */ unsigned tabwidth = g_settings_get_uint(prefs, PREFS_TAB_WIDTH); if(tabwidth == 0) tabwidth = DEFAULT_TAB_WIDTH; gtk_source_print_compositor_set_tab_width(compositor, tabwidth); gtk_source_print_compositor_set_wrap_mode(compositor, GTK_WRAP_WORD_CHAR); PangoFontDescription *font = get_font_description(); gchar *fontstring = pango_font_description_to_string(font); pango_font_description_free(font); gtk_source_print_compositor_set_body_font_name(compositor, fontstring); g_free(fontstring); GtkPageSetup *setup = i7_app_get_page_setup(i7_app_get()); gtk_source_print_compositor_set_top_margin(compositor, gtk_page_setup_get_top_margin(setup, GTK_UNIT_MM), GTK_UNIT_MM); gtk_source_print_compositor_set_bottom_margin(compositor, gtk_page_setup_get_bottom_margin(setup, GTK_UNIT_MM), GTK_UNIT_MM); gtk_source_print_compositor_set_left_margin(compositor, gtk_page_setup_get_left_margin(setup, GTK_UNIT_MM), GTK_UNIT_MM); gtk_source_print_compositor_set_right_margin(compositor, gtk_page_setup_get_right_margin(setup, GTK_UNIT_MM), GTK_UNIT_MM); /* Display a notification in the status bar while paginating */ i7_document_display_status_message(document, _("Paginating..."), PRINT_OPERATIONS); while(!gtk_source_print_compositor_paginate(compositor, context)) { i7_document_display_progress_percentage(document, gtk_source_print_compositor_get_pagination_progress(compositor)); while(gtk_events_pending()) gtk_main_iteration(); } i7_document_display_progress_percentage(document, 0.0); i7_document_remove_status_message(document, PRINT_OPERATIONS); gtk_print_operation_set_n_pages(print, gtk_source_print_compositor_get_n_pages(compositor)); }