forked from AuroraMiddleware/gtk
Better version of the previous patch
svn path=/trunk/; revision=17712
This commit is contained in:
parent
4ae147c887
commit
53931bcf21
@ -10,7 +10,7 @@
|
|||||||
* gtk/gtkprintoperation-unix.c
|
* gtk/gtkprintoperation-unix.c
|
||||||
(_gtk_print_operation_platform_backend_launch_preview):
|
(_gtk_print_operation_platform_backend_launch_preview):
|
||||||
Don't leak a file descriptor, and don't make the error
|
Don't leak a file descriptor, and don't make the error
|
||||||
dialog modal. (#421985, Morten Welinder)
|
dialog modal. (#421985, Morten Welinder, Christian Persch)
|
||||||
|
|
||||||
2007-04-29 Xan Lopez <xan@gnome.org>
|
2007-04-29 Xan Lopez <xan@gnome.org>
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#include <glib/gstdio.h>
|
||||||
#include "gtkprintoperation-private.h"
|
#include "gtkprintoperation-private.h"
|
||||||
#include "gtkmarshal.h"
|
#include "gtkmarshal.h"
|
||||||
#include "gtkmessagedialog.h"
|
#include "gtkmessagedialog.h"
|
||||||
@ -124,14 +125,12 @@ shell_command_substitute_file (const gchar *cmd,
|
|||||||
gboolean *settings_filename_replaced)
|
gboolean *settings_filename_replaced)
|
||||||
{
|
{
|
||||||
const gchar *inptr, *start;
|
const gchar *inptr, *start;
|
||||||
gchar *result;
|
|
||||||
GString *final;
|
GString *final;
|
||||||
|
|
||||||
g_return_val_if_fail (cmd != NULL, NULL);
|
g_return_val_if_fail (cmd != NULL, NULL);
|
||||||
g_return_val_if_fail (pdf_filename != NULL, NULL);
|
g_return_val_if_fail (pdf_filename != NULL, NULL);
|
||||||
g_return_val_if_fail (settings_filename != NULL, NULL);
|
g_return_val_if_fail (settings_filename != NULL, NULL);
|
||||||
|
|
||||||
result = NULL;
|
|
||||||
final = g_string_new (NULL);
|
final = g_string_new (NULL);
|
||||||
|
|
||||||
*pdf_filename_replaced = FALSE;
|
*pdf_filename_replaced = FALSE;
|
||||||
@ -170,11 +169,7 @@ shell_command_substitute_file (const gchar *cmd,
|
|||||||
}
|
}
|
||||||
g_string_append (final, start);
|
g_string_append (final, start);
|
||||||
|
|
||||||
result = final->str;
|
return g_string_free (final, FALSE);
|
||||||
|
|
||||||
g_string_free (final, FALSE);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -189,14 +184,15 @@ _gtk_print_operation_platform_backend_launch_preview (GtkPrintOperation *op,
|
|||||||
gchar *preview_cmd;
|
gchar *preview_cmd;
|
||||||
GtkSettings *settings;
|
GtkSettings *settings;
|
||||||
GtkPrintSettings *print_settings;
|
GtkPrintSettings *print_settings;
|
||||||
gchar *settings_filename;
|
gchar *settings_filename = NULL;
|
||||||
gchar *quoted_filename;
|
gchar *quoted_filename;
|
||||||
gchar *quoted_settings_filename;
|
gchar *quoted_settings_filename;
|
||||||
gboolean filename_used;
|
gboolean filename_used = FALSE;
|
||||||
gboolean settings_used;
|
gboolean settings_used = FALSE;
|
||||||
GdkScreen *screen;
|
GdkScreen *screen;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
gint fd;
|
gint fd;
|
||||||
|
gboolean retval;
|
||||||
|
|
||||||
cairo_surface_destroy (surface);
|
cairo_surface_destroy (surface);
|
||||||
|
|
||||||
@ -205,11 +201,15 @@ _gtk_print_operation_platform_backend_launch_preview (GtkPrintOperation *op,
|
|||||||
else
|
else
|
||||||
screen = gdk_screen_get_default ();
|
screen = gdk_screen_get_default ();
|
||||||
|
|
||||||
settings_filename = g_build_filename (g_get_tmp_dir (), "settingsXXXXXX.ini", NULL);
|
fd = g_file_open_tmp ("settingsXXXXXX.ini", &settings_filename, &error);
|
||||||
fd = g_mkstemp (settings_filename);
|
if (fd < 0)
|
||||||
|
goto out;
|
||||||
|
|
||||||
print_settings = gtk_print_operation_get_print_settings (op);
|
print_settings = gtk_print_operation_get_print_settings (op);
|
||||||
if (!gtk_print_settings_to_file (print_settings, settings_filename, &error))
|
retval = gtk_print_settings_to_file (print_settings, settings_filename, &error);
|
||||||
|
close (fd);
|
||||||
|
|
||||||
|
if (!retval)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
settings = gtk_settings_get_for_screen (screen);
|
settings = gtk_settings_get_for_screen (screen);
|
||||||
@ -233,8 +233,6 @@ _gtk_print_operation_platform_backend_launch_preview (GtkPrintOperation *op,
|
|||||||
g_strfreev (argv);
|
g_strfreev (argv);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
close (fd);
|
|
||||||
|
|
||||||
if (error != NULL)
|
if (error != NULL)
|
||||||
{
|
{
|
||||||
GtkWidget *edialog;
|
GtkWidget *edialog;
|
||||||
|
Loading…
Reference in New Issue
Block a user