José
On Fri, Jun 23, 2017 at 1:31 PM, Joseph Maher via evince-list <evince-list gnome org> wrote:
I have made a failed attempt to port the patch for bug 688636 to the current version
of evince in debian stable (stretch) which is 3.22.1. The patch attempts to add a
command line option to evince, so that it opens the pdf in a new window, even if it
is currently open. I've attached the patch below, and it compiles, but when I run
the binary I get:
(evince:8028): EvinceDocument-WARNING **: Error opening directory
'/usr/lib/x86_64-linux-gnu/evince/4/backends': No such file or directory
So possibly this is some build problem not directly related to the patch?
Any advice much appreciated! (patch appended to the end of this email).
Yours
Joseph
diff -r -U3 evince-3.22.1.orig/data/evince.1 evince-3.22.1/data/evince.1
--- evince-3.22.1.orig/data/evince.1 2014-11-29 01:40:15.000000000 -0800
+++ evince-3.22.1/data/evince.1 2017-06-22 18:17:13.388633637 -0700
@@ -33,6 +33,9 @@
\fB\-p, \-\-page\-label=PAGE\fR
Open the document on the page with the specified page label (or page number).
.TP
+\fB\-o, \-\-really\-open\fR
+Open new view of the document even if another window showing the document is already
open.
+.TP
\fB\-i, \-\-page\-index=NUMBER\fR
Open the document on the page with the specified page index (this is the exact page
number, not a page label).
.TP
diff -r -U3 evince-3.22.1.orig/shell/ev-application.c
evince-3.22.1/shell/ev-application.c
--- evince-3.22.1.orig/shell/ev-application.c 2016-07-17 01:51:40.000000000 -0700
+++ evince-3.22.1/shell/ev-application.c 2017-06-22 18:17:13.392633236 -0700
@@ -284,6 +284,7 @@
EvWindowRunMode mode;
gchar *search_string;
guint timestamp;
+ gboolean new_view;
} EvRegisterDocData;
static void
@@ -421,7 +422,7 @@
owner,
APPLICATION_DBUS_OBJECT_PATH,
APPLICATION_DBUS_INTERFACE,
- "Reload",
+ (data->new_view ? "NewView" : "Reload"),
g_variant_builder_end (&builder),
NULL,
G_DBUS_CALL_FLAGS_NONE,
@@ -454,7 +455,8 @@
EvLinkDest *dest,
EvWindowRunMode mode,
const gchar *search_string,
- guint timestamp)
+ guint timestamp,
+ gboolean new_view)
{
EvRegisterDocData *data;
@@ -490,6 +492,7 @@
data->mode = mode;
data->search_string = search_string ? g_strdup (search_string) : NULL;
data->timestamp = timestamp;
+ data->new_view = new_view;
g_dbus_connection_call (g_application_get_dbus_connection (G_APPLICATION
(application)),
EVINCE_DAEMON_SERVICE,
@@ -569,7 +572,6 @@
if (!gtk_widget_get_realized (GTK_WIDGET (ev_window)))
gtk_widget_realize (GTK_WIDGET (ev_window));
-
#ifdef GDK_WINDOWING_X11
gdk_window = gtk_widget_get_window (GTK_WIDGET (ev_window));
if (GDK_IS_X11_WINDOW (gdk_window)) {
@@ -623,7 +625,8 @@
EvLinkDest *dest,
EvWindowRunMode mode,
const gchar *search_string,
- guint timestamp)
+ guint timestamp,
+ gboolean new_view)
{
g_return_if_fail (uri != NULL);
@@ -639,7 +642,7 @@
/* Register the uri or send Reload to
* remote instance if already registered
*/
- ev_application_register_uri (application, uri, screen, dest, mode,
search_string, timestamp);
+ ev_application_register_uri (application, uri, screen, dest, mode,
search_string, timestamp, new_view);
#else
_ev_application_open_uri_at_dest (application, uri, screen, dest, mode,
search_string, timestamp);
#endif /* ENABLE_DBUS */
@@ -725,13 +728,16 @@
return TRUE;
}
-static gboolean
-handle_reload_cb (EvEvinceApplication *object,
- GDBusMethodInvocation *invocation,
- GVariant *args,
- guint timestamp,
- EvApplication *application)
-{
+typedef enum { HDC_RELOAD, HDC_NEWVIEW } hdc_action;
+
+ static void
+ handle_document_cb (EvEvinceApplication *object,
+ hdc_action action,
+ GVariant *args,
+ guint timestamp,
+ EvApplication *application)
+ {
+
GList *windows, *l;
GVariantIter iter;
const gchar *key;
@@ -741,6 +747,7 @@
EvWindowRunMode mode = EV_WINDOW_MODE_NORMAL;
const gchar *search_string = NULL;
GdkScreen *screen = NULL;
+ EvWindow *window = NULL;
g_variant_iter_init (&iter, args);
@@ -769,20 +776,54 @@
for (l = windows; l != NULL; l = g_list_next (l)) {
if (!EV_IS_WINDOW (l->data))
continue;
+ window = EV_WINDOW (l->data);
- ev_application_open_uri_in_window (application, NULL,
- EV_WINDOW (l->data),
- screen, dest, mode,
- search_string,
- timestamp);
+ switch (action) {
+ case HDC_NEWVIEW:
+ l = NULL; /* exit cycle */
+ /* FIXME screen and timestamp discarded here */
+ ev_window_new_view(window, dest, mode,
search_string);
+ break;
+ case HDC_RELOAD:
+ ev_application_open_uri_in_window (application, NULL,
+ EV_WINDOW (l->data),
+ screen, dest,
mode,
+ search_string,
+ timestamp);
+ break;
+ }
}
if (dest)
g_object_unref (dest);
+}
+
+static gboolean
+handle_reload_cb (EvEvinceApplication *object,
+ GDBusMethodInvocation *invocation,
+ GVariant *args,
+ guint timestamp,
+ EvApplication *application)
+{
+ handle_document_cb(object, HDC_RELOAD, args, timestamp, application);
- ev_evince_application_complete_reload (object, invocation);
+ ev_evince_application_complete_reload (object, invocation);
- return TRUE;
+ return TRUE;
+}
+
+static gboolean
+handle_new_view_cb (EvEvinceApplication *object,
+ GDBusMethodInvocation *invocation,
+ GVariant *args,
+ guint timestamp,
+ EvApplication *application)
+{
+ handle_document_cb(object, HDC_NEWVIEW, args, timestamp, application);
+
+ ev_evince_application_complete_new_view (object, invocation);
+
+ return TRUE;
}
#endif /* ENABLE_DBUS */
@@ -797,7 +838,7 @@
for (l = uri_list; l != NULL; l = l->next) {
ev_application_open_uri_at_dest (application, (char *)l->data,
screen, NULL, 0, NULL,
- timestamp);
+ timestamp, 0);
}
}
@@ -1173,6 +1214,9 @@
g_signal_connect (skeleton, "handle-reload",
G_CALLBACK (handle_reload_cb),
application);
+ g_signal_connect (skeleton, "handle-new-view",
+ G_CALLBACK (handle_new_view_cb),
+ application);
application->keys = ev_media_player_keys_new ();
return TRUE;
diff -r -U3 evince-3.22.1.orig/shell/ev-application.h
evince-3.22.1/shell/ev-application.h
--- evince-3.22.1.orig/shell/ev-application.h 2015-04-26 02:38:27.000000000 -0700
+++ evince-3.22.1/shell/ev-application.h 2017-06-22 18:17:13.392633236 -0700
@@ -58,7 +58,8 @@
EvLinkDest *dest,
EvWindowRunMode mode,
const gchar *search_string,
- guint32 timestamp);
+ guint32 timestamp,
+ gboolean new_view);
void ev_application_open_uri_list (EvApplication *application,
GSList *uri_list,
GdkScreen *screen,
diff -r -U3 evince-3.22.1.orig/shell/ev-gdbus.xml evince-3.22.1/shell/ev-gdbus.xml
--- evince-3.22.1.orig/shell/ev-gdbus.xml 2014-11-29 01:40:16.000000000 -0800
+++ evince-3.22.1/shell/ev-gdbus.xml 2017-06-22 18:17:13.392633236 -0700
@@ -8,6 +8,10 @@
<arg type='a{sv}' name='args' direction='in'/>
<arg type='u' name='timestamp' direction='in'/>
</method>
+ <method name='NewView'>
+ <arg type='a{sv}' name='args' direction='in'/>
+ <arg type='u' name='timestamp' direction='in'/>
+ </method>
<method name='GetWindowList'>
<arg type='ao' name='window_list' direction='out'/>
</method>
diff -r -U3 evince-3.22.1.orig/shell/ev-window.c evince-3.22.1/shell/ev-window.c
--- evince-3.22.1.orig/shell/ev-window.c 2016-10-11 22:41:36.000000000 -0700
+++ evince-3.22.1/shell/ev-window.c 2017-06-22 18:25:53.608283392 -0700
@@ -2588,6 +2588,24 @@
gtk_window_present (GTK_WINDOW (new_window));
}
+void ev_window_new_view (EvWindow *window,
+ EvLinkDest *dest,
+ EvWindowRunMode mode,
+ const gchar * search_string)
+{
+ EvWindow *new_window = EV_WINDOW (ev_window_new ());
+
+ if (window->priv->metadata)
+ new_window->priv->metadata = g_object_ref (window->priv->metadata);
+ ev_window_open_document (new_window,
+ window->priv->document,
+ dest, mode, search_string);
+ gtk_window_present (GTK_WINDOW (new_window));
+ }
+
+
+
+
static void
ev_window_cmd_file_open_copy (GSimpleAction *action,
GVariant *parameter,
@@ -5093,7 +5111,7 @@
{
ev_application_open_uri_at_dest (EV_APP, uri,
gtk_window_get_screen (GTK_WINDOW
(ev_window)),
- NULL, 0, NULL, gtk_get_current_event_time
());
+ NULL, 0, NULL, gtk_get_current_event_time
(), 0);
}
static void
@@ -5948,7 +5966,7 @@
ev_link_action_get_dest (action),
0,
NULL,
- gtk_get_current_event_time ());
+ gtk_get_current_event_time (), 0);
g_free (uri);
}
diff -r -U3 evince-3.22.1.orig/shell/ev-window.h evince-3.22.1/shell/ev-window.h
--- evince-3.22.1.orig/shell/ev-window.h 2015-04-26 02:38:27.000000000 -0700
+++ evince-3.22.1/shell/ev-window.h 2017-06-22 18:23:16.676305253 -0700
@@ -83,6 +83,10 @@
EvLinkDest *dest,
EvWindowRunMode mode,
const gchar
*search_string);
+void ev_window_new_view (EvWindow *ev_window,
+ EvLinkDest *dest,
+ EvWindowRunMode mode,
+ const gchar
*search_string);
void ev_window_open_recent_view (EvWindow *ev_window);
gboolean ev_window_is_empty (const EvWindow *ev_window);
void ev_window_print_range (EvWindow *ev_window,
diff -r -U3 evince-3.22.1.orig/shell/main.c evince-3.22.1/shell/main.c
--- evince-3.22.1.orig/shell/main.c 2015-04-26 02:38:27.000000000 -0700
+++ evince-3.22.1/shell/main.c 2017-06-22 18:17:13.404632038 -0700
@@ -47,6 +47,7 @@
static gint ev_page_index = 0;
static gchar *ev_named_dest;
static gboolean preview_mode = FALSE;
+static gboolean really_open = FALSE;
static gboolean fullscreen_mode = FALSE;
static gboolean presentation_mode = FALSE;
static gboolean unlink_temp_file = FALSE;
@@ -74,6 +75,7 @@
{ "fullscreen", 'f', 0, G_OPTION_ARG_NONE, &fullscreen_mode, N_("Run evince
in fullscreen mode"), NULL },
{ "presentation", 's', 0, G_OPTION_ARG_NONE, &presentation_mode, N_("Run
evince in presentation mode"), NULL },
{ "preview", 'w', 0, G_OPTION_ARG_NONE, &preview_mode, N_("Run evince as a
previewer"), NULL },
+ { "really-open", 'o', 0, G_OPTION_ARG_NONE, &really_open, N_("Open a new view
even if file is already open in evince"), NULL },
{ "find", 'l', 0, G_OPTION_ARG_STRING, &ev_find_string, N_("The word or
phrase to find in the document"), N_("STRING")},
{ "unlink-tempfile", 'u', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_NONE,
&unlink_temp_file, NULL, NULL },
{ "print-settings", 't', G_OPTION_FLAG_HIDDEN, G_OPTION_ARG_FILENAME,
&print_settings, NULL, NULL },
@@ -214,11 +216,9 @@
continue;
}
-
-
ev_application_open_uri_at_dest (EV_APP, uri, screen, dest,
mode, ev_find_string,
- GDK_CURRENT_TIME);
+ GDK_CURRENT_TIME, really_open);
if (dest)
g_object_unref (dest);
_______________________________________________
evince-list mailing list
evince-list gnome org
https://mail.gnome.org/mailman/listinfo/evince-list