summaryrefslogtreecommitdiff
path: root/saedit
diff options
context:
space:
mode:
authorVasily_Makarov <danilka.pro@gmail.com>2011-06-14 13:05:53 +0400
committerVasily_Makarov <danilka.pro@gmail.com>2011-06-14 13:05:53 +0400
commit34dbe2ca8daae2595ee6ff37632a15e68fcc7fc2 (patch)
treec8bc255e86da5efdb56a7e331c9b53602c6b92a4 /saedit
parent58178671d0d219b337cd7a6195a6d1d9e5c05407 (diff)
downloadtools-34dbe2ca8daae2595ee6ff37632a15e68fcc7fc2.tar.gz
tools-34dbe2ca8daae2595ee6ff37632a15e68fcc7fc2.tar.bz2
tools-34dbe2ca8daae2595ee6ff37632a15e68fcc7fc2.tar.xz
tools-34dbe2ca8daae2595ee6ff37632a15e68fcc7fc2.zip
saedit: Update
Diffstat (limited to 'saedit')
-rw-r--r--saedit/interface.h2
-rw-r--r--saedit/main.c61
-rw-r--r--saedit/main.h31
-rwxr-xr-xsaedit/saeditbin457582 -> 457431 bytes
-rw-r--r--saedit/search.h5
5 files changed, 45 insertions, 54 deletions
diff --git a/saedit/interface.h b/saedit/interface.h
index 7f9420d..6ad1309 100644
--- a/saedit/interface.h
+++ b/saedit/interface.h
@@ -90,7 +90,7 @@ void set_up_interface() {
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_window), NULL);
+ 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");
diff --git a/saedit/main.c b/saedit/main.c
index 769b55f..25b605f 100644
--- a/saedit/main.c
+++ b/saedit/main.c
@@ -108,8 +108,12 @@ void open_xml_file(GtkButton *button, gpointer buffer) {
gchar *buf;
size_t len;
g_file_get_contents(gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(xml_file_chooser_button)), &buf, &len, NULL);
- gtk_text_buffer_set_text((GtkTextBuffer *)buffer, buf, len);
- gtk_widget_set_sensitive(xml_file_save_button, TRUE);
+ if (g_utf8_validate(buf, len, NULL)) {
+ gtk_text_buffer_set_text((GtkTextBuffer *)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));
+ }
}
void free_imagesets(SAEInfo *sae_info) {
@@ -149,7 +153,7 @@ void save_to_xml_file(GtkButton *button, gpointer buffer) {
}
void data_folder_set_handler(GtkFileChooserButton *widget, gpointer data) {
- config->clientdata_folder = g_strjoin(SEPARATOR_SLASH, gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(data_folder_chooser_button)), POSTFIX_FOLDER, NULL);
+ 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)));
}
@@ -273,22 +277,7 @@ void show_animation(SAEInfo *sae_info) {
return FALSE;
}
-GList *merge_animations(SAEInfo *sae_info_bottom, SAEInfo *sae_info_top) {
- int time_top = 0, time_bottom = 0;
-}
-
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;
@@ -447,7 +436,7 @@ void set_up_imageset_by_name(const gchar *name, SAEInfo *sae_info) {
gchar *src = xml_node_get_attr_value(sae_info->imageset->node, "src");
format_src_string(src);
- gchar *datapath = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(data_folder_chooser_button));
+ gchar *datapath = config->clientdata_folder;
gchar *path = g_strjoin(SEPARATOR_SLASH, datapath, src, NULL);
sae_info->imageset->spriteset = gdk_pixbuf_new_from_file(path, NULL);
@@ -499,7 +488,7 @@ void imagesets_combo_box_changed_handler(GtkComboBox *widget, gpointer user_data
void load_options() {
paths->sprites = NULL;
- gchar *datapath = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(data_folder_chooser_button));
+ gchar *datapath = config->clientdata_folder;
gchar *path = g_strjoin(SEPARATOR_SLASH, datapath, "paths.xml", NULL);
XMLNode *node = ibus_xml_parse_file(path);
if (node != NULL) {
@@ -591,19 +580,16 @@ gboolean frame_image_button_press_event(GtkWidget *widget, GdkEventButton *butto
return FALSE;
}
-void show_imageset_window() {
+void show_imageset_dialog() {
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);
- gtk_widget_set_size_request(iwin, IMAGESET_PREVIEW_WINDOW_WIDTH, IMAGESET_PREVIEW_WINDOW_HEIGHT);
- gtk_widget_realize(win);
+ 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 *vbox = gtk_vbox_new(TRUE, 0);
GtkWidget *hbox = NULL;
GtkWidget *image = NULL;
GtkWidget *event_box = NULL;
@@ -611,7 +597,7 @@ void show_imageset_window() {
int x, y;
for (y = 0; y < h; y++) {
hbox = gtk_hbox_new(TRUE, 0);
- gtk_box_pack_start(GTK_BOX(vbox), hbox, TRUE, 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);
@@ -622,8 +608,7 @@ void show_imageset_window() {
gtk_container_add(GTK_CONTAINER(event_box), image);
}
}
- gtk_container_add(GTK_CONTAINER(iwin), vbox);
- gtk_widget_show_all(iwin);
+ gtk_widget_show_all(dialog);
}
void load_config() {
@@ -643,9 +628,17 @@ void load_config() {
void save_config_and_quit() {
GKeyFile *key_file = g_key_file_new();
- g_key_file_set_value(key_file, "General", "ClientdataFolder", config->clientdata_folder);
+ gchar *fuck = g_key_file_to_data(key_file, NULL, NULL);
+ g_key_file_set_value(key_file, "General", "ClientdataFolder",
+ g_strjoin(SEPARATOR_SLASH,
+ config->clientdata_folder,
+ POSTFIX_FOLDER,
+ NULL));
g_key_file_set_boolean(key_file, "General", "ShowGrid", config->show_grid);
- g_file_set_contents(g_strjoin(SEPARATOR_SLASH, g_get_user_config_dir(), FILE_CONFIG, NULL), g_key_file_to_data(key_file, NULL, NULL), -1, NULL);
+ g_file_set_contents(g_strjoin(SEPARATOR_SLASH, g_get_user_config_dir(), FILE_CONFIG, NULL),
+ g_key_file_to_data(key_file, NULL, NULL),
+ -1,
+ NULL);
g_key_file_free(key_file);
gtk_main_quit();
}
diff --git a/saedit/main.h b/saedit/main.h
index afa5a48..3afe623 100644
--- a/saedit/main.h
+++ b/saedit/main.h
@@ -84,6 +84,20 @@ typedef struct {
int offsetY;
} SAEInfo;
+static GdkPixbuf *sae_info_ground_new() {
+ GdkPixbuf *ground = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, GRID_SIZE * 3, GRID_SIZE * 3);
+ gdk_pixbuf_fill(ground, 0x00000000);
+ return ground;
+}
+
+static SAEInfo *sae_info_new() {
+ SAEInfo *res = g_new0(SAEInfo, 1);
+ res->ground = sae_info_ground_new();
+ res->sprite = frame_new(-1, 0, 0, 0);
+ res->imageset = imageset_info_new();
+ return res;
+}
+
typedef struct {
GList *sub_nodes;
@@ -139,21 +153,6 @@ static Keys *keys_new() {
return res;
}
-static GdkPixbuf *sae_info_ground_new() {
- GdkPixbuf *ground = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, GRID_SIZE * 3, GRID_SIZE * 3);
- gdk_pixbuf_fill(ground, 0x00000000);
- return ground;
-}
-
-static SAEInfo *sae_info_new() {
- SAEInfo *res = g_new0(SAEInfo, 1);
- res->ground = sae_info_ground_new();
- res->sprite = frame_new(-1, 0, 0, 0);
- res->imageset = imageset_info_new();
- return res;
-}
-
-
GtkWidget *win = NULL;
GtkWidget *darea = NULL;
GtkWidget *data_folder_chooser_button = NULL;
@@ -203,7 +202,7 @@ static void imagesets_combo_box_changed_handler(GtkComboBox *widget, gpointer us
static void parse_xml_buffer(GtkWidget *button, GtkSourceBuffer *buffer);
static void set_up_interface();
static void show_about_dialog();
-static void show_imageset_window();
+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);
diff --git a/saedit/saedit b/saedit/saedit
index 8d0488f..0a9f3f2 100755
--- a/saedit/saedit
+++ b/saedit/saedit
Binary files differ
diff --git a/saedit/search.h b/saedit/search.h
index e08a448..eacdc56 100644
--- a/saedit/search.h
+++ b/saedit/search.h
@@ -50,11 +50,10 @@ static GtkWidget *show_find_dialog() {
GTK_STOCK_FIND,
GTK_RESPONSE_NONE,
NULL);
+ gtk_widget_set_size_request(dialog, 240, 80);
+ gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
content_area = gtk_dialog_get_content_area(GTK_DIALOG(dialog));
- label = gtk_label_new(_("Text:"));
- gtk_container_add(GTK_CONTAINER(content_area), label);
-
entry = gtk_entry_new();
gtk_container_add(GTK_CONTAINER(content_area), entry);
find_entry = entry;