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));
}
This does a QI on a remote BonoboObjectClient object, and
if it supports the interface returns a newly constructed
BonoboPrintClient handle, otherwise NULL.
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.