evince r3579 - in trunk: . data shell



Author: carlosgc
Date: Wed Apr  8 13:10:27 2009
New Revision: 3579
URL: http://svn.gnome.org/viewvc/evince?rev=3579&view=rev

Log:
2009-04-08  Carlos Garcia Campos  <carlosgc gnome org>

	* data/evince-ui.xml:
	* shell/ev-application.[ch]: (ev_application_open_uri_at_dest),
	(ev_application_open_uri), (ev_application_open_uri_list):
	* shell/ev-print-operation.c: (export_print_done):
	* shell/ev-window.[ch]: (ev_window_setup_action_sensitivity),
	(update_chrome_visibility), (ev_window_clear_local_uri),
	(ev_window_load_job_cb), (window_open_file_copy_ready_cb),
	(ev_window_open_uri), (ev_window_cmd_file_open_copy_at_dest),
	(ev_window_cmd_recent_file_activate),
	(ev_window_open_recent_action_item_activated),
	(ev_window_dispose), (open_remote_link):
	* shell/main.c: (launch_previewer), (arguments_parse), (main):

	Remove the preview mode from EvWindow. EvPrintOperation now
	launches evince-previewer. The preview mode command line options
	have not been removed to keep backwards compatibility, launching
	evince-previewer when evince is run in preview mode.

Modified:
   trunk/ChangeLog
   trunk/data/evince-ui.xml
   trunk/shell/ev-application.c
   trunk/shell/ev-application.h
   trunk/shell/ev-print-operation.c
   trunk/shell/ev-window.c
   trunk/shell/ev-window.h
   trunk/shell/main.c

Modified: trunk/data/evince-ui.xml
==============================================================================
--- trunk/data/evince-ui.xml	(original)
+++ trunk/data/evince-ui.xml	Wed Apr  8 13:10:27 2009
@@ -123,18 +123,4 @@
      <toolitem name="StartPresentation" action="StartPresentation"/>
      <toolitem name="LeaveFullscreen" action="LeaveFullscreen"/>
   </toolbar>
-
-  <toolbar name="PreviewToolbar">
-     <toolitem name="GoPreviousPage" action="GoPreviousPage"/>
-     <toolitem name="GoNextPage" action="GoNextPage"/>
-     <separator/>
-     <toolitem name="PageSelector" action="PageSelector"/>
-     <separator/>
-     <toolitem name="ViewPageWidth" action="ViewPageWidth"/>
-     <toolitem name="ViewBestFit" action="ViewBestFit"/>
-     <toolitem name="ViewZoomIn" action="ViewZoomIn"/>
-     <toolitem name="ViewZoomOut" action="ViewZoomOut"/>
-     <separator/>
-     <toolitem name="PreviewPrint" action="PreviewPrint"/>
-  </toolbar>
 </ui>

Modified: trunk/shell/ev-application.c
==============================================================================
--- trunk/shell/ev-application.c	(original)
+++ trunk/shell/ev-application.c	Wed Apr  8 13:10:27 2009
@@ -386,48 +386,6 @@
 }
 
 /**
- * get_unlink_temp_file_from_args:
- * @args: a #GHashTable with data passed to the application.
- *
- * It does look if the unlink-temp-file option has been passed from the command
- * line returning it's boolean representation, otherwise it does return %FALSE.
- *
- * Returns: the boolean representation of the unlink-temp-file value or %FALSE
- *          in other case.
- */
-static gboolean
-get_unlink_temp_file_from_args (GHashTable *args)
-{
-	gboolean unlink_temp_file = FALSE;
-	GValue  *value = NULL;
-
-	g_assert (args != NULL);
-
-	value = g_hash_table_lookup (args, "unlink-temp-file");
-	if (value) {
-		unlink_temp_file = g_value_get_boolean (value);
-	}
-	
-	return unlink_temp_file;
-}
-
-static const gchar *
-get_print_settings_from_args (GHashTable *args)
-{
-	const gchar *print_settings = NULL;
-	GValue      *value = NULL;
-
-	g_assert (args != NULL);
-
-	value = g_hash_table_lookup (args, "print-settings");
-	if (value) {
-		print_settings = g_value_get_string (value);
-	}
-
-	return print_settings;
-}
-
-/**
  * ev_application_open_window:
  * @application: The instance of the application.
  * @args: A #GHashTable with the arguments data.
@@ -552,7 +510,6 @@
  * @screen: Thee screen where the link will be shown.
  * @dest: The #EvLinkDest of the document.
  * @mode: The run mode of the window.
- * @unlink_temp_file: The unlink_temp_file option value.
  * @timestamp: Current time value.
  */
 void
@@ -562,8 +519,6 @@
 				 EvLinkDest     *dest,
 				 EvWindowRunMode mode,
 				 const gchar    *search_string,
-				 gboolean        unlink_temp_file,
-				 const gchar    *print_settings, 
 				 guint           timestamp)
 {
 	EvWindow *new_window;
@@ -587,8 +542,7 @@
 
 	/* We need to load uri before showing the window, so
 	   we can restore window size without flickering */	
-	ev_window_open_uri (new_window, uri, dest, mode, search_string, 
-			    unlink_temp_file, print_settings);
+	ev_window_open_uri (new_window, uri, dest, mode, search_string);
 
 	if (!GTK_WIDGET_REALIZED (GTK_WIDGET (new_window)))
 		gtk_widget_realize (GTK_WIDGET (new_window));
@@ -626,8 +580,6 @@
 	EvLinkDest      *dest = NULL;
 	EvWindowRunMode  mode = EV_WINDOW_MODE_NORMAL;
 	const gchar     *search_string = NULL;
-	gboolean         unlink_temp_file = FALSE;
-	const gchar     *print_settings = NULL;
 	GdkScreen       *screen = NULL;
 
 	if (args) {
@@ -635,15 +587,11 @@
 		dest = get_destination_from_args (args);
 		mode = get_window_run_mode_from_args (args);
 		search_string = get_find_string_from_args (args);
-		unlink_temp_file = (mode == EV_WINDOW_MODE_PREVIEW &&
-				    get_unlink_temp_file_from_args (args));
-		print_settings = get_print_settings_from_args (args);
 	}
 	
 	ev_application_open_uri_at_dest (application, uri, screen,
 					 dest, mode, search_string,
-					 unlink_temp_file,
-					 print_settings, timestamp);
+					 timestamp);
 
 	if (dest)
 		g_object_unref (dest);
@@ -662,7 +610,7 @@
 	for (l = uri_list; l != NULL; l = l->next) {
 		ev_application_open_uri_at_dest (application, (char *)l->data,
 						 screen, NULL, 0, NULL,
-						 FALSE, NULL, timestamp);
+						 timestamp);
 	}
 }
 

Modified: trunk/shell/ev-application.h
==============================================================================
--- trunk/shell/ev-application.h	(original)
+++ trunk/shell/ev-application.h	Wed Apr  8 13:10:27 2009
@@ -69,8 +69,6 @@
 						      EvLinkDest      *dest,
 						      EvWindowRunMode  mode,
 						      const gchar     *search_string,
-						      gboolean         unlink_temp_file,
-						      const gchar     *print_settings, 
 						      guint32          timestamp);
 void	          ev_application_open_uri_list       (EvApplication   *application,
 		  			              GSList          *uri_list,

Modified: trunk/shell/ev-print-operation.c
==============================================================================
--- trunk/shell/ev-print-operation.c	(original)
+++ trunk/shell/ev-print-operation.c	Wed Apr  8 13:10:27 2009
@@ -743,6 +743,7 @@
 	EvPrintOperation *op = EV_PRINT_OPERATION (export);
 	GtkPrintSettings *settings;
 	EvFileExporterCapabilities capabilities;
+	GError *error = NULL;
 
 	g_assert (export->temp_file != NULL);
 	
@@ -773,49 +774,79 @@
 	}
 
 	if (export->print_preview) {
-		gchar *uri;
-		gchar *print_settings_file = NULL;
+		GKeyFile *key_file;
+		gchar    *data = NULL;
+		gsize     data_len;
+		gchar    *print_settings_file = NULL;
+
+		key_file = g_key_file_new ();
+
+		gtk_print_settings_to_key_file (settings, key_file, NULL);
+		gtk_page_setup_to_key_file (export->page_setup, key_file, NULL);
+		g_key_file_set_string (key_file, "Print Job", "title", export->job_name);
+
+		data = g_key_file_to_data (key_file, &data_len, &error);
+		if (data) {
+			gint fd;
+			
+			fd = g_file_open_tmp ("print-settingsXXXXXX", &print_settings_file, &error);
+			if (!error)
+				g_file_set_contents (print_settings_file, data, data_len, &error);
+			close (fd);
+			
+			g_free (data);
+		}
 
-		print_settings_file = ev_tmp_filename ("print-settings");
-		gtk_print_settings_to_file (settings, print_settings_file, NULL);
+		g_key_file_free (key_file);
 
-		uri = g_filename_to_uri (export->temp_file, NULL, NULL);
-		ev_application_open_uri_at_dest (EV_APP,
-						 uri,
-						 gtk_window_get_screen (export->parent_window),
-						 NULL,
-						 EV_WINDOW_MODE_PREVIEW,
-						 NULL,
-						 TRUE,
-						 print_settings_file,
-						 GDK_CURRENT_TIME);
-		g_free (print_settings_file);
-		g_free (uri);
+		if (!error) {
+			gint    argc;
+			gchar **argv;
+			gchar  *cmd;
+			gchar  *quoted_filename;
+			gchar  *quoted_settings_filename;
+
+			quoted_filename = g_shell_quote (export->temp_file);
+			quoted_settings_filename = g_shell_quote (print_settings_file);
+			cmd = g_strdup_printf ("evince-previewer --unlink-tempfile --print-settings %s %s",
+					       quoted_settings_filename, quoted_filename);
+
+			g_shell_parse_argv (cmd, &argc, &argv, &error);
+
+			g_free (quoted_filename);
+			g_free (quoted_settings_filename);
+			g_free (cmd);
+
+			if (!error) {
+				gdk_spawn_on_screen (gtk_window_get_screen (export->parent_window),
+						     NULL, argv, NULL,
+						     G_SPAWN_SEARCH_PATH,
+						     NULL, NULL, NULL,
+						     &error);
+			}
 
-		g_signal_emit (op, signals[DONE], 0, GTK_PRINT_OPERATION_RESULT_APPLY);
-		/* temp_file will be deleted by the previewer */
+			g_strfreev (argv);
+		}
 
-		ev_print_operation_export_run_next (export);
+		if (error) {
+			if (print_settings_file)
+				g_unlink (print_settings_file);
+			g_free (print_settings_file);
+		} else {
+			g_signal_emit (op, signals[DONE], 0, GTK_PRINT_OPERATION_RESULT_APPLY);
+			/* temp_file will be deleted by the previewer */
+
+			ev_print_operation_export_run_next (export);
+		}
 	} else {
 		GtkPrintJob *job;
-		GError      *error = NULL;
 		
 		job = gtk_print_job_new (export->job_name,
 					 export->printer,
 					 settings,
 					 export->page_setup);
 		gtk_print_job_set_source_file (job, export->temp_file, &error);
-		if (error) {
-			g_set_error_literal (&export->error,
-					     GTK_PRINT_ERROR,
-					     GTK_PRINT_ERROR_GENERAL,
-					     error->message);
-			g_error_free (error);
-			ev_print_operation_export_clear_temp_file (export);
-			g_signal_emit (op, signals[DONE], 0, GTK_PRINT_OPERATION_RESULT_ERROR);
-
-			ev_print_operation_export_run_next (export);
-		} else {
+		if (!error){
 			gtk_print_job_send (job,
 					    (GtkPrintJobCompleteFunc)print_job_finished,
 					    g_object_ref (export),
@@ -823,6 +854,18 @@
 		}
 	}
 	g_object_unref (settings);
+
+	if (error) {
+		g_set_error_literal (&export->error,
+				     GTK_PRINT_ERROR,
+				     GTK_PRINT_ERROR_GENERAL,
+				     error->message);
+		g_error_free (error);
+		ev_print_operation_export_clear_temp_file (export);
+		g_signal_emit (op, signals[DONE], 0, GTK_PRINT_OPERATION_RESULT_ERROR);
+
+		ev_print_operation_export_run_next (export);
+	}
 }
 
 static void

Modified: trunk/shell/ev-window.c
==============================================================================
--- trunk/shell/ev-window.c	(original)
+++ trunk/shell/ev-window.c	Wed Apr  8 13:10:27 2009
@@ -115,7 +115,6 @@
 	EV_CHROME_RAISE_TOOLBAR	= 1 << 3,
 	EV_CHROME_FULLSCREEN_TOOLBAR	= 1 << 4,
 	EV_CHROME_SIDEBAR	= 1 << 5,
-	EV_CHROME_PREVIEW_TOOLBAR       = 1 << 6,
 	EV_CHROME_NORMAL	= EV_CHROME_MENUBAR | EV_CHROME_TOOLBAR | EV_CHROME_SIDEBAR
 } EvChrome;
 
@@ -168,10 +167,6 @@
 	/* Presentation mode */
 	guint      presentation_timeout_id;
 
-	/* Preview mode */
-	GtkWidget *preview_toolbar;
-	gchar     *print_settings_file;
-
 	/* Popup view */
 	GtkWidget *view_popup;
 	EvLink    *link;
@@ -185,7 +180,6 @@
 	char *uri;
 	glong uri_mtime;
 	char *local_uri;
-	gboolean unlink_temp_file;
 	gboolean in_reload;
 	EvFileMonitor *monitor;
 	guint setup_document_idle;
@@ -279,7 +273,6 @@
 							 gboolean          unfullscreen_window);
 static void     ev_window_cmd_view_presentation         (GtkAction        *action,
 							 EvWindow         *window);
-static void     ev_window_run_preview                   (EvWindow         *window);
 static void     ev_view_popup_cmd_open_link             (GtkAction        *action,
 							 EvWindow         *window);
 static void     ev_view_popup_cmd_open_link_new_window  (GtkAction        *action,
@@ -307,7 +300,6 @@
 static void     find_bar_search_changed_cb              (EggFindBar       *find_bar,
 							 GParamSpec       *param,
 							 EvWindow         *ev_window);
-static void     ev_window_do_preview_print              (EvWindow         *window);
 static void     ev_window_load_file_remote              (EvWindow         *ev_window,
 							 GFile            *source_file);
 static void     ev_window_media_player_key_pressed      (EvWindow         *window,
@@ -419,7 +411,6 @@
 	ev_window_set_action_sensitive (ev_window, PAGE_SELECTOR_ACTION, has_pages);
 	ev_window_set_action_sensitive (ev_window, ZOOM_CONTROL_ACTION,  has_pages);
 	ev_window_set_action_sensitive (ev_window, NAVIGATION_ACTION,  FALSE);
-	ev_window_set_action_sensitive (ev_window, "PreviewPrint", has_pages && ok_to_print);
 
         ev_window_update_actions (ev_window);
 }
@@ -536,7 +527,6 @@
 	EvWindowPrivate *priv = window->priv;
 	gboolean menubar, toolbar, findbar, fullscreen_toolbar, sidebar;
 	gboolean fullscreen_mode, presentation, fullscreen;
-	gboolean preview_toolbar;
 
 	presentation = ev_view_get_presentation (EV_VIEW (priv->view));
 	fullscreen = ev_view_get_fullscreen (EV_VIEW (priv->view));
@@ -549,16 +539,12 @@
 			      (priv->chrome & EV_CHROME_RAISE_TOOLBAR) != 0) && fullscreen;
 	findbar = (priv->chrome & EV_CHROME_FINDBAR) != 0;
 	sidebar = (priv->chrome & EV_CHROME_SIDEBAR) != 0 && !presentation;
-	preview_toolbar = (priv->chrome& EV_CHROME_PREVIEW_TOOLBAR);
 
 	set_widget_visibility (priv->menubar, menubar);	
 	set_widget_visibility (priv->toolbar, toolbar);
 	set_widget_visibility (priv->find_bar, findbar);
 	set_widget_visibility (priv->sidebar, sidebar);
 	
-	if (priv->preview_toolbar)
-		set_widget_visibility (priv->preview_toolbar, preview_toolbar);
-
 	ev_window_set_action_sensitive (window, "EditToolbar", toolbar);
 	gtk_widget_set_sensitive (priv->menubar, menubar);
 
@@ -1328,16 +1314,6 @@
 }
 
 static void
-ev_window_clear_print_settings_file (EvWindow *ev_window)
-{
-	if (ev_window->priv->print_settings_file) {
-		g_unlink (ev_window->priv->print_settings_file);
-		g_free (ev_window->priv->print_settings_file);
-		ev_window->priv->print_settings_file = NULL;
-	}
-}
-
-static void
 ev_window_clear_temp_file (EvWindow *ev_window)
 {
 	GFile *file, *tempdir;
@@ -1381,14 +1357,9 @@
 		ev_window_set_document (ev_window, document);
 
 		setup_document_from_metadata (ev_window);
-		
-		if (ev_window->priv->window_mode != EV_WINDOW_MODE_PREVIEW) {
-			setup_view_from_metadata (ev_window);
-		}
+		setup_view_from_metadata (ev_window);
 
-		if (!ev_window->priv->unlink_temp_file) {
-			ev_window_add_recent (ev_window, ev_window->priv->uri);
-		}
+		ev_window_add_recent (ev_window, ev_window->priv->uri);
 
 		ev_window_title_set_type (ev_window->priv->title,
 					  EV_WINDOW_TITLE_DOCUMENT);
@@ -1425,9 +1396,6 @@
 		        case EV_WINDOW_MODE_PRESENTATION:
 				ev_window_run_presentation (ev_window);
 				break;
-		        case EV_WINDOW_MODE_PREVIEW:
-				ev_window_run_preview (ev_window);
-				break;
 		        default:
 				break;
 		}
@@ -1722,7 +1690,6 @@
 		   error->code == G_IO_ERROR_CANCELLED) {
 		ev_window_clear_load_job (ev_window);
 		ev_window_clear_local_uri (ev_window);
-		ev_window_clear_print_settings_file (ev_window);
 		g_free (ev_window->priv->uri);
 		ev_window->priv->uri = NULL;
 		g_object_unref (source);
@@ -1802,9 +1769,7 @@
 		    const char     *uri,
 		    EvLinkDest     *dest,
 		    EvWindowRunMode mode,
-		    const gchar    *search_string, 
-		    gboolean        unlink_temp_file,
-		    const gchar    *print_settings)
+		    const gchar    *search_string)
 {
 	GFile *source_file;
 
@@ -1824,17 +1789,10 @@
 	ev_window_close_dialogs (ev_window);
 	ev_window_clear_load_job (ev_window);
 	ev_window_clear_local_uri (ev_window);
-	ev_window_clear_print_settings_file (ev_window);
 	ev_view_set_loading (EV_VIEW (ev_window->priv->view), TRUE);
 
-	ev_window->priv->unlink_temp_file = unlink_temp_file;
 	ev_window->priv->window_mode = mode;
 
-	if (mode == EV_WINDOW_MODE_PREVIEW) {
-		ev_window->priv->print_settings_file = print_settings ? 
-			g_strdup (print_settings) : NULL;
-	}
-
 	if (ev_window->priv->uri)
 		g_free (ev_window->priv->uri);
 	ev_window->priv->uri = g_strdup (uri);
@@ -2178,8 +2136,6 @@
 					 dest,
 					 0,
 					 NULL, 
-					 TRUE,
-					 NULL,
 					 GDK_CURRENT_TIME);
 	g_free (symlink_uri);
 }
@@ -2213,8 +2169,7 @@
 	
 	ev_application_open_uri_at_dest (EV_APP, uri,
 					 gtk_window_get_screen (GTK_WINDOW (window)),
-					 NULL, 0, NULL, FALSE, NULL, 
-					 GDK_CURRENT_TIME);
+					 NULL, 0, NULL, GDK_CURRENT_TIME);
 }
 
 static void
@@ -2224,8 +2179,7 @@
 {
 	ev_application_open_uri_at_dest (EV_APP, uri,
 					 gtk_window_get_screen (GTK_WINDOW (window)),
-					 NULL, 0, NULL, FALSE, NULL, 
-					 GDK_CURRENT_TIME);
+					 NULL, 0, NULL, GDK_CURRENT_TIME);
 }
 
 static void
@@ -3599,38 +3553,6 @@
 }
 
 static void
-ev_window_run_preview (EvWindow *window)
-{
-	GtkAction *action;
-	
-	if (!window->priv->preview_toolbar) {
-		window->priv->preview_toolbar =
-			gtk_ui_manager_get_widget (window->priv->ui_manager,
-						   "/PreviewToolbar");
-
-		gtk_box_pack_start (GTK_BOX (window->priv->main_box),
-				    window->priv->preview_toolbar,
-				    FALSE, FALSE, 0);
-		gtk_box_reorder_child (GTK_BOX (window->priv->main_box),
-				       window->priv->preview_toolbar, 1);
-	}
-	
-	ev_view_set_continuous (EV_VIEW (window->priv->view), FALSE); 
-	
-	update_chrome_flag (window, EV_CHROME_TOOLBAR, FALSE);
-	update_chrome_flag (window, EV_CHROME_MENUBAR, FALSE);
-	update_chrome_flag (window, EV_CHROME_SIDEBAR, FALSE);
-
-	update_chrome_flag (window, EV_CHROME_PREVIEW_TOOLBAR, TRUE);
-	
-	action = gtk_action_group_get_action (window->priv->action_group,
-					      "PreviewPrint");
-	gtk_action_set_visible (action, TRUE);
-
-	update_chrome_visibility (window);
-}
-
-static void
 ev_window_screen_changed (GtkWidget *widget,
 			  GdkScreen *old_screen)
 {
@@ -3940,137 +3862,6 @@
 	ev_window_run_presentation (window);
 }
 
-static gboolean
-ev_window_enumerate_printer_cb (GtkPrinter *printer,
-				EvWindow   *window)
-{
-	EvWindowPrivate *priv = window->priv;
-	const gchar *printer_name;
-
-	printer_name = gtk_print_settings_get_printer (priv->print_settings);
-	if ((printer_name
-	     && strcmp (printer_name, gtk_printer_get_name (printer)) == 0) ||
-	    (!printer_name && gtk_printer_is_default (printer))) {
-		if (priv->printer)
-			g_object_unref (priv->printer);
-		priv->printer = g_object_ref (printer);
-
-		/* Now that we have the printer, we'll start the print */
-		ev_window_do_preview_print (window);
-
-		return TRUE; /* we're done */
-	}
-
-	return FALSE; /* continue the enumeration */
-}
-
-static void
-ev_window_preview_print_finished (GtkPrintJob *print_job,
-				  EvWindow    *window,
-				  GError      *error)
-{
-	if (error) {
-		ev_window_error_message (window, error,
-					 "%s", _("Failed to print document"));
-	}
-
-	g_object_unref (print_job);
-	gtk_widget_destroy (GTK_WIDGET (window));
-}
-
-static void
-ev_window_do_preview_print (EvWindow *window)
-{
-	EvWindowPrivate  *priv = window->priv;
-	GtkPrintJob      *job;
-	gchar            *filename;
-	GError           *error = NULL;
-
-	g_assert (priv->print_settings != NULL);
-	g_assert (priv->printer != NULL);
-
-	job = gtk_print_job_new (gtk_window_get_title (GTK_WINDOW (window)),
-				 priv->printer,
-				 priv->print_settings,
-				 priv->print_page_setup);
-
-	g_object_unref (priv->print_settings);
-	priv->print_settings = NULL;
-	g_object_unref (priv->print_page_setup);
-	priv->print_page_setup = NULL;
-	g_object_unref (priv->printer);
-	priv->printer = NULL;
-
-	filename = g_filename_from_uri (priv->local_uri ?
-					priv->local_uri : priv->uri,
-					NULL, NULL);
-
-	if (gtk_print_job_set_source_file (job, filename, &error)) {
-		gtk_print_job_send (job,
-				    (GtkPrintJobCompleteFunc)ev_window_preview_print_finished,
-				    window, NULL);
-	} else {
-		g_warning ("%s", error->message);
-		g_error_free (error);
-	}
-
-	g_free (filename);
-
-	gtk_widget_hide (GTK_WIDGET (window));
-}
-
-static void
-ev_window_cmd_preview_print (GtkAction *action, EvWindow *window)
-{
-	EvWindowPrivate  *priv = window->priv;
-	GtkPrintSettings *print_settings;
-	GtkPageSetup     *page_setup;
-	const gchar      *print_settings_file = priv->print_settings_file;
-
-	if (print_settings_file && g_file_test (print_settings_file, G_FILE_TEST_IS_REGULAR)) {
-		GKeyFile *key_file;
-		GError   *error = NULL;
-
-		key_file = g_key_file_new ();
-		g_key_file_load_from_file (key_file,
-					   print_settings_file,
-					   G_KEY_FILE_KEEP_COMMENTS |
-					   G_KEY_FILE_KEEP_TRANSLATIONS,
-					   &error);
-		if (!error) {
-			print_settings =
-				gtk_print_settings_new_from_key_file (key_file,
-								      "Print Settings",
-								      NULL);
-			print_settings = print_settings ? print_settings : gtk_print_settings_new ();
-			
-			page_setup = gtk_page_setup_new_from_key_file (key_file,
-								       "Page Setup",
-								       NULL);
-			page_setup = page_setup ? page_setup : gtk_page_setup_new ();
-		} else {
-			print_settings = gtk_print_settings_new ();
-			page_setup = gtk_page_setup_new ();
-			g_error_free (error);
-		}
-
-		g_key_file_free (key_file);
-	} else {
-		print_settings = gtk_print_settings_new ();
-		page_setup = gtk_page_setup_new ();
-	}
-	
-	if (priv->print_settings)
-		g_object_unref (priv->print_settings);
-	priv->print_settings = print_settings;
-	if (priv->print_page_setup)
-		g_object_unref (priv->print_page_setup);
-	priv->print_page_setup = page_setup;
-
-	gtk_enumerate_printers ((GtkPrinterFunc) ev_window_enumerate_printer_cb,
-				window, NULL, FALSE);
-}
-
 static void
 ev_window_cmd_escape (GtkAction *action, EvWindow *window)
 {
@@ -4950,8 +4741,6 @@
 	}
 
 	if (priv->uri) {
-		if (priv->unlink_temp_file)
-			ev_window_clear_temp_file (window);
 		g_free (priv->uri);
 		priv->uri = NULL;
 	}
@@ -4971,11 +4760,6 @@
 		priv->history = NULL;
 	}
 
-	if (priv->print_settings_file) {
-		ev_window_clear_print_settings_file (window);
-		priv->print_settings_file = NULL;
-	}
-
 	if (priv->presentation_timeout_id > 0) {
 		g_source_remove (priv->presentation_timeout_id);
 		priv->presentation_timeout_id = 0;
@@ -5095,9 +4879,6 @@
 	{ "StartPresentation", EV_STOCK_RUN_PRESENTATION, N_("Start Presentation"), NULL,
 	  N_("Start a presentation"),
 	  G_CALLBACK (ev_window_cmd_start_presentation) },
-	{ "PreviewPrint", GTK_STOCK_PRINT, N_("Print"), NULL,
-	  N_("Print this document"),
-	  G_CALLBACK (ev_window_cmd_preview_print) },
 
 	/* Accellerators */
 	{ "Escape", NULL, "", "Escape", "",
@@ -5564,8 +5345,6 @@
 					 ev_link_action_get_dest (action),
 					 0,
 					 NULL, 
-					 FALSE,
-					 NULL,
 					 GDK_CURRENT_TIME);
 
 	g_free (uri);

Modified: trunk/shell/ev-window.h
==============================================================================
--- trunk/shell/ev-window.h	(original)
+++ trunk/shell/ev-window.h	Wed Apr  8 13:10:27 2009
@@ -34,8 +34,7 @@
 typedef enum {
 	EV_WINDOW_MODE_NORMAL,
 	EV_WINDOW_MODE_FULLSCREEN,
-	EV_WINDOW_MODE_PRESENTATION,
-	EV_WINDOW_MODE_PREVIEW
+	EV_WINDOW_MODE_PRESENTATION
 } EvWindowRunMode;
 
 typedef struct {
@@ -77,9 +76,7 @@
 					   const char     *uri,
 					   EvLinkDest     *dest,
 					   EvWindowRunMode mode,
-					   const gchar    *search_string,
-					   gboolean        unlink_temp_file,
-					   const gchar    *print_settings);
+					   const gchar    *search_string);
 gboolean	ev_window_is_empty	  (const EvWindow *ev_window);
 void		ev_window_print_range     (EvWindow       *ev_window,
 					   int             first_page,

Modified: trunk/shell/main.c
==============================================================================
--- trunk/shell/main.c	(original)
+++ trunk/shell/main.c	Wed Apr  8 13:10:27 2009
@@ -76,6 +76,62 @@
 	{ NULL }
 };
 
+static gboolean
+launch_previewer (void)
+{
+	GString *cmd_str;
+	gchar   *cmd;
+	gint     argc;
+	gchar  **argv;
+	gboolean retval = FALSE;
+	GError  *error = NULL;
+
+	/* Rebuild the command line, ignoring options
+	 * not supported by the previewer and taking only
+	 * the first path given
+	 */
+	cmd_str = g_string_new ("evince-previewer");
+		
+	if (print_settings) {
+		gchar *quoted;
+
+		quoted = g_shell_quote (print_settings);
+		g_string_append_printf (cmd_str, " --print-settings %s", quoted);
+		g_free (quoted);
+	}
+
+	if (unlink_temp_file)
+		g_string_append (cmd_str, " --unlink-tempfile");
+
+	if (file_arguments) {
+		gchar *quoted;
+		
+		quoted = g_shell_quote (file_arguments[0]);
+		g_string_append_printf (cmd_str, " %s", quoted);
+		g_free (quoted);
+	}
+
+	cmd = g_string_free (cmd_str, FALSE);
+	g_shell_parse_argv (cmd, &argc, &argv, &error);
+	g_free (cmd);
+	
+	if (!error) {
+		retval = gdk_spawn_on_screen (gdk_screen_get_default (),
+					      NULL, argv, NULL,
+					      G_SPAWN_SEARCH_PATH,
+					      NULL, NULL, NULL,
+					      &error);
+		g_strfreev (argv);
+	}
+
+	if (error) {
+		g_warning ("Error launching previewer: %s\n", error->message);
+		g_error_free (error);
+	}
+
+	return retval;
+}
+
 static void
 value_free (GValue *value)
 {
@@ -96,8 +152,6 @@
  *                          the page of the document to display.
  *  mode                ->  only if the view mode is one of the availables,
  *                          the view mode.
- *  unlink-temp-file    ->  only if the view mode is preview mode and
- *                          unlink-temp-file has been passed, unlink-temp-file.
  *
  * Returns: a pointer into #GHashTable with data from the arguments.
  */
@@ -159,8 +213,6 @@
 		mode = EV_WINDOW_MODE_FULLSCREEN;
 	else if (presentation_mode)
 		mode = EV_WINDOW_MODE_PRESENTATION;
-	else if (preview_mode)
-		mode = EV_WINDOW_MODE_PREVIEW;
 	else
 		return args;
 
@@ -170,28 +222,6 @@
 
 	g_hash_table_insert (args, g_strdup ("mode"), value);
 
-	if (mode == EV_WINDOW_MODE_PREVIEW && unlink_temp_file) {
-		value = g_new0 (GValue, 1);
-		g_value_init (value, G_TYPE_BOOLEAN);
-		g_value_set_boolean (value, unlink_temp_file);
-
-		g_hash_table_insert (args,
-				     g_strdup ("unlink-temp-file"),
-				     value);
-	}
-
-	if (mode == EV_WINDOW_MODE_PREVIEW && print_settings) {
-		value = g_new0 (GValue, 1);
-		g_value_init (value, G_TYPE_STRING);
-		g_value_set_string (value, print_settings);
-
-		g_hash_table_insert (args,
-				     g_strdup ("print-settings"),
-				     value);
-		g_free (print_settings);
-		print_settings = NULL;
-	}
-
 	return args;
 }
 
@@ -360,6 +390,14 @@
 	}
 	g_option_context_free (context);
 
+	if (preview_mode) {
+		gboolean retval;
+		
+		retval = launch_previewer ();
+		
+		return retval ? 0 : 1;
+	}
+
 	args = arguments_parse ();
 
 #ifdef ENABLE_DBUS



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]