Skip to content

Commit

Permalink
dialogs.c: re-use refresh_serial() when serial intf now available
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
commodo committed Aug 27, 2018
1 parent e0bad3c commit 76b8e59
Showing 1 changed file with 12 additions and 13 deletions.
25 changes: 12 additions & 13 deletions dialogs.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 76b8e59

Please sign in to comment.