comparison gtk3/dw.c @ 1190:76262040ed5f

Added DW_PERCENT_INDETERMINATE which can be passed to dw_percent_set_pos() to show a rotating or otherwise indeterminate percent bar on supported platforms. Platforms which don't support it will either show no progress or potentially growing and contracting progress in the future if that doesn't look too weird. Committed from Windows so may be fixes coming for the other platforms soon.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 28 Sep 2011 08:22:48 +0000
parents 415c25f87d57
children 40500dabb112
comparison
equal deleted inserted replaced
1189:c5419ef79a77 1190:76262040ed5f
4760 */ 4760 */
4761 void dw_mle_thaw(HWND handle) 4761 void dw_mle_thaw(HWND handle)
4762 { 4762 {
4763 } 4763 }
4764 4764
4765 /* Internal function to update the progress bar
4766 * while in an indeterminate state.
4767 */
4768 gboolean _dw_update_progress_bar(gpointer data)
4769 {
4770 if(g_object_get_data(G_OBJECT(data, "_dw_alive")))
4771 {
4772 gtk_progress_bar_pulse(GTK_PROGRESS_BAR(data));
4773 return FALSE;
4774 }
4775 return TRUE;
4776 }
4777
4765 /* 4778 /*
4766 * Sets the percent bar position. 4779 * Sets the percent bar position.
4767 * Parameters: 4780 * Parameters:
4768 * handle: Handle to the percent bar to be set. 4781 * handle: Handle to the percent bar to be set.
4769 * position: Position of the percent bar withing the range. 4782 * position: Position of the percent bar withing the range.
4771 void dw_percent_set_pos(HWND handle, unsigned int position) 4784 void dw_percent_set_pos(HWND handle, unsigned int position)
4772 { 4785 {
4773 int _locked_by_me = FALSE; 4786 int _locked_by_me = FALSE;
4774 4787
4775 DW_MUTEX_LOCK; 4788 DW_MUTEX_LOCK;
4776 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(handle), (gfloat)position/100); 4789 if(position == DW_PERCENT_INDETERMINATE)
4790 {
4791 /* Check if we are indeterminate already */
4792 if(!g_object_get_data(G_OBJECT(handle), "_dw_alive"))
4793 {
4794 /* If not become indeterminate... and start a timer to continue */
4795 gtk_progress_bar_pulse(GTK_PROGRESS_BAR(handle));
4796 g_object_set_data(G_OBJECT(handle), "_dw_alive", GINT_TO_POINTER(1));
4797 g_timeout_add(100, (GSourceFunc)_dw_update_progress_bar, (gpointer)handle);
4798 }
4799 }
4800 else
4801 {
4802 /* Cancel the existing timer if one is there */
4803 g_object_set_data(G_OBJECT(handle), "_dw_alive", NULL);
4804 /* Set the position like normal */
4805 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(handle), (gfloat)position/100);
4806 }
4777 DW_MUTEX_UNLOCK; 4807 DW_MUTEX_UNLOCK;
4778 } 4808 }
4779 4809
4780 /* 4810 /*
4781 * Returns the position of the slider. 4811 * Returns the position of the slider.