Commit 33429e9f authored by Sven Neumann's avatar Sven Neumann Committed by Sven Neumann
Browse files

applied patch from Paul Seidel with further improvements to the playback

2007-06-20  Sven Neumann  <sven@gimp.org>

	* plug-ins/common/animationplay.c: applied patch from Paul 
Seidel
	with further improvements to the playback speed control (bug 
#338380).


svn path=/trunk/; revision=22809
parent 3f747cf0
2007-06-20 Sven Neumann <sven@gimp.org>
* plug-ins/common/animationplay.c: applied patch from Paul Seidel
with further improvements to the playback speed control (bug #338380).
2007-06-20 Sven Neumann <sven@gimp.org>
 
* app/base/tile-pyramid.c (tile_pyramid_write_quarter): added missing
......@@ -71,6 +71,8 @@ static void rewind_callback (GtkAction *action);
static void speed_up_callback (GtkAction *action);
static void speed_down_callback (GtkAction *action);
static void speed_reset_callback (GtkAction *action);
static void speedcombo_changed (GtkWidget *scombo,
gpointer data);
static gboolean repaint_sda (GtkWidget *darea,
GdkEventExpose *event,
gpointer data);
......@@ -82,7 +84,8 @@ static void render_frame (gint32 whichframe);
static void show_frame (void);
static void total_alpha_preview (guchar *ptr);
static void init_preview (void);
static void update_statusbar (void);
static void update_combobox (void);
static gdouble get_duration_factor (gint index);
/* tag util functions*/
......@@ -129,7 +132,7 @@ static guint timer = 0;
static GimpImageBaseType imagetype;
static guchar *palette;
static gint ncolours;
static gdouble duration_factor = 1.0;
static gint duration_index = 3;
/* for shaping */
......@@ -142,9 +145,7 @@ static gchar *shape_preview_mask = NULL;
static GtkWidget *shape_window = NULL;
static GdkWindow *root_win = NULL;
static gboolean detached = FALSE;
static GtkWidget *statusbar = NULL;
static guint message_context_id = 0;
static GtkWidget *speedcombo = NULL;
MAIN ()
......@@ -564,12 +565,16 @@ build_dialog (GimpImageBaseType basetype,
{
GtkWidget *toolbar;
GtkWidget *frame;
GtkWidget *main_vbox;
GtkWidget *vbox;
GtkWidget *hbox;
GtkWidget *abox;
GtkWidget *ebox;
GtkToolItem *item;
GtkAction *action;
GdkCursor *cursor;
gchar *name;
gint index;
gimp_ui_init (PLUG_IN_BINARY, TRUE);
......@@ -592,12 +597,12 @@ build_dialog (GimpImageBaseType basetype,
ui_manager = ui_manager_new (window);
vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (window), vbox);
gtk_widget_show (vbox);
main_vbox = gtk_vbox_new (FALSE, 0);
gtk_container_add (GTK_CONTAINER (window), main_vbox);
gtk_widget_show (main_vbox);
toolbar = gtk_ui_manager_get_widget (ui_manager, "/anim-play-toolbar");
gtk_box_pack_start (GTK_BOX (vbox), toolbar, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (main_vbox), toolbar, FALSE, FALSE, 0);
gtk_widget_show (toolbar);
item =
......@@ -606,6 +611,10 @@ build_dialog (GimpImageBaseType basetype,
gtk_separator_tool_item_set_draw (GTK_SEPARATOR_TOOL_ITEM (item), FALSE);
gtk_tool_item_set_expand (item, TRUE);
vbox = gtk_vbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (main_vbox), vbox, FALSE, FALSE, 0);
gtk_widget_show (vbox);
abox = gtk_alignment_new (0.5, 0.5, 0.0, 0.0);
gtk_box_pack_start (GTK_BOX (vbox), abox, TRUE, TRUE, 0);
gtk_widget_show (abox);
......@@ -625,15 +634,39 @@ build_dialog (GimpImageBaseType basetype,
G_CALLBACK (button_press),
NULL);
hbox = gtk_hbox_new (FALSE, 2);
gtk_box_pack_start (GTK_BOX (vbox), hbox, FALSE, FALSE, 0);
gtk_widget_show (hbox);
ebox = gtk_event_box_new ();
gtk_box_pack_start (GTK_BOX (hbox), ebox, FALSE, FALSE, 0);
gtk_widget_show (ebox);
speedcombo = gtk_combo_box_new_text ();
gtk_container_add (GTK_CONTAINER (ebox), speedcombo);
gtk_widget_show (speedcombo);
for (index = 0; index < 7; index++)
{
gchar *text;
text = g_strdup_printf ("%g %%", 100.0 / get_duration_factor (index));
gtk_combo_box_append_text (GTK_COMBO_BOX (speedcombo), text);
g_free (text);
}
gtk_combo_box_set_active (GTK_COMBO_BOX (speedcombo), 3);
g_signal_connect (speedcombo, "changed",
G_CALLBACK (speedcombo_changed),
NULL);
gimp_help_set_help_data (ebox, _("Playback speed"), NULL);
progress = gtk_progress_bar_new ();
gtk_box_pack_start (GTK_BOX (vbox), progress, FALSE, FALSE, 0);
gtk_box_pack_start (GTK_BOX (hbox), progress, TRUE, TRUE, 0);
gtk_widget_show (progress);
statusbar = gtk_statusbar_new ();
gtk_box_pack_start (GTK_BOX (vbox), statusbar, FALSE, FALSE, 0);
gtk_widget_show (statusbar);
update_statusbar ();
if (total_frames < 2)
{
action = gtk_ui_manager_get_action (ui_manager,
......@@ -1379,9 +1412,13 @@ window_destroy (GtkWidget *widget)
static gint
advance_frame_callback (gpointer data)
{
gdouble duration;
remove_timer();
timer = g_timeout_add (get_frame_duration ((frame_number + 1) % total_frames) * duration_factor,
duration = get_frame_duration ((frame_number + 1) % total_frames);
timer = g_timeout_add (duration * get_duration_factor (duration_index),
advance_frame_callback, NULL);
do_step ();
......@@ -1400,7 +1437,8 @@ play_callback (GtkToggleAction *action)
playing = gtk_toggle_action_get_active (action);
if (playing)
timer = g_timeout_add (get_frame_duration (frame_number) * duration_factor,
timer = g_timeout_add (get_frame_duration (frame_number) *
get_duration_factor (duration_index),
advance_frame_callback, NULL);
g_object_set (action,
......@@ -1408,6 +1446,30 @@ play_callback (GtkToggleAction *action)
NULL);
}
static gdouble
get_duration_factor (gint index)
{
switch (index)
{
case 0:
return 0.125;
case 1:
return 0.25;
case 2:
return 0.5;
case 3:
return 1.0;
case 4:
return 2.0;
case 5:
return 4.0;
case 6:
return 8.0;
default:
return 1.0;
}
}
static void
step_callback (GtkAction *action)
{
......@@ -1432,45 +1494,45 @@ rewind_callback (GtkAction *action)
static void
speed_up_callback (GtkAction *action)
{
if (duration_factor > 0.125)
duration_factor /= 2.0;
if (duration_index > 0)
--duration_index;
gtk_action_set_sensitive (action, duration_factor > 0.125);
gtk_action_set_sensitive (action, duration_index > 0);
action = gtk_ui_manager_get_action (ui_manager,
"/anim-play-popup/speed-reset");
gtk_action_set_sensitive (action, duration_factor != 1.0);
gtk_action_set_sensitive (action, duration_index != 3);
action = gtk_ui_manager_get_action (ui_manager,
"/anim-play-popup/speed-down");
gtk_action_set_sensitive (action, TRUE);
update_statusbar ();
update_combobox ();
}
static void
speed_down_callback (GtkAction *action)
{
if (duration_factor < 8.0)
duration_factor *= 2.0;
if (duration_index < 6)
++duration_index;
gtk_action_set_sensitive (action, duration_factor < 8.0);
gtk_action_set_sensitive (action, duration_index < 6);
action = gtk_ui_manager_get_action (ui_manager,
"/anim-play-popup/speed-reset");
gtk_action_set_sensitive (action, duration_factor != 1.0);
gtk_action_set_sensitive (action, duration_index != 3);
action = gtk_ui_manager_get_action (ui_manager,
"/anim-play-popup/speed-up");
gtk_action_set_sensitive (action, TRUE);
update_statusbar ();
update_combobox ();
}
static void
speed_reset_callback (GtkAction *action)
{
duration_factor = 1.0;
duration_index = 3;
gtk_action_set_sensitive (action, FALSE);
......@@ -1482,33 +1544,34 @@ speed_reset_callback (GtkAction *action)
"/anim-play-popup/speed-up");
gtk_action_set_sensitive (action, TRUE);
update_statusbar ();
update_combobox ();
}
static void
update_statusbar (void)
speedcombo_changed (GtkWidget *scombo, gpointer data)
{
gchar *status_message;
GtkAction * action;
if (message_context_id == 0)
{
message_context_id =
gtk_statusbar_get_context_id (GTK_STATUSBAR (statusbar),
"speed-playback");
}
else
{
gtk_statusbar_pop (GTK_STATUSBAR (statusbar),
message_context_id);
}
duration_index = gtk_combo_box_get_active (GTK_COMBO_BOX (scombo));
status_message = g_strdup_printf (_("Playback speed: %d %%"),
(gint) ROUND (100.0 / duration_factor));
action = gtk_ui_manager_get_action (ui_manager,
"/anim-play-popup/speed-reset");
gtk_action_set_sensitive (action, duration_index != 3);
action = gtk_ui_manager_get_action (ui_manager,
"/anim-play-popup/speed-down");
gtk_action_set_sensitive (action, duration_index < 6);
gtk_statusbar_push (GTK_STATUSBAR (statusbar),
message_context_id, status_message);
action = gtk_ui_manager_get_action (ui_manager,
"/anim-play-popup/speed-up");
gtk_action_set_sensitive (action, duration_index > 0);
}
g_free (status_message);
static void
update_combobox (void)
{
gtk_combo_box_set_active (GTK_COMBO_BOX (speedcombo), duration_index);
}
/* tag util. */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment