Adds uiProgressBar(Set)Indeterminate for unix
This commit is contained in:
parent
e07a7b3d05
commit
560cca5bc9
|
@ -75,6 +75,12 @@ static void showHide(uiButton *b, void *data)
|
|||
uiControlShow(c);
|
||||
}
|
||||
|
||||
static void setIndeterminate(uiButton *b, void *data)
|
||||
{
|
||||
uiProgressBar *p = uiProgressBar(data);
|
||||
uiProgressBarSetIndeterminate(p, !uiProgressBarIndeterminate(p));
|
||||
}
|
||||
|
||||
static void deleteFirst(uiButton *b, void *data)
|
||||
{
|
||||
uiForm *f = uiForm(data);
|
||||
|
@ -89,6 +95,7 @@ uiBox *makePage13(void)
|
|||
uiButton *b;
|
||||
uiForm *f;
|
||||
uiEntry *e;
|
||||
uiProgressBar *p;
|
||||
|
||||
page13 = newVerticalBox();
|
||||
|
||||
|
@ -123,6 +130,12 @@ uiBox *makePage13(void)
|
|||
|
||||
uiFormAppend(f, "MLE", uiControl(uiNewMultilineEntry()), 1);
|
||||
|
||||
p = uiNewProgressBar();
|
||||
uiBoxAppend(page13, uiControl(p), 0);
|
||||
b = uiNewButton("Toggle indeterminate");
|
||||
uiButtonOnClicked(b, setIndeterminate, p);
|
||||
uiBoxAppend(page13, uiControl(b), 0);
|
||||
|
||||
b = uiNewButton("Show/Hide");
|
||||
uiButtonOnClicked(b, showHide, e);
|
||||
uiBoxAppend(page13, uiControl(b), 0);
|
||||
|
|
2
ui.h
2
ui.h
|
@ -190,7 +190,7 @@ typedef struct uiProgressBar uiProgressBar;
|
|||
_UI_EXTERN int uiProgressBarValue(uiProgressBar *p);
|
||||
_UI_EXTERN void uiProgressBarSetValue(uiProgressBar *p, int n);
|
||||
_UI_EXTERN int uiProgressBarIndeterminate(uiProgressBar *p);
|
||||
_UI_EXTERN void uiProgressBarSetindeterminate(uiProgressBar *p, int indeterminate);
|
||||
_UI_EXTERN void uiProgressBarSetIndeterminate(uiProgressBar *p, int indeterminate);
|
||||
_UI_EXTERN uiProgressBar *uiNewProgressBar(void);
|
||||
|
||||
typedef struct uiSeparator uiSeparator;
|
||||
|
|
|
@ -5,6 +5,7 @@ struct uiProgressBar {
|
|||
uiUnixControl c;
|
||||
GtkWidget *widget;
|
||||
GtkProgressBar *pbar;
|
||||
int indeterminate;
|
||||
};
|
||||
|
||||
uiUnixControlAllDefaults(uiProgressBar)
|
||||
|
@ -21,6 +22,28 @@ void uiProgressBarSetValue(uiProgressBar *p, int value)
|
|||
gtk_progress_bar_set_fraction(p->pbar, ((gdouble) value) / 100);
|
||||
}
|
||||
|
||||
int uiProgressBarIndeterminate(uiProgressBar *p)
|
||||
{
|
||||
return p->indeterminate;
|
||||
}
|
||||
|
||||
gboolean uiProgressBarPulse(uiProgressBar *p)
|
||||
{
|
||||
if (!GTK_IS_WIDGET(p->pbar) || !p->indeterminate)
|
||||
return 0;
|
||||
|
||||
gtk_progress_bar_pulse(p->pbar);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void uiProgressBarSetIndeterminate(uiProgressBar *p, int indeterminate)
|
||||
{
|
||||
p->indeterminate = indeterminate;
|
||||
|
||||
if (indeterminate)
|
||||
g_timeout_add(100, uiProgressBarPulse, p);
|
||||
}
|
||||
|
||||
uiProgressBar *uiNewProgressBar(void)
|
||||
{
|
||||
uiProgressBar *p;
|
||||
|
|
Loading…
Reference in New Issue