From 6440f8bc99e5b8c2bf86a853684278bcfd797d92 Mon Sep 17 00:00:00 2001 From: Vasily_Makarov Date: Wed, 8 Feb 2012 12:21:02 +0400 Subject: Added toolbar and corrected working with GList --- saedit/interface.c | 4 ++++ saedit/interface.ui | 62 ++++++++++++++++++++++++++++++++++++----------------- saedit/main.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++- saedit/main.h | 9 +++++++- saedit/sae.c | 4 +++- 5 files changed, 115 insertions(+), 23 deletions(-) diff --git a/saedit/interface.c b/saedit/interface.c index 0cee0e5..0adb153 100644 --- a/saedit/interface.c +++ b/saedit/interface.c @@ -11,6 +11,7 @@ GtkWidget *reload_menu_item = NULL; GtkWidget *find_dialog = NULL; +GtkWidget *toolbar = NULL; void find_menu_item_activate_callback(GtkWidget *menuitem, gpointer user_data) { gtk_dialog_run(GTK_DIALOG(find_dialog)); @@ -88,6 +89,9 @@ void set_up_interface() { //Setup GtkDrawingArea darea = GTK_WIDGET(gtk_builder_get_object(builder, "darea1")); + //Setup GtkToolbar + toolbar = GTK_WIDGET(gtk_builder_get_object(builder, "toolbar")); + 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")); diff --git a/saedit/interface.ui b/saedit/interface.ui index 5c21d81..a1321d0 100644 --- a/saedit/interface.ui +++ b/saedit/interface.ui @@ -469,19 +469,19 @@ Reid Yaro <reidyaro@gmail.com> False True - 3 + 4 - - gtk-save + + gtk-open False True True True False True - + False @@ -490,15 +490,15 @@ Reid Yaro <reidyaro@gmail.com> - - gtk-open + + gtk-save False True True True False True - + False @@ -539,17 +539,17 @@ Reid Yaro <reidyaro@gmail.com> - True - False - 0 - liststore1 - 0 - + True + False + 0 + 0 + liststore1 + False False - 8 + 9 @@ -572,14 +572,14 @@ Reid Yaro <reidyaro@gmail.com> True False 0 - liststore2 - 0 + 0 + liststore2 False False - 10 + 11 @@ -602,8 +602,8 @@ Reid Yaro <reidyaro@gmail.com> True False 0 - liststore3 - 0 + 0 + liststore3 @@ -643,6 +643,7 @@ Reid Yaro <reidyaro@gmail.com> True False + False False @@ -652,6 +653,7 @@ Reid Yaro <reidyaro@gmail.com> First frame True gtk-goto-first + True @@ -667,6 +669,7 @@ Reid Yaro <reidyaro@gmail.com> Previous frame True gtk-go-back + True @@ -682,6 +685,23 @@ Reid Yaro <reidyaro@gmail.com> Continue sequencing True gtk-media-play + + + + True + True + + + + + False + True + False + False + Pause sequencing + True + gtk-media-pause + True @@ -697,6 +717,7 @@ Reid Yaro <reidyaro@gmail.com> Next frame True gtk-go-forward + True @@ -704,7 +725,7 @@ Reid Yaro <reidyaro@gmail.com> - + False True False @@ -712,6 +733,7 @@ Reid Yaro <reidyaro@gmail.com> Last frame True gtk-goto-last + True diff --git a/saedit/main.c b/saedit/main.c index 87f52a4..ed3c244 100644 --- a/saedit/main.c +++ b/saedit/main.c @@ -130,6 +130,7 @@ void free_imageset(SAEInfo *sae_info) { sae_info->imageset = imageset_new(); sae_info->ground = sae_info_ground_new(); gtk_widget_set_sensitive(imageset_preview_menu_item, FALSE); + gtk_widget_set_sensitive(toolbar, FALSE); } void free_actions(SAEInfo *sae_info) { @@ -215,6 +216,56 @@ void open_menu_item_activate_callback(GtkMenuItem *menuitem, GtkFileChooserDialo gtk_dialog_run(GTK_DIALOG(fcdialog)); } +//>Toolbar callbacks +void toolbar_to_first_clicked_callback(GtkToolButton *toolbutton, gpointer user_data) { + gen_sae_info->animation = g_list_first(gen_sae_info->animation); + Frame *sprite = gen_sae_info->animation->data; + gen_sae_info->sprite = sprite; + gtk_widget_queue_draw(darea); +} + +void toolbar_prev_frame_clicked_callback(GtkToolButton *toolbutton, gpointer user_data) { + GList *prev = g_list_previous(gen_sae_info->animation); + if (prev == NULL) + return; + gen_sae_info->animation = prev; + Frame *sprite = gen_sae_info->animation->data; + gen_sae_info->sprite = sprite; + gtk_widget_queue_draw(darea); +} + +void toolbar_play_clicked_callback(GtkToolButton *toolbutton, gpointer user_data) { + show_animation(gen_sae_info); +} + +void toolbar_pause_clicked_callback(GtkToolButton *toolbutton, gpointer user_data) { + int tag = gen_sae_info->anim_tag; + if (tag > 0) { + kill_timeout(tag); + GList *prev = g_list_previous(gen_sae_info->animation); + if (prev == NULL) + prev = g_list_last(gen_sae_info->animation); + gen_sae_info->animation = prev; + } +} + +void toolbar_next_frame_clicked_callback(GtkToolButton *toolbutton, gpointer user_data) { + GList *next = g_list_next(gen_sae_info->animation); + if (next == NULL) + return; + gen_sae_info->animation = next; + Frame *sprite = gen_sae_info->animation->data; + gen_sae_info->sprite = sprite; + gtk_widget_queue_draw(darea); +} + +void toolbar_to_last_clicked_callback(GtkToolButton *toolbutton, gpointer user_data) { + gen_sae_info->animation = g_list_last(gen_sae_info->animation); + Frame *sprite = gen_sae_info->animation->data; + gen_sae_info->sprite = sprite; + gtk_widget_queue_draw(darea); +} + //Dialogs void show_about_dialog() { @@ -320,7 +371,12 @@ void show_animation(SAEInfo *sae_info) { Frame *sprite = sae_info->animation->data; sae_info->sprite = sprite; gtk_widget_queue_draw(darea); - sae_info->animation = sae_info->animation->next; + + GList *next = g_list_next(sae_info->animation); + if (next == NULL) + next = g_list_first(sae_info->animation); + + sae_info->animation = next; sae_info->anim_tag = g_timeout_add(sprite->delay, (GSourceFunc)show_animation, sae_info); } @@ -408,6 +464,7 @@ void set_up_imageset_by_name(const gchar *name, SAEInfo *sae_info) { } gtk_widget_set_sensitive(imageset_preview_menu_item, TRUE); + gtk_widget_set_sensitive(toolbar, TRUE); sae_info->imageset->spriteset_width = gdk_pixbuf_get_width(sae_info->imageset->spriteset); sae_info->imageset->spriteset_height = gdk_pixbuf_get_height(sae_info->imageset->spriteset); diff --git a/saedit/main.h b/saedit/main.h index 059e091..a02fd3a 100644 --- a/saedit/main.h +++ b/saedit/main.h @@ -84,8 +84,16 @@ void show_wrong_source_buffer_dialog(); void show_grid_menu_item_toggled_callback(GtkCheckMenuItem *checkmenuitem, gpointer user_data); void actions_combo_box_changed_callback(GtkComboBoxText *widget, gpointer user_data); void imagesets_combo_box_changed_callback(GtkComboBoxText *widget, gpointer user_data); +void animations_combo_box_changed_callback(GtkComboBoxText *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); +//>Toolbar callbacks +void toolbar_to_first_clicked_callback(GtkToolButton *toolbutton, gpointer user_data); +void toolbar_prev_frame_clicked_callback(GtkToolButton *toolbutton, gpointer user_data); +void toolbar_play_clicked_callback(GtkToolButton *toolbutton, gpointer user_data); +void toolbar_pause_clicked_callback(GtkToolButton *toolbutton, gpointer user_data); +void toolbar_next_frame_clicked_callback(GtkToolButton *toolbutton, gpointer user_data); +void toolbar_to_last_clicked_callback(GtkToolButton *toolbutton, gpointer user_data); //Dialogs void show_imageset_dialog(); @@ -96,7 +104,6 @@ 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 animations_combo_box_changed_callback(GtkComboBoxText *widget, gpointer user_data); void set_up_imageset_by_name(const gchar* name, SAEInfo *sae_info); void parse_xml_buffer(GtkWidget *button, GtkSourceBuffer *buffer); void set_up_interface(); diff --git a/saedit/sae.c b/saedit/sae.c index 0501269..bb57bd5 100644 --- a/saedit/sae.c +++ b/saedit/sae.c @@ -127,7 +127,9 @@ gboolean set_up_animation_by_direction(SAEInfo *sae_info, const gchar *direction } if (sae_info->animation == NULL) return FALSE; - if (count > 1) + /*if (count > 1) { g_list_last(sae_info->animation)->next = g_list_first(sae_info->animation); + g_list_first(sae_info->animation)->prev = g_list_last(sae_info->animation); + }*/ return TRUE; } -- cgit v1.2.3-70-g09d2