summaryrefslogtreecommitdiff
path: root/saedit
diff options
context:
space:
mode:
Diffstat (limited to 'saedit')
-rw-r--r--saedit/config.c4
-rw-r--r--saedit/config.h5
-rw-r--r--saedit/interface.c (renamed from saedit/interface.h)23
-rw-r--r--saedit/interface.ui176
-rw-r--r--saedit/main.c226
-rw-r--r--saedit/main.h51
-rw-r--r--saedit/sae.c4
-rw-r--r--saedit/sae.h5
-rw-r--r--saedit/search.c34
-rw-r--r--saedit/search.h10
-rw-r--r--saedit/xml.c3
-rw-r--r--saedit/xml.h4
12 files changed, 359 insertions, 186 deletions
diff --git a/saedit/config.c b/saedit/config.c
index c514e26..98a1325 100644
--- a/saedit/config.c
+++ b/saedit/config.c
@@ -9,10 +9,6 @@
| |
\*=======================================*/
-#include <glib.h>
-#include <ibusxml.h>
-#include "common.h"
-#include "xml.h"
#include "config.h"
Options *config_options_new() {
diff --git a/saedit/config.h b/saedit/config.h
index c8904d5..e7c5fb5 100644
--- a/saedit/config.h
+++ b/saedit/config.h
@@ -12,6 +12,11 @@
#ifndef CONFIG_H
#define CONFIG_H
+#include <glib.h>
+#include <ibusxml.h>
+#include "common.h"
+#include "xml.h"
+
#define OPTION_SPRITES_DEFAULT "graphics/sprites/"
#define KEY_SHOW_GRID_DEFAULT TRUE
diff --git a/saedit/interface.h b/saedit/interface.c
index c2a4e2f..8238416 100644
--- a/saedit/interface.h
+++ b/saedit/interface.c
@@ -9,12 +9,11 @@
| |
\*=======================================*/
-#include "main.h"
-
GtkWidget *reload_menu_item = NULL;
+GtkWidget *find_dialog = NULL;
void find_menu_item_activate_callback(GtkWidget *menuitem, gpointer user_data) {
- search_find_dialog_show(win, source_view);
+ gtk_dialog_run(GTK_DIALOG(find_dialog));
}
void save_dialog_response_callback(GtkWidget *dialog, gint response_id, gpointer user_data) {
@@ -57,6 +56,8 @@ void file_new() {
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);
+
+ free_lists(gen_sae_info);
}
void set_up_interface() {
@@ -65,6 +66,7 @@ void set_up_interface() {
gtk_builder_add_from_file(builder, "interface.ui", NULL);
gtk_builder_connect_signals(builder, NULL);
+ //Setup main window
win = GTK_WIDGET(gtk_builder_get_object(builder, "win_main"));
//Setup GtkSourceView
@@ -73,8 +75,9 @@ void set_up_interface() {
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));
+ search_init(source_view);
- //Setup ScrolledWindow
+ //Setup GtkScrolledWindow
GtkWidget *scrolled_window = NULL;
scrolled_window = GTK_WIDGET(gtk_builder_get_object(builder, "scrolledwindow1"));
gtk_scrolled_window_set_hadjustment(GTK_SCROLLED_WINDOW(scrolled_window),
@@ -85,20 +88,30 @@ void set_up_interface() {
//Setup GtkDrawingArea
darea = GTK_WIDGET(gtk_builder_get_object(builder, "darea1"));
-
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"));
data_folder_chooser_button = GTK_WIDGET(gtk_builder_get_object(builder, "datafcbutton"));
xml_file_chooser_button = GTK_WIDGET(gtk_builder_get_object(builder, "xmlfcbutton"));
+ xml_file_open_button = GTK_WIDGET(gtk_builder_get_object(builder, "xmlfobutton"));
+ xml_file_save_button = GTK_WIDGET(gtk_builder_get_object(builder, "xmlfsbutton"));
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"));
+ //Setup GtkAboutDialog
+ about_dialog = GTK_WIDGET(gtk_builder_get_object(builder, "about_dialog"));
+
+ //Setup Find dialog
+ find_dialog = GTK_WIDGET(gtk_builder_get_object(builder, "find_dialog"));
+ gtk_widget_hide(find_dialog);
+
file_new();
gtk_widget_show_all(win);
gtk_widget_show_all(source_view);
+
+ g_object_unref(builder);
}
diff --git a/saedit/interface.ui b/saedit/interface.ui
index 594c111..73193ee 100644
--- a/saedit/interface.ui
+++ b/saedit/interface.ui
@@ -3,6 +3,44 @@
<requires lib="gtk+" version="2.24"/>
<!-- interface-requires gtksourceview 0.0 -->
<!-- interface-naming-policy project-wide -->
+ <object class="GtkAboutDialog" id="about_dialog">
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="window_position">center</property>
+ <property name="icon">icon.svg</property>
+ <property name="type_hint">dialog</property>
+ <property name="transient_for">win_main</property>
+ <property name="program_name">Sprite Animation Editor</property>
+ <property name="version">⍺0.1.1</property>
+ <property name="copyright" translatable="yes">Copyleft ↄ Vasily_Makarov 2011</property>
+ <property name="comments" translatable="yes">Sprite Animation Editor could be used to edit animations from Evol and The Mana World projects</property>
+ <property name="authors">Dan "Vasily_Makarov" Sagunov &lt;danilka.pro@gmail.com&gt;
+Reid Yaro &lt;reidyaro@gmail.com&gt;</property>
+ <property name="logo">icon.svg</property>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="dialog-vbox3">
+ <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_area3">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ </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>
+ </object>
<object class="GtkFileChooserDialog" id="fcdialog1">
<property name="can_focus">False</property>
<property name="border_width">5</property>
@@ -66,6 +104,94 @@
<action-widget response="0">button2</action-widget>
</action-widgets>
</object>
+ <object class="GtkDialog" id="find_dialog">
+ <property name="width_request">240</property>
+ <property name="height_request">80</property>
+ <property name="can_focus">False</property>
+ <property name="border_width">5</property>
+ <property name="title" translatable="yes">Find</property>
+ <property name="resizable">False</property>
+ <property name="destroy_with_parent">True</property>
+ <property name="type_hint">dialog</property>
+ <property name="skip_taskbar_hint">True</property>
+ <property name="skip_pager_hint">True</property>
+ <property name="deletable">False</property>
+ <property name="transient_for">win_main</property>
+ <signal name="response" handler="search_find_dialog_response_callback" object="find_dialog_entry" swapped="no"/>
+ <child internal-child="vbox">
+ <object class="GtkVBox" id="dialog-vbox4">
+ <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_area4">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="layout_style">end</property>
+ <child>
+ <object class="GtkButton" id="button4">
+ <property name="label">gtk-find</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="button5">
+ <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>
+ <object class="GtkEntry" id="find_dialog_entry">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="invisible_char">•</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="secondary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">True</property>
+ <property name="secondary_icon_sensitive">True</property>
+ </object>
+ <packing>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <placeholder/>
+ </child>
+ </object>
+ </child>
+ <action-widgets>
+ <action-widget response="-3">button4</action-widget>
+ <action-widget response="-6">button5</action-widget>
+ </action-widgets>
+ </object>
<object class="GtkListStore" id="liststore1">
<columns>
<!-- column-name text -->
@@ -118,7 +244,7 @@
<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"/>
+ <signal name="activate" handler="open_menu_item_activate_callback" object="fcdialog1" swapped="no"/>
</object>
</child>
<child>
@@ -215,7 +341,7 @@
<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"/>
+ <signal name="toggled" handler="show_grid_menu_item_toggled_callback" swapped="no"/>
</object>
</child>
<child>
@@ -329,7 +455,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">4</property>
+ <property name="position">3</property>
</packing>
</child>
<child>
@@ -345,7 +471,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">5</property>
+ <property name="position">4</property>
</packing>
</child>
<child>
@@ -365,6 +491,21 @@
</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="GtkButton" id="button3">
<property name="label" translatable="yes">Parse XML Buffer</property>
<property name="visible">True</property>
@@ -380,10 +521,10 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="label3">
+ <object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes">Imagesets</property>
+ <property name="label" translatable="yes">Actions</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
@@ -391,7 +532,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">7</property>
+ <property name="position">9</property>
</packing>
</child>
<child>
@@ -409,10 +550,10 @@
</packing>
</child>
<child>
- <object class="GtkLabel" id="label4">
+ <object class="GtkLabel" id="label5">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="label" translatable="yes">Actions</property>
+ <property name="label" translatable="yes">Directions</property>
<attributes>
<attribute name="weight" value="bold"/>
</attributes>
@@ -420,7 +561,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
- <property name="position">9</property>
+ <property name="position">11</property>
</packing>
</child>
<child>
@@ -437,21 +578,6 @@
</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>
diff --git a/saedit/main.c b/saedit/main.c
index 5c771b1..8385f60 100644
--- a/saedit/main.c
+++ b/saedit/main.c
@@ -9,22 +9,10 @@
| |
\*=======================================*/
-#include <stdlib.h>
-#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>
-
-#include "common.h"
-#include "xml.h"
-#include "config.h"
-#include "sae.h"
#include "main.h"
-#include "search.h"
-#include "interface.h"
+#include "interface.c"
+
+//Cairo functions
cairo_surface_t *get_grid_surface(int w, int h) {
cairo_surface_t *surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, (w + 2) * GRID_SIZE, (h + 2) * GRID_SIZE);
@@ -93,6 +81,8 @@ gboolean darea_expose_event(GtkWidget *widget, GdkEventExpose *event, SAEInfo *s
return FALSE;
}
+//String functions (common)
+
gchar *markup_bold(gchar *str) {
gchar *buffer[255];
g_sprintf(buffer, "<b>%s</b>", str);
@@ -105,6 +95,8 @@ void format_src_string(gchar *src) {
strncpy(str, "\0", 1);
}
+//File working
+
void open_xml_file(GtkButton *button) {
gtk_widget_set_sensitive(xml_file_open_button, TRUE);
gtk_widget_set_sensitive(reload_menu_item, TRUE);
@@ -117,8 +109,19 @@ void open_xml_file(GtkButton *button) {
} else {
gtk_file_chooser_unselect_all(GTK_FILE_CHOOSER(xml_file_chooser_button));
}
+
+ free_lists(gen_sae_info);
+}
+
+void save_to_xml_file(gchar *filename) {
+ 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(filename, gtk_text_buffer_get_text(source_buffer, &start, &end, NULL), -1, NULL);
}
+//SAEInfo functions (must be ported to sae.c)
+
void free_imagesets(SAEInfo *sae_info) {
free_imageset(sae_info);
sae_info->imagesets = NULL;
@@ -137,19 +140,32 @@ void free_actions(SAEInfo *sae_info) {
gtk_list_store_clear(GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(sae_info->actions_combo_box))));
}
-void save_to_xml_file(gchar *filename) {
- 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(filename, gtk_text_buffer_get_text(source_buffer, &start, &end, NULL), -1, NULL);
+void free_animations(SAEInfo *sae_info) {
+ sae_info->animations = NULL;
+
+ if (sae_info->animations_combo_box != NULL)
+ gtk_list_store_clear(GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(sae_info->animations_combo_box))));
+
+ kill_timeout(sae_info->anim_tag);
+ sae_info->anim_tag = 0;
+ sae_info->sprite = frame_new(-1, 0, 0, 0);
+ set_sprite_by_index(0, sae_info);
}
+void free_lists(SAEInfo *sae_info) {
+ free_imagesets(sae_info);
+ free_actions(sae_info);
+ free_animations(sae_info);
+}
+
+//Callbacks
+
void data_folder_set_callback(GtkFileChooserButton *widget, gpointer data) {
config->clientdata_folder = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(data_folder_chooser_button));
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(xml_file_chooser_button), gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget)));
}
-void show_grid_menu_item_toggled(GtkCheckMenuItem *checkmenuitem, gpointer user_data) {
+void show_grid_menu_item_toggled_callback(GtkCheckMenuItem *checkmenuitem, gpointer user_data) {
config->show_grid = gtk_check_menu_item_get_active(checkmenuitem);
gtk_widget_queue_draw(darea);
}
@@ -165,6 +181,77 @@ void show_wrong_source_buffer_dialog() {
gtk_widget_show_all(dialog);
}
+void actions_combo_box_changed_callback(GtkComboBox *widget, gpointer user_data) {
+ if (player != NULL)
+ set_up_action_by_name(gtk_combo_box_get_active_text(widget), player);
+ set_up_action_by_name(gtk_combo_box_get_active_text(widget), gen_sae_info);
+}
+
+void animations_combo_box_changed_callback(GtkComboBox *widget, gpointer user_data) {
+ set_up_animation_by_direction(gen_sae_info, gtk_combo_box_get_active_text(widget));
+ if (player != NULL) {
+ set_up_animation_by_direction(player, gtk_combo_box_get_active_text(widget));
+ show_animation(player);
+ }
+ show_animation(gen_sae_info);
+}
+
+void imagesets_combo_box_changed_callback(GtkComboBox *widget, gpointer user_data) {
+ if (gtk_combo_box_get_active_text(widget) != NULL)
+ set_up_imageset_by_name(gtk_combo_box_get_active_text(widget), gen_sae_info);
+}
+
+gboolean frame_image_button_press_event_callback(GtkWidget *widget, GdkEventButton *button, int index) {
+ gchar buf[10];
+ gint len = g_sprintf(buf, "%d", index);
+ gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(source_buffer), buf, len);
+ return FALSE;
+}
+
+void open_menu_item_activate_callback(GtkMenuItem *menuitem, GtkFileChooserDialog *fcdialog) {
+ gtk_dialog_run(fcdialog);
+}
+
+//Dialogs
+
+void show_about_dialog() {
+ gtk_dialog_run(about_dialog);
+ gtk_widget_hide(about_dialog);
+}
+
+void show_imageset_dialog() {
+ if (gen_sae_info->imageset->spriteset == NULL) return;
+ GtkWidget *dialog = gtk_dialog_new();
+ GtkWidget *content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
+ gtk_window_set_title(GTK_WINDOW(dialog), _("Imageset preview"));
+ gtk_window_set_transient_for(dialog, GTK_WINDOW(win));
+
+ int w = gen_sae_info->imageset->spriteset_width / gen_sae_info->imageset->width;
+ int h = gen_sae_info->imageset->spriteset_height / gen_sae_info->imageset->height;
+
+ GtkWidget *hbox = NULL;
+ GtkWidget *image = NULL;
+ GtkWidget *event_box = NULL;
+
+ int x, y;
+ for (y = 0; y < h; y++) {
+ hbox = gtk_hbox_new(TRUE, 0);
+ gtk_container_add(content_area, hbox);
+ for (x = 0; x < w; x++) {
+ event_box = gtk_event_box_new();
+ g_signal_connect(G_OBJECT(event_box), "button-press-event", G_CALLBACK(frame_image_button_press_event_callback), w * y + x);
+ gtk_box_pack_start(GTK_BOX(hbox), event_box, TRUE, TRUE, 0);
+
+ image = gtk_image_new_from_pixbuf(get_sprite_by_index(w * y + x, gen_sae_info));
+ gtk_widget_add_events(image, GDK_BUTTON_PRESS_MASK);
+ gtk_container_add(GTK_CONTAINER(event_box), image);
+ }
+ }
+ gtk_widget_show_all(dialog);
+}
+
+//Main functions
+
void set_sprite_by_index(size_t index, SAEInfo *sae_info) {
sae_info->sprite->pixbuf = get_sprite_by_index(index, sae_info);
gtk_widget_queue_draw(darea);
@@ -197,9 +284,7 @@ void set_up_actions_by_imageset_name(gchar *imageset_name, SAEInfo *sae_info) {
gboolean set_up_imagesets(SAEInfo *sae_info) {
GList *_imagesets_list = NULL;
- free_imagesets(sae_info);
- free_actions(sae_info);
- free_animations(sae_info);
+ free_lists(sae_info);
GList *list = sae_info->root->sub_nodes;
XMLNode *node = NULL;
while (TRUE) {
@@ -278,21 +363,6 @@ gboolean set_up_action_by_name(const gchar *name, SAEInfo *sae_info) {
return TRUE;
}
-void actions_combo_box_changed_callback(GtkComboBox *widget, gpointer user_data) {
- if (player != NULL)
- set_up_action_by_name(gtk_combo_box_get_active_text(widget), player);
- set_up_action_by_name(gtk_combo_box_get_active_text(widget), gen_sae_info);
-}
-
-void animations_combo_box_changed_callback(GtkComboBox *widget, gpointer user_data) {
- set_up_animation_by_direction(gen_sae_info, gtk_combo_box_get_active_text(widget));
- if (player != NULL) {
- set_up_animation_by_direction(player, gtk_combo_box_get_active_text(widget));
- show_animation(player);
- }
- show_animation(gen_sae_info);
-}
-
void set_up_imageset_by_name(const gchar *name, SAEInfo *sae_info) {
free_imageset(sae_info);
free_actions(sae_info);
@@ -370,11 +440,6 @@ void set_up_imageset_by_name(const gchar *name, SAEInfo *sae_info) {
set_sprite_by_index(0, sae_info);
}
-void imagesets_combo_box_changed_callback(GtkComboBox *widget, gpointer user_data) {
- if (gtk_combo_box_get_active_text(widget) != NULL)
- set_up_imageset_by_name(gtk_combo_box_get_active_text(widget), gen_sae_info);
-}
-
void load_options() {
gchar *datapath = config->clientdata_folder;
gchar *path = g_strjoin(SEPARATOR_SLASH, datapath, "paths.xml", NULL);
@@ -382,9 +447,7 @@ void load_options() {
}
void parse_xml_text(gchar *text, SAEInfo *sae_info) {
- free_imagesets(sae_info);
- free_actions(sae_info);
- free_animations(sae_info);
+ free_lists(sae_info);
XMLNode *_root_node = ibus_xml_parse_buffer(text);
sae_info->root = _root_node;
@@ -431,62 +494,6 @@ void parse_xml_buffer(GtkWidget *button, GtkSourceBuffer *buffer) {
parse_xml_text(gtk_text_iter_get_text(&beg, &end), gen_sae_info);
}
-void show_about_dialog() {
- gchar *authors[] = {"Dan Sagunov <danilka.pro@gmail.com>",
- "Reid Yaro <reidyaro@gmail.com>",
- NULL};
- gtk_show_about_dialog(GTK_WINDOW(win),
- "authors", authors,
- "comments", _("Sprite Animation Editor could be used to edit animations from Evol and The Mana World projects"),
- "copyright", "Copyleft \u2184 Vasily_Makarov 2011",
- "program-name", "Sprite Animation Editor",
- "version", "0.1 prealpha",
- "logo", icon,
- NULL);
-}
-
-void open_menu_item_activate(GtkMenuItem *menuitem, GtkFileChooserDialog *fcdialog) {
- gtk_dialog_run(fcdialog);
-}
-
-gboolean frame_image_button_press_event(GtkWidget *widget, GdkEventButton *button, int index) {
- gchar buf[10];
- gint len = g_sprintf(buf, "%d", index);
- gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(source_buffer), buf, len);
- return FALSE;
-}
-
-void show_imageset_dialog() {
- if (gen_sae_info->imageset->spriteset == NULL) return;
- GtkWidget *dialog = gtk_dialog_new();
- GtkWidget *content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
- gtk_window_set_title(GTK_WINDOW(dialog), _("Imageset preview"));
- gtk_window_set_transient_for(dialog, GTK_WINDOW(win));
-
- int w = gen_sae_info->imageset->spriteset_width / gen_sae_info->imageset->width;
- int h = gen_sae_info->imageset->spriteset_height / gen_sae_info->imageset->height;
-
- GtkWidget *hbox = NULL;
- GtkWidget *image = NULL;
- GtkWidget *event_box = NULL;
-
- int x, y;
- for (y = 0; y < h; y++) {
- hbox = gtk_hbox_new(TRUE, 0);
- gtk_container_add(content_area, hbox);
- for (x = 0; x < w; x++) {
- event_box = gtk_event_box_new();
- g_signal_connect(G_OBJECT(event_box), "button-press-event", G_CALLBACK(frame_image_button_press_event), w * y + x);
- gtk_box_pack_start(GTK_BOX(hbox), event_box, TRUE, TRUE, 0);
-
- image = gtk_image_new_from_pixbuf(get_sprite_by_index(w * y + x, gen_sae_info));
- gtk_widget_add_events(image, GDK_BUTTON_PRESS_MASK);
- gtk_container_add(GTK_CONTAINER(event_box), image);
- }
- }
- gtk_widget_show_all(dialog);
-}
-
void load_config() {
config_keys_load(config);
gtk_file_chooser_select_filename(GTK_FILE_CHOOSER(data_folder_chooser_button), config->clientdata_folder);
@@ -498,19 +505,6 @@ void save_config_and_quit() {
gtk_main_quit();
}
-
-void free_animations(SAEInfo *sae_info) {
- sae_info->animations = NULL;
-
- if (sae_info->animations_combo_box != NULL)
- gtk_list_store_clear(GTK_LIST_STORE(gtk_combo_box_get_model(GTK_COMBO_BOX(sae_info->animations_combo_box))));
-
- kill_timeout(sae_info->anim_tag);
- sae_info->anim_tag = 0;
- sae_info->sprite = frame_new(-1, 0, 0, 0);
- set_sprite_by_index(0, sae_info);
-}
-
int main(int argc, char *argv[]) {
gtk_init(&argc, &argv);
diff --git a/saedit/main.h b/saedit/main.h
index 99340cc..163a685 100644
--- a/saedit/main.h
+++ b/saedit/main.h
@@ -12,6 +12,20 @@
#ifndef MAIN_H
#define MAIN_H
+#include <stdlib.h>
+#include <gtk/gtk.h>
+#include <gtksourceview/gtksourceview.h>
+#include <gtksourceview/gtksourcelanguagemanager.h>
+#include <gtksourceview/gtksourceiter.h>
+#include <cairo.h>
+#include <glib/gi18n.h>
+
+#include "common.h"
+#include "xml.h"
+#include "config.h"
+#include "sae.h"
+#include "search.h"
+
const int MIN_WIDTH = 600;
const int MIN_HEIGHT = 600;
@@ -32,6 +46,7 @@ GtkWidget *xml_file_save_button = NULL;
GtkWidget *imageset_preview_menu_item = NULL;
GtkWidget *show_grid_menu_item = NULL;
GtkWidget *source_view = NULL;
+GtkWidget *about_dialog = NULL;
GtkSourceBuffer *source_buffer = NULL;
@@ -43,38 +58,50 @@ GdkPixbuf *icon = NULL;
Options *paths;
Keys *config;
+//Cairo functions
+cairo_surface_t *get_grid_surface(int w, int h);
+gboolean darea_expose_event(GtkWidget *widget, GdkEventExpose *event, SAEInfo *sae_info);
+
+//String functions (common)
gchar *markup_bold(gchar *str);
void format_src_string(gchar *src);
+
+//File working
void open_xml_file(GtkButton *button);
+void save_to_xml_file(gchar *filename);
+
+//SAEInfo functions
void free_imagesets(SAEInfo *sae_info);
void free_actions(SAEInfo *sae_info);
-void save_to_xml_file(gchar *filename);
+void free_animations(SAEInfo *sae_info);
+void free_imageset(SAEInfo *sae_info);
+
+//Callbacks
void data_folder_set_callback(GtkFileChooserButton *widget, gpointer data);
void show_wrong_source_buffer_dialog();
+void show_grid_menu_item_toggled_callback(GtkCheckMenuItem *checkmenuitem, gpointer user_data);
+void actions_combo_box_changed_callback(GtkComboBox *widget, gpointer user_data);
+void imagesets_combo_box_changed_callback(GtkComboBox *widget, gpointer user_data);
+void open_menu_item_activate_callback(GtkMenuItem *menuitem, GtkFileChooserDialog *fcdialog);
+gboolean frame_image_button_press_event_callback(GtkWidget *widget, GdkEventButton *button, int index);
+
+//Dialogs
+void show_imageset_dialog();
+void show_about_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
diff --git a/saedit/sae.c b/saedit/sae.c
index 17027ea..736e90d 100644
--- a/saedit/sae.c
+++ b/saedit/sae.c
@@ -9,10 +9,6 @@
| |
\*=======================================*/
-#include <gtk/gtk.h>
-#include <ibusxml.h>
-#include "common.h"
-#include "xml.h"
#include "sae.h"
void kill_timeout(guint tag) {
diff --git a/saedit/sae.h b/saedit/sae.h
index e89db25..b6867e3 100644
--- a/saedit/sae.h
+++ b/saedit/sae.h
@@ -12,6 +12,11 @@
#ifndef SAE_H
#define SAE_H
+#include <gtk/gtk.h>
+#include <ibusxml.h>
+#include "common.h"
+#include "xml.h"
+
void kill_timeout(guint tag);
typedef struct {
diff --git a/saedit/search.c b/saedit/search.c
index 041d972..f98063f 100644
--- a/saedit/search.c
+++ b/saedit/search.c
@@ -9,12 +9,9 @@
| |
\*=======================================*/
-#include <gtk/gtk.h>
-#include "common.h"
#include "search.h"
GtkWidget *search_text_view = NULL;
-GtkWidget *search_find_dialog_entry = NULL;
gchar *search_last_text = NULL;
gboolean search_find_text(gchar *text) {
@@ -28,11 +25,11 @@ gboolean search_find_text(gchar *text) {
GtkTextIter m_start, m_end, start;
gtk_text_buffer_get_selection_bounds(text_buffer, NULL, &start);
- found = gtk_source_iter_forward_search(&start, text, 0, &m_start, &m_end, NULL);
+ found = gtk_source_iter_forward_search(&start, text, GTK_SOURCE_SEARCH_CASE_INSENSITIVE, &m_start, &m_end, NULL);
if (!found) {
gtk_text_buffer_get_start_iter(text_buffer, &start);
- found = gtk_source_iter_forward_search(&start, text, 0, &m_start, &m_end, NULL);
+ found = gtk_source_iter_forward_search(&start, text, GTK_SOURCE_SEARCH_CASE_INSENSITIVE, &m_start, &m_end, NULL);
}
if (found) {
@@ -54,17 +51,25 @@ gboolean search_find_next() {
search_find_text(search_last_text);
}
-void search_find_dialog_response_callback(GtkDialog *dialog,
+void search_find_dialog_response_callback(GtkWidget *dialog,
gint response_id,
- gpointer user_data) {
- if (response_id != GTK_RESPONSE_ACCEPT)
- return;
+ gpointer entry) {
- if (!GTK_IS_TEXT_VIEW(search_text_view))
- return;
+ if (response_id == GTK_RESPONSE_CANCEL || response_id == GTK_RESPONSE_DELETE_EVENT)
+ gtk_widget_hide(dialog);
+ else {
- if (GTK_IS_ENTRY(search_find_dialog_entry))
- search_find_text(g_strdup(gtk_entry_get_text(GTK_ENTRY(search_find_dialog_entry))));
+ g_return_if_fail(response_id == GTK_RESPONSE_ACCEPT);
+ g_return_if_fail(GTK_IS_TEXT_VIEW(search_text_view));
+ g_return_if_fail(GTK_IS_ENTRY(GTK_ENTRY(entry)));
+
+ search_find_text(g_strdup(gtk_entry_get_text(GTK_ENTRY(entry))));
+
+ }
+}
+
+void search_init(GtkWidget *text_view) {
+ search_text_view = text_view;
}
void search_find_dialog_show(GtkWindow *parent,
@@ -91,10 +96,9 @@ void search_find_dialog_show(GtkWindow *parent,
g_signal_connect(dialog,
"response",
G_CALLBACK(search_find_dialog_response_callback),
- NULL);
+ entry);
search_text_view = text_view;
- search_find_dialog_entry = entry;
gtk_dialog_run(dialog);
}
diff --git a/saedit/search.h b/saedit/search.h
index 5d2b5ff..350bc70 100644
--- a/saedit/search.h
+++ b/saedit/search.h
@@ -12,9 +12,15 @@
#ifndef SEARCH_H
#define SEARCH_H
+#include <gtk/gtk.h>
+#include <gtksourceview/gtksourceiter.h>
+#include "common.h"
+
+void search_init(GtkWidget *text_view);
gboolean search_find_text(gchar *text);
gboolean search_find_next();
-void search_find_dialog_show(GtkWindow *parent,
- GtkWidget *text_view);
+void search_find_dialog_response_callback(GtkWidget *dialog,
+ gint response_id,
+ gpointer entry);
#endif
diff --git a/saedit/xml.c b/saedit/xml.c
index 6120d5c..2968082 100644
--- a/saedit/xml.c
+++ b/saedit/xml.c
@@ -9,9 +9,6 @@
| |
\*=======================================*/
-#include <glib.h>
-#include <ibusxml.h>
-#include "common.h"
#include "xml.h"
gchar **xml_attr_new(gchar *name, gchar *value) {
diff --git a/saedit/xml.h b/saedit/xml.h
index 02bd207..2a8875e 100644
--- a/saedit/xml.h
+++ b/saedit/xml.h
@@ -11,6 +11,10 @@
#ifndef XML_H
#define XML_H
+#include <glib.h>
+#include <ibusxml.h>
+#include "common.h"
+
gchar **xml_attr_new(gchar *name, gchar *value);
gchar *xml_node_get_attr_value(XMLNode *node, gchar *attr_name);
gint xml_node_compare_with_name_func(gconstpointer a, gconstpointer b);