Bug 344522 – support non-local destination files (GtkPrint):
2008-09-30 Marek Kasik <mkasik@redhat.com> Bug 344522 – support non-local destination files (GtkPrint): * gtk/gtkprintunixdialog.c * gtk/gtkprinteroptionwidget.c: Process URI instead of filename. * modules/printbackends/file/gtkprintbackendfile.c: Add ability to save files on non-local filesystems. svn path=/trunk/; revision=21552
This commit is contained in:
@ -316,7 +316,7 @@ typedef struct {
|
||||
GtkPrintBackend *backend;
|
||||
GtkPrintJobCompleteFunc callback;
|
||||
GtkPrintJob *job;
|
||||
GIOChannel *target_io;
|
||||
GFileOutputStream *target_io_stream;
|
||||
gpointer user_data;
|
||||
GDestroyNotify dnotify;
|
||||
} _PrintStreamData;
|
||||
@ -330,8 +330,8 @@ file_print_cb (GtkPrintBackendFile *print_backend,
|
||||
|
||||
GDK_THREADS_ENTER ();
|
||||
|
||||
if (ps->target_io != NULL)
|
||||
g_io_channel_unref (ps->target_io);
|
||||
if (ps->target_io_stream != NULL)
|
||||
g_output_stream_close (G_OUTPUT_STREAM (ps->target_io_stream), NULL, NULL);
|
||||
|
||||
if (ps->callback)
|
||||
ps->callback (ps->job, ps->user_data, error);
|
||||
@ -374,11 +374,12 @@ file_write (GIOChannel *source,
|
||||
{
|
||||
gsize bytes_written;
|
||||
|
||||
g_io_channel_write_chars (ps->target_io,
|
||||
buf,
|
||||
bytes_read,
|
||||
&bytes_written,
|
||||
&error);
|
||||
g_output_stream_write_all (G_OUTPUT_STREAM (ps->target_io_stream),
|
||||
buf,
|
||||
bytes_read,
|
||||
&bytes_written,
|
||||
NULL,
|
||||
&error);
|
||||
}
|
||||
|
||||
if (error != NULL || read_status == G_IO_STATUS_EOF)
|
||||
@ -414,7 +415,8 @@ gtk_print_backend_file_print_stream (GtkPrintBackend *print_backend,
|
||||
GtkPrinter *printer;
|
||||
_PrintStreamData *ps;
|
||||
GtkPrintSettings *settings;
|
||||
gchar *uri, *filename;
|
||||
gchar *uri;
|
||||
GFile *file = NULL;
|
||||
|
||||
printer = gtk_print_job_get_printer (job);
|
||||
settings = gtk_print_job_get_settings (job);
|
||||
@ -428,18 +430,15 @@ gtk_print_backend_file_print_stream (GtkPrintBackend *print_backend,
|
||||
|
||||
internal_error = NULL;
|
||||
uri = output_file_from_settings (settings, NULL);
|
||||
filename = g_filename_from_uri (uri, NULL, &internal_error);
|
||||
g_free (uri);
|
||||
|
||||
if (filename == NULL)
|
||||
if (uri == NULL)
|
||||
goto error;
|
||||
|
||||
ps->target_io = g_io_channel_new_file (filename, "w", &internal_error);
|
||||
file = g_file_new_for_uri (uri);
|
||||
ps->target_io_stream = g_file_replace (file, NULL, FALSE, G_FILE_CREATE_NONE, NULL, &internal_error);
|
||||
|
||||
g_free (filename);
|
||||
|
||||
if (internal_error == NULL)
|
||||
g_io_channel_set_encoding (ps->target_io, NULL, &internal_error);
|
||||
g_object_unref (file);
|
||||
g_free (uri);
|
||||
|
||||
error:
|
||||
if (internal_error != NULL)
|
||||
|
||||
Reference in New Issue
Block a user