BonoboPrintClient

Name

BonoboPrintClient -- provides an easy interface for supporting remote printing

Synopsis



typedef     BonoboPrintClient;
typedef     BonoboPrintClientClass;
typedef     BonoboPrintData;
BonoboPrintClient* bonobo_print_client_new  (Bonobo_Print corba_print);
BonoboPrintClient* bonobo_print_client_get  (BonoboObjectClient *object);
void        bonobo_print_client_render      (BonoboPrintClient *client,
                                             BonoboPrintData *pd);
BonoboPrintData* bonobo_print_data_new      (double width,
                                             double height);
BonoboPrintData* bonobo_print_data_new_full (double width,
                                             double height,
                                             double width_first_page,
                                             double width_per_page,
                                             double height_first_page,
                                             double height_per_page);
void        bonobo_print_data_free          (BonoboPrintData *pd);
GnomePrintMeta* bonobo_print_data_get_meta  (BonoboPrintData *pd);
void        bonobo_print_data_render        (GnomePrintContext *pc,
                                             double x,
                                             double y,
                                             BonoboPrintData *pd,
                                             double meta_x,
                                             double meta_y);

Description

The BonoboPrintClient is rather an ugly, but functional API for printing remote objects. As with all embeddables sizing and layout is controled by the container application.

Note, if you think that this API needs to be substantialy more complicated, handle pagination etc. you are probably not implementing your embeddable correctly. Please read the section in BonoboEmbeddable on BonoboControls. If you are a 'toplevel' container you get to do complicated things, you should merge a print menu into your container and do what you like internaly.

Example 1. Basic sample component printing code

void
object_print (BonoboObjectClient *object,
	      GnomePrintContext  *ctx,
	      gdouble             x,
	      gdouble             y,
	      gdouble             width,
	      gdouble             height)
{
	BonoboPrintClient *print_client = bonobo_print_client_get (object);
	BonoboPrintData   *print_data;

	if (!print_client) /* No remote printing interface - a broken Embeddable */
		return;

	print_data = bonobo_print_data_new (width, height);
	bonobo_print_client_render (print_client, print_data);
	bonobo_print_data_render (ctx, x, y, print_data, 0.0, 0.0);
	bonobo_print_data_free (print_data);

	gtk_object_unref (GTK_OBJECT (print_client));
}

void
sample_app_print_preview (SampleApp *app)
{
	GList *l;
	double ypos = 0.0;
	GnomePrintMaster *pm;
	GnomePrintContext *ctx;
	GnomePrintMasterPreview *pv;

	pm = gnome_print_master_new();
	ctx = gnome_print_master_get_context (pm);

	/*
	 *  The hardcoded 320.0 x 200.0 should be the visible
	 * point size of the Embeddable in the document.
	 */
	for (l = app->components; l; l = l->next) {
		BonoboClientSite *site = l->data;

		object_print (bonobo_client_site_get_embeddable (site),
			      ctx, 0.0, ypos, 320.0, 320.0);
		ypos += 320.0;
	}

	gnome_print_showpage (ctx);
	gnome_print_context_close (ctx);
	gnome_print_master_close (pm);

	pv = gnome_print_master_preview_new (pm, "Component demo");
	gtk_widget_show  (GTK_WIDGET (pv));
	gtk_object_unref (GTK_OBJECT (pm));
}
    

Details

BonoboPrintClient

typedef struct {
	GtkObject    parent;
	Bonobo_Print corba_print;
} BonoboPrintClient;


BonoboPrintClientClass

typedef struct {
	GtkObjectClass			parent;
} BonoboPrintClientClass;


BonoboPrintData

typedef struct {
	double width;
	double height;
	
	double width_first_page;
	double width_per_page;
	double height_first_page;
	double height_per_page;

	GnomePrintMeta *meta_data;
} BonoboPrintData;


bonobo_print_client_new ()

BonoboPrintClient* bonobo_print_client_new  (Bonobo_Print corba_print);

corba_print : a remote Bonobo_Print interface handle
Returns : a newly constructed BonoboPrintClient


bonobo_print_client_get ()

BonoboPrintClient* bonobo_print_client_get  (BonoboObjectClient *object);

This does a QI on a remote BonoboObjectClient object, and if it supports the interface returns a newly constructed BonoboPrintClient handle, otherwise NULL.

object : the print client
Returns : a new handle or NULL.


bonobo_print_client_render ()

void        bonobo_print_client_render      (BonoboPrintClient *client,
                                             BonoboPrintData *pd);

This routine is used to encourage a remote print client to print itself. The BonoboPrintData specifies the size information for the remote client to render itself to. After render the BonoboPrintData contains the meta data for the rendered page. This interface is baroque.

client : the print client.
pd : the intialized print data


bonobo_print_data_new ()

BonoboPrintData* bonobo_print_data_new      (double width,
                                             double height);

This constructs a BonoboPrintData with default scissor data.

width : the width in pts of the component to render
height : the height in pts of the component to render
Returns : a new BonoboPrintData object.


bonobo_print_data_new_full ()

BonoboPrintData* bonobo_print_data_new_full (double width,
                                             double height,
                                             double width_first_page,
                                             double width_per_page,
                                             double height_first_page,
                                             double height_per_page);

This initializes a BonoboPrintData to contain the above parameters so that it can be used by bonobo_print_client_render

width : the width in pts of the component to render
height : the height in pts of the component to render
width_first_page : the clear width available on the first page
width_per_page : the width available on subsequent pages
height_first_page : the clear height available on the first page
height_per_page : the height available on subsequent pages
Returns : a new BonoboPrintData object.


bonobo_print_data_free ()

void        bonobo_print_data_free          (BonoboPrintData *pd);

Releases all resources associated with the print data.

pd : the print data


bonobo_print_data_get_meta ()

GnomePrintMeta* bonobo_print_data_get_meta  (BonoboPrintData *pd);

pd : the print data
Returns : the meta_data from pd


bonobo_print_data_render ()

void        bonobo_print_data_render        (GnomePrintContext *pc,
                                             double x,
                                             double y,
                                             BonoboPrintData *pd,
                                             double meta_x,
                                             double meta_y);

This is used to render the print data in pd onto a GnomePrintContext in ctx.

pc : 
x : the tlc bbox x
y : the ltc bbox y
pd : the print data to render
meta_x : the offset into the print data x
meta_y : the offset into the print data y

See Also

BonoboPrint, BonoboEmbeddable