From 3cad16ffd82801dd1f6e3672bf3c4fdbf13b4fe8 Mon Sep 17 00:00:00 2001 From: Vasily_Makarov Date: Sun, 12 Jun 2011 00:06:04 +0400 Subject: saedit: Add binary and code review --- saedit/main.c | 41 +++++++++++++++++++++++------------------ saedit/main.h | 1 + saedit/saedit | Bin 0 -> 451613 bytes 3 files changed, 24 insertions(+), 18 deletions(-) create mode 100755 saedit/saedit (limited to 'saedit') 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 ", "Reid Yaro ", diff --git a/saedit/main.h b/saedit/main.h index 63e9cc7..bc17e7e 100644 --- a/saedit/main.h +++ b/saedit/main.h @@ -48,6 +48,7 @@ static AnimationInfo *animation_info_new_with_params(GList *sub_nodes_new, guint AnimationInfo *res = g_new0(AnimationInfo, 1); res->sub_nodes = sub_nodes_new; res->anim_tag = anim_tag_new; + return res; } typedef struct { diff --git a/saedit/saedit b/saedit/saedit new file mode 100755 index 0000000..12184a5 Binary files /dev/null and b/saedit/saedit differ -- cgit v1.2.3-70-g09d2