Beispiel #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);
}
Beispiel #2
0
/* Callback for when of the items from the File->Open Recent submenu
 is selected */
void
action_open_recent(GtkAction *action, I7App *app)
{
	GtkRecentInfo *item = gtk_recent_chooser_get_current_item(GTK_RECENT_CHOOSER(action));
	g_assert(gtk_recent_info_has_application(item, "Inform 7"));

	GFile *file = g_file_new_for_uri(gtk_recent_info_get_uri(item));

	if(gtk_recent_info_has_group(item, "inform7_project")) {
		i7_story_new_from_file(app, file);
	} else if(gtk_recent_info_has_group(item, "inform7_extension")) {
		i7_extension_new_from_file(app, file, FALSE);
	} else if(gtk_recent_info_has_group(item, "inform7_builtin")) {
		i7_extension_new_from_file(app, file, TRUE);
	} else {
		g_warning("Recent manager file does not have an Inform tag. This means "
			"it was not saved by Inform. I'll try to open it anyway.");
		i7_story_new_from_file(app, file);
	}

	g_object_unref(file);
	gtk_recent_info_unref(item);
}
Beispiel #3
0
/* Callback for when one of the items from the File->Open Extension submenu
 is selected, and it is a user-installed extension */
void
on_open_extension_activate(GtkMenuItem *menuitem, GFile *file)
{
	i7_extension_new_from_file(i7_app_get(), file, FALSE);
}