libui/redo/unix/progressbar.c

35 lines
711 B
C
Raw Normal View History

2015-06-11 18:07:06 -05:00
// 11 june 2015
#include "uipriv_unix.h"
2015-08-27 22:00:34 -05:00
struct uiProgressBar {
uiUnixControl c;
2015-06-11 18:07:06 -05:00
GtkWidget *widget;
2015-06-27 18:46:11 -05:00
GtkProgressBar *pbar;
2015-06-11 18:07:06 -05:00
};
2015-08-27 22:00:34 -05:00
uiUnixDefineControl(
uiProgressBar, // type name
uiProgressBarType // type function
)
2015-06-11 18:07:06 -05:00
2015-08-27 22:00:34 -05:00
void uiProgressBarSetValue(uiProgressBar *p, int value)
2015-06-11 18:07:06 -05:00
{
if (value < 0 || value > 100)
complain("value %d out of range in progressbarSetValue()", value);
gtk_progress_bar_set_fraction(p->pbar, ((gdouble) value) / 100);
2015-06-11 18:07:06 -05:00
}
uiProgressBar *uiNewProgressBar(void)
{
2015-08-27 22:00:34 -05:00
uiProgressBar *p;
2015-06-11 18:07:06 -05:00
p = (uiProgressBar *) uiNewControl(uiProgressBarType());
2015-06-11 18:07:06 -05:00
2015-06-27 18:46:11 -05:00
p->widget = gtk_progress_bar_new();
p->pbar = GTK_PROGRESS_BAR(p->widget);
2015-06-11 18:07:06 -05:00
2015-08-27 22:00:34 -05:00
uiUnixFinishNewControl(p, uiProgressBar);
2015-06-11 18:07:06 -05:00
2015-08-27 22:00:34 -05:00
return p;
2015-06-11 18:07:06 -05:00
}