]> git.draconx.ca Git - gob-dx.git/blobdiff - src/parse.y
Release 2.0.12
[gob-dx.git] / src / parse.y
index a6471cec26a3716f7374fd2d22b39119e8682fab..f5d368800d945a00b9367d11e206c6dd6b851071 100644 (file)
@@ -46,6 +46,7 @@ static GList *error_vals = NULL;
 
 static char *chunk_size = NULL;
 static char *bonobo_object_class = NULL;
+static int glade_xml = FALSE;
 static GList *interfaces = NULL;
 static GList *typestack = NULL;
 static GList *funcargs = NULL;
@@ -61,6 +62,7 @@ static int destructor_line = 0;
 static gboolean destructor_simple = TRUE;
 static char *initializer = NULL;
 static int initializer_line = 0;
+static int glade_widget = FALSE;
 
 static char *onerror = NULL;
 static char *defreturn = NULL;
@@ -126,6 +128,7 @@ push_variable (char *name, int scope, int line_no, char *postfix)
        var = node_new (VARIABLE_NODE,
                        "scope", scope,
                        "vtype:steal", type,
+                       "glade_widget", glade_widget,
                        "id:steal", name,
                        "line_no", line_no,
                        "destructor_unref", destructor_unref,
@@ -134,8 +137,10 @@ push_variable (char *name, int scope, int line_no, char *postfix)
                        "destructor_simple", destructor_simple,
                        "initializer:steal", initializer,
                        "initializer_line", initializer_line,
+                       "initializer_simple", TRUE,
                        NULL);
        class_nodes = g_list_append(class_nodes, var);
+       glade_widget = FALSE;
 }
 
 static void
@@ -462,6 +467,41 @@ get_prop_enum_flag_cast (Property *prop)
        return ret;
 }
 
+static void
+add_construct_glade (char * file, char * root, char * domain)
+{
+       Node *var;
+       Type * type;
+       GList * flags = NULL;
+       char * set;
+       
+       type = (Type *)node_new (TYPE_NODE,
+                                "name", "GladeXML",
+                                "pointer", "*",
+                                NULL);
+       initializer = g_strdup_printf("\t{\n"
+                                     "\tGtkWidget * root;\n"
+                                     "\to->_priv->_glade_xml = glade_xml_new(%s, %s, %s);\n"
+                                     "\troot = glade_xml_get_widget(o->_priv->_glade_xml, %s);\n"
+                                     "\tgtk_widget_show(root);\n"
+                                     "\tgtk_container_add(GTK_CONTAINER(o), root);\n"
+                                     "\tglade_xml_signal_autoconnect_full(o->_priv->_glade_xml, (GladeXMLConnectFunc)___glade_xml_connect_foreach, (gpointer)o);\n"
+                                     "}\n", file, root, domain ? domain : "NULL", root);
+       
+       var = node_new (VARIABLE_NODE,
+                       "scope", PRIVATE_SCOPE,
+                       "vtype:steal", type,
+                       "glade_widget", FALSE,
+                       "id:steal", "_glade_xml",
+                       "destructor_unref", FALSE,
+                       "destructor", "g_object_unref", 
+                       "destructor_simple", TRUE,
+                       "initializer", initializer,
+                       "initializer_simple", FALSE,
+                       NULL);
+       class_nodes = g_list_prepend(class_nodes, var);
+}
+
 static void
 property_link_and_export (Node *node)
 {
@@ -735,10 +775,12 @@ classdec: CLASS TYPETOKEN FROM TYPETOKEN  classflags {
                                          "otype:steal", $<id>2,
                                          "ptype:steal", $<id>4,
                                          "bonobo_object_class:steal", bonobo_object_class,
+                                         "glade_xml", glade_xml,
                                          "interfaces:steal", interfaces,
                                          "chunk_size:steal", chunk_size,
                                          NULL);
                        bonobo_object_class = NULL;
+                       glade_xml = FALSE;
                        chunk_size = NULL;
                        interfaces = NULL;
                                                }
@@ -778,6 +820,42 @@ classflags:
                                YYERROR;
                        }
                }
+       | '(' TOKEN STRING STRING ')' classflags {
+                       if (strcmp ($<id>2, "GladeXML") == 0) {
+                               glade_xml = TRUE;
+                               add_construct_glade($<id>3, $<id>4, NULL);
+                       } else {
+                               yyerror(_("parse error"));
+                               YYERROR;
+                       }
+               }
+       | '(' TOKEN STRING STRING STRING ')' classflags {
+                       if (strcmp ($<id>2, "GladeXML") == 0) {
+                               glade_xml = TRUE;
+                               add_construct_glade($<id>3, $<id>4, $<id>5);
+                       } else {
+                               yyerror(_("parse error"));
+                               YYERROR;
+                       }
+               }
+       | '(' TOKEN TOKEN STRING ')' classflags {
+                       if (strcmp ($<id>2, "GladeXML") == 0) {
+                               glade_xml = TRUE;
+                               add_construct_glade($<id>3, $<id>4, NULL);
+                       } else {
+                               yyerror(_("parse error"));
+                               YYERROR;
+                       }
+               }
+       | '(' TOKEN TOKEN STRING STRING ')' classflags {
+                       if (strcmp ($<id>2, "GladeXML") == 0) {
+                               glade_xml = TRUE;
+                               add_construct_glade($<id>3, $<id>4, $<id>5);
+                       } else {
+                               yyerror(_("parse error"));
+                               YYERROR;
+                       }
+               }
        ;       
 
 classcode:     classcode thing                 { ; }
@@ -878,6 +956,14 @@ varoptions:        destructor initializer  { ; }
        |       initializer destructor  { ; }
        |       initializer             { destructor = NULL; }
        |       destructor              { initializer = NULL; }
+       |       TOKEN                   {
+                       if (strcmp ($<id>1, "GladeXML") == 0) {
+                               glade_widget = TRUE;
+                       } else {
+                               yyerror(_("parse error"));
+                               YYERROR;
+                       }
+                                       }
        |                               {
                        destructor = NULL;
                        initializer = NULL;