[pve-devel] [PATCH installer] implement previous button

Oguz Bektas o.bektas at proxmox.com
Thu Nov 29 12:38:40 CET 2018


Signed-off-by: Oguz Bektas <o.bektas at proxmox.com>
---
 proxinstall | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/proxinstall b/proxinstall
index 9945dd1..43da7be 100755
--- a/proxinstall
+++ b/proxinstall
@@ -190,8 +190,19 @@ my $ipv4_reverse_mask = [
     '255.255.255.255',
 ];
 
+my $stack_number = 0; # init number for function stack
+
+my %function_stack = ( # global function stack
+    1 => \&create_intro_view,
+    2 => \&create_hdsel_view,
+    3 => \&create_country_view,
+    4 => \&create_password_view,
+    5 => \&create_ipconf_view,
+);
+
 my ($window, $cmdbox, $inbox, $htmlview);
 my ($next, $next_fctn, $target_hd);
+my $prev;
 my ($progress, $progress_status);
 my ($ipversion, $ipaddress, $ipconf_entry_addr);
 my ($netmask, $ipconf_entry_mask);
@@ -1682,6 +1693,20 @@ sub display_html {
     $last_display_change = time();
 }
 
+sub prev_fctn {
+
+    my ($text, $fctn) = @_;
+
+    $stack_number = $stack_number - 1;
+    $fctn = $stack_number if !$fctn;
+    $text = "_Previous" if !$text;
+    $prev->set_label ($text);
+
+    $function_stack{lc $stack_number}();
+
+    $prev->grab_focus ();
+}
+
 sub set_next {
     my ($text, $fctn) = @_;
 
@@ -1721,6 +1746,13 @@ sub create_main_window {
     $next = Gtk3::Button->new ('_Next');
     $next->signal_connect (clicked => sub { $last_display_change = 0; &$next_fctn (); });
     $cmdbox->pack_end ($next, 0, 0, 10);
+
+
+    $prev = Gtk3::Button->new ('_Previous');
+    $prev->signal_connect (clicked => sub { $last_display_change = 0; &prev_fctn (); });
+    $cmdbox->pack_end ($prev, 0, 0, 10);
+
+
     my $abort = Gtk3::Button->new ('_Abort');
     $abort->set_can_focus (0);
     $cmdbox->pack_start ($abort, 0, 0, 10);
@@ -1899,6 +1931,8 @@ my $ipconf_first_view = 1;
 
 sub create_ipconf_view {
 
+    $stack_number = 5;
+
     cleanup_view ();
     display_html ("ipconf.htm");
 
@@ -2165,6 +2199,9 @@ sub update_zonelist {
 
 sub create_password_view {
 
+    $stack_number = 4;
+    $prev->set_sensitive (1); # enable previous button at this point
+
     cleanup_view ();
 
     my $vbox2 =  Gtk3::VBox->new (0, 0);
@@ -2254,6 +2291,9 @@ sub create_password_view {
 
 sub create_country_view {
 
+    $stack_number = 3;
+    $prev->set_sensitive (0);
+
     cleanup_view ();
 
     my $countryhash = $cmap->{countryhash};
@@ -2886,6 +2926,9 @@ sub get_btrfs_raid_setup {
 
 sub create_hdsel_view {
 
+    $stack_number = 2;
+    $prev->set_sensitive (0);
+
     cleanup_view ();
 
     my $vbox =  Gtk3::VBox->new (0, 0);
@@ -2997,6 +3040,9 @@ sub create_extract_view {
 
 sub create_intro_view {
 
+    $stack_number = 1;
+    $prev->set_sensitive (0);
+
     cleanup_view ();
 
     if ($setup->{product} eq 'pve') {
-- 
2.11.0





More information about the pve-devel mailing list