diff options
author | Vasily_Makarov <danilka.pro@gmail.com> | 2011-06-13 21:15:53 +0400 |
---|---|---|
committer | Vasily_Makarov <danilka.pro@gmail.com> | 2011-06-13 21:15:53 +0400 |
commit | 5e2ebc5c3c09fd219e7002b1ff6d25d5306c5356 (patch) | |
tree | 32bbb7e6690164bf35c6228853356d56f717e0bd /saedit | |
parent | 68504bc13794cc8628062d89eb77065b172a2d5a (diff) | |
download | evol-tools-5e2ebc5c3c09fd219e7002b1ff6d25d5306c5356.tar.gz evol-tools-5e2ebc5c3c09fd219e7002b1ff6d25d5306c5356.tar.bz2 evol-tools-5e2ebc5c3c09fd219e7002b1ff6d25d5306c5356.tar.xz evol-tools-5e2ebc5c3c09fd219e7002b1ff6d25d5306c5356.zip |
saedit: Fixed save bug
Diffstat (limited to 'saedit')
-rw-r--r-- | saedit/interface.h | 22 | ||||
-rw-r--r-- | saedit/main.c | 23 | ||||
-rw-r--r-- | saedit/main.h | 2 | ||||
-rwxr-xr-x | saedit/saedit | bin | 456336 -> 456240 bytes | |||
-rw-r--r-- | saedit/search.h | 60 |
5 files changed, 87 insertions, 20 deletions
diff --git a/saedit/interface.h b/saedit/interface.h index 76aca08..97307dd 100644 --- a/saedit/interface.h +++ b/saedit/interface.h @@ -20,8 +20,7 @@ void set_up_interface() { GtkWidget *menuitem = NULL; GtkWidget *menu = NULL; GtkWidget *vpaned = NULL; - GtkWidget *hscrollbar = NULL; - GtkWidget *vscrollbar = NULL; + GtkWidget *scrolled_window = NULL; GtkSourceLanguageManager *langman = gtk_source_language_manager_get_default(); source_buffer = gtk_source_buffer_new_with_language(gtk_source_language_manager_get_language(langman, "xml")); @@ -30,6 +29,7 @@ void set_up_interface() { gtk_window_set_title(GTK_WINDOW(win), "Sprite Animation Editor"); gtk_window_set_position(GTK_WINDOW(win), GTK_WIN_POS_CENTER); gtk_window_set_icon(GTK_WINDOW(win), icon); + //gtk_window_set_modal(GTK_WINDOW(win), TRUE); gtk_widget_realize(win); g_signal_connect(win, "destroy", G_CALLBACK(save_config_and_quit), NULL); gtk_widget_set_size_request(win, MIN_WIDTH, MIN_HEIGHT); @@ -169,25 +169,17 @@ void set_up_interface() { darea = gtk_drawing_area_new(); gtk_paned_pack1(GTK_PANED(vpaned), darea, FALSE, FALSE); gtk_widget_set_size_request(darea, -1, 120); - //g_signal_connect(darea, "expose-event", G_CALLBACK(darea_expose_event), player); g_signal_connect(darea, "expose-event", G_CALLBACK(darea_expose_event), gen_sae_info); - hbox = gtk_hbox_new(FALSE, 0); - gtk_paned_pack2(GTK_PANED(vpaned), hbox, TRUE, FALSE); - gtk_widget_set_size_request(hbox, -1, 50); - - vbox = gtk_vbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(hbox), vbox, TRUE, TRUE, 0); - text = gtk_source_view_new_with_buffer(source_buffer); + source_view = text; gtk_source_view_set_show_line_numbers(GTK_SOURCE_VIEW(text), TRUE); - gtk_box_pack_start(GTK_BOX(vbox), text, TRUE, TRUE, 0); - hscrollbar = gtk_hscrollbar_new(gtk_text_view_get_hadjustment(text)); - gtk_box_pack_start(GTK_BOX(vbox), hscrollbar, FALSE, TRUE, 0); + scrolled_window = gtk_scrolled_window_new(gtk_text_view_get_hadjustment(text), gtk_text_view_get_vadjustment(text)); + gtk_paned_pack2(GTK_PANED(vpaned), scrolled_window, TRUE, FALSE); + gtk_widget_set_size_request(scrolled_window, -1, 50); - vscrollbar = gtk_vscrollbar_new(gtk_text_view_get_vadjustment(text)); - gtk_box_pack_start(GTK_BOX(hbox), vscrollbar, FALSE, TRUE, 0); + gtk_container_add(scrolled_window, text); gtk_widget_show_all(win); gtk_widget_show_all(text); diff --git a/saedit/main.c b/saedit/main.c index 44bb565..94a728d 100644 --- a/saedit/main.c +++ b/saedit/main.c @@ -10,6 +10,7 @@ \*=======================================*/ #include "main.h" +#include "search.h" #include "interface.h" void kill_timeout(int tag) { @@ -141,7 +142,10 @@ void free_animations(SAEInfo *sae_info) { } void save_to_xml_file(GtkButton *button, gpointer buffer) { - g_file_set_contents(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(xml_file_chooser_button)), buffer, sizeof(buffer), NULL); + GtkTextIter start, end; + gtk_text_buffer_get_start_iter(source_buffer, &start); + gtk_text_buffer_get_end_iter(source_buffer, &end); + g_file_set_contents(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(xml_file_chooser_button)), gtk_text_buffer_get_text(source_buffer, &start, &end, NULL), -1, NULL); } void data_folder_set_handler(GtkFileChooserButton *widget, gpointer data) { @@ -274,6 +278,17 @@ GList *merge_animations(SAEInfo *sae_info_bottom, SAEInfo *sae_info_top) { } gboolean set_up_animation_by_direction(SAEInfo *sae_info, const gchar *direction) { + /*GtkTextIter beg, end, start; + gtk_text_buffer_get_start_iter(source_buffer, &start); + gtk_source_iter_forward_search(&start, "place -->", 0, &beg, &end, NULL); + gtk_text_buffer_place_cursor(source_buffer, &beg); + gtk_text_buffer_move_mark_by_name(source_buffer, "selection_bound", &end); + gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (source_view), + gtk_text_buffer_get_insert (source_buffer), + 0.25, + FALSE, + 0.0, + 0.0);*/ if (sae_info->imageset->spriteset == NULL) return FALSE; sae_info->animation = NULL; @@ -407,7 +422,6 @@ void animations_combo_box_changed_handler(GtkComboBox *widget, gpointer user_dat } void set_up_imageset_by_name(const gchar *name, SAEInfo *sae_info) { - g_printf("\n%s\n", name); free_imageset(sae_info); free_actions(sae_info); free_animations(sae_info); @@ -435,7 +449,6 @@ void set_up_imageset_by_name(const gchar *name, SAEInfo *sae_info) { format_src_string(src); gchar *datapath = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(data_folder_chooser_button)); gchar *path = g_strjoin(SEPARATOR_SLASH, datapath, src, NULL); - printf("\n%s\n", path); sae_info->imageset->spriteset = gdk_pixbuf_new_from_file(path, NULL); if (sae_info->imageset->spriteset == NULL) { @@ -466,7 +479,6 @@ void set_up_imageset_by_name(const gchar *name, SAEInfo *sae_info) { gchar *text; gchar *sprites_path = paths->sprites; gchar *player_file = g_strjoin(NULL, sprites_path, DIR_PLAYERS, player_attr, ".xml", NULL); - printf("%s\n", player_file); if (g_file_get_contents(player_file, &text, NULL, NULL)) { player = sae_info_new(); parse_xml_text(text, player); @@ -519,7 +531,6 @@ void parse_xml_text(gchar *text, SAEInfo *sae_info) { return; } - printf("%s", paths->sprites); GList *list = g_list_find_custom(_root_node->sub_nodes, "include", xml_node_compare_with_name); while (list != NULL) { XMLNode *node = list->data; @@ -583,6 +594,7 @@ gboolean frame_image_button_press_event(GtkWidget *widget, GdkEventButton *butto void show_imageset_window() { if (gen_sae_info->imageset->spriteset == NULL) return; GtkWidget *iwin = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_transient_for(iwin, GTK_WINDOW(win)); gtk_window_set_title(GTK_WINDOW(iwin), "Imageset preview"); gtk_window_set_position(GTK_WINDOW(iwin), GTK_WIN_POS_CENTER); gtk_widget_add_events(iwin, GDK_BUTTON_PRESS_MASK); @@ -649,6 +661,7 @@ int main(int argc, char *argv[]) { paths = g_new0(Options, 1); set_up_interface(); + //find_window_new(win); load_config(); gtk_main(); diff --git a/saedit/main.h b/saedit/main.h index f7fe877..f84ef5a 100644 --- a/saedit/main.h +++ b/saedit/main.h @@ -13,6 +13,7 @@ #include <gtk/gtk.h> #include <gtksourceview/gtksourceview.h> #include <gtksourceview/gtksourcelanguagemanager.h> +#include <gtksourceview/gtksourceiter.h> #include <ibusxml.h> #include <cairo.h> #include <glib/gi18n.h> @@ -161,6 +162,7 @@ GtkWidget *xml_file_open_button = NULL; GtkWidget *xml_file_save_button = NULL; GtkWidget *imageset_preview_menu_item = NULL; GtkWidget *show_grid_menu_item = NULL; +GtkWidget *source_view = NULL; GtkSourceBuffer *source_buffer = NULL; diff --git a/saedit/saedit b/saedit/saedit Binary files differindex 03a018e..b13d88b 100755 --- a/saedit/saedit +++ b/saedit/saedit diff --git a/saedit/search.h b/saedit/search.h new file mode 100644 index 0000000..8e648e1 --- /dev/null +++ b/saedit/search.h @@ -0,0 +1,60 @@ +/*=======================================*\ +| ____ ____ | +| / \ /\ | | +| \____ / \ |____ | +| \ /____\ | | +| \____/prite / \nimation |____ditor | +| | +| Copyleft Vasily_Makarov 2011 | +| | +\*=======================================*/ + +GtkWidget *find_entry; + +static gboolean find_text(GtkWidget *button, gpointer user_data) { + GtkTextIter beg, end, start; + gtk_text_buffer_get_start_iter(source_buffer, &start); + if (!gtk_source_iter_forward_search(&start, gtk_entry_get_text(find_entry), 0, &beg, &end, NULL)) + return FALSE; + gtk_text_buffer_place_cursor(source_buffer, &beg); + gtk_text_view_set_cursor_visible(source_view, FALSE); + gtk_text_buffer_move_mark_by_name(source_buffer, "selection_bound", &end); + gtk_text_mark_set_visible(gtk_text_buffer_get_insert (source_buffer), TRUE); + gtk_text_view_scroll_to_mark (GTK_TEXT_VIEW (source_view), + gtk_text_buffer_get_insert (source_buffer), + 0.25, + FALSE, + 0.0, + 0.0); + gtk_text_buffer_place_cursor(source_buffer, &end); +} + +static GtkWidget *find_window_new(GtkWindow *parent) { + GtkWidget *window; + GtkWidget *vbox; + GtkWidget *entry; + GtkWidget *button; + + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + gtk_window_set_transient_for(window, parent); + gtk_window_set_position(GTK_WINDOW(window), GTK_WIN_POS_CENTER); + gtk_window_set_title(GTK_WINDOW(window), _("Find")); + gtk_widget_set_size_request(window, 250, 100); + gtk_container_set_border_width(window, 4); + gtk_window_set_resizable(GTK_WINDOW(window), FALSE); + gtk_widget_realize(window); + + vbox = gtk_vbox_new(FALSE, 4); + gtk_container_add(window, vbox); + + entry = gtk_entry_new(); + gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 0); + find_entry = entry; + + button = gtk_button_new_with_label(_("Find")); + gtk_widget_set_size_request(button, 64, 32); + gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 0); + g_signal_connect(button, "clicked", find_text, NULL); + + gtk_widget_show_all(window); +} |