summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan Nicholson <dbn.lists@gmail.com>2012-05-26 23:55:56 -0700
committerDan Nicholson <dbn.lists@gmail.com>2012-05-26 23:55:56 -0700
commite7da2197c47e28732eda70ae244d5c5d09a747f4 (patch)
tree8c9f96910d45d665d741944b520d60c6e42821f5 /src
parentd4e1b942ff7df3624d3da1c71aded32a3701fb6a (diff)
Add a Open in Evince toolbar button
There are many, many features available in Evince that I have no intention of supporting here. The purpose of this plugin is to display documents simply in the browser. Add a button to launch the current file in the full Evince viewer.
Diffstat (limited to 'src')
-rw-r--r--src/evbp-viewer.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/evbp-viewer.c b/src/evbp-viewer.c
index befefa6..73d3d68 100644
--- a/src/evbp-viewer.c
+++ b/src/evbp-viewer.c
@@ -126,6 +126,42 @@ evbp_viewer_save_copy(GtkAction *action, EvbpViewer *viewer)
}
static void
+evbp_viewer_open_evince(GtkAction *action, EvbpViewer *viewer)
+{
+ GAppInfoCreateFlags flags;
+ GAppInfo *app;
+ GAppLaunchContext *context;
+ const gchar *docuri;
+ GList *uris = NULL;
+ GError *error = NULL;
+
+ /* create the evince app info and launch context */
+ flags = G_APP_INFO_CREATE_SUPPORTS_URIS |
+ G_APP_INFO_CREATE_SUPPORTS_STARTUP_NOTIFICATION;
+ app = g_app_info_create_from_commandline("evince", NULL, flags, &error);
+ if (!app) {
+ g_warning("Couldn't create application info for evince: %s\n",
+ error->message);
+ g_error_free(error);
+ return;
+ }
+ context = g_app_launch_context_new();
+
+ /* launch evince with the current uri */
+ docuri = ev_document_get_uri(viewer->document);
+ uris = g_list_append(uris, (gpointer)docuri);
+ if (!g_app_info_launch_uris(G_APP_INFO(app), uris, NULL, &error)) {
+ g_warning("Couldn't launch evince with file %s: %s\n", docuri,
+ error->message);
+ g_error_free(error);
+ }
+
+ g_list_free(uris);
+ g_object_unref(context);
+ g_object_unref(app);
+}
+
+static void
evbp_viewer_previous_page(GtkAction *action, EvbpViewer *viewer)
{
ev_view_previous_page(EV_VIEW(viewer->view));
@@ -281,6 +317,10 @@ static const GtkActionEntry action_entries[] = {
"_Save Copy", "<control>s",
"Save a copy of the document",
G_CALLBACK(evbp_viewer_save_copy) },
+ { "OpenInEvince", "evince",
+ "_Open in Evince", NULL,
+ "Open the document in the Evince viewer",
+ G_CALLBACK(evbp_viewer_open_evince) },
{ "GoPreviousPage", GTK_STOCK_GO_UP,
"_Previous Page", "<control>Page_Up",
"Go to the previous page",
@@ -315,6 +355,7 @@ static const gchar ui_string[] =
"<ui>\n"
" <toolbar name=\"ViewerToolbar\">\n"
" <toolitem name=\"SaveCopy\" action =\"SaveCopy\"/>\n"
+ " <toolitem name=\"OpenInEvince\" action =\"OpenInEvince\"/>\n"
" <separator/>\n"
" <toolitem name=\"GoPreviousPage\" action=\"GoPreviousPage\"/>\n"
" <toolitem name=\"GoNextPage\" action=\"GoNextPage\"/>\n"