Merge branch 'pu'
[jungerl.git] / lib / gtkNode / src / gtkNode_internal.c
blob98061df533733ed9d278eb38a112eb2053c87db4
1 #include "gtkNode.h"
2 #include <string.h>
4 gboolean GN_glade_init(int arity, ei_x_buff *XBUF, char *B, int *I){
5 char *xml_filename;
7 if ( ! gn_check_arity(XBUF, 1, arity) )
8 return FALSE;
9 if ( ! gn_get_arg_gchar(XBUF, B, I, &xml_filename) )
10 return FALSE; /* free */
12 if ( gn_glade_init(xml_filename) ) {
13 gn_put_void(XBUF);
14 free(xml_filename);
15 return TRUE;
16 }else{
17 gn_enc_1_error(XBUF, "glade_init_failed");
18 free(xml_filename);
19 return FALSE;
23 gboolean GN_new_gvalue(int arity, ei_x_buff *XBUF, char *B, int *I){
24 gchar name[MAXATOMLEN+1];
25 gchar gtype[MAXATOMLEN+1];
26 char key[200] = "GValue-";
27 GType gtyp;
28 GValue* gval;
30 if ( ! gn_check_arity(XBUF, 2, arity) ) return FALSE;
31 if ( ! gn_get_arg_gchar_fix(XBUF, B, I, name) ) return FALSE;
32 if ( ! gn_get_arg_gchar_fix(XBUF, B, I, gtype) ) return FALSE;
34 strcat(key, name);
35 if ( hash_lookup(key) ) {
36 gn_enc_2_error(XBUF, "already_exists");
37 ei_x_encode_atom(XBUF, key);
38 return FALSE;
41 if( ! (gtyp = gn_GType_from_name(gtype)) || ! G_TYPE_IS_VALUE_TYPE(gtyp) ) {
42 gn_enc_2_error(XBUF, "not_value_type");
43 ei_x_encode_atom(XBUF, gtype);
44 return FALSE;
47 gval = g_new0(GValue,1);
48 hash_insert(key, (void*)gval);
49 g_value_init(gval, gtyp);
50 gn_put_void(XBUF);
51 return TRUE;
54 gboolean GN_pango_layout_set_text(int ARI, ei_x_buff *XBUF, char *B, int *I){
55 char* text;
56 char* descr_str;
57 PangoLayout* layout;
58 PangoFontDescription* descr;
60 /* no return value */
62 if ( ! gn_check_arity(XBUF, 3, ARI) )
63 return FALSE;
64 if ( ! gn_get_arg_struct(XBUF, B, I, "PangoLayout", (void**)&layout) )
65 return FALSE;
66 if ( ! gn_get_arg_gchar(XBUF, B, I, &text) ) /* free */
67 return FALSE;
68 if ( ! gn_get_arg_gchar(XBUF, B, I, &descr_str) ) { /* free */
69 free(text);
70 return FALSE;
73 descr = pango_font_description_from_string(descr_str);
74 pango_layout_set_font_description(layout, descr);
75 pango_layout_set_text(layout,text,(int)strlen(text));
76 pango_font_description_free(descr);
78 gn_put_void(XBUF);
79 free(text);
80 free(descr_str);
81 return TRUE;
84 gboolean GN_widget_get_attr(int ARI, ei_x_buff *XBUF, char *B, int *I) {
85 gchar attr[MAXATOMLEN+1];
86 GtkWidget* widget;
88 if ( ! gn_check_arity(XBUF, 2, ARI) ) return FALSE;
89 if ( ! gn_get_arg_object(XBUF, B, I, GTK_TYPE_WIDGET, (GObject**)&widget) )
90 return FALSE;
91 if ( ! gn_get_arg_gchar_fix(XBUF, B, I, attr) ) return FALSE;
93 if ( strcmp("window",attr) == 0 ){
94 gn_put_object(XBUF,(GObject*) widget->window);
95 }else if ( strcmp("x",attr) == 0 ) {
96 gn_put_longlong(XBUF,(long long)widget->allocation.x);
97 }else if ( strcmp("y",attr) == 0 ) {
98 gn_put_longlong(XBUF,(long long)widget->allocation.y);
99 }else if ( strcmp("width",attr) == 0 ) {
100 gn_put_longlong(XBUF,(long long)widget->allocation.width);
101 }else if ( strcmp("height",attr) == 0 ) {
102 gn_put_longlong(XBUF,(long long)widget->allocation.height);
103 }else{
104 gn_enc_2_error(XBUF, "no_such_attr");
105 ei_x_encode_atom(XBUF, attr);
106 return FALSE;
108 return TRUE;