diff options
author | Vasily_Makarov <danilka.pro@gmail.com> | 2011-06-12 00:06:04 +0400 |
---|---|---|
committer | Vasily_Makarov <danilka.pro@gmail.com> | 2011-06-12 00:06:04 +0400 |
commit | 3cad16ffd82801dd1f6e3672bf3c4fdbf13b4fe8 (patch) | |
tree | 443564845f88305b22f42572b48345bc17d51498 /saedit/main.c | |
parent | 4fc25dc9a745a7efed2b0868ef90c82c14acfcc0 (diff) | |
download | evol-tools-3cad16ffd82801dd1f6e3672bf3c4fdbf13b4fe8.tar.gz evol-tools-3cad16ffd82801dd1f6e3672bf3c4fdbf13b4fe8.tar.bz2 evol-tools-3cad16ffd82801dd1f6e3672bf3c4fdbf13b4fe8.tar.xz evol-tools-3cad16ffd82801dd1f6e3672bf3c4fdbf13b4fe8.zip |
saedit: Add binary and code review
Diffstat (limited to 'saedit/main.c')
-rw-r--r-- | saedit/main.c | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/saedit/main.c b/saedit/main.c index 9d89eca..12c873c 100644 --- a/saedit/main.c +++ b/saedit/main.c @@ -237,7 +237,8 @@ gboolean sequence_source_func(SequenceInfo *seq) { size_t end; sscanf(end_attr, "%d", &end); if (current_sprite->index == end) { - seq->anim_info->anim_tag = g_timeout_add(seq->delay, show_animation_by_info, seq->anim_info); + guint *anim_tag = seq->anim_info->anim_tag; + *anim_tag = g_timeout_add(seq->delay, show_animation_by_info, seq->anim_info); return FALSE; } set_sprite_by_index(current_sprite->index+1); @@ -451,24 +452,16 @@ void load_options() { paths->sprites = g_strjoin(SEPARATOR_SLASH, datapath, paths->sprites, NULL); } -void parse_xml_buffer(GtkWidget *button, GtkSourceBuffer *buffer) { - free_imagesets(); - free_actions(); - free_animations(); - load_options(); - - GtkTextIter beg, end; - 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) { +void parse_xml_text(gchar *text, XMLNode **root_node) { + XMLNode *_root_node = ibus_xml_parse_buffer(text); + *root_node = _root_node; + if (_root_node == NULL) { show_wrong_source_buffer_dialog(); return; } printf("%s", paths->sprites); - GList *list = g_list_find_custom(root->sub_nodes, "include", xml_node_compare_with_name); + GList *list = g_list_find_custom(_root_node->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"); @@ -476,7 +469,7 @@ void parse_xml_buffer(GtkWidget *button, GtkSourceBuffer *buffer) { file_attr = g_strjoin(NULL, paths->sprites, 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); + g_list_concat(_root_node->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); @@ -486,19 +479,31 @@ void parse_xml_buffer(GtkWidget *button, GtkSourceBuffer *buffer) { offsetX = 0; offsetY = 0; - gchar *name_attr = xml_node_get_attr_value(root, "name"); - gchar *action_attr = xml_node_get_attr_value(root, "action"); + gchar *name_attr = xml_node_get_attr_value(_root_node, "name"); + gchar *action_attr = xml_node_get_attr_value(_root_node, "action"); if (name_attr != NULL && action_attr != NULL) if (g_strcmp0(name_attr, "player") == 0 && g_strcmp0(action_attr, "stand") == 0) offsetY = -16; - if (!set_up_imagesets(root)) { + if (!set_up_imagesets(_root_node)) { show_wrong_source_buffer_dialog(); return; } } +void parse_xml_buffer(GtkWidget *button, GtkSourceBuffer *buffer) { + free_imagesets(); + free_actions(); + free_animations(); + load_options(); + + GtkTextIter beg, end; + gtk_text_buffer_get_start_iter(GTK_TEXT_BUFFER(buffer), &beg); + gtk_text_buffer_get_end_iter(GTK_TEXT_BUFFER(buffer), &end); + parse_xml_text(gtk_text_iter_get_text(&beg, &end), &root); +} + void show_about_dialog() { gchar *authors[] = {"Dan Sagunov <danilka.pro@gmail.com>", "Reid Yaro <reidyaro@gmail.com>", |