minor cleanups.

2006-12-26  Sven Neumann  <sven@gimp.org>

	* plug-ins/print/print: minor cleanups.
This commit is contained in:
Sven Neumann
2006-12-26 12:36:43 +00:00
committed by Sven Neumann
parent 3dd2f1d36a
commit 9152bf5d52
2 changed files with 58 additions and 47 deletions

View File

@ -1,11 +1,11 @@
2006-12-26 Sven Neumann <sven@gimp.org>
* plug-ins/print/print-settings.c: cleaned up error handling.
* plug-ins/print/print: minor cleanups.
2006-12-26 Sven Neumann <sven@gimp.org>
* plug-ins/print/print-settings.c (check_version): check keyfile
before accessing it. Minor code cleanup.
before accessing it. Cleaned up error handling.
2006-12-25 Sven Neumann <sven@gimp.org>

View File

@ -32,6 +32,7 @@
#include "libgimp/stdplugins-intl.h"
#define PRINT_PROC_NAME "file-print-gtk"
#define PLUG_IN_BINARY "print"
@ -165,11 +166,13 @@ print_image (gint32 image_ID,
PrintData *data;
data = g_new0 (PrintData, 1);
data->num_pages = 1;
data->image_id = image_ID;
data->drawable_id = drawable_ID;
data->operation = operation;
data->print_size_changed = FALSE;
gimp_image_get_resolution (data->image_id, &data->xres, &data->yres);
load_print_settings (data);
@ -186,7 +189,7 @@ print_image (gint32 image_ID,
if (interactive)
{
GtkPrintOperationResult res;
GtkPrintOperationResult result;
g_signal_connect (operation, "create-custom-widget",
G_CALLBACK (create_custom_widget),
@ -200,14 +203,20 @@ print_image (gint32 image_ID,
gtk_print_operation_set_custom_tab_label (operation, _("Layout"));
res = gtk_print_operation_run (operation,
result = gtk_print_operation_run (operation,
GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
NULL, &error);
if (res == GTK_PRINT_OPERATION_RESULT_APPLY ||
res == GTK_PRINT_OPERATION_RESULT_IN_PROGRESS)
switch (result)
{
case GTK_PRINT_OPERATION_RESULT_APPLY:
case GTK_PRINT_OPERATION_RESULT_IN_PROGRESS:
save_print_settings (data);
break;
case GTK_PRINT_OPERATION_RESULT_ERROR:
case GTK_PRINT_OPERATION_RESULT_CANCEL:
break;
}
}
else
@ -220,7 +229,10 @@ print_image (gint32 image_ID,
g_object_unref (operation);
if (error)
{
g_message (error->message);
g_error_free (error);
}
return TRUE;
}
@ -282,8 +294,7 @@ custom_widget_apply (GtkPrintOperation *operation,
{
gimp_image_undo_group_start (data->image_id);
gimp_image_set_resolution (data->image_id,
data->xres, data->yres);
gimp_image_set_resolution (data->image_id, data->xres, data->yres);
gimp_image_set_unit (data->image_id, data->unit);
gimp_image_undo_group_end (data->image_id);
@ -363,10 +374,10 @@ print_preview (GtkPrintOperation *operation,
if (draw_page_cairo (context, data))
{
cairo_status_t status;
gchar *fname;
gchar *filename;
fname = gimp_temp_name ("png");
status = cairo_surface_write_to_png (surface, fname);
filename = gimp_temp_name ("png");
status = cairo_surface_write_to_png (surface, filename);
cairo_destroy (cr);
cairo_surface_destroy (surface);
@ -377,10 +388,9 @@ print_preview (GtkPrintOperation *operation,
dialog = gtk_dialog_new ();
gtk_window_set_title (GTK_WINDOW (dialog), _("Print Preview"));
image = gtk_image_new_from_file (fname);
image = gtk_image_new_from_file (filename);
g_unlink (fname);
g_free (fname);
g_unlink (filename);
gtk_box_pack_start (GTK_BOX (GTK_DIALOG (dialog)->vbox),
image, FALSE, FALSE, 0);
@ -390,8 +400,9 @@ print_preview (GtkPrintOperation *operation,
gtk_widget_destroy (dialog);
}
g_free (filename);
}
return TRUE;
}