summaryrefslogtreecommitdiff
path: root/saedit
diff options
context:
space:
mode:
authorVasily_Makarov <danilka.pro@gmail.com>2011-06-11 00:17:52 +0400
committerVasily_Makarov <danilka.pro@gmail.com>2011-06-11 00:17:52 +0400
commitce00f0c02e785db498e59d006251d98d3234e835 (patch)
treeee08ef1e8d92e3bb4fde98cb9952e8602cd3fabc /saedit
parenta1cfce737e02f8a7ad29acbc8bfd55a6ee888bd0 (diff)
downloadevol-tools-ce00f0c02e785db498e59d006251d98d3234e835.tar.gz
evol-tools-ce00f0c02e785db498e59d006251d98d3234e835.tar.bz2
evol-tools-ce00f0c02e785db498e59d006251d98d3234e835.tar.xz
evol-tools-ce00f0c02e785db498e59d006251d98d3234e835.zip
saedit: Add paths loading
Diffstat (limited to 'saedit')
-rw-r--r--saedit/main.c30
-rw-r--r--saedit/main.h9
2 files changed, 35 insertions, 4 deletions
diff --git a/saedit/main.c b/saedit/main.c
index 8577745..51acc87 100644
--- a/saedit/main.c
+++ b/saedit/main.c
@@ -391,7 +391,32 @@ void imagesets_combo_box_changed_handler(GtkComboBox *widget, gpointer user_data
set_up_imageset_by_node(list->data);
}
+void load_options() {
+ paths->sprites = NULL;
+ gchar *datapath = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(data_folder_chooser_button));
+ gchar *path = g_strjoin(SLASH_SEPARATOR, datapath, "paths.xml", NULL);
+ XMLNode *node = ibus_xml_parse_file(path);
+ if (node != NULL) {
+ GList *list = node->sub_nodes;
+ while (TRUE) {
+ list = g_list_find_custom(list, "option", xml_node_compare_with_name);
+ if (list == NULL)
+ break;
+ gchar *name_attr = xml_node_get_attr_value(list->data, "name");
+ if (name_attr != NULL) {
+ if (g_strcmp0(name_attr, "sprites") == 0)
+ paths->sprites = xml_node_get_attr_value(list->data, "value");
+ }
+ list = list->next;
+ }
+ }
+ if (paths->sprites == NULL) paths->sprites = OPTION_SPRITES_DEFAULT;
+ paths->sprites = g_strjoin(SLASH_SEPARATOR, datapath, paths->sprites, NULL);
+}
+
void parse_xml_buffer(GtkWidget *button, GtkSourceBuffer *buffer) {
+ 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);
@@ -402,13 +427,13 @@ void parse_xml_buffer(GtkWidget *button, GtkSourceBuffer *buffer) {
return;
}
- gchar *spritespath = g_strjoin(SLASH_SEPARATOR, gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(data_folder_chooser_button)), SPRITES_PATH, NULL);
+ printf("%s", paths->sprites);
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);
+ 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);
@@ -639,6 +664,7 @@ int main(int argc, char *argv[]) {
icon = gdk_pixbuf_new_from_file(ICON_FILE, NULL);
+ paths = g_new0(options, 1);
current_sprite = sprite_info_new(-1, 0, 0);
imageset = imageset_info_new();
diff --git a/saedit/main.h b/saedit/main.h
index 56ac08a..00ba08c 100644
--- a/saedit/main.h
+++ b/saedit/main.h
@@ -27,7 +27,7 @@ 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/";
+const gchar *OPTION_SPRITES_DEFAULT = "graphics/sprites/";
typedef struct {
@@ -44,6 +44,10 @@ typedef struct {
static sprite_info *sprite_info_new(int index, int offsetX, int offsetY);
typedef struct {
+ gchar *sprites;
+} options;
+
+typedef struct {
XMLNode *node;
int offsetX;
int offsetY;
@@ -80,9 +84,9 @@ GdkPixbuf *icon = NULL;
XMLNode *root = NULL;
imageset_info *imageset = NULL;
-
sprite_info *current_sprite;
guint running_animation = 0;
+options *paths;
static gboolean show_animation_by_sub_nodes (GList *sub_nodes);
static gchar *markup_bold(gchar *str);
@@ -119,3 +123,4 @@ static cairo_surface_t *get_grid_surface(int w, int h);
static gboolean darea_expose_event(GtkWidget *widget, GdkEventExpose *event, gpointer data);
static void load_config();
static void save_config_and_quit();
+static void load_options();