Fixed event propagation in GTK+ uiDateTimePicker.
This commit is contained in:
parent
6533c0be32
commit
e00a91ded4
|
@ -558,6 +558,7 @@ struct uiDateTimePicker {
|
||||||
uiprivDateTimePickerWidget *d;
|
uiprivDateTimePickerWidget *d;
|
||||||
void (*onChanged)(uiDateTimePicker *, void *);
|
void (*onChanged)(uiDateTimePicker *, void *);
|
||||||
void *onChangedData;
|
void *onChangedData;
|
||||||
|
gulong setBlock;
|
||||||
};
|
};
|
||||||
|
|
||||||
uiUnixControlAllDefaults(uiDateTimePicker)
|
uiUnixControlAllDefaults(uiDateTimePicker)
|
||||||
|
@ -588,12 +589,17 @@ void uiDateTimePickerSetTime(uiDateTimePicker *d, const struct tm *time)
|
||||||
time_t t;
|
time_t t;
|
||||||
struct tm tmbuf;
|
struct tm tmbuf;
|
||||||
|
|
||||||
|
// TODO find a better way to avoid this; possibly by removing the signal entirely, or the call to dateTimeChanged() (most likely both)
|
||||||
|
g_signal_handler_block(d->d, d->setBlock);
|
||||||
|
|
||||||
// Copy time because mktime() modifies its argument
|
// Copy time because mktime() modifies its argument
|
||||||
memcpy(&tmbuf, time, sizeof (struct tm));
|
memcpy(&tmbuf, time, sizeof (struct tm));
|
||||||
t = mktime(&tmbuf);
|
t = mktime(&tmbuf);
|
||||||
|
|
||||||
uiprivDateTimePickerWidget_setTime(d->d, g_date_time_new_from_unix_local(t));
|
uiprivDateTimePickerWidget_setTime(d->d, g_date_time_new_from_unix_local(t));
|
||||||
dateTimeChanged(d->d);
|
dateTimeChanged(d->d);
|
||||||
|
|
||||||
|
g_signal_handler_unblock(d->d, d->setBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiDateTimePickerOnChanged(uiDateTimePicker *d, void (*f)(uiDateTimePicker *, void *), void *data)
|
void uiDateTimePickerOnChanged(uiDateTimePicker *d, void (*f)(uiDateTimePicker *, void *), void *data)
|
||||||
|
@ -647,7 +653,7 @@ uiDateTimePicker *finishNewDateTimePicker(GtkWidget *(*fn)(void))
|
||||||
|
|
||||||
d->widget = (*fn)();
|
d->widget = (*fn)();
|
||||||
d->d = uiprivDateTimePickerWidget(d->widget);
|
d->d = uiprivDateTimePickerWidget(d->widget);
|
||||||
g_signal_connect(d->widget, "changed", G_CALLBACK(onChanged), d);
|
d->setBlock = g_signal_connect(d->widget, "changed", G_CALLBACK(onChanged), d);
|
||||||
uiDateTimePickerOnChanged(d, defaultOnChanged, NULL);
|
uiDateTimePickerOnChanged(d, defaultOnChanged, NULL);
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
|
|
Loading…
Reference in New Issue