only connect to page layout changes for the lifetime of the dialog.

2008-02-04  Sven Neumann  <sven@gimp.org>

	* plug-ins/print/print-page-layout.c: only connect to page 
layout
	changes for the lifetime of the dialog.
	
	* plug-ins/print/print-page-setup.[ch]
	* plug-ins/print/print.c: use a	temporary procedure to notify 
the
	Print procedure about changes to the page setup.


svn path=/trunk/; revision=24793
This commit is contained in:
Sven Neumann
2008-02-04 21:49:08 +00:00
committed by Sven Neumann
parent 50ad5cfd32
commit f17bfcef0d
5 changed files with 113 additions and 15 deletions

View File

@ -1,3 +1,12 @@
2008-02-04 Sven Neumann <sven@gimp.org>
* plug-ins/print/print-page-layout.c: only connect to page layout
changes for the lifetime of the dialog.
* plug-ins/print/print-page-setup.[ch]
* plug-ins/print/print.c: use a temporary procedure to notify the
Print procedure about changes to the page setup.
2008-02-04 Michael Natterer <mitch@gimp.org>
* app/base/gimphistogram.[ch]: add refcounting and replace free()

View File

@ -198,9 +198,9 @@ print_page_layout_gui (PrintData *data)
print_size_info_set_page_setup (&info);
g_signal_connect (data->operation, "notify::default-page-setup",
G_CALLBACK (print_page_setup_notify),
&info);
g_signal_connect_object (data->operation, "notify::default-page-setup",
G_CALLBACK (print_page_setup_notify),
layout, 0);
return layout;
}

View File

@ -24,28 +24,26 @@
#include "print-page-setup.h"
static void print_page_setup_save (GtkPrintOperation *operation);
void
print_page_setup_dialog (GtkPrintOperation *operation)
{
GtkPrintSettings *settings = gtk_print_settings_new ();
GtkPrintSettings *settings;
GtkPageSetup *setup;
print_page_setup_load (operation);
g_return_if_fail (GTK_IS_PRINT_OPERATION (operation));
setup = gtk_print_operation_get_default_page_setup (operation);
settings = gtk_print_settings_new ();
setup = gtk_print_run_page_setup_dialog (NULL, setup, settings);
g_object_unref (settings);
gtk_print_operation_set_default_page_setup (operation, setup);
print_page_setup_save (operation);
}
gboolean
print_page_setup_load (GtkPrintOperation *operation)
print_page_setup_load (GtkPrintOperation *operation,
gint32 image_ID)
{
GtkPageSetup *setup;
gchar *filename;
@ -67,7 +65,7 @@ print_page_setup_load (GtkPrintOperation *operation)
return FALSE;
}
static void
void
print_page_setup_save (GtkPrintOperation *operation)
{
GtkPageSetup *setup;

View File

@ -18,5 +18,8 @@
void print_page_setup_dialog (GtkPrintOperation *operation);
gboolean print_page_setup_load (GtkPrintOperation *operation);
gboolean print_page_setup_load (GtkPrintOperation *operation,
gint32 image_ID);
void print_page_setup_save (GtkPrintOperation *operation);

View File

@ -68,6 +68,14 @@ static void draw_page (GtkPrintOperation *print,
static GtkWidget * create_custom_widget (GtkPrintOperation *operation,
PrintData *data);
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;
const GimpPlugInInfo PLUG_IN_INFO =
@ -178,6 +186,7 @@ print_image (gint32 image_ID,
GError *error = NULL;
gint32 orig_image_ID = image_ID;
gint32 drawable_ID = gimp_image_get_active_drawable (image_ID);
gchar *temp_proc;
PrintData data;
GimpExportReturn export;
@ -193,7 +202,7 @@ print_image (gint32 image_ID,
print_operation_set_name (operation, orig_image_ID);
print_page_setup_load (operation);
print_page_setup_load (operation, orig_image_ID);
/* fill in the PrintData struct */
data.num_pages = 1;
@ -224,6 +233,10 @@ print_image (gint32 image_ID,
G_CALLBACK (end_print),
&image_ID);
print_operation = operation;
temp_proc = print_temp_proc_install (orig_image_ID);
gimp_extension_enable ();
if (interactive)
{
gimp_ui_init (PLUG_IN_BINARY, FALSE);
@ -249,6 +262,10 @@ print_image (gint32 image_ID,
NULL, &error);
}
gimp_uninstall_temp_proc (temp_proc);
g_free (temp_proc);
print_operation = NULL;
g_object_unref (operation);
if (gimp_image_is_valid (image_ID))
@ -267,14 +284,34 @@ static GimpPDBStatusType
page_setup (gint32 image_ID)
{
GtkPrintOperation *operation;
gchar *name;
gimp_ui_init (PLUG_IN_BINARY, FALSE);
operation = gtk_print_operation_new ();
print_page_setup_load (operation, image_ID);
print_page_setup_dialog (operation);
print_page_setup_save (operation);
g_object_unref (operation);
/* FIXME: notify the print procedure about the changed page setup */
/* now notify a running print procedure about this change */
name = print_temp_proc_name (image_ID);
if (name)
{
GimpParam *return_vals;
gint n_return_vals;
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);
g_free (name);
}
return GIMP_PDB_SUCCESS;
}
@ -362,3 +399,54 @@ create_custom_widget (GtkPrintOperation *operation,
{
return print_page_layout_gui (data);
}
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)
{
return g_strdup_printf (PRINT_PROC_NAME "-temp-%d", image_ID);
}
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;
}