/* update the animation information for each widget. This will also queue a redraw * and stop the animation if it is done. */ static gboolean update_animation_info (gpointer key, gpointer value, gpointer user_data) { AnimationInfo *animation_info = value; GtkWidget *widget = key; g_assert ((widget != NULL) && (animation_info != NULL)); /* remove the widget from the hash table if it is not drawable */ if (!gtk_widget_is_drawable (widget)) { return TRUE; } if (GE_IS_PROGRESS_BAR (widget)) { gfloat fraction = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (widget)); /* stop animation for filled/not filled progress bars */ if (fraction <= 0.0 || fraction >= 1.0) return TRUE; } force_widget_redraw (widget); /* stop at stop_time */ if (animation_info->stop_time != 0 && g_timer_elapsed (animation_info->timer, NULL) > animation_info->stop_time) return TRUE; return FALSE; }
/* This function also needs to unref the weak reference. */ static void destroy_animation_info_and_weak_unref (gpointer data) { AnimationInfo *animation_info = data; /* force a last redraw. This is so that if the animation is removed, * the widget is left in a sane state. */ force_widget_redraw (animation_info->widget); g_object_weak_unref (G_OBJECT (animation_info->widget), on_animated_widget_destruction, data); animation_info_destroy (animation_info); }
/* This function also needs to unref the weak reference. */ static void qtcAnimationDestroyInfoAndWeakUnref(gpointer data) { AnimationInfo *animation_info = data; /* force a last redraw. This is so that if the animation is removed, * the widget is left in a sane state. */ force_widget_redraw(animation_info->widget); g_object_weak_unref(G_OBJECT(animation_info->widget), qtcAnimationOnWidgetDestruction, data); qtcAnimationDestroyInfo(animation_info); }
/* update the animation information for each widget. This will also queue a redraw * and stop the animation if it is done. */ static gboolean update_animation_info (gpointer key, gpointer value, gpointer user_data) { AnimationInfo *animation_info = value; GtkWidget *widget = key; gdouble elapsed; if ((widget == NULL) || (animation_info == NULL)) g_assert_not_reached (); /* remove the widget from the hash table if it is not drawable */ if (!GTK_WIDGET_DRAWABLE (widget)) return TRUE; if (GTK_IS_PROGRESS_BAR (widget)) { gfloat fraction = gtk_progress_bar_get_fraction (GTK_PROGRESS_BAR (widget)); /* stop animation for filled/not filled progress bars */ if (fraction <= 0.0 || fraction >= 1.0) return TRUE; animation_info->update_delay--; if (animation_info->update_delay <= 0) { animation_info->update_delay = PROGRESSBAR_DELAY; force_widget_redraw (widget); } } else force_widget_redraw (widget); /* stop at stop_time */ if (animation_info->stop_time != 0 && g_timer_elapsed (animation_info->timer, NULL) > animation_info->stop_time) return TRUE; return FALSE; }
/* update the animation information for each widget. This will also queue a redraw * and stop the animation if it is done. */ static gboolean qtcAnimationUpdateInfo(gpointer key, gpointer value, gpointer user_data) { QTC_UNUSED(user_data); AnimationInfo *animation_info = value; GtkWidget *widget = key; if ((widget == NULL) || (animation_info == NULL)) g_assert_not_reached(); /* remove the widget from the hash table if it is not drawable */ if (!gtk_widget_is_drawable(widget)) return TRUE; if (GTK_IS_PROGRESS_BAR(widget)) { gfloat fraction = gtk_progress_bar_get_fraction(GTK_PROGRESS_BAR(widget)); /* stop animation for filled/not filled progress bars */ if (fraction <= 0.0 || fraction >= 1.0) { return TRUE; } } else if (GTK_IS_ENTRY(widget)) { gfloat fraction = gtk_entry_get_progress_fraction(GTK_ENTRY(widget)); /* stop animation for filled/not filled progress bars */ if(fraction <= 0.0 || fraction >= 1.0) { return TRUE; } } force_widget_redraw(widget); /* stop at stop_time */ if(animation_info->stop_time != 0 && g_timer_elapsed(animation_info->timer, NULL) > animation_info->stop_time) return TRUE; return FALSE; }