public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH installer v2] fix #4869: Show state in management interface ComboBox
@ 2023-10-17 13:57 Maximiliano Sandoval R
  2023-10-18 12:00 ` Filip Schauer
  0 siblings, 1 reply; 2+ messages in thread
From: Maximiliano Sandoval R @ 2023-10-17 13:57 UTC (permalink / raw)
  To: pve-devel

From: Maximiliano Sandoval <m.sandoval@proxmox.com>

This is a continuation of
https://lists.proxmox.com/pipermail/pve-devel/2023-August/058639.html.

Signed-off-by: Maximiliano Sandoval R <m.sandoval@proxmox.com>
---
 proxinstall | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/proxinstall b/proxinstall
index d5b2565..d1f8ae2 100755
--- a/proxinstall
+++ b/proxinstall
@@ -341,10 +341,20 @@ sub create_ipconf_view {
 
     my ($cidr_box, $ipconf_entry_addr, $ipconf_entry_mask) = create_cidr_inputs($cidr);
 
-    my $device_cb = Gtk3::ComboBoxText->new();
+    my $device_model = Gtk3::ListStore->new('Glib::String', 'Glib::String');
+    my $device_cb = Gtk3::ComboBox->new_with_model($device_model);
     $device_cb->set_active(0);
     $device_cb->set_visible(1);
 
+    my $icon_cell = Gtk3::CellRendererText->new();
+    $device_cb->pack_start($icon_cell, 0);
+    $device_cb->add_attribute($icon_cell, 'text', 0);
+    $icon_cell->set_property('foreground', 'green');
+
+    my $cell = Gtk3::CellRendererText->new();
+    $device_cb->pack_start($cell, 0);
+    $device_cb->add_attribute($cell, 'text', 1);
+
     my $get_device_desc = sub {
 	my $iface = shift;
 	return "$iface->{name} - $iface->{mac} ($iface->{driver})";
@@ -374,7 +384,16 @@ sub create_ipconf_view {
     my $i = 0;
     for my $index (sort keys $ipconf->{ifaces}->%*) {
 	my $iface = $ipconf->{ifaces}->{$index};
-	$device_cb->append_text($get_device_desc->($iface));
+	my $iter = $device_model->append();
+	my $symbol;
+	{
+	    use utf8;
+	    $symbol = "$iface->{state}" eq "UP" ? '●' : ' ';
+	}
+	$device_model->set($iter,
+	   0 => $symbol,
+	   1 => $get_device_desc->($iface),
+	);
 	$device_active_map->{$i} = $index;
 	$device_active_reverse_map->{$iface->{name}} = $i;
 	if ($ipconf_first_view && $index == $ipconf->{default}) {
-- 
2.39.2





^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [pve-devel] [PATCH installer v2] fix #4869: Show state in management interface ComboBox
  2023-10-17 13:57 [pve-devel] [PATCH installer v2] fix #4869: Show state in management interface ComboBox Maximiliano Sandoval R
@ 2023-10-18 12:00 ` Filip Schauer
  0 siblings, 0 replies; 2+ messages in thread
From: Filip Schauer @ 2023-10-18 12:00 UTC (permalink / raw)
  To: pve-devel

Tested this in the installer and it looks good to me.

Tested-by: Filip Schauer <f.schauer@proxmox.com>

On 17/10/2023 15:57, Maximiliano Sandoval R wrote:
> From: Maximiliano Sandoval <m.sandoval@proxmox.com>
>
> This is a continuation of
> https://lists.proxmox.com/pipermail/pve-devel/2023-August/058639.html.
>
> Signed-off-by: Maximiliano Sandoval R <m.sandoval@proxmox.com>
> ---
>   proxinstall | 23 +++++++++++++++++++++--
>   1 file changed, 21 insertions(+), 2 deletions(-)
>
> diff --git a/proxinstall b/proxinstall
> index d5b2565..d1f8ae2 100755
> --- a/proxinstall
> +++ b/proxinstall
> @@ -341,10 +341,20 @@ sub create_ipconf_view {
>   
>       my ($cidr_box, $ipconf_entry_addr, $ipconf_entry_mask) = create_cidr_inputs($cidr);
>   
> -    my $device_cb = Gtk3::ComboBoxText->new();
> +    my $device_model = Gtk3::ListStore->new('Glib::String', 'Glib::String');
> +    my $device_cb = Gtk3::ComboBox->new_with_model($device_model);
>       $device_cb->set_active(0);
>       $device_cb->set_visible(1);
>   
> +    my $icon_cell = Gtk3::CellRendererText->new();
> +    $device_cb->pack_start($icon_cell, 0);
> +    $device_cb->add_attribute($icon_cell, 'text', 0);
> +    $icon_cell->set_property('foreground', 'green');
> +
> +    my $cell = Gtk3::CellRendererText->new();
> +    $device_cb->pack_start($cell, 0);
> +    $device_cb->add_attribute($cell, 'text', 1);
> +
>       my $get_device_desc = sub {
>   	my $iface = shift;
>   	return "$iface->{name} - $iface->{mac} ($iface->{driver})";
> @@ -374,7 +384,16 @@ sub create_ipconf_view {
>       my $i = 0;
>       for my $index (sort keys $ipconf->{ifaces}->%*) {
>   	my $iface = $ipconf->{ifaces}->{$index};
> -	$device_cb->append_text($get_device_desc->($iface));
> +	my $iter = $device_model->append();
> +	my $symbol;
> +	{
> +	    use utf8;
> +	    $symbol = "$iface->{state}" eq "UP" ? '●' : ' ';
> +	}
> +	$device_model->set($iter,
> +	   0 => $symbol,
> +	   1 => $get_device_desc->($iface),
> +	);
>   	$device_active_map->{$i} = $index;
>   	$device_active_reverse_map->{$iface->{name}} = $i;
>   	if ($ipconf_first_view && $index == $ipconf->{default}) {




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-10-18 12:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-17 13:57 [pve-devel] [PATCH installer v2] fix #4869: Show state in management interface ComboBox Maximiliano Sandoval R
2023-10-18 12:00 ` Filip Schauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal