libui/redo/unix/progressbar.c

44 lines
1016 B
C
Raw Normal View History

2015-06-11 18:07:06 -05:00
// 11 june 2015
#include "uipriv_unix.h"
struct progressbar {
uiProgressBar p;
GtkWidget *widget;
2015-06-27 18:46:11 -05:00
GtkProgressBar *pbar;
2015-06-11 18:07:06 -05:00
};
uiDefineControlType(uiProgressBar, uiTypeProgressBar, struct progressbar)
static uintptr_t progressbarHandle(uiControl *c)
{
struct progressbar *p = (struct progressbar *) c;
return (uintptr_t) (p->widget);
}
static void progressbarSetValue(uiProgressBar *pp, int value)
{
struct progressbar *p = (struct progressbar *) pp;
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)
{
struct progressbar *p;
p = (struct progressbar *) uiNewControl(uiTypeProgressBar());
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);
uiUnixMakeSingleWidgetControl(uiControl(p), p->widget);
2015-06-11 18:07:06 -05:00
uiControl(p)->Handle = progressbarHandle;
uiProgressBar(p)->SetValue = progressbarSetValue;
return uiProgressBar(p);
}