File: testplugin.c

package info (click to toggle)
genius 1.0.24-2
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 27,952 kB
  • sloc: ansic: 105,597; xml: 67,672; sh: 4,537; makefile: 2,089; lex: 499; yacc: 298; perl: 54; python: 22
file content (70 lines) | stat: -rw-r--r-- 1,507 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include "config.h"
#include <stdio.h>
#include <glib.h>
#include "calc.h"
#include "plug_api.h"
#include "eval.h"
#include "dict.h"
#include "geloutput.h"

static GelETree *
TestPluginFunction_op (GelCtx *ctx, GelETree * * a, int *exception)
{
	gel_output_printf (gel_main_out, _("This is the test-plugin function\n"));

	/* return a null */
	return gel_makenum_null ();
}

static void
open (void)
{
	GelEFunc *f;

	gel_output_printf (gel_main_out, _("You have opened test plugin!\n\n"
				       "Will evaluate 2+2 as a demonstration\n"
				       "2+2 = "));

	gel_evalexp ("2+2", NULL, gel_main_out, NULL, TRUE, NULL);

	gel_output_printf (gel_main_out, _("For my next trick I will add a "
				       "function named "
				       "TestPluginFunction\n\n"));

	f = d_addfunc (d_makebifunc (d_intern ("TestPluginFunction"),
				     TestPluginFunction_op, 0));
	d_add_named_args (f, "");
	gel_add_category ("TestPluginFunction" , "misc");
	gel_add_description ("TestPluginFunction",
			 "This is a test function added by the test plugin");

	gel_output_printf (gel_main_out, _("That's it, isn't this fun\n\n"));
}

static gboolean
save_state (const char *unique_id)
{
	printf("testplugin save_state(%s)\n", unique_id);
	return FALSE;
}

static void
restore_state (const char *unique_id)
{
	printf ("testplugin restore_state(%s)\n", unique_id);

	/* we open on restore */
	open ();
}

static GelPluginInfo info = {
	open,
	save_state,
	restore_state
};

GelPluginInfo *
init_func (void)
{
	return &info;
}