summaryrefslogtreecommitdiff
path: root/shell/ev-window.c
diff options
context:
space:
mode:
authorraveit65 <[email protected]>2016-07-14 10:54:11 +0200
committerraveit65 <[email protected]>2016-07-22 15:23:49 +0200
commit96ca9e82a9f98a2224f01fcdada6434a85fb29b0 (patch)
tree7b62f6d7198167467991ef0484566c506953f9af /shell/ev-window.c
parentb0ec3f2702050fdbbb33e07f64dd518828d05883 (diff)
downloadatril-96ca9e82a9f98a2224f01fcdada6434a85fb29b0.tar.bz2
atril-96ca9e82a9f98a2224f01fcdada6434a85fb29b0.tar.xz
Add Send To action to file menu
It uses caja-sendto to allow you to send the current document by email, to a removable device, etc. If caja-sendto command is not present in path, the menu item is hidden. https://bugzilla.gnome.org/show_bug.cgi?id=569913 Taken from: https://git.gnome.org/browse/evince/commit/?id=c9ce578
Diffstat (limited to 'shell/ev-window.c')
-rw-r--r--shell/ev-window.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/shell/ev-window.c b/shell/ev-window.c
index 2fb1a66c..ca15fda8 100644
--- a/shell/ev-window.c
+++ b/shell/ev-window.c
@@ -380,6 +380,8 @@ static void zoom_control_changed_cb (EphyZoomAction *action,
static guint ev_window_n_copies = 0;
+static gchar *caja_sendto = NULL;
+
G_DEFINE_TYPE (EvWindow, ev_window, GTK_TYPE_WINDOW)
static gdouble
@@ -465,6 +467,7 @@ ev_window_setup_action_sensitivity (EvWindow *ev_window)
ev_window_set_action_sensitive (ev_window, "FileSaveAs", has_document && ok_to_copy);
ev_window_set_action_sensitive (ev_window, "FilePrint", has_pages && ok_to_print);
ev_window_set_action_sensitive (ev_window, "FileProperties", has_document && has_properties);
+ ev_window_set_action_sensitive (ev_window, "FileSendTo", has_document);
/* Edit menu */
ev_window_set_action_sensitive (ev_window, "EditSelectAll", has_pages && can_get_text);
@@ -3118,6 +3121,45 @@ ev_window_cmd_save_as (GtkAction *action, EvWindow *ev_window)
gtk_widget_show (fc);
}
+ static void
+ev_window_cmd_send_to (GtkAction *action,
+ EvWindow *ev_window)
+{
+ GAppInfo *app_info;
+ gchar *command;
+ const char *uri;
+ GError *error = NULL;
+
+ uri = ev_window->priv->local_uri ? ev_window->priv->local_uri : ev_window->priv->uri;
+ command = g_strdup_printf ("%s %s", caja_sendto, uri);
+ app_info = g_app_info_create_from_commandline (command, NULL, 0, &error);
+ if (app_info) {
+ GdkAppLaunchContext *context;
+ GdkScreen *screen;
+
+ screen = gtk_window_get_screen (GTK_WINDOW (ev_window));
+#if GTK_CHECK_VERSION (3, 0, 0)
+ context = gdk_display_get_app_launch_context (gdk_screen_get_display (screen));
+#else
+ context = gdk_app_launch_context_new ();
+ gdk_app_launch_context_set_display (context, gdk_screen_get_display (screen));
+#endif
+ gdk_app_launch_context_set_screen (context, screen);
+ gdk_app_launch_context_set_timestamp (context, gtk_get_current_event_time ());
+ g_app_info_launch (app_info, NULL, G_APP_LAUNCH_CONTEXT (context), &error);
+ g_object_unref (context);
+
+ g_object_unref (app_info);
+ }
+ g_free (command);
+
+ if (error) {
+ ev_window_error_message (ev_window, error, "%s",
+ _("Could not send current document"));
+ g_error_free (error);
+ }
+}
+
static GKeyFile *
get_print_settings_file (void)
{
@@ -6063,6 +6105,8 @@ ev_window_class_init (EvWindowClass *ev_window_class)
widget_class->window_state_event = ev_window_state_event;
widget_class->drag_data_received = ev_window_drag_data_received;
+ caja_sendto = g_find_program_in_path ("caja-sendto");
+
g_type_class_add_private (g_object_class, sizeof (EvWindowPrivate));
}
@@ -6085,6 +6129,9 @@ static const GtkActionEntry entries[] = {
{ "FileSaveAs", GTK_STOCK_SAVE_AS, N_("_Save a Copy…"), "<control>S",
N_("Save a copy of the current document"),
G_CALLBACK (ev_window_cmd_save_as) },
+ { "FileSendTo", NULL, N_("Send _To..."), NULL,
+ N_("Send current document by mail, instant message..."),
+ G_CALLBACK (ev_window_cmd_send_to) },
{ "FilePrint", GTK_STOCK_PRINT, N_("_Print…"), "<control>P",
N_("Print this document"),
G_CALLBACK (ev_window_cmd_file_print) },
@@ -6442,6 +6489,9 @@ set_action_properties (GtkActionGroup *action_group)
{
GtkAction *action;
+ action = gtk_action_group_get_action (action_group, "FileSendTo");
+ gtk_action_set_visible (action, caja_sendto != NULL);
+
action = gtk_action_group_get_action (action_group, "GoPreviousPage");
g_object_set (action, "is-important", TRUE, NULL);
/*translators: this is the label for toolbar button*/