[pve-devel] [PATCH ha-manager 4/7] sim: allow new service request states over gui
Thomas Lamprecht
t.lamprecht at proxmox.com
Fri Jan 13 14:22:16 CET 2017
Change the old enabled/disabled GTK "Switch" element to a ComboBox
one and add all possible service states, so we can simulate the real
world behaviour with its new states better.
Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
src/PVE/HA/Sim/RTHardware.pm | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/src/PVE/HA/Sim/RTHardware.pm b/src/PVE/HA/Sim/RTHardware.pm
index ca15275..0e7c622 100644
--- a/src/PVE/HA/Sim/RTHardware.pm
+++ b/src/PVE/HA/Sim/RTHardware.pm
@@ -295,7 +295,7 @@ sub set_service_state {
my ($self, $sid) = @_;
my $d = $self->{service_gui}->{$sid} || die "no such service '$sid'";
- my $state = $d->{enable_btn}->get_active() ? 'started' : 'disabled';
+ my $state = $d->{request_state_cb}->get_active_text();
$self->{service_config} = $self->SUPER::set_service_state($sid, $state);
@@ -420,9 +420,9 @@ sub create_service_control {
$sgrid->set_column_spacing(5);
$sgrid->set('margin', 5);
- my $w = Gtk3::Label->new('Service');
+ my $w = Gtk3::Label->new('Service ID');
$sgrid->attach($w, 0, 0, 1, 1);
- $w = Gtk3::Label->new('Enable');
+ $w = Gtk3::Label->new('Request State');
$sgrid->attach($w, 1, 0, 1, 1);
$w = Gtk3::Label->new('Node');
$sgrid->attach($w, 3, 0, 1, 1);
@@ -440,13 +440,18 @@ sub create_service_control {
$w = Gtk3::Label->new($sid);
$sgrid->attach($w, 0, $row, 1, 1);
- $w = Gtk3::Switch->new();
+ $w = Gtk3::ComboBoxText->new();
$sgrid->attach($w, 1, $row, 1, 1);
- $w->set_active(1) if $d->{state} eq 'started';
- $self->{service_gui}->{$sid}->{enable_btn} = $w;
- $w->signal_connect('notify::active' => sub {
+ my $count = 0;
+ foreach my $state (qw(started stopped disabled)) {
+ $w->append_text($state);
+ $w->set_active($count) if $d->{state} eq $state;
+ $count++;
+ }
+ $self->{service_gui}->{$sid}->{request_state_cb} = $w;
+ $w->signal_connect(changed => sub {
$self->set_service_state($sid);
- }),
+ });
$w = Gtk3::Button->new('Migrate');
--
2.1.4
More information about the pve-devel
mailing list