diff options
-rw-r--r-- | saedit/interface.h | 251 | ||||
-rw-r--r-- | saedit/interface.h.old | 310 | ||||
-rw-r--r-- | saedit/interface.ui | 531 | ||||
-rw-r--r-- | saedit/main.c | 10 | ||||
-rw-r--r-- | saedit/main.h | 69 |
5 files changed, 915 insertions, 256 deletions
diff --git a/saedit/interface.h b/saedit/interface.h index e0e5519..c2a4e2f 100644 --- a/saedit/interface.h +++ b/saedit/interface.h @@ -9,6 +9,8 @@ | | \*=======================================*/ +#include "main.h" + GtkWidget *reload_menu_item = NULL; void find_menu_item_activate_callback(GtkWidget *menuitem, gpointer user_data) { @@ -58,240 +60,45 @@ void file_new() { } void set_up_interface() { - GtkWidget *button = NULL; - GtkWidget *hbox = NULL; - GtkWidget *vbox = NULL; - GtkWidget *vbbox = NULL; - GtkWidget *text = NULL; - GtkWidget *label = NULL; - GtkWidget *menubar = NULL; - GtkWidget *menuitem = NULL; - GtkWidget *menu = NULL; - GtkWidget *vpaned = NULL; - GtkWidget *scrolled_window = NULL; - GtkWidget *fcdialog = 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")); - text = gtk_source_view_new_with_buffer(source_buffer); - source_view = text; - - win = gtk_window_new(GTK_WINDOW_TOPLEVEL); - 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_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); - GtkAccelGroup *ag = gtk_accel_group_new(); - gtk_window_add_accel_group(win, ag); - - fcdialog = gtk_file_chooser_dialog_new(_("Open file"), win, GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); - - vbox = gtk_vbox_new(FALSE, 0); - gtk_container_add(GTK_CONTAINER(win), vbox); - - //Menubar setup - menubar = gtk_menu_bar_new(); - gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0); - - //File menu - menu = gtk_menu_new(); - gtk_menu_set_accel_group(menu, ag); - - menuitem = gtk_menu_item_new_with_label(_("New")); - g_signal_connect(menuitem, "activate", G_CALLBACK(file_new), NULL); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); - - gtk_menu_item_set_accel_path(GTK_MENU_ITEM(menuitem), "<MenuItems>/File/New"); - gtk_accel_map_change_entry("<MenuItems>/File/New", gdk_keyval_from_name("N"), GDK_CONTROL_MASK, TRUE); - - menuitem = gtk_menu_item_new_with_label(_("Open...")); - g_signal_connect(menuitem, "activate", open_menu_item_activate, fcdialog); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); - - gtk_menu_item_set_accel_path(GTK_MENU_ITEM(menuitem), "<MenuItems>/File/Open"); - gtk_accel_map_change_entry("<MenuItems>/File/Open", gdk_keyval_from_name("O"), GDK_CONTROL_MASK, TRUE); - - menuitem = gtk_menu_item_new_with_label(_("Reload")); - gtk_widget_set_sensitive(menuitem, FALSE); - g_signal_connect(menuitem, "activate", G_CALLBACK(open_xml_file), source_buffer); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); - - gtk_menu_item_set_accel_path(GTK_MENU_ITEM(menuitem), "<MenuItems>/File/Reload"); - gtk_accel_map_change_entry("<MenuItems>/File/Reload", gdk_keyval_from_name("R"), GDK_CONTROL_MASK, TRUE); - - reload_menu_item = menuitem; - - gtk_menu_shell_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); - - menuitem = gtk_menu_item_new_with_label(_("Save")); - g_signal_connect(menuitem, "activate", G_CALLBACK(save_menu_item_activate_callback), NULL); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); - - gtk_menu_item_set_accel_path(GTK_MENU_ITEM(menuitem), "<MenuItems>/File/Save"); - gtk_accel_map_change_entry("<MenuItems>/File/Save", gdk_keyval_from_name("S"), GDK_CONTROL_MASK, TRUE); - - menuitem = gtk_menu_item_new_with_label(_("Save as...")); - g_signal_connect(menuitem, "activate", G_CALLBACK(save_dialog_show), NULL); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); - - gtk_menu_item_set_accel_path(GTK_MENU_ITEM(menuitem), "<MenuItems>/File/SaveAs"); - gtk_accel_map_change_entry("<MenuItems>/File/SaveAs", gdk_keyval_from_name("S"), GDK_CONTROL_MASK + GDK_SHIFT_MASK, TRUE); - - menuitem = gtk_menu_item_new_with_label(_("File")); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu); - gtk_menu_shell_append(GTK_MENU_SHELL(menubar), menuitem); - - //Search menu - menu = gtk_menu_new(); - gtk_menu_set_accel_group(menu, ag); - - menuitem = gtk_menu_item_new_with_label(_("Find...")); - g_signal_connect(menuitem, "activate", find_menu_item_activate_callback, NULL); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); - - gtk_menu_item_set_accel_path(GTK_MENU_ITEM(menuitem), "<MenuItems>/Search/Find"); - gtk_accel_map_change_entry("<MenuItems>/Search/Find", gdk_keyval_from_name("F"), GDK_CONTROL_MASK, TRUE); - menuitem = gtk_menu_item_new_with_label(_("Find next")); - g_signal_connect(menuitem, "activate", search_find_next, NULL); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); + GtkBuilder *builder = gtk_builder_new(); + gtk_builder_add_from_file(builder, "interface.ui", NULL); + gtk_builder_connect_signals(builder, NULL); - gtk_menu_item_set_accel_path(GTK_MENU_ITEM(menuitem), "<MenuItems>/Search/FindNext"); - gtk_accel_map_change_entry("<MenuItems>/Search/FindNext", gdk_keyval_from_name("F3"), 0, TRUE); + win = GTK_WIDGET(gtk_builder_get_object(builder, "win_main")); - menuitem = gtk_menu_item_new_with_label(_("Search")); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu); - gtk_menu_shell_append(GTK_MENU_SHELL(menubar), menuitem); - - //View menu - menu = gtk_menu_new(); - gtk_menu_set_accel_group(menu, ag); - - menuitem = gtk_check_menu_item_new_with_label(_("Show grid")); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); - - g_signal_connect(menuitem, "toggled", show_grid_menu_item_toggled, NULL); - - gtk_menu_item_set_accel_path(menuitem, "<MenuItems>/View/ShowGrid"); - gtk_accel_map_change_entry("<MenuItems>/View/ShowGrid", gdk_keyval_from_name("G"), GDK_CONTROL_MASK, TRUE); - - show_grid_menu_item = menuitem; - - menuitem = gtk_menu_item_new_with_label(_("Imageset preview")); - gtk_widget_set_sensitive(menuitem, FALSE); - g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(show_imageset_dialog), NULL); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); - - gtk_menu_item_set_accel_path(menuitem, "<MenuItems>/View/ImagesetPreview"); - gtk_accel_map_change_entry("<MenuItems>/View/ImagesetPreview", gdk_keyval_from_name("I"), GDK_CONTROL_MASK, TRUE); - - imageset_preview_menu_item = menuitem; - - menuitem = gtk_menu_item_new_with_label(_("View")); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu); - gtk_menu_shell_append(GTK_MENU_SHELL(menubar), menuitem); - - //Help menu - menu = gtk_menu_new(); - menuitem = gtk_menu_item_new_with_label(_("About")); - g_signal_connect(menuitem, "activate", show_about_dialog, NULL); - gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); - - menuitem = gtk_menu_item_new_with_label(_("Help")); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu); - gtk_menu_shell_append(GTK_MENU_SHELL(menubar), menuitem); - - hbox = gtk_hbox_new(FALSE, 0); - gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0); - - //Left part setup - vbbox = gtk_vbutton_box_new(); - gtk_button_box_set_layout(GTK_BUTTON_BOX(vbbox), GTK_BUTTONBOX_START); - gtk_button_box_set_child_size(GTK_BUTTON_BOX(vbbox), 180, 0); - gtk_box_pack_start(GTK_BOX(hbox), vbbox, FALSE, TRUE, 0); - - label = gtk_label_new(""); - gtk_label_set_markup(GTK_LABEL(label), markup_bold(_("Clientdata folder"))); - gtk_box_pack_start(GTK_BOX(vbbox), label, TRUE, TRUE, 0); - - data_folder_chooser_button = gtk_file_chooser_button_new(_("Clientdata folder"), 0); - gtk_box_pack_start(GTK_BOX(vbbox), data_folder_chooser_button, TRUE, TRUE, 0); - gtk_file_chooser_set_action(GTK_FILE_CHOOSER(data_folder_chooser_button), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); - g_signal_connect(data_folder_chooser_button, "selection-changed", G_CALLBACK(data_folder_set_callback), NULL); - - label = gtk_label_new(""); - gtk_label_set_markup(GTK_LABEL(label), markup_bold(_("XML source file"))); - gtk_box_pack_start(GTK_BOX(vbbox), label, TRUE, TRUE, 0); - - xml_file_chooser_button = gtk_file_chooser_button_new_with_dialog(fcdialog); - gtk_box_pack_start(GTK_BOX(vbbox), xml_file_chooser_button, TRUE, TRUE, 0); - g_signal_connect(xml_file_chooser_button, "file-set", G_CALLBACK(open_xml_file), source_buffer); - - xml_file_open_button = gtk_button_new_from_stock(GTK_STOCK_OPEN); - gtk_widget_set_sensitive(xml_file_open_button, FALSE); - gtk_box_pack_start(GTK_BOX(vbbox), xml_file_open_button, TRUE, TRUE, 0); - g_signal_connect(xml_file_open_button, "clicked", G_CALLBACK(open_xml_file), source_buffer); - - xml_file_save_button = gtk_button_new_from_stock(GTK_STOCK_SAVE); - gtk_widget_set_sensitive(xml_file_save_button, FALSE); - gtk_box_pack_start(GTK_BOX(vbbox), xml_file_save_button, TRUE, TRUE, 0); - g_signal_connect(xml_file_save_button, "clicked", G_CALLBACK(xml_file_save_button_callback), NULL); - gtk_widget_set_accel_path(xml_file_save_button, "<Buttons>/SaveXMLBuffer", ag); - //gtk_accel_map_change_entry("<Buttons>/SaveXMLBuffer", gdk_keyval_from_name("S"), GDK_CONTROL_MASK, TRUE); - - button = gtk_button_new_with_label(_("Parse XML buffer")); - gtk_box_pack_start(GTK_BOX(vbbox), button, TRUE, TRUE, 0); - g_signal_connect(button, "clicked", G_CALLBACK(parse_xml_buffer), source_buffer); - gtk_widget_set_accel_path(button, "<Buttons>/ParseXMLBuffer", ag); - gtk_accel_map_change_entry("<Buttons>/ParseXMLBuffer", gdk_keyval_from_name("P"), GDK_CONTROL_MASK, TRUE); - - label = gtk_label_new(""); - gtk_label_set_markup(GTK_LABEL(label), markup_bold(_("Imagesets"))); - gtk_box_pack_start(GTK_BOX(vbbox), label, TRUE, TRUE, 0); - - gen_sae_info->imagesets_combo_box = gtk_combo_box_new_text(); - g_signal_connect(gen_sae_info->imagesets_combo_box, "changed", G_CALLBACK(imagesets_combo_box_changed_callback), NULL); - gtk_box_pack_start(GTK_BOX(vbbox), gen_sae_info->imagesets_combo_box, TRUE, TRUE, 0); - - label = gtk_label_new(""); - gtk_label_set_markup(GTK_LABEL(label), markup_bold(_("Actions"))); - gtk_box_pack_start(GTK_BOX(vbbox), label, TRUE, TRUE, 0); + //Setup GtkSourceView + GtkSourceLanguageManager *langman = gtk_source_language_manager_get_default(); + source_buffer = gtk_source_buffer_new_with_language(gtk_source_language_manager_get_language(langman, "xml")); - gen_sae_info->actions_combo_box = gtk_combo_box_new_text(); - g_signal_connect(gen_sae_info->actions_combo_box, "changed", G_CALLBACK(actions_combo_box_changed_callback), NULL); - gtk_box_pack_start(GTK_BOX(vbbox), gen_sae_info->actions_combo_box, TRUE, TRUE, 0); + source_view = GTK_WIDGET(gtk_builder_get_object(builder, "source_view")); + gtk_text_view_set_buffer(GTK_TEXT_VIEW(source_view), GTK_TEXT_BUFFER(source_buffer)); - label = gtk_label_new(""); - gtk_label_set_markup(GTK_LABEL(label), markup_bold(_("Directions"))); - gtk_box_pack_start(GTK_BOX(vbbox), label, TRUE, TRUE, 0); + //Setup ScrolledWindow + GtkWidget *scrolled_window = NULL; + scrolled_window = GTK_WIDGET(gtk_builder_get_object(builder, "scrolledwindow1")); + gtk_scrolled_window_set_hadjustment(GTK_SCROLLED_WINDOW(scrolled_window), + gtk_text_view_get_hadjustment(GTK_TEXT_VIEW(source_view))); + gtk_scrolled_window_set_vadjustment(GTK_SCROLLED_WINDOW(scrolled_window), + gtk_text_view_get_vadjustment(GTK_TEXT_VIEW(source_view))); - gen_sae_info->animations_combo_box = gtk_combo_box_new_text(); - g_signal_connect(gen_sae_info->animations_combo_box, "changed", G_CALLBACK(animations_combo_box_changed_callback), NULL); - gtk_box_pack_start(GTK_BOX(vbbox), gen_sae_info->animations_combo_box, TRUE, TRUE, 0); + //Setup GtkDrawingArea + darea = GTK_WIDGET(gtk_builder_get_object(builder, "darea1")); - //Right part setup - vpaned = gtk_vpaned_new(); - gtk_box_pack_end(GTK_BOX(hbox), vpaned, TRUE, TRUE, 0); - 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), gen_sae_info); + reload_menu_item = GTK_WIDGET(gtk_builder_get_object(builder, "menuitem6")); + show_grid_menu_item = GTK_WIDGET(gtk_builder_get_object(builder, "menuitem11")); + imageset_preview_menu_item = GTK_WIDGET(gtk_builder_get_object(builder, "menuitem12")); - source_view = text; - gtk_source_view_set_show_line_numbers(GTK_SOURCE_VIEW(text), TRUE); + data_folder_chooser_button = GTK_WIDGET(gtk_builder_get_object(builder, "datafcbutton")); + xml_file_chooser_button = GTK_WIDGET(gtk_builder_get_object(builder, "xmlfcbutton")); - 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); + gen_sae_info->imagesets_combo_box = GTK_WIDGET(gtk_builder_get_object(builder, "imagesetscbox")); + gen_sae_info->actions_combo_box = GTK_WIDGET(gtk_builder_get_object(builder, "actionscbox")); + gen_sae_info->animations_combo_box = GTK_WIDGET(gtk_builder_get_object(builder, "animationscbox")); file_new(); - gtk_container_add(scrolled_window, text); - gtk_widget_show_all(win); - gtk_widget_show_all(text); + gtk_widget_show_all(source_view); } diff --git a/saedit/interface.h.old b/saedit/interface.h.old new file mode 100644 index 0000000..925d5cb --- /dev/null +++ b/saedit/interface.h.old @@ -0,0 +1,310 @@ +/*=======================================*\ +| ____ ____ | +| / \ /\ | | +| \____ / \ |____ | +| \ /____\ | | +| \____/prite / \nimation |____ditor | +| | +| Copyleft Vasily_Makarov 2011 | +| | +\*=======================================*/ + +#include "main.h" + +GtkWidget *reload_menu_item = NULL; + +void find_menu_item_activate_callback(GtkWidget *menuitem, gpointer user_data) { + search_find_dialog_show(win, source_view); +} + +void save_dialog_response_callback(GtkWidget *dialog, gint response_id, gpointer user_data) { + if (response_id == GTK_RESPONSE_ACCEPT) { + gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog)); + if (filename != NULL) { + save_to_xml_file(filename); + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(xml_file_chooser_button), filename); + } + } + gtk_widget_destroy(dialog); +} + +void save_dialog_show() { + GtkDialog *dialog = gtk_file_chooser_dialog_new(_("Save file as..."), win, GTK_FILE_CHOOSER_ACTION_SAVE, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL); + g_signal_connect(dialog, "response", G_CALLBACK(save_dialog_response_callback), NULL); + gtk_dialog_run(dialog); +} + +void save_menu_item_activate_callback(GtkWidget *menuitem, GtkWidget *fsdialog) { + gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(xml_file_chooser_button)); + if (filename != NULL) + save_to_xml_file(filename); + else + save_dialog_show(); +} + +void xml_file_save_button_callback(GtkWidget *button, gpointer user_data) { + gchar *filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(xml_file_chooser_button)); + if (filename != NULL) + save_to_xml_file(filename); +} + +void file_new() { + GtkTextIter start, end; + gtk_text_buffer_get_bounds(source_buffer, &start, &end); + gtk_text_buffer_delete(source_buffer, &start, &end); + gchar *temp; + if (g_file_get_contents(FILE_TEMPLATE, &temp, NULL, NULL)) + gtk_text_buffer_set_text(GTK_TEXT_BUFFER(source_buffer), temp, -1); + gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(xml_file_chooser_button), ""); + gtk_widget_set_sensitive(reload_menu_item, FALSE); +} + +void set_up_interface() { + + GtkBuilder *builder = gtk_builder_new(); + gtk_builder_add_from_file(builder, "interface.ui", NULL); + gtk_builder_connect_signals(builder, NULL); + + GtkWindow *win1 = GTK_WIDGET(gtk_builder_get_object(builder, "win_main")); + + GtkWidget *button = NULL; + GtkWidget *hbox = NULL; + GtkWidget *vbox = NULL; + GtkWidget *vbbox = NULL; + GtkWidget *text = NULL; + GtkWidget *label = NULL; + GtkWidget *menubar = NULL; + GtkWidget *menuitem = NULL; + GtkWidget *menu = NULL; + GtkWidget *vpaned = NULL; + GtkWidget *scrolled_window = NULL; + GtkWidget *fcdialog = 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")); + text = gtk_source_view_new_with_buffer(source_buffer); + source_view = text; + + win = gtk_window_new(GTK_WINDOW_TOPLEVEL); + 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_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); + GtkAccelGroup *ag = gtk_accel_group_new(); + gtk_window_add_accel_group(win, ag); + + fcdialog = gtk_file_chooser_dialog_new(_("Open file"), win, GTK_FILE_CHOOSER_ACTION_OPEN, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT, NULL); + + vbox = gtk_vbox_new(FALSE, 0); + gtk_container_add(GTK_CONTAINER(win), vbox); + + //Menubar setup + menubar = gtk_menu_bar_new(); + gtk_box_pack_start(GTK_BOX(vbox), menubar, FALSE, TRUE, 0); + + //File menu + menu = gtk_menu_new(); + gtk_menu_set_accel_group(menu, ag); + + menuitem = gtk_menu_item_new_with_label(_("New")); + g_signal_connect(menuitem, "activate", G_CALLBACK(file_new), NULL); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); + + gtk_menu_item_set_accel_path(GTK_MENU_ITEM(menuitem), "<MenuItems>/File/New"); + gtk_accel_map_change_entry("<MenuItems>/File/New", gdk_keyval_from_name("N"), GDK_CONTROL_MASK, TRUE); + + menuitem = gtk_menu_item_new_with_label(_("Open...")); + g_signal_connect(menuitem, "activate", open_menu_item_activate, fcdialog); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); + + gtk_menu_item_set_accel_path(GTK_MENU_ITEM(menuitem), "<MenuItems>/File/Open"); + gtk_accel_map_change_entry("<MenuItems>/File/Open", gdk_keyval_from_name("O"), GDK_CONTROL_MASK, TRUE); + + menuitem = gtk_menu_item_new_with_label(_("Reload")); + gtk_widget_set_sensitive(menuitem, FALSE); + g_signal_connect(menuitem, "activate", G_CALLBACK(open_xml_file), NULL); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); + + gtk_menu_item_set_accel_path(GTK_MENU_ITEM(menuitem), "<MenuItems>/File/Reload"); + gtk_accel_map_change_entry("<MenuItems>/File/Reload", gdk_keyval_from_name("R"), GDK_CONTROL_MASK, TRUE); + + reload_menu_item = menuitem; + + gtk_menu_shell_append(GTK_MENU_SHELL(menu), gtk_separator_menu_item_new()); + + menuitem = gtk_menu_item_new_with_label(_("Save")); + g_signal_connect(menuitem, "activate", G_CALLBACK(save_menu_item_activate_callback), NULL); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); + + gtk_menu_item_set_accel_path(GTK_MENU_ITEM(menuitem), "<MenuItems>/File/Save"); + gtk_accel_map_change_entry("<MenuItems>/File/Save", gdk_keyval_from_name("S"), GDK_CONTROL_MASK, TRUE); + + menuitem = gtk_menu_item_new_with_label(_("Save as...")); + g_signal_connect(menuitem, "activate", G_CALLBACK(save_dialog_show), NULL); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); + + gtk_menu_item_set_accel_path(GTK_MENU_ITEM(menuitem), "<MenuItems>/File/SaveAs"); + gtk_accel_map_change_entry("<MenuItems>/File/SaveAs", gdk_keyval_from_name("S"), GDK_CONTROL_MASK + GDK_SHIFT_MASK, TRUE); + + menuitem = gtk_menu_item_new_with_label(_("File")); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu); + gtk_menu_shell_append(GTK_MENU_SHELL(menubar), menuitem); + + //Search menu + menu = gtk_menu_new(); + gtk_menu_set_accel_group(menu, ag); + + menuitem = gtk_menu_item_new_with_label(_("Find...")); + g_signal_connect(menuitem, "activate", find_menu_item_activate_callback, NULL); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); + + gtk_menu_item_set_accel_path(GTK_MENU_ITEM(menuitem), "<MenuItems>/Search/Find"); + gtk_accel_map_change_entry("<MenuItems>/Search/Find", gdk_keyval_from_name("F"), GDK_CONTROL_MASK, TRUE); + + menuitem = gtk_menu_item_new_with_label(_("Find next")); + g_signal_connect(menuitem, "activate", search_find_next, NULL); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); + + gtk_menu_item_set_accel_path(GTK_MENU_ITEM(menuitem), "<MenuItems>/Search/FindNext"); + gtk_accel_map_change_entry("<MenuItems>/Search/FindNext", gdk_keyval_from_name("F3"), 0, TRUE); + + menuitem = gtk_menu_item_new_with_label(_("Search")); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu); + gtk_menu_shell_append(GTK_MENU_SHELL(menubar), menuitem); + + //View menu + menu = gtk_menu_new(); + gtk_menu_set_accel_group(menu, ag); + + menuitem = gtk_check_menu_item_new_with_label(_("Show grid")); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); + + g_signal_connect(menuitem, "toggled", show_grid_menu_item_toggled, NULL); + + gtk_menu_item_set_accel_path(menuitem, "<MenuItems>/View/ShowGrid"); + gtk_accel_map_change_entry("<MenuItems>/View/ShowGrid", gdk_keyval_from_name("G"), GDK_CONTROL_MASK, TRUE); + + show_grid_menu_item = menuitem; + + menuitem = gtk_menu_item_new_with_label(_("Imageset preview")); + gtk_widget_set_sensitive(menuitem, FALSE); + g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(show_imageset_dialog), NULL); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); + + gtk_menu_item_set_accel_path(menuitem, "<MenuItems>/View/ImagesetPreview"); + gtk_accel_map_change_entry("<MenuItems>/View/ImagesetPreview", gdk_keyval_from_name("I"), GDK_CONTROL_MASK, TRUE); + + imageset_preview_menu_item = menuitem; + + menuitem = gtk_menu_item_new_with_label(_("View")); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu); + gtk_menu_shell_append(GTK_MENU_SHELL(menubar), menuitem); + + //Help menu + menu = gtk_menu_new(); + menuitem = gtk_menu_item_new_with_label(_("About")); + g_signal_connect(menuitem, "activate", show_about_dialog, NULL); + gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); + + menuitem = gtk_menu_item_new_with_label(_("Help")); + gtk_menu_item_set_submenu(GTK_MENU_ITEM(menuitem), menu); + gtk_menu_shell_append(GTK_MENU_SHELL(menubar), menuitem); + + hbox = gtk_hbox_new(FALSE, 0); + gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, TRUE, 0); + + //Left part setup + vbbox = gtk_vbutton_box_new(); + gtk_button_box_set_layout(GTK_BUTTON_BOX(vbbox), GTK_BUTTONBOX_START); + gtk_button_box_set_child_size(GTK_BUTTON_BOX(vbbox), 180, 0); + gtk_box_pack_start(GTK_BOX(hbox), vbbox, FALSE, TRUE, 0); + + label = gtk_label_new(""); + gtk_label_set_markup(GTK_LABEL(label), markup_bold(_("Clientdata folder"))); + gtk_box_pack_start(GTK_BOX(vbbox), label, TRUE, TRUE, 0); + + data_folder_chooser_button = gtk_file_chooser_button_new(_("Clientdata folder"), 0); + gtk_box_pack_start(GTK_BOX(vbbox), data_folder_chooser_button, TRUE, TRUE, 0); + gtk_file_chooser_set_action(GTK_FILE_CHOOSER(data_folder_chooser_button), GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER); + g_signal_connect(data_folder_chooser_button, "selection-changed", G_CALLBACK(data_folder_set_callback), NULL); + + label = gtk_label_new(""); + gtk_label_set_markup(GTK_LABEL(label), markup_bold(_("XML source file"))); + gtk_box_pack_start(GTK_BOX(vbbox), label, TRUE, TRUE, 0); + + xml_file_chooser_button = gtk_file_chooser_button_new_with_dialog(fcdialog); + gtk_box_pack_start(GTK_BOX(vbbox), xml_file_chooser_button, TRUE, TRUE, 0); + g_signal_connect(xml_file_chooser_button, "file-set", G_CALLBACK(open_xml_file), NULL); + + xml_file_open_button = gtk_button_new_from_stock(GTK_STOCK_OPEN); + gtk_widget_set_sensitive(xml_file_open_button, FALSE); + gtk_box_pack_start(GTK_BOX(vbbox), xml_file_open_button, TRUE, TRUE, 0); + g_signal_connect(xml_file_open_button, "clicked", G_CALLBACK(open_xml_file), NULL); + + xml_file_save_button = gtk_button_new_from_stock(GTK_STOCK_SAVE); + gtk_widget_set_sensitive(xml_file_save_button, FALSE); + gtk_box_pack_start(GTK_BOX(vbbox), xml_file_save_button, TRUE, TRUE, 0); + g_signal_connect(xml_file_save_button, "clicked", G_CALLBACK(xml_file_save_button_callback), NULL); + gtk_widget_set_accel_path(xml_file_save_button, "<Buttons>/SaveXMLBuffer", ag); + //gtk_accel_map_change_entry("<Buttons>/SaveXMLBuffer", gdk_keyval_from_name("S"), GDK_CONTROL_MASK, TRUE); + + button = gtk_button_new_with_label(_("Parse XML buffer")); + gtk_box_pack_start(GTK_BOX(vbbox), button, TRUE, TRUE, 0); + g_signal_connect(button, "clicked", G_CALLBACK(parse_xml_buffer), NULL); + gtk_widget_set_accel_path(button, "<Buttons>/ParseXMLBuffer", ag); + gtk_accel_map_change_entry("<Buttons>/ParseXMLBuffer", gdk_keyval_from_name("P"), GDK_CONTROL_MASK, TRUE); + + label = gtk_label_new(""); + gtk_label_set_markup(GTK_LABEL(label), markup_bold(_("Imagesets"))); + gtk_box_pack_start(GTK_BOX(vbbox), label, TRUE, TRUE, 0); + + gen_sae_info->imagesets_combo_box = GTK_WIDGET(gtk_builder_get_object(builder, "imagesetscbox")); + /*gen_sae_info->imagesets_combo_box = gtk_combo_box_new_text(); + g_signal_connect(gen_sae_info->imagesets_combo_box, "changed", G_CALLBACK(imagesets_combo_box_changed_callback), NULL); + gtk_box_pack_start(GTK_BOX(vbbox), gen_sae_info->imagesets_combo_box, TRUE, TRUE, 0);*/ + + label = gtk_label_new(""); + gtk_label_set_markup(GTK_LABEL(label), markup_bold(_("Actions"))); + gtk_box_pack_start(GTK_BOX(vbbox), label, TRUE, TRUE, 0); + + gen_sae_info->actions_combo_box = GTK_WIDGET(gtk_builder_get_object(builder, "actionscbox")); + /*gen_sae_info->actions_combo_box = gtk_combo_box_new_text(); + g_signal_connect(gen_sae_info->actions_combo_box, "changed", G_CALLBACK(actions_combo_box_changed_callback), NULL); + gtk_box_pack_start(GTK_BOX(vbbox), gen_sae_info->actions_combo_box, TRUE, TRUE, 0);*/ + + label = gtk_label_new(""); + gtk_label_set_markup(GTK_LABEL(label), markup_bold(_("Directions"))); + gtk_box_pack_start(GTK_BOX(vbbox), label, TRUE, TRUE, 0); + + gen_sae_info->animations_combo_box = GTK_WIDGET(gtk_builder_get_object(builder, "animationscbox")); + /*gen_sae_info->animations_combo_box = gtk_combo_box_new_text(); + g_signal_connect(gen_sae_info->animations_combo_box, "changed", G_CALLBACK(animations_combo_box_changed_callback), NULL); + gtk_box_pack_start(GTK_BOX(vbbox), gen_sae_info->animations_combo_box, TRUE, TRUE, 0);*/ + + //Right part setup + vpaned = gtk_vpaned_new(); + gtk_box_pack_end(GTK_BOX(hbox), vpaned, TRUE, TRUE, 0); + + 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), gen_sae_info); + + source_view = text; + gtk_source_view_set_show_line_numbers(GTK_SOURCE_VIEW(text), TRUE); + + 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); + + file_new(); + + gtk_container_add(scrolled_window, text); + + gtk_widget_show_all(win); + gtk_widget_show_all(win1); + gtk_widget_show_all(text); +} diff --git a/saedit/interface.ui b/saedit/interface.ui new file mode 100644 index 0000000..594c111 --- /dev/null +++ b/saedit/interface.ui @@ -0,0 +1,531 @@ +<?xml version="1.0" encoding="UTF-8"?> +<interface> + <requires lib="gtk+" version="2.24"/> + <!-- interface-requires gtksourceview 0.0 --> + <!-- interface-naming-policy project-wide --> + <object class="GtkFileChooserDialog" id="fcdialog1"> + <property name="can_focus">False</property> + <property name="border_width">5</property> + <property name="title" translatable="yes">Open file</property> + <property name="type_hint">dialog</property> + <child internal-child="vbox"> + <object class="GtkVBox" id="dialog-vbox1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="spacing">2</property> + <child internal-child="action_area"> + <object class="GtkHButtonBox" id="dialog-action_area1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="layout_style">end</property> + <child> + <object class="GtkButton" id="button1"> + <property name="label">gtk-open</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkButton" id="button2"> + <property name="label">gtk-cancel</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> + <property name="use_stock">True</property> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">end</property> + <property name="position">0</property> + </packing> + </child> + <child> + <placeholder/> + </child> + </object> + </child> + <action-widgets> + <action-widget response="-3">button1</action-widget> + <action-widget response="0">button2</action-widget> + </action-widgets> + </object> + <object class="GtkListStore" id="liststore1"> + <columns> + <!-- column-name text --> + <column type="gchararray"/> + </columns> + </object> + <object class="GtkWindow" id="win_main"> + <property name="width_request">600</property> + <property name="height_request">600</property> + <property name="can_focus">False</property> + <property name="title" translatable="yes">Sprite Animation Editor</property> + <property name="window_position">center</property> + <property name="default_width">600</property> + <property name="default_height">600</property> + <property name="icon">icon.svg</property> + <signal name="destroy" handler="save_config_and_quit" swapped="no"/> + <child> + <object class="GtkVBox" id="vbox1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkMenuBar" id="menubar1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkMenuItem" id="menuitem1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="use_action_appearance">False</property> + <property name="label" translatable="yes">_File</property> + <property name="use_underline">True</property> + <child type="submenu"> + <object class="GtkMenu" id="menu1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkMenuItem" id="menuitem4"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="use_action_appearance">False</property> + <property name="label" translatable="yes">_New</property> + <property name="use_underline">True</property> + <signal name="activate" handler="file_new" swapped="no"/> + </object> + </child> + <child> + <object class="GtkMenuItem" id="menuitem5"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="use_action_appearance">False</property> + <property name="label" translatable="yes">_Open...</property> + <property name="use_underline">True</property> + <signal name="activate" handler="open_menu_item_activate" object="fcdialog1" swapped="no"/> + </object> + </child> + <child> + <object class="GtkMenuItem" id="menuitem6"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="use_action_appearance">False</property> + <property name="label" translatable="yes">_Reload</property> + <property name="use_underline">True</property> + <signal name="activate" handler="open_xml_file" swapped="no"/> + </object> + </child> + <child> + <object class="GtkSeparatorMenuItem" id="menuitem15"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="use_action_appearance">False</property> + </object> + </child> + <child> + <object class="GtkMenuItem" id="menuitem7"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="use_action_appearance">False</property> + <property name="label" translatable="yes">_Save</property> + <property name="use_underline">True</property> + <signal name="activate" handler="save_menu_item_activate_callback" swapped="no"/> + </object> + </child> + <child> + <object class="GtkMenuItem" id="menuitem8"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="use_action_appearance">False</property> + <property name="label" translatable="yes">Save _As...</property> + <property name="use_underline">True</property> + <signal name="activate" handler="save_dialog_show" swapped="no"/> + </object> + </child> + </object> + </child> + </object> + </child> + <child> + <object class="GtkMenuItem" id="menuitem2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="use_action_appearance">False</property> + <property name="label" translatable="yes">_Search</property> + <property name="use_underline">True</property> + <child type="submenu"> + <object class="GtkMenu" id="menu2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkMenuItem" id="menuitem9"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="use_action_appearance">False</property> + <property name="label" translatable="yes">_Find...</property> + <property name="use_underline">True</property> + <signal name="activate" handler="find_menu_item_activate_callback" swapped="no"/> + </object> + </child> + <child> + <object class="GtkMenuItem" id="menuitem10"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="use_action_appearance">False</property> + <property name="label" translatable="yes">Find _Next</property> + <property name="use_underline">True</property> + <signal name="activate" handler="search_find_next" swapped="no"/> + </object> + </child> + </object> + </child> + </object> + </child> + <child> + <object class="GtkMenuItem" id="menuitem3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="use_action_appearance">False</property> + <property name="label" translatable="yes">_View</property> + <property name="use_underline">True</property> + <child type="submenu"> + <object class="GtkMenu" id="menu3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkCheckMenuItem" id="menuitem11"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="use_action_appearance">False</property> + <property name="label" translatable="yes">Show _Grid</property> + <property name="use_underline">True</property> + <signal name="toggled" handler="show_grid_menu_item_toggled" swapped="no"/> + </object> + </child> + <child> + <object class="GtkMenuItem" id="menuitem12"> + <property name="visible">True</property> + <property name="sensitive">False</property> + <property name="can_focus">False</property> + <property name="use_action_appearance">False</property> + <property name="label" translatable="yes">_Imageset view</property> + <property name="use_underline">True</property> + <signal name="activate" handler="show_imageset_dialog" swapped="no"/> + </object> + </child> + </object> + </child> + </object> + </child> + <child> + <object class="GtkMenuItem" id="menuitem13"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="use_action_appearance">False</property> + <property name="label" translatable="yes">_Help</property> + <property name="use_underline">True</property> + <child type="submenu"> + <object class="GtkMenu" id="menu4"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkMenuItem" id="menuitem14"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="use_action_appearance">False</property> + <property name="label" translatable="yes">_About</property> + <property name="use_underline">True</property> + <signal name="activate" handler="show_about_dialog" swapped="no"/> + </object> + </child> + </object> + </child> + </object> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkHBox" id="hbox1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <child> + <object class="GtkVButtonBox" id="vbuttonbox1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="layout_style">start</property> + <child> + <object class="GtkLabel" id="label2"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Clientdata folder</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkFileChooserButton" id="datafcbutton"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="action">select-folder</property> + <property name="title" translatable="yes">Clientdata folder</property> + <signal name="selection-changed" handler="data_folder_set_callback" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">1</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label1"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">XML source file</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">2</property> + </packing> + </child> + <child> + <object class="GtkFileChooserButton" id="xmlfcbutton"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="dialog">fcdialog1</property> + <property name="title" translatable="yes">Select XML file</property> + <signal name="file-set" handler="open_xml_file" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">4</property> + </packing> + </child> + <child> + <object class="GtkButton" id="xmlfobutton"> + <property name="label">gtk-open</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> + <property name="use_stock">True</property> + <signal name="clicked" handler="open_xml_file" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">5</property> + </packing> + </child> + <child> + <object class="GtkButton" id="xmlfsbutton"> + <property name="label">gtk-save</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> + <property name="use_stock">True</property> + <signal name="clicked" handler="xml_file_save_button_callback" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">5</property> + </packing> + </child> + <child> + <object class="GtkButton" id="button3"> + <property name="label" translatable="yes">Parse XML Buffer</property> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="receives_default">True</property> + <property name="use_action_appearance">False</property> + <signal name="clicked" handler="parse_xml_buffer" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">7</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label3"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Imagesets</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">7</property> + </packing> + </child> + <child> + <object class="GtkComboBoxText" id="imagesetscbox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="model">liststore1</property> + <property name="active">0</property> + <signal name="changed" handler="imagesets_combo_box_changed_callback" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">9</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label4"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Actions</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">9</property> + </packing> + </child> + <child> + <object class="GtkComboBoxText" id="actionscbox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="active">0</property> + <signal name="changed" handler="actions_combo_box_changed_callback" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">11</property> + </packing> + </child> + <child> + <object class="GtkLabel" id="label5"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="label" translatable="yes">Directions</property> + <attributes> + <attribute name="weight" value="bold"/> + </attributes> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">11</property> + </packing> + </child> + <child> + <object class="GtkComboBoxText" id="animationscbox"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="active">0</property> + <signal name="changed" handler="animations_combo_box_changed_callback" swapped="no"/> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">34</property> + </packing> + </child> + </object> + <packing> + <property name="expand">False</property> + <property name="fill">False</property> + <property name="position">0</property> + </packing> + </child> + <child> + <object class="GtkVPaned" id="vpaned1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <child> + <object class="GtkDrawingArea" id="darea1"> + <property name="height_request">120</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <signal name="expose-event" handler="darea_expose_event" swapped="no"/> + </object> + <packing> + <property name="resize">True</property> + <property name="shrink">True</property> + </packing> + </child> + <child> + <object class="GtkScrolledWindow" id="scrolledwindow1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">automatic</property> + <property name="vscrollbar_policy">automatic</property> + <child> + <object class="GtkSourceView" id="source_view"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="left_margin">2</property> + <property name="right_margin">2</property> + <property name="show_line_numbers">True</property> + <property name="tab_width">4</property> + <property name="auto_indent">True</property> + <property name="indent_on_tab">False</property> + </object> + </child> + </object> + <packing> + <property name="resize">True</property> + <property name="shrink">True</property> + </packing> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">1</property> + </packing> + </child> + </object> + </child> + </object> +</interface> diff --git a/saedit/main.c b/saedit/main.c index c18b901..5c771b1 100644 --- a/saedit/main.c +++ b/saedit/main.c @@ -58,6 +58,9 @@ cairo_surface_t *get_grid_surface(int w, int h) { } gboolean darea_expose_event(GtkWidget *widget, GdkEventExpose *event, SAEInfo *sae_info) { + if (sae_info == NULL) + sae_info = gen_sae_info; + int width = widget->allocation.width, height = widget->allocation.height; @@ -102,14 +105,14 @@ void format_src_string(gchar *src) { strncpy(str, "\0", 1); } -void open_xml_file(GtkButton *button, gpointer buffer) { +void open_xml_file(GtkButton *button) { gtk_widget_set_sensitive(xml_file_open_button, TRUE); gtk_widget_set_sensitive(reload_menu_item, TRUE); gchar *buf; size_t len; g_file_get_contents(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(xml_file_chooser_button)), &buf, &len, NULL); if (g_utf8_validate(buf, len, NULL)) { - gtk_text_buffer_set_text((GtkTextBuffer *)buffer, buf, len); + gtk_text_buffer_set_text(source_buffer, buf, len); gtk_widget_set_sensitive(xml_file_save_button, TRUE); } else { gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(xml_file_chooser_button)); @@ -416,6 +419,9 @@ void parse_xml_text(gchar *text, SAEInfo *sae_info) { } void parse_xml_buffer(GtkWidget *button, GtkSourceBuffer *buffer) { + if (buffer == NULL) + buffer = source_buffer; + player = NULL; load_options(); diff --git a/saedit/main.h b/saedit/main.h index 5ef398b..99340cc 100644 --- a/saedit/main.h +++ b/saedit/main.h @@ -9,6 +9,9 @@ | | \*=======================================*/ +#ifndef MAIN_H +#define MAIN_H + const int MIN_WIDTH = 600; const int MIN_HEIGHT = 600; @@ -40,36 +43,38 @@ GdkPixbuf *icon = NULL; Options *paths; Keys *config; -static gchar *markup_bold(gchar *str); -static void format_src_string(gchar *src); -static void open_xml_file(GtkButton *button, gpointer buffer); -static void free_imagesets(SAEInfo *sae_info); -static void free_actions(SAEInfo *sae_info); -static void save_to_xml_file(gchar *filename); -static void data_folder_set_callback(GtkFileChooserButton *widget, gpointer data); -static void show_wrong_source_buffer_dialog(); -static void set_sprite_by_index(size_t index, SAEInfo *sae_info); -static void set_up_actions_by_imageset_name(gchar *imageset_name, SAEInfo *sae_info); -static gboolean set_up_imagesets(SAEInfo *sae_info); -static gboolean show_general_animation(SAEInfo *sae_info); -static gboolean set_up_action_by_name(const gchar *name, SAEInfo *sae_info); -static void actions_combo_box_changed_callback(GtkComboBox *widget, gpointer user_data); -static void animations_combo_box_changed_callback(GtkComboBox *widget, gpointer user_data); -static void set_up_imageset_by_name(const gchar* name, SAEInfo *sae_info); -static void imagesets_combo_box_changed_callback(GtkComboBox *widget, gpointer user_data); -static void parse_xml_buffer(GtkWidget *button, GtkSourceBuffer *buffer); -static void set_up_interface(); -static void show_about_dialog(); -static void show_imageset_dialog(); -static gboolean frame_image_button_press_event(GtkWidget *widget, GdkEventButton *button, int index); -static cairo_surface_t *get_grid_surface(int w, int h); -static gboolean darea_expose_event(GtkWidget *widget, GdkEventExpose *event, SAEInfo *sae_info); -static void load_config(); -static void save_config_and_quit(); -static void load_options(); -static void free_imageset(); -static void show_grid_menu_item_toggled(GtkCheckMenuItem *checkmenuitem, gpointer user_data); -static void open_menu_item_activate(GtkMenuItem *menuitem, GtkFileChooserDialog *fcdialog); -static void parse_xml_text(gchar *text, SAEInfo *sae_info); -static void show_animation(SAEInfo *sae_info); +gchar *markup_bold(gchar *str); +void format_src_string(gchar *src); +void open_xml_file(GtkButton *button); +void free_imagesets(SAEInfo *sae_info); +void free_actions(SAEInfo *sae_info); +void save_to_xml_file(gchar *filename); +void data_folder_set_callback(GtkFileChooserButton *widget, gpointer data); +void show_wrong_source_buffer_dialog(); +void set_sprite_by_index(size_t index, SAEInfo *sae_info); +void set_up_actions_by_imageset_name(gchar *imageset_name, SAEInfo *sae_info); +gboolean set_up_imagesets(SAEInfo *sae_info); +gboolean show_general_animation(SAEInfo *sae_info); +gboolean set_up_action_by_name(const gchar *name, SAEInfo *sae_info); +void actions_combo_box_changed_callback(GtkComboBox *widget, gpointer user_data); +void animations_combo_box_changed_callback(GtkComboBox *widget, gpointer user_data); +void set_up_imageset_by_name(const gchar* name, SAEInfo *sae_info); +void imagesets_combo_box_changed_callback(GtkComboBox *widget, gpointer user_data); +void parse_xml_buffer(GtkWidget *button, GtkSourceBuffer *buffer); +void set_up_interface(); +void show_about_dialog(); +void show_imageset_dialog(); +gboolean frame_image_button_press_event(GtkWidget *widget, GdkEventButton *button, int index); +cairo_surface_t *get_grid_surface(int w, int h); +gboolean darea_expose_event(GtkWidget *widget, GdkEventExpose *event, SAEInfo *sae_info); +void load_config(); +void save_config_and_quit(); +void load_options(); +void free_imageset(); +void show_grid_menu_item_toggled(GtkCheckMenuItem *checkmenuitem, gpointer user_data); +void open_menu_item_activate(GtkMenuItem *menuitem, GtkFileChooserDialog *fcdialog); +void parse_xml_text(gchar *text, SAEInfo *sae_info); +void show_animation(SAEInfo *sae_info); void free_animations(SAEInfo *sae_info); + +#endif |