diff options
-rw-r--r-- | saedit/interface.c | 4 | ||||
-rw-r--r-- | saedit/interface.ui | 62 | ||||
-rw-r--r-- | saedit/main.c | 59 | ||||
-rw-r--r-- | saedit/main.h | 9 | ||||
-rw-r--r-- | 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></property> <packing> <property name="expand">False</property> <property name="fill">True</property> - <property name="position">3</property> + <property name="position">4</property> </packing> </child> <child> - <object class="GtkButton" id="xmlfsbutton"> - <property name="label">gtk-save</property> + <object class="GtkButton" id="xmlfobutton"> + <property name="label">gtk-open</property> <property name="use_action_appearance">False</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"/> + <signal name="clicked" handler="open_xml_file" swapped="no"/> </object> <packing> <property name="expand">False</property> @@ -490,15 +490,15 @@ Reid Yaro <reidyaro@gmail.com></property> </packing> </child> <child> - <object class="GtkButton" id="xmlfobutton"> - <property name="label">gtk-open</property> + <object class="GtkButton" id="xmlfsbutton"> + <property name="label">gtk-save</property> <property name="use_action_appearance">False</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"/> + <signal name="clicked" handler="xml_file_save_button_callback" swapped="no"/> </object> <packing> <property name="expand">False</property> @@ -539,17 +539,17 @@ Reid Yaro <reidyaro@gmail.com></property> </child> <child> <object class="GtkComboBoxText" id="imagesetscbox"> - <property name="visible">True</property> - <property name="can_focus">False</property> - <property name="active">0</property> - <property name="model">liststore1</property> - <property name="entry_text_column">0</property> - <signal name="changed" handler="imagesets_combo_box_changed_callback" swapped="no"/> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="active">0</property> + <property name="entry_text_column">0</property> + <property name="model">liststore1</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">8</property> + <property name="position">9</property> </packing> </child> <child> @@ -572,14 +572,14 @@ Reid Yaro <reidyaro@gmail.com></property> <property name="visible">True</property> <property name="can_focus">False</property> <property name="active">0</property> - <property name="model">liststore2</property> - <property name="entry_text_column">0</property> + <property name="entry_text_column">0</property> + <property name="model">liststore2</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">10</property> + <property name="position">11</property> </packing> </child> <child> @@ -602,8 +602,8 @@ Reid Yaro <reidyaro@gmail.com></property> <property name="visible">True</property> <property name="can_focus">False</property> <property name="active">0</property> - <property name="model">liststore3</property> - <property name="entry_text_column">0</property> + <property name="entry_text_column">0</property> + <property name="model">liststore3</property> <signal name="changed" handler="animations_combo_box_changed_callback" swapped="no"/> </object> <packing> @@ -643,6 +643,7 @@ Reid Yaro <reidyaro@gmail.com></property> <object class="GtkToolbar" id="toolbar"> <property name="visible">True</property> <property name="can_focus">False</property> + <property name="sensitive">False</property> <child> <object class="GtkToolButton" id="toolbar-to-first"> <property name="use_action_appearance">False</property> @@ -652,6 +653,7 @@ Reid Yaro <reidyaro@gmail.com></property> <property name="label" translatable="yes">First frame</property> <property name="use_underline">True</property> <property name="stock_id">gtk-goto-first</property> + <signal name="clicked" handler="toolbar_to_first_clicked_callback" swapped="no"/> </object> <packing> <property name="expand">True</property> @@ -667,6 +669,7 @@ Reid Yaro <reidyaro@gmail.com></property> <property name="label" translatable="yes">Previous frame</property> <property name="use_underline">True</property> <property name="stock_id">gtk-go-back</property> + <signal name="clicked" handler="toolbar_prev_frame_clicked_callback" swapped="no"/> </object> <packing> <property name="expand">True</property> @@ -682,6 +685,23 @@ Reid Yaro <reidyaro@gmail.com></property> <property name="label" translatable="yes">Continue sequencing</property> <property name="use_underline">True</property> <property name="stock_id">gtk-media-play</property> + <signal name="clicked" handler="toolbar_play_clicked_callback" swapped="no"/> + </object> + <packing> + <property name="expand">True</property> + <property name="homogeneous">True</property> + </packing> + </child> + <child> + <object class="GtkToolButton" id="toolbar-pause"> + <property name="use_action_appearance">False</property> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="use_action_appearance">False</property> + <property name="label" translatable="yes">Pause sequencing</property> + <property name="use_underline">True</property> + <property name="stock_id">gtk-media-pause</property> + <signal name="clicked" handler="toolbar_pause_clicked_callback" swapped="no"/> </object> <packing> <property name="expand">True</property> @@ -697,6 +717,7 @@ Reid Yaro <reidyaro@gmail.com></property> <property name="label" translatable="yes">Next frame</property> <property name="use_underline">True</property> <property name="stock_id">gtk-go-forward</property> + <signal name="clicked" handler="toolbar_next_frame_clicked_callback" swapped="no"/> </object> <packing> <property name="expand">True</property> @@ -704,7 +725,7 @@ Reid Yaro <reidyaro@gmail.com></property> </packing> </child> <child> - <object class="GtkToolButton" id="toolbar-to-end"> + <object class="GtkToolButton" id="toolbar-to-last"> <property name="use_action_appearance">False</property> <property name="visible">True</property> <property name="can_focus">False</property> @@ -712,6 +733,7 @@ Reid Yaro <reidyaro@gmail.com></property> <property name="label" translatable="yes">Last frame</property> <property name="use_underline">True</property> <property name="stock_id">gtk-goto-last</property> + <signal name="clicked" handler="toolbar_to_last_clicked_callback" swapped="no"/> </object> <packing> <property name="expand">True</property> 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; } |