Skip to content

Commit

Permalink
iio_widget: add iio_widget_update_value()
Browse files Browse the repository at this point in the history
Add an API to only update the gui value of a specific widget. This is
useful when we have to do the actual attribute reading before we need to
update the GUI.

In the next patch, we'll introduce an user of this API.

Signed-off-by: Nuno Sa <[email protected]>
  • Loading branch information
nunojsa committed Jun 6, 2024
1 parent fdb2f83 commit 4ceed02
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
12 changes: 12 additions & 0 deletions iio_widget.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,18 @@ static gboolean iio_widget_signal_unblock(gpointer arg)
return FALSE;
}

void iio_widget_update_value(struct iio_widget *widget, const char *ensm, size_t len)
{
guint sig = 0;

if (widget->sig_handler_data)
sig = g_signal_handlers_block_matched(G_OBJECT(widget->widget), G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, widget->sig_handler_data);
widget->update_value(widget, ensm, len);

if (sig)
g_timeout_add(1, (GSourceFunc)iio_widget_signal_unblock, widget);
}
/*
* The point of these is that when we update a widget, we can receive a different value from the
* iio dev from the one in the GUI (eg: a failed call to widget->save() or an autonomous update).
Expand Down
1 change: 1 addition & 0 deletions iio_widget.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ void iio_make_widget_update_signal_based(struct iio_widget *widget, GCallback ha
void iio_update_widgets(struct iio_widget *widgets, unsigned int num_widgets);
void iio_update_widgets_block_signals_by_data(struct iio_widget *widgets, unsigned int num_widgets);
void iio_widget_update(struct iio_widget *widget);
void iio_widget_update_value(struct iio_widget *widget, const char *ensm, size_t len);
void iio_update_widgets_of_device(struct iio_widget *widgets,
unsigned int num_widgets, struct iio_device *dev);
void iio_widget_update_block_signals_by_data(struct iio_widget *widget);
Expand Down

0 comments on commit 4ceed02

Please sign in to comment.