Skip to content

Populate a combo box with known network interfaces

Read /proc/net/dev Use getifaddrs() on Linux/OpenBSD/NetBSD/FreeBSD to enumerate the list of available network interfaces, and use a GtkComboBoxText to list them in the options dialog. If /proc getifaddrs() is not available (strict permissions, running on something other than Linux), an interface name can still be manually typed in.

Warts:

  • Hitting enter (or selecting an interface from the list) doesn't automatically update the plugin's UI anymore (until you close the settings dialog). Unfortunately the combo box's changed signal gets fired for each character typed into the entry field, and there's no way to get a pointer to the underlying GtkEntry in order to listen for activate or handle key presses.
  • On non-Linux systems, or systems where /proc/net/dev is locked down (if that's a thing) systems without getifaddrs(), we still display a combo box, even though it will be empty. It's of course still possible to manually type in an interface name, as before.
Edited by Brian Tarricone

Merge request reports