Ejemplo n.º 1
0
GtkWidget *
create_welcome_dialog(void)
{
	I7App *theapp = i7_app_get();
	GFile *file = i7_app_get_data_file_va(theapp, "ui", "welcomedialog.ui", NULL);
	GtkBuilder *builder = create_new_builder(file, theapp);
	g_object_unref(file);
	GtkWidget *retval = GTK_WIDGET(load_object(builder, "welcomedialog"));

	/* Set the background pixmap for this window */
	GtkRcStyle *newstyle = gtk_widget_get_modifier_style(retval);
	file = i7_app_get_data_file_va(theapp, "Resources", "Welcome Background.png", NULL);
	newstyle->bg_pixmap_name[GTK_STATE_NORMAL] = g_file_get_path(file); /* take ownership */
	g_object_unref(file);
	gtk_widget_modify_style(retval, newstyle);

	/* Set the font size to 12 pixels for the widgets in this window */
	PangoFontDescription *font = pango_font_description_new();
	pango_font_description_set_absolute_size(font, 12.0 * PANGO_SCALE);
	gtk_widget_modify_font(GTK_WIDGET(load_object(builder, "welcome_label")), font);
	pango_font_description_free(font);

	/* If there is no "last project", make the reopen button inactive */
	GFile *last_project = i7_app_get_last_opened_project(theapp);
	if(last_project) {
		gtk_widget_set_sensitive(GTK_WIDGET(load_object(builder, "welcome_reopen_button")), TRUE);
		g_object_unref(last_project);
	}
	g_object_unref(builder);

	return retval;
}
Ejemplo n.º 2
0
/* Help->Recipe Book */
void
action_help_recipe_book(GtkAction *action, I7Story *story)
{
	GFile *file = i7_app_get_data_file_va(i7_app_get(), "Documentation", "Rallegs.html", NULL);
	i7_story_show_docpage(story, file);
	g_object_unref(file);
}
Ejemplo n.º 3
0
/* Help->License */
void
action_help_license(GtkAction *action, I7Story *story)
{
	GFile *file = i7_app_get_data_file_va(i7_app_get(), "Documentation", "licenses", "license.html", NULL);
	i7_story_show_docpage(story, file);
	g_object_unref(file);
}
Ejemplo n.º 4
0
/* Search the documentation pages for the string 'text', building the index
  if necessary */
void
i7_search_window_search_documentation(I7SearchWindow *self)
{
	GError *err;

	if(doc_index == NULL) { /* documentation index hasn't been built yet */
		GFile *doc_file = i7_app_get_data_file_va(i7_app_get(), "Documentation", NULL);

		GFileEnumerator *docdir;
		if((docdir = g_file_enumerate_children(doc_file, "standard::*", G_FILE_QUERY_INFO_NONE, NULL, &err)) == NULL) {
			IO_ERROR_DIALOG(GTK_WINDOW(self), doc_file, err, _("opening documentation directory"));
			g_object_unref(doc_file);
			return;
		}

		start_spinner(self);

		GFileInfo *info;
		while((info = g_file_enumerator_next_file(docdir, NULL, &err)) != NULL) {
			const char *basename = g_file_info_get_name(info);
			const char *displayname = g_file_info_get_display_name(info);

			if(!g_str_has_suffix(basename, ".html") ||
			   (!g_str_has_prefix(basename, "doc") && !g_str_has_prefix(basename, "Rdoc")))
				continue;

			char *label = g_strdup_printf(_("Please be patient, indexing %s..."), displayname);
			gtk_label_set_text(GTK_LABEL(self->search_text), label);
			g_free(label);

			while(gtk_events_pending())
				gtk_main_iteration();

			GFile *file = g_file_get_child(doc_file, basename);
			GSList *doctexts = html_to_ascii(file, g_str_has_prefix(basename, "R"));
			g_object_unref(file);
			if(doctexts != NULL) {
				GSList *iter;
				/* Append the entries to the documentation index and search them
				right now while we're at it */
				for(iter = doctexts; iter != NULL; iter = g_slist_next(iter)) {
					doc_index = g_list_prepend(doc_index, iter->data);
					search_documentation(iter->data, self);
				}
				g_slist_free(doctexts);
			}
		}
		g_object_unref(doc_file);

		stop_spinner(self);
		update_label(self);
	} else {
		start_spinner(self);
		g_list_foreach(doc_index, (GFunc)search_documentation, self);
		stop_spinner(self);
	}
	return;
}
Ejemplo n.º 5
0
static void
i7_search_window_init(I7SearchWindow *self)
{
	I7_SEARCH_WINDOW_USE_PRIVATE(self, priv);

	priv->document = NULL;
	priv->text = NULL;
	priv->ignore_case = FALSE;
	priv->algorithm = I7_SEARCH_CONTAINS;

	gtk_window_set_destroy_with_parent(GTK_WINDOW(self), TRUE);
	gtk_window_set_icon_name(GTK_WINDOW(self), "inform7");
	gtk_window_set_skip_taskbar_hint(GTK_WINDOW(self), TRUE);
	gtk_window_set_title(GTK_WINDOW(self), _("Search Results"));
	gtk_window_set_type_hint(GTK_WINDOW(self), GDK_WINDOW_TYPE_HINT_UTILITY);
	gtk_container_set_border_width(GTK_CONTAINER(self), 12);
	gtk_window_set_default_size(GTK_WINDOW(self), 400, 400);

	/* Build the interface from the builder file */
	GFile *file = i7_app_get_data_file_va(i7_app_get(), "ui", "searchwindow.ui", NULL);
	GtkBuilder *builder = create_new_builder(file, self);
	g_object_unref(file);

	/* Build the rest of the interface */
	gtk_container_add(GTK_CONTAINER(self), GTK_WIDGET(load_object(builder, "search_window")));
	priv->results = GTK_LIST_STORE(load_object(builder, "results"));
	gtk_tree_view_column_set_cell_data_func(GTK_TREE_VIEW_COLUMN(load_object(builder, "result_column")),
		GTK_CELL_RENDERER(load_object(builder, "result_renderer")),
		(GtkTreeCellDataFunc)result_data_func, self, NULL);
	gtk_tree_view_column_set_cell_data_func(GTK_TREE_VIEW_COLUMN(load_object(builder, "document_column")),
		GTK_CELL_RENDERER(load_object(builder, "document_renderer")),
		(GtkTreeCellDataFunc)location_data_func, self, NULL);
	gtk_tree_view_column_set_cell_data_func(GTK_TREE_VIEW_COLUMN(load_object(builder, "type_column")),
		GTK_CELL_RENDERER(load_object(builder, "type_renderer")),
		(GtkTreeCellDataFunc)type_data_func, NULL, NULL);
	g_signal_connect(self, "delete-event", G_CALLBACK(on_search_window_delete_event), NULL);

	/* Save public pointers to other widgets */
	LOAD_WIDGET(search_text);
	LOAD_WIDGET(results_view);
	LOAD_WIDGET(spinner);

	/* Builder object not needed anymore */
	g_object_unref(builder);
}
Ejemplo n.º 6
0
/* Display any errors from Inform 6 and decide what to do next. 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
finish_i6_compiler(GPid pid, gint status, CompilerData *data)
{
    I7_STORY_USE_PRIVATE(data->story, priv);

    /* Clear the progress indicator */
    gdk_threads_enter();
    i7_document_remove_status_message(I7_DOCUMENT(data->story), COMPILE_OPERATIONS);
    i7_document_clear_progress(I7_DOCUMENT(data->story));
    gdk_threads_leave();

    /* Get exit code from I6 process */
    int exit_code = WIFEXITED(status)? WEXITSTATUS(status) : -1;

    /* Display the exit status of the I6 compiler in the Progress tab */
    gchar *statusmsg = g_strdup_printf(_("\nCompiler finished with code %d\n"),
                                       exit_code);
    GtkTextIter iter;
    gdk_threads_enter();
    gtk_text_buffer_get_end_iter(priv->progress, &iter);
    gtk_text_buffer_insert(priv->progress, &iter, statusmsg, -1);
    gdk_threads_leave();
    g_free(statusmsg);

    GtkTextIter start, end;
    int line;
    GFile *loadfile = NULL;

    /* Display the appropriate HTML error pages */
    gdk_threads_enter();
    for(line = gtk_text_buffer_get_line_count(priv->progress); line >= 0; line--) {
        gchar *msg;
        gtk_text_buffer_get_iter_at_line(priv->progress, &start, line);
        end = start;
        gtk_text_iter_forward_to_line_end(&end);
        msg = gtk_text_iter_get_text(&start, &end);
        if(strstr(msg, "rror:")) { /* "Error:", "Fatal error:" */
            if(strstr(msg, "The memory setting ") && strstr(msg, " has been exceeded."))
                loadfile = i7_app_get_data_file_va(i7_app_get(), "Resources", "en", "ErrorI6MemorySetting.html", NULL);
            else if(strstr(msg, "This program has overflowed the maximum readable-memory size of the "))
                loadfile = i7_app_get_data_file_va(i7_app_get(), "Resources", "en", "ErrorI6Readable.html", NULL);
            else if(strstr(msg, "The story file exceeds "))
                loadfile = i7_app_get_data_file_va(i7_app_get(), "Resources", "en", "ErrorI6TooBig.html", NULL);
            else
                loadfile = i7_app_get_data_file_va(i7_app_get(), "Resources", "en", "ErrorI6.html", NULL);
            g_free(msg);
            break;
        }
        g_free(msg);
    }
    gdk_threads_leave();
    if(!loadfile && exit_code != 0)
        loadfile = i7_app_get_data_file_va(i7_app_get(), "Resources", "en", "ErrorI6.html", NULL);
    if(loadfile) {
        g_clear_object(&data->results_file);
        data->results_file = loadfile; /* assumes reference */
    }

    /* Stop here and show the Results/Report tab if there was an error */
    if(exit_code != 0) {
        finish_compiling(FALSE, data);
        return;
    }

    /* Decide what to do next */
    if(!data->create_blorb) {
        I7Story *story = data->story;
        finish_compiling(TRUE, data);
        /* Hold the GDK lock for the callback */
        gdk_threads_enter();
        (priv->compile_finished_callback)(story, priv->compile_finished_callback_data);
        gdk_threads_leave();
        return;
    }

    prepare_cblorb_compiler(data);
    start_cblorb_compiler(data);
}
Ejemplo n.º 7
0
/* Display any errors from the NI compiler and continue on. 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
finish_ni_compiler(GPid pid, gint status, CompilerData *data)
{
    I7_STORY_USE_PRIVATE(data->story, priv);
    I7App *theapp = i7_app_get();
    GSettings *prefs = i7_app_get_prefs(theapp);

    /* Clear the progress indicator */
    gdk_threads_enter();
    i7_document_remove_status_message(I7_DOCUMENT(data->story), COMPILE_OPERATIONS);
    i7_document_clear_progress(I7_DOCUMENT(data->story));
    gdk_threads_leave();

    /* Get the ni.exe exit code */
    int exit_code = WIFEXITED(status)? WEXITSTATUS(status) : -1;

    /* Display the appropriate HTML error or success page */
    GFile *problems_file = NULL;
    if(exit_code <= 1) {
        /* In the case of success or a "normal" failure, or a negative error
         code should one occur, display the compiler's generated Problems.html*/
        problems_file = g_file_get_child(data->builddir_file, "Problems.html");
    } else {
        gchar *file = g_strdup_printf("Error%i.html", exit_code);
        problems_file = i7_app_check_data_file_va(theapp, "Resources", "en", file, NULL);
        g_free(file);
        if(!problems_file)
            problems_file = i7_app_get_data_file_va(theapp, "Resources", "en", "Error0.html", NULL);
    }

    g_clear_object(&data->results_file);
    data->results_file = problems_file; /* assumes reference */

    if(g_settings_get_boolean(prefs, PREFS_SHOW_DEBUG_LOG)) {
        /* Update */
        gdk_threads_enter();
        while(gtk_events_pending())
            gtk_main_iteration();
        gdk_threads_leave();

        /* Refresh the debug log */
        gchar *text;
        GFile *debug_file = g_file_get_child(data->builddir_file, "Debug log.txt");
        /* Ignore errors, just don't show it if it's not there */
        if(g_file_load_contents(debug_file, NULL, &text, NULL, NULL, NULL)) {
            gdk_threads_enter();
            gtk_text_buffer_set_text(priv->debug_log, text, -1);
            gdk_threads_leave();
            g_free(text);
        }
        g_object_unref(debug_file);

        /* Refresh the I6 code */
        GFile *i6_file = g_file_get_child(data->builddir_file, "auto.inf");
        if(g_file_load_contents(i6_file, NULL, &text, NULL, NULL, NULL)) {
            gdk_threads_enter();
            gtk_text_buffer_set_text(GTK_TEXT_BUFFER(priv->i6_source), text, -1);
            gdk_threads_leave();
            g_free(text);
        }
        g_object_unref(i6_file);
    }

    /* Stop here and show the Results/Report tab if there was an error */
    if(exit_code != 0) {
        finish_compiling(FALSE, data);
        return;
    }

    /* Reload the Index in the background */
    i7_story_reload_index_tabs(data->story, FALSE);

    /* Read in the Blorb manifest */
    GFile *file = i7_document_get_file(I7_DOCUMENT(data->story));
    GFile *manifest_file = g_file_get_child(file, "manifest.plist");
    g_object_unref(file);
    PlistObject *manifest = plist_read_file(manifest_file, NULL, NULL);
    g_object_unref(manifest_file);
    /* If that failed, then silently keep the old manifest */
    if(manifest) {
        plist_object_free(priv->manifest);
        priv->manifest = manifest;
    }

    /* Decide what to do next */
    if(data->refresh_only) {
        I7Story *story = data->story;
        finish_compiling(TRUE, data);
        /* Hold the GDK lock for the callback */
        gdk_threads_enter();
        (priv->compile_finished_callback)(story, priv->compile_finished_callback_data);
        gdk_threads_leave();
        return;
    }

    prepare_i6_compiler(data);
    start_i6_compiler(data);
}