diff options
author | Vasily_Makarov <danilka.pro@gmail.com> | 2011-06-10 23:09:00 +0400 |
---|---|---|
committer | Vasily_Makarov <danilka.pro@gmail.com> | 2011-06-10 23:09:00 +0400 |
commit | a1cfce737e02f8a7ad29acbc8bfd55a6ee888bd0 (patch) | |
tree | d41c31330ba407430c84f2d6e425502b14021768 | |
parent | e6961262ebcc6d146470876af9e5dc4fd3ac4442 (diff) | |
download | evol-tools-a1cfce737e02f8a7ad29acbc8bfd55a6ee888bd0.tar.gz evol-tools-a1cfce737e02f8a7ad29acbc8bfd55a6ee888bd0.tar.bz2 evol-tools-a1cfce737e02f8a7ad29acbc8bfd55a6ee888bd0.tar.xz evol-tools-a1cfce737e02f8a7ad29acbc8bfd55a6ee888bd0.zip |
saedit: Add <include> support :D
-rw-r--r-- | saedit/main.c | 18 | ||||
-rw-r--r-- | saedit/main.h | 3 |
2 files changed, 21 insertions, 0 deletions
diff --git a/saedit/main.c b/saedit/main.c index 565bfc2..8577745 100644 --- a/saedit/main.c +++ b/saedit/main.c @@ -396,11 +396,29 @@ void parse_xml_buffer(GtkWidget *button, GtkSourceBuffer *buffer) { gtk_text_buffer_get_start_iter(GTK_TEXT_BUFFER(buffer), &beg); gtk_text_buffer_get_end_iter(GTK_TEXT_BUFFER(buffer), &end); root = ibus_xml_parse_buffer(gtk_text_iter_get_text(&beg, &end)); + if (root == NULL) { show_wrong_source_buffer_dialog(); return; } + gchar *spritespath = g_strjoin(SLASH_SEPARATOR, gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(data_folder_chooser_button)), SPRITES_PATH, NULL); + GList *list = g_list_find_custom(root->sub_nodes, "include", xml_node_compare_with_name); + while (list != NULL) { + XMLNode *node = list->data; + gchar *file_attr = xml_node_get_attr_value(node, "file"); + if (file_attr != NULL) { + file_attr = g_strjoin(NULL, spritespath, file_attr, NULL); + gchar *buf; + if (g_file_get_contents(file_attr, &buf, NULL, NULL)) + g_list_concat(root->sub_nodes, ibus_xml_parse_buffer(buf)->sub_nodes); + } + if (list->next != NULL) + list = g_list_find_custom(list->next, "include", xml_node_compare_with_name); + else + list = NULL; + } + offsetX = 0; offsetY = 0; gchar *name_attr = xml_node_get_attr_value(root, "name"); diff --git a/saedit/main.h b/saedit/main.h index c735dc9..56ac08a 100644 --- a/saedit/main.h +++ b/saedit/main.h @@ -26,6 +26,9 @@ const gchar *BACKGROUNDS_DIR = "backgrounds"; const gchar *ICON_FILE = "icon.svg"; const gchar *CONFIG_FILE = "/saedit/config.ini"; const gchar *FOLDER_POSTFIX = "/..."; +const gchar *SLASH_SEPARATOR = "/"; +const gchar *SPRITES_PATH = "graphics/sprites/"; + typedef struct { XMLNode *node; |