2006-12-10 05:33:38 +08:00
|
|
|
/* GIMP - The GNU Image Manipulation Program
|
2006-06-23 05:58:56 +08:00
|
|
|
* Copyright (C) 1995 Spencer Kimball and Peter Mattis
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
#include <libgimp/gimp.h>
|
|
|
|
#include <libgimp/gimpui.h>
|
|
|
|
|
2006-06-27 06:48:05 +08:00
|
|
|
#include "print.h"
|
|
|
|
#include "print-settings.h"
|
|
|
|
#include "print-page-layout.h"
|
2008-02-05 00:59:45 +08:00
|
|
|
#include "print-page-setup.h"
|
2006-06-27 06:48:05 +08:00
|
|
|
#include "print-draw-page.h"
|
2006-06-23 05:58:56 +08:00
|
|
|
|
2006-06-27 06:48:05 +08:00
|
|
|
#include "libgimp/stdplugins-intl.h"
|
2006-06-23 05:58:56 +08:00
|
|
|
|
2006-06-23 16:46:46 +08:00
|
|
|
|
2008-02-01 15:10:55 +08:00
|
|
|
#define PLUG_IN_BINARY "print"
|
|
|
|
|
|
|
|
#define PRINT_PROC_NAME "file-print-gtk"
|
|
|
|
#define PAGE_SETUP_PROC_NAME "file-print-gtk-page-setup"
|
2008-02-05 06:03:09 +08:00
|
|
|
#define PRINT_TEMP_PROC_NAME "file-print-gtk-page-setup-notify-temp"
|
2006-06-23 05:58:56 +08:00
|
|
|
|
2006-12-26 20:36:43 +08:00
|
|
|
|
|
|
|
static void query (void);
|
|
|
|
static void run (const gchar *name,
|
|
|
|
gint nparams,
|
|
|
|
const GimpParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals);
|
2006-06-23 05:58:56 +08:00
|
|
|
|
2008-02-01 15:10:55 +08:00
|
|
|
static GimpPDBStatusType print_image (gint32 image_ID,
|
2008-08-24 01:11:40 +08:00
|
|
|
gboolean interactive,
|
|
|
|
GError **error);
|
2008-02-01 15:10:55 +08:00
|
|
|
static GimpPDBStatusType page_setup (gint32 image_ID);
|
2006-06-23 05:58:56 +08:00
|
|
|
|
2008-08-24 01:11:40 +08:00
|
|
|
static void print_show_error (const gchar *message);
|
2007-07-24 15:22:35 +08:00
|
|
|
static void print_operation_set_name (GtkPrintOperation *operation,
|
|
|
|
gint image_ID);
|
2006-06-23 05:58:56 +08:00
|
|
|
|
2007-07-24 15:22:35 +08:00
|
|
|
static void begin_print (GtkPrintOperation *operation,
|
|
|
|
GtkPrintContext *context,
|
|
|
|
PrintData *data);
|
|
|
|
static void end_print (GtkPrintOperation *operation,
|
|
|
|
GtkPrintContext *context,
|
2008-08-08 03:22:19 +08:00
|
|
|
gint32 *layer_ID);
|
2007-07-24 15:22:35 +08:00
|
|
|
static void draw_page (GtkPrintOperation *print,
|
|
|
|
GtkPrintContext *context,
|
|
|
|
gint page_nr,
|
|
|
|
PrintData *data);
|
2006-06-23 05:58:56 +08:00
|
|
|
|
2007-07-24 15:22:35 +08:00
|
|
|
static GtkWidget * create_custom_widget (GtkPrintOperation *operation,
|
|
|
|
PrintData *data);
|
2006-06-23 05:58:56 +08:00
|
|
|
|
2008-02-05 05:49:08 +08:00
|
|
|
static gchar * print_temp_proc_name (gint32 image_ID);
|
|
|
|
static gchar * print_temp_proc_install (gint32 image_ID);
|
|
|
|
|
|
|
|
|
|
|
|
/* Keep a reference to the current GtkPrintOperation
|
|
|
|
* for access by the temporary procedure.
|
|
|
|
*/
|
|
|
|
static GtkPrintOperation *print_operation = NULL;
|
2006-06-30 01:58:54 +08:00
|
|
|
|
2006-12-29 22:26:55 +08:00
|
|
|
|
2006-06-23 05:58:56 +08:00
|
|
|
const GimpPlugInInfo PLUG_IN_INFO =
|
|
|
|
{
|
|
|
|
NULL, /* init_proc */
|
|
|
|
NULL, /* quit_proc */
|
|
|
|
query, /* query_proc */
|
|
|
|
run, /* run_proc */
|
|
|
|
};
|
|
|
|
|
|
|
|
MAIN ()
|
|
|
|
|
|
|
|
static void
|
|
|
|
query (void)
|
|
|
|
{
|
|
|
|
static const GimpParamDef print_args[] =
|
|
|
|
{
|
2006-12-26 20:36:43 +08:00
|
|
|
{ GIMP_PDB_INT32, "run-mode", "Interactive, non-interactive" },
|
2007-07-25 23:30:03 +08:00
|
|
|
{ GIMP_PDB_IMAGE, "image", "Image to print" }
|
2006-06-23 05:58:56 +08:00
|
|
|
};
|
|
|
|
|
2006-06-27 06:48:05 +08:00
|
|
|
gimp_install_procedure (PRINT_PROC_NAME,
|
2006-06-23 16:46:46 +08:00
|
|
|
N_("Print the image"),
|
|
|
|
"Print the image using the GTK+ Print API.",
|
2007-07-26 03:50:28 +08:00
|
|
|
"Bill Skaggs, Sven Neumann, Stefan Röllin",
|
2008-02-01 15:10:55 +08:00
|
|
|
"Bill Skaggs <weskaggs@primate.ucdavis.edu>",
|
2007-07-25 23:30:03 +08:00
|
|
|
"2006, 2007",
|
2006-06-23 05:58:56 +08:00
|
|
|
N_("_Print..."),
|
2006-12-27 21:46:27 +08:00
|
|
|
"*",
|
2006-06-23 05:58:56 +08:00
|
|
|
GIMP_PLUGIN,
|
|
|
|
G_N_ELEMENTS (print_args), 0,
|
|
|
|
print_args, NULL);
|
|
|
|
|
2006-06-27 06:48:05 +08:00
|
|
|
gimp_plugin_menu_register (PRINT_PROC_NAME, "<Image>/File/Send");
|
|
|
|
gimp_plugin_icon_register (PRINT_PROC_NAME, GIMP_ICON_TYPE_STOCK_ID,
|
2006-06-23 05:58:56 +08:00
|
|
|
(const guint8 *) GTK_STOCK_PRINT);
|
2006-06-27 06:48:05 +08:00
|
|
|
|
2008-02-01 15:10:55 +08:00
|
|
|
gimp_install_procedure (PAGE_SETUP_PROC_NAME,
|
|
|
|
N_("Adjust page size and orientation for printing"),
|
2008-04-25 20:30:10 +08:00
|
|
|
"Adjust page size and orientation for printing the "
|
|
|
|
"image using the GTK+ Print API.",
|
2008-02-01 15:10:55 +08:00
|
|
|
"Bill Skaggs, Sven Neumann, Stefan Röllin",
|
|
|
|
"Sven Neumann <sven@gimp.org>",
|
|
|
|
"2008",
|
2008-02-05 15:50:26 +08:00
|
|
|
N_("Page Set_up"),
|
2008-02-01 15:10:55 +08:00
|
|
|
"*",
|
|
|
|
GIMP_PLUGIN,
|
|
|
|
G_N_ELEMENTS (print_args), 0,
|
|
|
|
print_args, NULL);
|
|
|
|
|
|
|
|
gimp_plugin_menu_register (PAGE_SETUP_PROC_NAME, "<Image>/File/Send");
|
2008-02-22 21:42:47 +08:00
|
|
|
|
|
|
|
#if GTK_CHECK_VERSION(2,13,0)
|
|
|
|
gimp_plugin_icon_register (PAGE_SETUP_PROC_NAME, GIMP_ICON_TYPE_STOCK_ID,
|
|
|
|
(const guint8 *) GTK_STOCK_PAGE_SETUP);
|
|
|
|
#endif
|
2006-06-23 05:58:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
run (const gchar *name,
|
|
|
|
gint nparams,
|
|
|
|
const GimpParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals)
|
|
|
|
{
|
2008-08-24 01:11:40 +08:00
|
|
|
static GimpParam values[2];
|
|
|
|
GimpRunMode run_mode;
|
|
|
|
GimpPDBStatusType status;
|
|
|
|
gint32 image_ID;
|
|
|
|
GError *error = NULL;
|
2006-06-23 05:58:56 +08:00
|
|
|
|
|
|
|
run_mode = param[0].data.d_int32;
|
|
|
|
|
|
|
|
INIT_I18N ();
|
|
|
|
|
|
|
|
*nreturn_vals = 1;
|
|
|
|
*return_vals = values;
|
2006-12-29 23:36:54 +08:00
|
|
|
|
2008-02-01 15:10:55 +08:00
|
|
|
g_thread_init (NULL);
|
|
|
|
|
2006-06-23 05:58:56 +08:00
|
|
|
values[0].type = GIMP_PDB_STATUS;
|
|
|
|
values[0].data.d_status = GIMP_PDB_EXECUTION_ERROR;
|
|
|
|
|
2008-02-01 15:10:55 +08:00
|
|
|
image_ID = param[1].data.d_int32;
|
2006-06-23 05:58:56 +08:00
|
|
|
|
2006-06-27 06:48:05 +08:00
|
|
|
if (strcmp (name, PRINT_PROC_NAME) == 0)
|
2006-06-23 05:58:56 +08:00
|
|
|
{
|
2008-08-24 01:11:40 +08:00
|
|
|
status = print_image (image_ID, run_mode == GIMP_RUN_INTERACTIVE, &error);
|
|
|
|
|
|
|
|
if (error && run_mode == GIMP_RUN_INTERACTIVE)
|
|
|
|
{
|
|
|
|
print_show_error (error->message);
|
|
|
|
g_clear_error (&error);
|
|
|
|
}
|
2008-02-01 15:10:55 +08:00
|
|
|
}
|
|
|
|
else if (strcmp (name, PAGE_SETUP_PROC_NAME) == 0)
|
|
|
|
{
|
|
|
|
if (run_mode == GIMP_RUN_INTERACTIVE)
|
|
|
|
{
|
|
|
|
status = page_setup (image_ID);
|
|
|
|
}
|
|
|
|
else
|
2006-06-23 05:58:56 +08:00
|
|
|
{
|
2008-02-01 15:10:55 +08:00
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
2006-06-23 05:58:56 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
status = GIMP_PDB_CALLING_ERROR;
|
|
|
|
}
|
|
|
|
|
2008-08-24 01:11:40 +08:00
|
|
|
if (status != GIMP_PDB_SUCCESS && error)
|
|
|
|
{
|
|
|
|
*nreturn_vals = 2;
|
|
|
|
values[1].type = GIMP_PDB_STRING;
|
|
|
|
values[1].data.d_string = error->message;
|
|
|
|
}
|
|
|
|
|
2006-06-23 05:58:56 +08:00
|
|
|
values[0].data.d_status = status;
|
|
|
|
}
|
|
|
|
|
2008-02-01 15:10:55 +08:00
|
|
|
static GimpPDBStatusType
|
2008-08-24 01:11:40 +08:00
|
|
|
print_image (gint32 image_ID,
|
|
|
|
gboolean interactive,
|
|
|
|
GError **error)
|
2006-06-23 05:58:56 +08:00
|
|
|
{
|
2008-08-24 01:11:40 +08:00
|
|
|
GtkPrintOperation *operation;
|
|
|
|
GtkPrintOperationResult result;
|
|
|
|
gchar *temp_proc;
|
|
|
|
gint32 layer;
|
|
|
|
PrintData data;
|
2007-07-20 04:32:53 +08:00
|
|
|
|
2008-08-08 03:22:19 +08:00
|
|
|
/* create a print layer from the projection */
|
|
|
|
layer = gimp_layer_new_from_visible (image_ID, image_ID, PRINT_PROC_NAME);
|
2007-07-20 04:32:53 +08:00
|
|
|
|
2007-07-24 15:22:35 +08:00
|
|
|
operation = gtk_print_operation_new ();
|
|
|
|
|
2008-04-07 18:38:38 +08:00
|
|
|
gtk_print_operation_set_n_pages (operation, 1);
|
2008-08-08 03:22:19 +08:00
|
|
|
print_operation_set_name (operation, image_ID);
|
2007-07-24 15:22:35 +08:00
|
|
|
|
2008-08-08 03:22:19 +08:00
|
|
|
print_page_setup_load (operation, image_ID);
|
2008-02-05 00:59:45 +08:00
|
|
|
|
2007-07-24 15:05:06 +08:00
|
|
|
/* fill in the PrintData struct */
|
2008-08-08 03:22:19 +08:00
|
|
|
data.image_id = image_ID;
|
|
|
|
data.drawable_id = layer;
|
2007-07-24 05:17:47 +08:00
|
|
|
data.unit = gimp_get_default_unit ();
|
|
|
|
data.image_unit = gimp_image_get_unit (image_ID);
|
|
|
|
data.offset_x = 0;
|
|
|
|
data.offset_y = 0;
|
2007-08-09 05:28:07 +08:00
|
|
|
data.center = CENTER_BOTH;
|
2007-07-24 05:17:47 +08:00
|
|
|
data.use_full_page = FALSE;
|
|
|
|
data.operation = operation;
|
2006-06-23 05:58:56 +08:00
|
|
|
|
2007-07-24 05:17:47 +08:00
|
|
|
gimp_image_get_resolution (image_ID, &data.xres, &data.yres);
|
2006-12-26 20:36:43 +08:00
|
|
|
|
2008-02-26 02:59:04 +08:00
|
|
|
print_settings_load (&data);
|
2006-06-23 05:58:56 +08:00
|
|
|
|
2008-10-22 23:01:34 +08:00
|
|
|
gtk_print_operation_set_unit (operation, GTK_UNIT_PIXEL);
|
2008-02-24 21:08:51 +08:00
|
|
|
|
2006-12-26 05:03:27 +08:00
|
|
|
g_signal_connect (operation, "begin-print",
|
|
|
|
G_CALLBACK (begin_print),
|
2007-07-24 05:17:47 +08:00
|
|
|
&data);
|
2006-12-26 05:03:27 +08:00
|
|
|
g_signal_connect (operation, "draw-page",
|
|
|
|
G_CALLBACK (draw_page),
|
2007-07-24 05:17:47 +08:00
|
|
|
&data);
|
2006-12-26 05:03:27 +08:00
|
|
|
g_signal_connect (operation, "end-print",
|
|
|
|
G_CALLBACK (end_print),
|
2007-07-25 15:36:15 +08:00
|
|
|
&image_ID);
|
2007-07-24 15:05:06 +08:00
|
|
|
|
2008-02-05 05:49:08 +08:00
|
|
|
print_operation = operation;
|
2008-08-08 03:22:19 +08:00
|
|
|
temp_proc = print_temp_proc_install (image_ID);
|
2008-02-05 05:49:08 +08:00
|
|
|
gimp_extension_enable ();
|
|
|
|
|
2006-06-23 05:58:56 +08:00
|
|
|
if (interactive)
|
|
|
|
{
|
2008-02-01 15:10:55 +08:00
|
|
|
gimp_ui_init (PLUG_IN_BINARY, FALSE);
|
|
|
|
|
2007-07-25 18:48:25 +08:00
|
|
|
g_signal_connect_swapped (operation, "end-print",
|
2008-02-26 02:59:04 +08:00
|
|
|
G_CALLBACK (print_settings_save),
|
2007-07-25 18:48:25 +08:00
|
|
|
&data);
|
2006-06-23 05:58:56 +08:00
|
|
|
|
2006-06-27 06:48:05 +08:00
|
|
|
g_signal_connect (operation, "create-custom-widget",
|
2006-12-26 05:03:27 +08:00
|
|
|
G_CALLBACK (create_custom_widget),
|
2007-07-24 05:17:47 +08:00
|
|
|
&data);
|
2006-06-27 06:48:05 +08:00
|
|
|
|
2007-08-09 05:48:31 +08:00
|
|
|
gtk_print_operation_set_custom_tab_label (operation, _("Image Settings"));
|
2006-06-27 06:48:05 +08:00
|
|
|
|
2008-08-24 01:11:40 +08:00
|
|
|
result = gtk_print_operation_run (operation,
|
|
|
|
GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG,
|
|
|
|
NULL, error);
|
2006-06-23 05:58:56 +08:00
|
|
|
}
|
|
|
|
else
|
2006-12-26 05:03:27 +08:00
|
|
|
{
|
2008-08-24 01:11:40 +08:00
|
|
|
result = gtk_print_operation_run (operation,
|
|
|
|
GTK_PRINT_OPERATION_ACTION_PRINT,
|
|
|
|
NULL, error);
|
2006-12-26 05:03:27 +08:00
|
|
|
}
|
2006-06-23 05:58:56 +08:00
|
|
|
|
2008-02-05 05:49:08 +08:00
|
|
|
gimp_uninstall_temp_proc (temp_proc);
|
|
|
|
g_free (temp_proc);
|
|
|
|
print_operation = NULL;
|
|
|
|
|
2006-06-23 05:58:56 +08:00
|
|
|
g_object_unref (operation);
|
|
|
|
|
2008-08-08 03:22:19 +08:00
|
|
|
if (gimp_drawable_is_valid (layer))
|
|
|
|
gimp_drawable_delete (layer);
|
2007-07-20 04:32:53 +08:00
|
|
|
|
2008-08-24 01:11:40 +08:00
|
|
|
switch (result)
|
2007-07-26 05:26:36 +08:00
|
|
|
{
|
2008-08-24 01:11:40 +08:00
|
|
|
case GTK_PRINT_OPERATION_RESULT_APPLY:
|
|
|
|
case GTK_PRINT_OPERATION_RESULT_IN_PROGRESS:
|
|
|
|
return GIMP_PDB_SUCCESS;
|
|
|
|
|
|
|
|
case GTK_PRINT_OPERATION_RESULT_CANCEL:
|
|
|
|
return GIMP_PDB_CANCEL;
|
|
|
|
|
|
|
|
case GTK_PRINT_OPERATION_RESULT_ERROR:
|
|
|
|
return GIMP_PDB_EXECUTION_ERROR;
|
2007-07-26 05:26:36 +08:00
|
|
|
}
|
|
|
|
|
2008-08-24 01:11:40 +08:00
|
|
|
return GIMP_PDB_EXECUTION_ERROR;
|
2008-02-01 15:10:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static GimpPDBStatusType
|
|
|
|
page_setup (gint32 image_ID)
|
|
|
|
{
|
2008-04-07 03:45:27 +08:00
|
|
|
GtkPrintOperation *operation;
|
2008-08-21 02:11:26 +08:00
|
|
|
GimpParam *return_vals;
|
2008-04-07 03:45:27 +08:00
|
|
|
gchar *name;
|
2008-08-21 02:11:26 +08:00
|
|
|
gint n_return_vals;
|
2008-02-05 00:59:45 +08:00
|
|
|
|
2008-02-01 15:10:55 +08:00
|
|
|
gimp_ui_init (PLUG_IN_BINARY, FALSE);
|
|
|
|
|
2008-02-05 00:59:45 +08:00
|
|
|
operation = gtk_print_operation_new ();
|
2008-02-05 05:49:08 +08:00
|
|
|
|
|
|
|
print_page_setup_load (operation, image_ID);
|
2008-02-05 00:59:45 +08:00
|
|
|
print_page_setup_dialog (operation);
|
2008-02-26 04:40:22 +08:00
|
|
|
print_page_setup_save (operation, image_ID);
|
2008-02-05 05:49:08 +08:00
|
|
|
|
2008-02-05 00:59:45 +08:00
|
|
|
g_object_unref (operation);
|
|
|
|
|
2008-02-05 05:49:08 +08:00
|
|
|
/* now notify a running print procedure about this change */
|
|
|
|
name = print_temp_proc_name (image_ID);
|
|
|
|
|
2008-08-21 02:11:26 +08:00
|
|
|
/* we don't want the core to show an error message if the
|
|
|
|
* temporary procedure does not exist
|
2008-04-07 03:45:27 +08:00
|
|
|
*/
|
2008-08-21 02:11:26 +08:00
|
|
|
gimp_plugin_set_pdb_error_handler (GIMP_PDB_ERROR_HANDLER_PLUGIN);
|
2008-04-07 03:45:27 +08:00
|
|
|
|
2008-08-21 02:11:26 +08:00
|
|
|
return_vals = gimp_run_procedure (name,
|
|
|
|
&n_return_vals,
|
|
|
|
GIMP_PDB_IMAGE, image_ID,
|
|
|
|
GIMP_PDB_END);
|
|
|
|
gimp_destroy_params (return_vals, n_return_vals);
|
2008-02-01 15:10:55 +08:00
|
|
|
|
2008-04-07 03:45:27 +08:00
|
|
|
g_free (name);
|
|
|
|
|
2008-02-05 00:59:45 +08:00
|
|
|
return GIMP_PDB_SUCCESS;
|
2007-07-26 05:26:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2008-08-24 01:11:40 +08:00
|
|
|
print_show_error (const gchar *message)
|
2007-07-26 05:26:36 +08:00
|
|
|
{
|
2008-08-24 01:11:40 +08:00
|
|
|
GtkWidget *dialog;
|
2007-07-27 00:22:17 +08:00
|
|
|
|
2008-08-24 01:11:40 +08:00
|
|
|
dialog = gtk_message_dialog_new (NULL, 0,
|
|
|
|
GTK_MESSAGE_ERROR,
|
|
|
|
GTK_BUTTONS_OK,
|
2008-11-04 22:05:24 +08:00
|
|
|
"%s",
|
2008-08-24 01:11:40 +08:00
|
|
|
_("An error occurred while trying to print:"));
|
2006-12-30 22:08:33 +08:00
|
|
|
|
2008-08-24 01:11:40 +08:00
|
|
|
gtk_message_dialog_format_secondary_text (GTK_MESSAGE_DIALOG (dialog),
|
2008-11-04 22:05:24 +08:00
|
|
|
"%s", message);
|
2006-12-30 22:08:33 +08:00
|
|
|
|
2008-08-24 01:11:40 +08:00
|
|
|
gtk_dialog_run (GTK_DIALOG (dialog));
|
|
|
|
gtk_widget_destroy (dialog);
|
2006-06-23 05:58:56 +08:00
|
|
|
}
|
|
|
|
|
2007-07-24 15:22:35 +08:00
|
|
|
static void
|
|
|
|
print_operation_set_name (GtkPrintOperation *operation,
|
|
|
|
gint image_ID)
|
|
|
|
{
|
2007-07-26 03:50:28 +08:00
|
|
|
gchar *name = gimp_image_get_name (image_ID);
|
2007-07-24 15:22:35 +08:00
|
|
|
|
2007-07-26 03:50:28 +08:00
|
|
|
gtk_print_operation_set_job_name (operation, name);
|
2007-07-24 15:22:35 +08:00
|
|
|
|
2007-07-24 16:56:09 +08:00
|
|
|
g_free (name);
|
2007-07-24 15:22:35 +08:00
|
|
|
}
|
|
|
|
|
2006-06-23 05:58:56 +08:00
|
|
|
static void
|
|
|
|
begin_print (GtkPrintOperation *operation,
|
2006-12-26 05:03:27 +08:00
|
|
|
GtkPrintContext *context,
|
|
|
|
PrintData *data)
|
2006-06-23 05:58:56 +08:00
|
|
|
{
|
2007-07-20 04:32:53 +08:00
|
|
|
gtk_print_operation_set_use_full_page (operation, data->use_full_page);
|
2006-12-27 21:46:27 +08:00
|
|
|
|
|
|
|
gimp_progress_init (_("Printing"));
|
2006-06-23 05:58:56 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
end_print (GtkPrintOperation *operation,
|
2006-12-26 05:03:27 +08:00
|
|
|
GtkPrintContext *context,
|
2008-08-08 03:22:19 +08:00
|
|
|
gint32 *layer_ID)
|
2006-06-23 05:58:56 +08:00
|
|
|
{
|
2008-08-08 03:22:19 +08:00
|
|
|
/* we don't need the print layer any longer, delete it */
|
|
|
|
if (gimp_drawable_is_valid (*layer_ID))
|
2007-07-25 15:36:15 +08:00
|
|
|
{
|
2008-08-08 03:22:19 +08:00
|
|
|
gimp_drawable_delete (*layer_ID);
|
|
|
|
*layer_ID = -1;
|
2007-07-25 15:36:15 +08:00
|
|
|
}
|
2006-12-29 23:36:54 +08:00
|
|
|
|
2007-07-25 18:48:25 +08:00
|
|
|
gimp_progress_end ();
|
2007-08-16 02:19:52 +08:00
|
|
|
|
|
|
|
/* generate events to solve the problems described in bug #466928 */
|
2008-02-25 23:06:03 +08:00
|
|
|
g_timeout_add_seconds (1, (GSourceFunc) gtk_true, NULL);
|
2006-12-29 22:26:55 +08:00
|
|
|
}
|
2006-06-23 05:58:56 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
draw_page (GtkPrintOperation *operation,
|
2006-12-26 05:03:27 +08:00
|
|
|
GtkPrintContext *context,
|
2007-07-24 15:05:06 +08:00
|
|
|
gint page_nr,
|
2006-12-26 05:03:27 +08:00
|
|
|
PrintData *data)
|
2006-06-23 05:58:56 +08:00
|
|
|
{
|
2008-02-22 18:03:01 +08:00
|
|
|
print_draw_page (context, data);
|
|
|
|
|
|
|
|
gimp_progress_update (1.0);
|
2006-06-23 05:58:56 +08:00
|
|
|
}
|
|
|
|
|
2006-06-27 06:48:05 +08:00
|
|
|
/*
|
|
|
|
* This callback creates a "custom" widget that gets inserted into the
|
|
|
|
* print operation dialog.
|
|
|
|
*/
|
|
|
|
static GtkWidget *
|
|
|
|
create_custom_widget (GtkPrintOperation *operation,
|
2006-12-26 05:03:27 +08:00
|
|
|
PrintData *data)
|
2006-06-23 05:58:56 +08:00
|
|
|
{
|
2008-02-27 04:06:30 +08:00
|
|
|
return print_page_layout_gui (data, PRINT_PROC_NAME);
|
2006-06-23 05:58:56 +08:00
|
|
|
}
|
2008-02-05 05:49:08 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
print_temp_proc_run (const gchar *name,
|
|
|
|
gint nparams,
|
|
|
|
const GimpParam *param,
|
|
|
|
gint *nreturn_vals,
|
|
|
|
GimpParam **return_vals)
|
|
|
|
{
|
|
|
|
static GimpParam values[1];
|
|
|
|
|
|
|
|
values[0].type = GIMP_PDB_STATUS;
|
|
|
|
values[0].data.d_status = GIMP_PDB_SUCCESS;
|
|
|
|
|
|
|
|
*nreturn_vals = 1;
|
|
|
|
*return_vals = values;
|
|
|
|
|
|
|
|
if (print_operation && nparams == 1)
|
|
|
|
print_page_setup_load (print_operation, param[0].data.d_int32);
|
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
|
|
|
print_temp_proc_name (gint32 image_ID)
|
|
|
|
{
|
2008-02-05 06:03:09 +08:00
|
|
|
return g_strdup_printf (PRINT_TEMP_PROC_NAME "-%d", image_ID);
|
2008-02-05 05:49:08 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static gchar *
|
|
|
|
print_temp_proc_install (gint32 image_ID)
|
|
|
|
{
|
|
|
|
static const GimpParamDef args[] =
|
|
|
|
{
|
|
|
|
{ GIMP_PDB_IMAGE, "image", "Image to print" }
|
|
|
|
};
|
|
|
|
|
|
|
|
gchar *name = print_temp_proc_name (image_ID);
|
|
|
|
|
|
|
|
gimp_install_temp_proc (name,
|
|
|
|
"DON'T USE THIS ONE",
|
|
|
|
"Temporary procedure to notify the Print plug-in "
|
|
|
|
"about changes to the Page Setup.",
|
|
|
|
"Sven Neumann",
|
|
|
|
"Sven Neumann",
|
|
|
|
"2008",
|
|
|
|
NULL,
|
|
|
|
"",
|
|
|
|
GIMP_TEMPORARY,
|
|
|
|
G_N_ELEMENTS (args), 0, args, NULL,
|
|
|
|
print_temp_proc_run);
|
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|