File: rendcschtml.c

package info (click to toggle)
entity 1.0.1-8
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 5,604 kB
  • ctags: 5,394
  • sloc: ansic: 64,242; sh: 7,377; makefile: 776; perl: 319
file content (90 lines) | stat: -rw-r--r-- 2,219 bytes parent folder | download | duplicates (2)
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <entity.h>
#include <cschtml/cschtml.h>
#include "../gtk/gtk-common.h"


static void
rendcschtml_set_data (ENode * node, EBuf * data)
{
    CscHTML *cschtml;
    CscHTMLStream *handle;


    cschtml = CSC_HTML (enode_get_kv (node, "html-widget"));

    EDEBUG (("cschtml", "inserting %s", data->str));

    handle = csc_html_begin (cschtml);
    csc_html_write (cschtml, handle, data->str, data->len);
    csc_html_end (cschtml, handle, CSC_HTML_STREAM_OK);
}

static void
rendcschtml_parent (ENode * parent_node, ENode * child_node)
{
    erend_short_curcuit_parent (parent_node, child_node);
}

static void
rendcschtml_destroy (ENode * node)
{
    GtkWidget *html;

    html = enode_get_kv (node, "html-widget");
    gtk_widget_destroy (html);
}

/* The html widget goes nuts if you don't put it in a scrollwindow. */
static void
rendcschtml_render (ENode * node)
{
    GtkWidget *scrollwindow;
    GtkWidget *html;
    CscHTML *cschtml;
    CscHTMLStream *handle;

    EDEBUG (("cschtml", "creating new cschtml"));

    scrollwindow = gtk_scrolled_window_new (NULL, NULL);
    html = csc_html_new ();
    cschtml = CSC_HTML (html);

    enode_set_kv (node, "html-widget", html);
    enode_set_kv (node, "top-widget", scrollwindow);

    EDEBUG (("cschtml", "starting with %s", node->data->str));

    handle = csc_html_begin (cschtml);
    csc_html_write (cschtml, handle, node->data->str, node->data->len);
    csc_html_end (cschtml, handle, CSC_HTML_STREAM_OK);

    gtk_container_add (GTK_CONTAINER (scrollwindow), html);

    enode_attribs_sync (node);
    rendgtk_show_cond (node, scrollwindow);
    rendgtk_show_cond (node, html);
}

void
renderer_init (RendererFlags flags)
{
    Element *element;
    ElementAttr *e_attr;

    EDEBUG (("cschtml", "registering cschtml"));

    if (flags & RENDERER_REGISTER)
    {
	EDEBUG (("cschtml", "Registering <cschtml> element"));
	element = g_new0 (Element, 1);
	element->render_func = rendcschtml_render;
	element->parent_func = rendcschtml_parent;
	element->destroy_func = rendcschtml_destroy;
	element->set_data_func = rendcschtml_set_data;
	element->tag = "cschtml";
	element_register (element);

	/* For now we don't register any attributes. */
    }
}