Hi!
I updated Michal 'hramrach' Suchanek's original patch from bug 688636 to the
current git tree - patch actually attached to the email this time.
This patch adds a -o option which forces evince to open a new window for the
file.
I would really like to see this functionality in the main tree - is there
anything I can do to assist this happening?
Yours
Joseph
commit a6ce89dd110b604cb4f36e013446237c34a85a8e
Author: Joseph Maher <maher@debian>
Date: Sat Sep 14 22:20:40 2013 -0400
Update Michal 'hramrach' Suchanek's patch from bug 688636 to the current git tree
patch: add option to always open a new window when opening a file is requested
Committer: Joseph Maher <[email protected]>
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
modified: data/evince.1
modified: shell/ev-application.c
modified: shell/ev-application.h
modified: shell/ev-gdbus.xml
modified: shell/ev-window.c
modified: shell/ev-window.h
modified: shell/main.c
diff --git a/data/evince.1 b/data/evince.1
index 9add86a..227ec16 100644
--- a/data/evince.1
+++ b/data/evince.1
@@ -33,6 +33,9 @@ Prints the command line options.
\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 --git a/shell/ev-application.c b/shell/ev-application.c
index 2115596..dadfab1 100644
--- a/shell/ev-application.c
+++ b/shell/ev-application.c
@@ -138,7 +138,7 @@ ev_application_load_session (EvApplication *application)
ev_application_open_uri_at_dest (application, uri,
gdk_screen_get_default (),
NULL, 0, NULL,
- GDK_CURRENT_TIME);
+ GDK_CURRENT_TIME, 0);
g_free (uri);
g_key_file_free (state_file);
@@ -351,6 +351,7 @@ typedef struct {
EvWindowRunMode mode;
gchar *search_string;
guint timestamp;
+ gboolean new_view;
} EvRegisterDocData;
static void
@@ -491,7 +492,7 @@ on_register_uri_cb (GObject *source_object,
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,
@@ -524,7 +525,8 @@ ev_application_register_uri (EvApplication *application,
EvLinkDest *dest,
EvWindowRunMode mode,
const gchar *search_string,
- guint timestamp)
+ guint timestamp,
+ gboolean new_view)
{
EvRegisterDocData *data;
@@ -560,6 +562,7 @@ ev_application_register_uri (EvApplication *application,
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,
@@ -639,7 +642,6 @@ ev_application_open_uri_in_window (EvApplication *application,
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)) {
@@ -693,7 +695,8 @@ ev_application_open_uri_at_dest (EvApplication *application,
EvLinkDest *dest,
EvWindowRunMode mode,
const gchar *search_string,
- guint timestamp)
+ guint timestamp,
+ gboolean new_view)
{
g_return_if_fail (uri != NULL);
@@ -709,7 +712,7 @@ ev_application_open_uri_at_dest (EvApplication *application,
/* 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 */
@@ -783,13 +786,16 @@ handle_get_window_list_cb (EvEvinceApplication *object,
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;
@@ -800,6 +806,7 @@ handle_reload_cb (EvEvinceApplication *object,
EvWindowRunMode mode = EV_WINDOW_MODE_NORMAL;
const gchar *search_string = NULL;
GdkScreen *screen = NULL;
+ EvWindow *window = NULL;
g_variant_iter_init (&iter, args);
@@ -832,20 +839,54 @@ handle_reload_cb (EvEvinceApplication *object,
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);
+}
- ev_evince_application_complete_reload (object, invocation);
+static gboolean
+handle_reload_cb (EvEvinceApplication *object,
+ GDBusMethodInvocation *invocation,
+ GVariant *args,
+ guint timestamp,
+ EvApplication *application)
+{
+ handle_document_cb(object, HDC_RELOAD, args, timestamp, application);
- return TRUE;
+ ev_evince_application_complete_reload (object, invocation);
+
+ 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 */
@@ -860,7 +901,7 @@ ev_application_open_uri_list (EvApplication *application,
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);
}
}
@@ -1106,6 +1147,9 @@ ev_application_dbus_register (GApplication *gapplication,
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 --git a/shell/ev-application.h b/shell/ev-application.h
index 5ec870e..4274b61 100644
--- a/shell/ev-application.h
+++ b/shell/ev-application.h
@@ -59,7 +59,8 @@ void ev_application_open_uri_at_dest (EvApplication *applicati
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 --git a/shell/ev-gdbus.xml b/shell/ev-gdbus.xml
index b6b50d1..8392b0f 100644
--- a/shell/ev-gdbus.xml
+++ b/shell/ev-gdbus.xml
@@ -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 --git a/shell/ev-window.c b/shell/ev-window.c
index f258155..d2d331e 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -2530,16 +2530,25 @@ static void
ev_window_open_copy_at_dest (EvWindow *window,
EvLinkDest *dest)
{
+ ev_window_new_view(window, dest, 0, NULL);
+}
+
+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, 0, NULL);
+ dest, mode, search_string);
gtk_window_present (GTK_WINDOW (new_window));
}
+
static void
ev_window_cmd_file_open_copy (GtkAction *action, EvWindow *window)
{
@@ -2560,7 +2569,7 @@ ev_window_cmd_recent_file_activate (GtkAction *action,
ev_application_open_uri_at_dest (EV_APP, uri,
gtk_window_get_screen (GTK_WINDOW (window)),
- NULL, 0, NULL, gtk_get_current_event_time ());
+ NULL, 0, NULL, gtk_get_current_event_time (), 0);
}
static void
@@ -2570,7 +2579,7 @@ ev_window_open_recent_action_item_activated (EvOpenRecentAction *action,
{
ev_application_open_uri_at_dest (EV_APP, uri,
gtk_window_get_screen (GTK_WINDOW (window)),
- NULL, 0, NULL, gtk_get_current_event_time ());
+ NULL, 0, NULL, gtk_get_current_event_time (), 0);
}
static void
@@ -6632,7 +6641,7 @@ open_remote_link (EvWindow *window, EvLinkAction *action)
ev_link_action_get_dest (action),
0,
NULL,
- gtk_get_current_event_time ());
+ gtk_get_current_event_time (), 0);
g_free (uri);
}
diff --git a/shell/ev-window.h b/shell/ev-window.h
index fd2d0b5..247ffec 100644
--- a/shell/ev-window.h
+++ b/shell/ev-window.h
@@ -81,6 +81,10 @@ void ev_window_open_document (EvWindow *ev_window,
EvLinkDest *dest,
EvWindowRunMode mode,
const gchar *search_string);
+void ev_window_new_view (EvWindow *ev_window,
+ EvLinkDest *dest,
+ EvWindowRunMode mode,
+ const gchar *search_string);
gboolean ev_window_is_empty (const EvWindow *ev_window);
void ev_window_print_range (EvWindow *ev_window,
int first_page,
diff --git a/shell/main.c b/shell/main.c
index c1e756b..ec3f9e9 100644
--- a/shell/main.c
+++ b/shell/main.c
@@ -54,6 +54,7 @@ static gchar *ev_find_string;
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;
@@ -81,6 +82,7 @@ static const GOptionEntry goption_options[] =
{ "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 },
@@ -221,11 +223,9 @@ load_files (const char **files)
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
[email protected]
https://mail.gnome.org/mailman/listinfo/evince-list