From 76b8e595575ab053c1c135d8880213c31c4ac6c5 Mon Sep 17 00:00:00 2001 From: Alexandru Ardelean Date: Fri, 24 Aug 2018 10:50:40 +0300 Subject: [PATCH] dialogs.c: re-use refresh_serial() when serial intf now available When serial interface not available it, dialogs will be unavailable. To cleanup the code, move this in the refresh_serial() function, under the SERIAL_BACKEND definition. Signed-off-by: Alexandru Ardelean --- dialogs.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/dialogs.c b/dialogs.c index 44f202cdf..706b9ae18 100644 --- a/dialogs.c +++ b/dialogs.c @@ -463,7 +463,8 @@ static void refresh_usb(void) } #ifdef SERIAL_BACKEND -static void refresh_serial(void) { +static void refresh_serial(GtkBuilder *builder) +{ GtkListStore *liststore; struct sp_port **ports; int i; @@ -486,6 +487,15 @@ static void refresh_serial(void) { gtk_widget_set_sensitive(dialogs.connect_serial, false); } } +#else +static void refresh_serial(GtkBuilder *builder) +{ + /* Serial Backend - hide if not supported */ + gtk_widget_hide(dialogs.connect_seriald); + gtk_widget_hide(dialogs.connect_serial); + gtk_widget_hide(dialogs.connect_serialbr); + gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object(builder, "connect_serial_label"))); +} #endif char * usb_get_serialnumber(struct iio_context *context) @@ -1164,19 +1174,8 @@ void dialogs_init(GtkBuilder *builder) } } - /* Serial Backend - hide if not supported */ -#ifndef SERIAL_BACKEND - gtk_widget_hide(dialogs.connect_seriald); - gtk_widget_hide(dialogs.connect_serial); - gtk_widget_hide(dialogs.connect_serialbr); - gtk_widget_hide(GTK_WIDGET(gtk_builder_get_object(builder, "connect_serial_label"))); -#endif - refresh_usb(); - -#ifdef SERIAL_BACKEND - refresh_serial(); -#endif + refresh_serial(builder); g_signal_connect(dialogs.net_ip, "key-press-event", (GCallback) connect_key_press_cb, dialogs.connect);