]> www.fi.muni.cz Git - evince.git/blobdiff - shell/ev-window.c
[printing] Embed page setup settings in the print dialog
[evince.git] / shell / ev-window.c
index 8356ead31c3ac10a535273346e22dc5aa5ebd3d3..6f98711f4a38486fd8f01e60fbb42e5c4b382cdc 100644 (file)
@@ -395,7 +395,9 @@ ev_window_setup_action_sensitivity (EvWindow *ev_window)
        /* File menu */
        ev_window_set_action_sensitive (ev_window, "FileOpenCopy", has_document);
        ev_window_set_action_sensitive (ev_window, "FileSaveAs", has_document && ok_to_copy);
+#if !GTK_CHECK_VERSION (2, 17, 4)
        ev_window_set_action_sensitive (ev_window, "FilePageSetup", has_pages && ok_to_print);
+#endif
        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);
 
@@ -2075,7 +2077,7 @@ file_open_dialog_response_cb (GtkWidget *chooser,
 
                ev_application_open_uri_list (EV_APP, uris,
                                              gtk_window_get_screen (GTK_WINDOW (ev_window)),
-                                             GDK_CURRENT_TIME);
+                                             gtk_get_current_event_time ());
 
                g_slist_foreach (uris, (GFunc)g_free, NULL);
                g_slist_free (uris);
@@ -2177,7 +2179,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, GDK_CURRENT_TIME);
+                                        NULL, 0, NULL, gtk_get_current_event_time ());
 }
 
 static void
@@ -2187,7 +2189,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, GDK_CURRENT_TIME);
+                                        NULL, 0, NULL, gtk_get_current_event_time ());
 }
 
 static void
@@ -2908,6 +2910,13 @@ ev_window_print_operation_done (EvPrintOperation       *op,
 
                print_settings = ev_print_operation_get_print_settings (op);
                ev_window_save_print_settings (ev_window, print_settings);
+
+               if (ev_print_operation_get_embed_page_setup (op)) {
+                       GtkPageSetup *page_setup;
+
+                       page_setup = ev_print_operation_get_default_page_setup (op);
+                       ev_window_save_print_page_setup (ev_window, page_setup);
+               }
        }
 
                break;
@@ -3081,6 +3090,7 @@ ev_window_print_range (EvWindow *ev_window,
        ev_print_operation_set_current_page (op, current_page);
        ev_print_operation_set_print_settings (op, print_settings);
        ev_print_operation_set_default_page_setup (op, print_page_setup);
+       ev_print_operation_set_embed_page_setup (op, TRUE);
 
        g_object_unref (print_settings);
        g_object_unref (print_page_setup);
@@ -3946,7 +3956,7 @@ ev_window_cmd_help_contents (GtkAction *action, EvWindow *ev_window)
 
        gtk_show_uri (gtk_window_get_screen (GTK_WINDOW (ev_window)),
                      "ghelp:evince",
-                     GDK_CURRENT_TIME,
+                     gtk_get_current_event_time (),
                      &error);
        if (error) {
                ev_window_error_message (ev_window, error, 
@@ -5407,7 +5417,8 @@ launch_action (EvWindow *window, EvLinkAction *action)
        context = G_APP_LAUNCH_CONTEXT (gdk_app_launch_context_new ());
        gdk_app_launch_context_set_screen (GDK_APP_LAUNCH_CONTEXT (context),
                                           gtk_window_get_screen (GTK_WINDOW (window)));
-       gdk_app_launch_context_set_timestamp (GDK_APP_LAUNCH_CONTEXT (context), GDK_CURRENT_TIME);
+       gdk_app_launch_context_set_timestamp (GDK_APP_LAUNCH_CONTEXT (context),
+                                              gtk_get_current_event_time ());
        
        file_list.data = file;
        if (!g_app_info_launch (app_info, &file_list, context, &error)) {
@@ -5419,6 +5430,7 @@ launch_action (EvWindow *window, EvLinkAction *action)
        
        g_object_unref (app_info);
        g_object_unref (file);
+        /* FIXMEchpe: unref launch context? */
 
        /* According to the PDF spec filename can be an executable. I'm not sure
           allowing to launch executables is a good idea though. -- marco */
@@ -5436,7 +5448,7 @@ launch_external_uri (EvWindow *window, EvLinkAction *action)
        gdk_app_launch_context_set_screen (GDK_APP_LAUNCH_CONTEXT (context),
                                           gtk_window_get_screen (GTK_WINDOW (window)));
        gdk_app_launch_context_set_timestamp (GDK_APP_LAUNCH_CONTEXT (context),
-                                             GDK_CURRENT_TIME);
+                                             gtk_get_current_event_time ());
 
        if (!g_strstr_len (uri, strlen (uri), "://") &&
            !g_str_has_prefix (uri, "mailto:")) {
@@ -5444,10 +5456,10 @@ launch_external_uri (EvWindow *window, EvLinkAction *action)
                
                /* Not a valid uri, assuming it's http */
                http = g_strdup_printf ("http://%s", uri);
-               ret = g_app_info_launch_default_for_uri (http, NULL, &error);
+               ret = g_app_info_launch_default_for_uri (http, context, &error);
                g_free (http);
        } else {
-               ret = g_app_info_launch_default_for_uri (uri, NULL, &error);
+               ret = g_app_info_launch_default_for_uri (uri, context, &error);
        }
        
        if (ret == FALSE) {
@@ -5455,6 +5467,8 @@ launch_external_uri (EvWindow *window, EvLinkAction *action)
                                         "%s", _("Unable to open external link"));
                g_error_free (error);
        }
+
+        /* FIXMEchpe: unref launch context? */
 }
 
 static void
@@ -5474,7 +5488,7 @@ open_remote_link (EvWindow *window, EvLinkAction *action)
                                         ev_link_action_get_dest (action),
                                         0,
                                         NULL, 
-                                        GDK_CURRENT_TIME);
+                                        gtk_get_current_event_time ());
 
        g_free (uri);
 }
@@ -5754,7 +5768,7 @@ ev_attachment_popup_cmd_open_attachment (GtkAction *action, EvWindow *window)
                
                attachment = (EvAttachment *) l->data;
                
-               ev_attachment_open (attachment, screen, GDK_CURRENT_TIME, &error);
+               ev_attachment_open (attachment, screen, gtk_get_current_event_time (), &error);
 
                if (error) {
                        ev_window_error_message (window, error, 
@@ -6035,7 +6049,17 @@ ev_window_init (EvWindow *ev_window)
                g_error_free (error);
        }
        g_free (ui_path);
-       
+
+#if GTK_CHECK_VERSION (2, 17, 4)
+       {
+               GtkAction *action;
+
+               action = gtk_action_group_get_action (ev_window->priv->action_group,
+                                                     "FilePageSetup");
+               g_object_set (action, "visible", FALSE, "sensitive", FALSE, NULL);
+       }
+#endif
+
        ev_window->priv->recent_manager = gtk_recent_manager_get_default ();
        ev_window->priv->recent_action_group = NULL;
        ev_window->priv->recent_ui_id = 0;