1 #include <stdio.h>
2 #include "samples.h"
3 
4 static void
ctx_error_func(GPContext * context,const char * str,void * data)5 ctx_error_func (GPContext *context, const char *str, void *data)
6 {
7         fprintf  (stderr, "\n*** Contexterror ***              \n%s\n",str);
8         fflush   (stderr);
9 }
10 
11 static void
ctx_status_func(GPContext * context,const char * str,void * data)12 ctx_status_func (GPContext *context, const char *str, void *data)
13 {
14         fprintf  (stderr, "%s\n", str);
15         fflush   (stderr);
16 }
17 
sample_create_context()18 GPContext* sample_create_context() {
19 	GPContext *context;
20 
21 	/* This is the mandatory part */
22 	context = gp_context_new();
23 
24 	/* All the parts below are optional! */
25         gp_context_set_error_func (context, ctx_error_func, NULL);
26         gp_context_set_status_func (context, ctx_status_func, NULL);
27 
28 	/* also:
29 	gp_context_set_cancel_func    (p->context, ctx_cancel_func,  p);
30         gp_context_set_message_func   (p->context, ctx_message_func, p);
31         if (isatty (STDOUT_FILENO))
32                 gp_context_set_progress_funcs (p->context,
33                         ctx_progress_start_func, ctx_progress_update_func,
34                         ctx_progress_stop_func, p);
35 	 */
36 	return context;
37 }
38