Example #1
0
/* Callback for double-clicking on one of the search results */
void
on_results_view_row_activated(GtkTreeView *treeview, GtkTreePath *path, GtkTreeViewColumn *column, I7SearchWindow *self)
{
	I7_SEARCH_WINDOW_USE_PRIVATE(self, priv);
	GtkTreeIter iter;
	GtkTreeModel *model = gtk_tree_view_get_model(treeview);
	g_return_if_fail(model);

	if(!(gtk_tree_model_get_iter(model, &iter, path)))
		return;
	GFile *file;
	int result_type, lineno;
	char *anchor;
	gtk_tree_model_get(model, &iter,
		I7_RESULT_FILE_COLUMN, &file,
		I7_RESULT_ANCHOR_COLUMN, &anchor,
		I7_RESULT_RESULT_TYPE_COLUMN, &result_type,
		I7_RESULT_LINE_NUMBER_COLUMN, &lineno,
		-1);

	switch(result_type) {
	case I7_RESULT_TYPE_DOCUMENTATION:
	case I7_RESULT_TYPE_RECIPE_BOOK:
	{
		/* Display the documentation page in the appropriate widget if this
		 is a story with facing pages. Otherwise, open the documentation in
		 the web browser. */
		if(I7_IS_STORY(priv->document)) {
			/* Jump to the proper example */
			char *filepath = g_file_get_path(file);
			if(anchor != NULL) {
				i7_story_show_docpage_at_anchor(I7_STORY(priv->document), file, anchor);
				g_free(anchor);
			} else
				i7_story_show_docpage(I7_STORY(priv->document), file);

			g_free(filepath);
		} else {
			show_file_in_browser(file, GTK_WINDOW(self));
		}
	}
		break;
	case I7_RESULT_TYPE_PROJECT:
		i7_document_jump_to_line(priv->document, lineno);
		break;
	case I7_RESULT_TYPE_EXTENSION:
	{
		I7Document *ext = i7_app_get_already_open(i7_app_get(), file);
		if(ext == NULL) {
			ext = I7_DOCUMENT(i7_extension_new_from_file(i7_app_get(), file, FALSE));
		}
		i7_document_jump_to_line(ext, lineno);
	}
		break;
	default:
		g_assert_not_reached();
	}
	g_object_unref(file);
}
Example #2
0
static void
location_data_func(GtkTreeViewColumn *column, GtkCellRenderer *cell, GtkTreeModel *model, GtkTreeIter *iter, I7SearchWindow *self)
{
	I7_SEARCH_WINDOW_USE_PRIVATE(self, priv);

	I7ResultType type;
	guint lineno;
	GFile *file;
	char *text = NULL, *filename, *location;

	gtk_tree_model_get(model, iter,
		I7_RESULT_RESULT_TYPE_COLUMN, &type,
		I7_RESULT_LINE_NUMBER_COLUMN, &lineno,
		I7_RESULT_FILE_COLUMN, &file,
		I7_RESULT_LOCATION_COLUMN, &location,
		-1);

	switch(type) {
		case I7_RESULT_TYPE_PROJECT:
			if(I7_IS_STORY(priv->document))
				text = g_strdup_printf(_("Story, line %d"), lineno);
			else {
				gchar *displayname = i7_document_get_display_name(priv->document);
				if(displayname == NULL) {
					text = g_strdup_printf(_("Untitled story, line %d"), lineno);
				} else {
					text = g_strdup_printf(_("%s, line %d"), displayname, lineno);
					g_free(displayname);
				}
			}
			break;
		case I7_RESULT_TYPE_EXTENSION:
		{
			/* Get the file's display name */
			filename = file_get_display_name(file);

			text = g_strdup_printf(
				  /* TRANSLATORS: EXTENSION_NAME, line NUMBER */
				  _("%s, line %d"), filename, lineno);
			g_free(filename);
		}
			break;
		case I7_RESULT_TYPE_DOCUMENTATION:
		case I7_RESULT_TYPE_RECIPE_BOOK:
			text = g_strdup(location);
		default:
			;
	}

	g_object_set(cell, "text", text, NULL);
	g_object_unref(file);
	g_free(text);
}
Example #3
0
static void
set_glulx_interpreter(I7Document *document, gpointer data)
{
	if(I7_IS_STORY(document))
		i7_story_set_use_git(I7_STORY(document), GPOINTER_TO_INT(data));
}