! Please note that this is a snapshot of our old Bugzilla server, which is read only since May 29, 2020. Please go to gitlab.xfce.org for our new server !
[PATCH] Add network device combobox
Status:
RESOLVED: MOVED
Severity:
enhancement
Product:
Xfce4-netload-plugin
Component:
General

Comments

Description Miguel Guedes 2012-07-11 00:11:46 CEST
New feature

* Replace network device entry box with combobox

* Get list of detected network interfaces

* Populate new combobox with list of detected network interfaces

* Allow for a network device to still be entered manually, so old functionality retained

* Platform specific code can be easily added; so far only Linux implemented
Comment 1 Mike Massonnet editbugs 2012-07-11 11:50:12 CEST
(In reply to comment #0)
> * Get list of detected network interfaces
> * Platform specific code can be easily added; so far only Linux implemented

It's possible to look into libgtop:

http://git.gnome.org/browse/libgtop/tree/sysdeps (/*/netlist.c)

- Linux: http://git.gnome.org/browse/libgtop/tree/sysdeps/linux/netlist.c
- FreeBSD: http://git.gnome.org/browse/libgtop/tree/sysdeps/freebsd/netlist.c

Under Linux the list of devices is available through different means. Libgtop looks into /proc/net/dev, but it doesn't tell if the devices are up or not. (It's possible to look into /sys/class/net/<DEVICE>/operstate for that (the sysfs is officially available since Linux 2.6).)

Under FreeBSD the devices are fetched with builtin functionnality <net/if.h>. This is POSIX and therefore works cross-platform.
http://pwet.fr/man/linux/conventions/posix/if_h

Code can be copied from the libgtop project, there is netlist (list of devices) and netload (state of devices, up or down, bytes exchanged, etc).

(In reply to comment #0)
> * Replace network device entry box with combobox
> * Populate new combobox with list of detected network interfaces
> * Allow for a network device to still be entered manually, so old
> functionality retained

The GtkComboBoxEntry widget is done for that.
Comment 2 Miguel Guedes 2012-07-11 12:53:44 CEST
(In reply to comment #1)
> Under Linux the list of devices is available through different means.
> Libgtop looks into /proc/net/dev, but it doesn't tell if the devices are up
> or not. (It's possible to look into /sys/class/net/<DEVICE>/operstate for
> that (the sysfs is officially available since Linux 2.6).)

I'm using a socket-based approach which - I'm not sure here though - should be compatible with FreeBsd and possibly even other platforms that implement it? Unsure whether it is POSIX compliant though. Good thing about this approach is it returns a list of network interfaces which are up (loopback included.)

> 
> The GtkComboBoxEntry widget is done for that.

GtkComboBoxEntry seems to have been deprecated (see here: http://developer.gnome.org/gtk/2.24/GtkComboBoxEntry.html#GtkComboBoxEntry-struct

And so is the approach I'd initially used so I've just now migrated the code to use GtkComboBoxEntry instead. However, it seems to have been deprecated too but I can't find the right replacement for it. It now works nicely though and, unlike my first attempt, integrates nicely with the current GTK theme.

Also, new feature now added:

 * work right out of the box upon adding plugin. Find first available network interface if one hasn't been specified. Reverts to first loopback device found (if one exists) if no network interfaces are available.
   https://bugzilla.xfce.org/show_bug.cgi?id=7431

 * in addition, the fact that the plugin only presents a list of available (as in up) network interfaces seems to also address the bug report found here:
   https://bugzilla.xfce.org/show_bug.cgi?id=3362

   However this will only work if a network device hasn't been specified, which means the plugin will find the first up interface available. Might be nice to implement code to check whether specified interface is up and, if not, revert to finding first available network? Or possibly add an option to allow plugin to behave in this way?


New improved patch can be found here: http://paste.ubuntu.com/1085987/
(I've not been having luck lately attaching patches to bugzilla after the report has been created but will still try now)
Comment 3 Miguel Guedes 2012-07-11 12:59:35 CEST
Apologies! I meant https://bugzilla.xfce.org/show_bug.cgi?id=3880 instead of https://bugzilla.xfce.org/show_bug.cgi?id=7431 above.
Comment 4 Miguel Guedes 2012-07-11 13:05:10 CEST
Also, forgot to mention that this an implementation of the original idea by Mike Massonnet here: https://bugzilla.xfce.org/show_bug.cgi?id=9076#c4
Comment 5 Git Bot editbugs 2020-05-23 00:19:34 CEST
-- GitLab Migration Automatic Message --

This bug has been migrated to xfce.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.xfce.org/panel-plugins/xfce4-netload-plugin/-/issues/4.

Please create an account or use an existing account on one of our supported OAuth providers. 

If you want to fork to submit patches and merge requests please continue reading here: https://docs.xfce.org/contribute/dev/git/start#gitlab_forks_and_merge_requests

Also feel free to reach out to us on the mailing list https://mail.xfce.org/mailman/listinfo/xfce4-dev

Bug #9101

Reported by:
Miguel Guedes
Reported on: 2012-07-11
Last modified on: 2020-05-23

People

Assignee:
Mike Massonnet
CC List:
1 user

Version

Attachments

Additional information