From b4514df81580d9b34d35692750dd0755f9d5fb9c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Dominik=20M=C3=B6slinger?= <dominik.moeslinger@univie.ac.at>
Date: Wed, 7 Jul 2021 16:45:56 +0200
Subject: [PATCH] TST: Closing the tabs works now, Progress View: Scroll Bars
 added, Resizing updated Small updates

---
 Tst/progress_view/progress_view.py | 22 ++++++++--------------
 Tst/tst/tst.py                     | 14 +++++++++++++-
 Tst/tst/view.py                    | 11 +++++------
 3 files changed, 26 insertions(+), 21 deletions(-)

diff --git a/Tst/progress_view/progress_view.py b/Tst/progress_view/progress_view.py
index 4dc5d25..f84d763 100644
--- a/Tst/progress_view/progress_view.py
+++ b/Tst/progress_view/progress_view.py
@@ -123,6 +123,7 @@ class TestProgressView(Gtk.ApplicationWindow):
         self.box = Gtk.Box()
         self.box.set_orientation(Gtk.Orientation.VERTICAL)
         self.add(self.box)
+        #self.set_position(self.get_default_size()[1] * 0.2)
 
         self.path_frame = Gtk.Frame()
         self.path_box = Gtk.Box()
@@ -171,7 +172,7 @@ class TestProgressView(Gtk.ApplicationWindow):
         self.path_box.pack_start(self.box_file_path_3, True, True, 0)
 
         self.path_frame.add(self.path_box)
-        self.box.pack_start(self.path_frame, True, True, 0)
+        self.box.pack_start(self.path_frame, False, True, 0)
 
         self.title_box = Gtk.HBox()
         self.test_label = Gtk.Label()
@@ -204,8 +205,8 @@ class TestProgressView(Gtk.ApplicationWindow):
         self.view.expand_all()
 
         self.scroll_win = Gtk.ScrolledWindow()
-        self.scroll_win.set_min_content_height(int(confignator.get_option(section='progress-viewer-window-size', option='minimum-height')))
-        self.scroll_win.set_min_content_width(int(confignator.get_option(section='progress-viewer-window-size', option='minimum-width-step-mode')))
+        #self.scroll_win.set_min_content_height(int(confignator.get_option(section='progress-viewer-window-size', option='minimum-height')))
+        #self.scroll_win.set_min_content_width(int(confignator.get_option(section='progress-viewer-window-size', option='minimum-width-step-mode')))
         self.scroll_win.add(self.view)
         self.box.pack_start(self.scroll_win, True, True, 0)
 
@@ -292,7 +293,6 @@ class TestProgressView(Gtk.ApplicationWindow):
 
     def make_treeview(self):
         # self.view.set_enable_tree_lines(True)
-        print(self.get_size())
         if self.sort_button.get_active():  # Only if sorted by executions
             # column 0
             renderer_number = Gtk.CellRendererText()
@@ -374,15 +374,8 @@ class TestProgressView(Gtk.ApplicationWindow):
         column_result.set_min_width(50)
         # column_result.set_cell_data_func(cell_renderer=renderer_result, func=set_bkgrd_clr, func_data=None)
         self.view.append_column(column_result)
-        print(self.get_size())
         return
 
-    def tooltip_treeview(self, widget, *args):
-        #print(widget)
-        #print(args)
-        #print(self.view.get_path_at_pos(args[0], args[1]))
-        pass
-        return True
     def get_log_file_paths_from_json_file_name(self, filename):
         from testlib import testing_logger
         paths = {}
@@ -548,11 +541,13 @@ class TestProgressView(Gtk.ApplicationWindow):
         if self.sort_button.get_active():
             self.progress_tree_store = Gtk.TreeStore(str, str, str, str, str, str, str, str, str, str, str, str, str)
             self.scroll_win.set_min_content_width(int(confignator.get_option(section='progress-viewer-window-size', option='minimum-width-run-mode')))
-            self.resize(int(confignator.get_option(section='progress-viewer-window-size', option='basic-width-run-mode')),int(confignator.get_option(section='progress-viewer-window-size', option='basic-height')))
+            if self.get_size()[0] == int(confignator.get_option(section='progress-viewer-window-size', option='basic-width-step-mode')):
+                self.resize(int(confignator.get_option(section='progress-viewer-window-size', option='basic-width-run-mode')), self.get_size()[1])
         else:
             self.progress_tree_store = Gtk.TreeStore(str, str, str, str, str, str, str, str, str, str, str)
             self.scroll_win.set_min_content_width(int(confignator.get_option(section='progress-viewer-window-size', option='minimum-width-step-mode')))
-            self.resize(int(confignator.get_option(section='progress-viewer-window-size', option='basic-width-step-mode')), int(confignator.get_option(section='progress-viewer-window-size', option='basic-height')))
+            if self.get_size()[0] == int(confignator.get_option(section='progress-viewer-window-size', option='basic-width-run-mode')):
+                self.resize(int(confignator.get_option(section='progress-viewer-window-size', option='basic-width-step-mode')), self.get_size()[1])
         self.sorted_model = Gtk.TreeModelSort(model=self.progress_tree_store)
         self.sorted_model.set_sort_column_id(1, Gtk.SortType.ASCENDING)
         self.view.set_model(self.sorted_model)
@@ -775,7 +770,6 @@ class TestProgressView(Gtk.ApplicationWindow):
         else:
             # analyse the command log
             self.cmd_steps = analyse_command_log.get_steps_and_commands(filepath)
-            print(self.cmd_steps)
             self.load_cmd_into_tree_store(self.progress_tree_store, self.cmd_steps)
             self.set_test_title()
 
diff --git a/Tst/tst/tst.py b/Tst/tst/tst.py
index 4795105..a145c22 100755
--- a/Tst/tst/tst.py
+++ b/Tst/tst/tst.py
@@ -421,7 +421,7 @@ class TstAppWindow(Gtk.ApplicationWindow):
         label.set_text(label_text)
         btn_close = Gtk.Button.new_from_icon_name('window-close-symbolic', Gtk.IconSize.BUTTON)
         btn_close.set_tooltip_text('Close')
-        btn_close.connect('clicked', self.on_close)
+        btn_close.connect('clicked', self.on_close_clicked)
         box.pack_start(label, True, True, 0)
         box.pack_start(btn_close, True, True, 0)
         box.show_all()
@@ -482,6 +482,18 @@ class TstAppWindow(Gtk.ApplicationWindow):
             self.notebook.remove_page(current_page)
         self.update_model_viewer()
 
+    def on_close_clicked(self, widget):
+        """
+        Closing the page on which was clicked
+        """
+        for i in range(0, self.notebook.get_n_pages()):  # Loop over all availabe page numbers
+            page = self.notebook.get_nth_page(i)    # Get page widget
+            if self.notebook.get_tab_label(page) == widget.get_parent():    # Check if the label widget is the same as for the given widget
+                self.notebook.remove_page(i)    # If so close the page
+                return
+
+        #self.notebook.remove_page(widget.get_parent())
+
     def on_open(self, *args):
         dialog = Gtk.FileChooserDialog('Please choose a file',
                                        self,
diff --git a/Tst/tst/view.py b/Tst/tst/view.py
index 0e7b657..6b2e433 100644
--- a/Tst/tst/view.py
+++ b/Tst/tst/view.py
@@ -1367,7 +1367,6 @@ class Edit_Pre_Post_Con_Dialog(Gtk.Dialog):
             self.section_dict = generator.get_precon_sections()
         else:
             self.section_dict = generator.get_postcon_sections()
-
         self.view()
 
         self.show_all()
@@ -1393,9 +1392,10 @@ class Edit_Pre_Post_Con_Dialog(Gtk.Dialog):
         self.selection_box.pack_start(self.save_button, False, True, 0)
 
         box = self.get_content_area()
-        box.pack_start(self.selection_box, True, True, 0)
+        box.pack_start(self.selection_box, False, True, 0)
         box.pack_start(self.scrolled_window, True, True, 0)
-
+        #box.add(self.selection_box)
+        #box.pack_end(self.scrolled_window, True, True, 0)
 
     def get_con_sections_model(self):
         data_model = Gtk.ListStore(str, int, int)
@@ -1486,8 +1486,8 @@ class Edit_Pre_Post_Con_Dialog(Gtk.Dialog):
         # textview is scrolled
         self.scrolled_window.add(self.textview)
 
-        box = self.get_content_area()
-        box.add(self.selection_box)
+        #box = self.get_content_area()
+        #box.add(self.selection_box)
 
         return
 
@@ -1505,7 +1505,6 @@ class Edit_Pre_Post_Con_Dialog(Gtk.Dialog):
             for count, line in enumerate(entry_array):
                 entry += line
             entry_file_obj.close()
-
         return entry
 
 
-- 
GitLab