From 544fd763fc4e2990491b04ed3e6f9699f6d88720 Mon Sep 17 00:00:00 2001
From: Marko Mecina <marko.mecina@univie.ac.at>
Date: Fri, 9 Sep 2022 11:50:22 +0200
Subject: [PATCH] replace test step button labels with icons

+ select current MIB in IDB chooser dialog
---
 Ccs/pixmap/collapse.svg | 99 +++++++++++++++++++++++++++++++++++++++++
 Ccs/pixmap/expand.svg   | 99 +++++++++++++++++++++++++++++++++++++++++
 Tst/tst/tst.py          | 12 +++--
 Tst/tst/view.py         | 40 ++++++++++-------
 4 files changed, 231 insertions(+), 19 deletions(-)
 create mode 100644 Ccs/pixmap/collapse.svg
 create mode 100644 Ccs/pixmap/expand.svg

diff --git a/Ccs/pixmap/collapse.svg b/Ccs/pixmap/collapse.svg
new file mode 100644
index 0000000..209678a
--- /dev/null
+++ b/Ccs/pixmap/collapse.svg
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   width="26.510696mm"
+   height="28.219185mm"
+   viewBox="0 0 26.510696 28.219185"
+   version="1.1"
+   id="svg5"
+   inkscape:version="1.2.1 (9c6d41e410, 2022-07-14)"
+   sodipodi:docname="collapse.svg"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:svg="http://www.w3.org/2000/svg">
+  <sodipodi:namedview
+     id="namedview7"
+     pagecolor="#ffffff"
+     bordercolor="#999999"
+     borderopacity="1"
+     inkscape:showpageshadow="0"
+     inkscape:pageopacity="0"
+     inkscape:pagecheckerboard="0"
+     inkscape:deskcolor="#d1d1d1"
+     inkscape:document-units="mm"
+     showgrid="false"
+     inkscape:zoom="2.3786088"
+     inkscape:cx="183.09022"
+     inkscape:cy="531.82348"
+     inkscape:window-width="2560"
+     inkscape:window-height="1385"
+     inkscape:window-x="0"
+     inkscape:window-y="27"
+     inkscape:window-maximized="1"
+     inkscape:current-layer="layer1" />
+  <defs
+     id="defs2">
+    <marker
+       style="overflow:visible"
+       id="Arrow3-7"
+       refX="0"
+       refY="0"
+       orient="auto-start-reverse"
+       inkscape:stockid="Arrow3"
+       markerWidth="11"
+       markerHeight="11"
+       viewBox="0 0 4.2071068 7"
+       inkscape:isstock="true"
+       inkscape:collect="always"
+       preserveAspectRatio="xMidYMid"
+       markerUnits="userSpaceOnUse">
+      <path
+         style="fill:none;stroke:context-stroke;stroke-width:1;stroke-linecap:round"
+         d="M 3,-3 0,0 3,3"
+         id="arrow3-5"
+         transform="rotate(180,0.125,0)"
+         sodipodi:nodetypes="ccc" />
+    </marker>
+    <marker
+       style="overflow:visible"
+       id="Arrow3-7-5"
+       refX="0"
+       refY="0"
+       orient="auto-start-reverse"
+       inkscape:stockid="Arrow3"
+       markerWidth="11"
+       markerHeight="11"
+       viewBox="0 0 4.2071068 7"
+       inkscape:isstock="true"
+       inkscape:collect="always"
+       preserveAspectRatio="xMidYMid"
+       markerUnits="userSpaceOnUse">
+      <path
+         style="fill:none;stroke:context-stroke;stroke-width:1;stroke-linecap:round"
+         d="M 3,-3 0,0 3,3"
+         id="arrow3-5-6"
+         transform="rotate(180,0.125,0)"
+         sodipodi:nodetypes="ccc" />
+    </marker>
+  </defs>
+  <g
+     inkscape:label="Ebene 1"
+     inkscape:groupmode="layer"
+     id="layer1"
+     transform="translate(-54.299432,-112.5212)">
+    <path
+       style="fill:none;stroke:#000000;stroke-width:1.375;stroke-linecap:round;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
+       d="M 54.986932,126.6308 H 80.122625"
+       id="path2600" />
+    <path
+       style="fill:none;stroke:#000000;stroke-width:1.744;stroke-linecap:round;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow3-7)"
+       d="m 67.554779,130.0808 v 9.7876"
+       id="path2600-3-3" />
+    <path
+       style="fill:none;stroke:#000000;stroke-width:1.744;stroke-linecap:round;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow3-7-5)"
+       d="m 67.554779,123.1808 v -9.7876"
+       id="path2600-3-3-2" />
+  </g>
+</svg>
diff --git a/Ccs/pixmap/expand.svg b/Ccs/pixmap/expand.svg
new file mode 100644
index 0000000..37e398d
--- /dev/null
+++ b/Ccs/pixmap/expand.svg
@@ -0,0 +1,99 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   width="26.510681mm"
+   height="28.219215mm"
+   viewBox="0 0 26.510681 28.219215"
+   version="1.1"
+   id="svg5"
+   inkscape:version="1.2.1 (9c6d41e410, 2022-07-14)"
+   sodipodi:docname="collapse.svg"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:svg="http://www.w3.org/2000/svg">
+  <sodipodi:namedview
+     id="namedview7"
+     pagecolor="#ffffff"
+     bordercolor="#999999"
+     borderopacity="1"
+     inkscape:showpageshadow="0"
+     inkscape:pageopacity="0"
+     inkscape:pagecheckerboard="0"
+     inkscape:deskcolor="#d1d1d1"
+     inkscape:document-units="mm"
+     showgrid="false"
+     inkscape:zoom="2.3786088"
+     inkscape:cx="183.09022"
+     inkscape:cy="531.82348"
+     inkscape:window-width="2560"
+     inkscape:window-height="1385"
+     inkscape:window-x="0"
+     inkscape:window-y="27"
+     inkscape:window-maximized="1"
+     inkscape:current-layer="layer1" />
+  <defs
+     id="defs2">
+    <marker
+       style="overflow:visible"
+       id="Arrow3-7-9"
+       refX="0"
+       refY="0"
+       orient="auto-start-reverse"
+       inkscape:stockid="Arrow3"
+       markerWidth="11"
+       markerHeight="11"
+       viewBox="0 0 4.2071068 7"
+       inkscape:isstock="true"
+       inkscape:collect="always"
+       preserveAspectRatio="xMidYMid"
+       markerUnits="userSpaceOnUse">
+      <path
+         style="fill:none;stroke:context-stroke;stroke-width:1;stroke-linecap:round"
+         d="M 3,-3 0,0 3,3"
+         id="arrow3-5-1"
+         transform="rotate(180,0.125,0)"
+         sodipodi:nodetypes="ccc" />
+    </marker>
+    <marker
+       style="overflow:visible"
+       id="Arrow3-7-5-2"
+       refX="0"
+       refY="0"
+       orient="auto-start-reverse"
+       inkscape:stockid="Arrow3"
+       markerWidth="11"
+       markerHeight="11"
+       viewBox="0 0 4.2071068 7"
+       inkscape:isstock="true"
+       inkscape:collect="always"
+       preserveAspectRatio="xMidYMid"
+       markerUnits="userSpaceOnUse">
+      <path
+         style="fill:none;stroke:context-stroke;stroke-width:1;stroke-linecap:round"
+         d="M 3,-3 0,0 3,3"
+         id="arrow3-5-6-7"
+         transform="rotate(180,0.125,0)"
+         sodipodi:nodetypes="ccc" />
+    </marker>
+  </defs>
+  <g
+     inkscape:label="Ebene 1"
+     inkscape:groupmode="layer"
+     id="layer1"
+     transform="translate(-109.32506,-110.6955)">
+    <path
+       style="fill:none;stroke:#000000;stroke-width:1.375;stroke-linecap:round;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1"
+       d="m 110.01256,124.8051 h 25.13569"
+       id="path2600-0" />
+    <path
+       style="fill:none;stroke:#000000;stroke-width:1.744;stroke-linecap:round;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow3-7-9)"
+       d="m 122.58041,137.41068 v -9.7876"
+       id="path2600-3-3-9" />
+    <path
+       style="fill:none;stroke:#000000;stroke-width:1.744;stroke-linecap:round;stroke-linejoin:miter;stroke-dasharray:none;stroke-opacity:1;marker-start:url(#Arrow3-7-5-2)"
+       d="m 122.58041,112.19952 v 9.7876"
+       id="path2600-3-3-2-3" />
+  </g>
+</svg>
diff --git a/Tst/tst/tst.py b/Tst/tst/tst.py
index a39b10d..e0d8208 100755
--- a/Tst/tst/tst.py
+++ b/Tst/tst/tst.py
@@ -1064,9 +1064,11 @@ class TstAppWindow(Gtk.ApplicationWindow):
         about_dialog.present()
         return
 
-    def on_set_idb_version(self, *args):
+    def on_set_idb_version(self, widget):
         self.reconnect_mib()
-        dialog = IDBChooser()
+        # get current MIB name
+        mibname = widget.get_label_widget().get_text().replace('IDB: ', '')
+        dialog = IDBChooser(mibname)
         dialog.set_transient_for(self)
 
         response = dialog.run()
@@ -1111,7 +1113,7 @@ class TstAppWindow(Gtk.ApplicationWindow):
 
 
 class IDBChooser(Gtk.Dialog):
-    def __init__(self):
+    def __init__(self, cur_mibname):
         super(IDBChooser, self).__init__(title='Select MIB')
         self.add_buttons(Gtk.STOCK_OK, Gtk.ResponseType.OK, Gtk.STOCK_CANCEL, Gtk.ResponseType.CANCEL)
         self.set_size_request(300, 200)
@@ -1127,6 +1129,10 @@ class IDBChooser(Gtk.Dialog):
         self.selection = tv.get_selection()
         self.selection.set_mode(Gtk.SelectionMode.SINGLE)
 
+        for i, row in enumerate(idb_selection):
+            if row[0] == cur_mibname:
+                self.selection.select_path(idb_selection.get_path(idb_selection.get_iter(i)))
+
         col = Gtk.TreeViewColumn('SCHEMA NAME', Gtk.CellRendererText(), text=0)
         tv.append_column(col)
 
diff --git a/Tst/tst/view.py b/Tst/tst/view.py
index 8973e3f..2b5f3c2 100644
--- a/Tst/tst/view.py
+++ b/Tst/tst/view.py
@@ -8,7 +8,7 @@ import db_interaction
 
 gi.require_version('Gtk', '3.0')
 gi.require_version('GtkSource', '3.0')
-from gi.repository import Gtk, Gdk, GtkSource
+from gi.repository import Gtk, Gdk, GtkSource, GdkPixbuf
 # -------------------------------------------
 import data_model
 import dnd_data_parser
@@ -174,14 +174,13 @@ class Board(Gtk.Box):
         self.lbl_box_comment.pack_start(self.label_comment, False, False, 0)
         # Make the area where the real command is entered
         self.comment_scrolled_window = Gtk.ScrolledWindow()
-        #self.comment_scrolled_window.set_size_request(200, 100)
+        # self.comment_scrolled_window.set_size_request(200, 100)
         self.test_meta_data_comment = Gtk.TextView.new()
         self.comment_scrolled_window.add(self.test_meta_data_comment)
 
         self.test_comment_box.pack_start(self.lbl_box_comment, False, False, 0)
         self.test_comment_box.pack_start(self.comment_scrolled_window, True, True, 0)
 
-
         # add the meta data
         self.test_meta_data_box.pack_start(self.test_meta_data_labels, False, True, 0)
         self.test_meta_data_box.pack_start(self.test_meta_data_entries, False, True, 0)
@@ -193,21 +192,31 @@ class Board(Gtk.Box):
         # making the toolbar
         self.btn_add_step = Gtk.ToolButton()
         self.btn_add_step.set_label(_('Add step'))
+        self.btn_add_step.set_tooltip_text(_('Add step'))
+        self.btn_add_step.set_icon_name('list-add')
         self.btn_add_step.connect('clicked', self.on_btn_clicked_add_step)
         self.btn_collapse_all_steps = Gtk.ToolButton()
         self.btn_collapse_all_steps.set_label(_('Collapse all steps'))
+        self.btn_collapse_all_steps.set_tooltip_text(_('Collapse all steps'))
+        pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(ccs_path + '/pixmap/collapse.svg', 24, 24)
+        icon = Gtk.Image.new_from_pixbuf(pixbuf)
+        self.btn_collapse_all_steps.set_icon_widget(icon)
         self.btn_collapse_all_steps.connect('clicked', self.collapse_all_steps)
         self.btn_expand_all_steps = Gtk.ToolButton()
         self.btn_expand_all_steps.set_label(_('Expand all steps'))
+        self.btn_expand_all_steps.set_tooltip_text(_('Expand all steps'))
+        pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_size(ccs_path + '/pixmap/expand.svg', 24, 24)
+        icon = Gtk.Image.new_from_pixbuf(pixbuf)
+        self.btn_expand_all_steps.set_icon_widget(icon)
         self.btn_expand_all_steps.connect('clicked', self.expand_all_steps)
-        #self.btn_add_parallel = Gtk.ToolButton()
-        #self.btn_add_parallel.set_label(_('Add parallel sequence'))
-        #self.btn_add_parallel.connect('clicked', self.on_btn_clicked_add_parallel)
+        # self.btn_add_parallel = Gtk.ToolButton()
+        # self.btn_add_parallel.set_label(_('Add parallel sequence'))
+        # self.btn_add_parallel.connect('clicked', self.on_btn_clicked_add_parallel)
         self.toolbar = Gtk.Toolbar()
         self.toolbar.insert(self.btn_add_step, 0)
         self.toolbar.insert(self.btn_collapse_all_steps, 1)
         self.toolbar.insert(self.btn_expand_all_steps, 2)
-        #self.toolbar.insert(self.btn_add_parallel, 3)
+        # self.toolbar.insert(self.btn_add_parallel, 3)
         self.pack_start(self.toolbar, False, True, 0)
 
         # add the grid for steps
@@ -326,7 +335,7 @@ class Board(Gtk.Box):
 
         :param: step_number: number of a step
         """
-        step_to_add = StepWidget(model=self.model, step_number=step_number, app=self.app, board=self, logger=self.logger)
+        step_to_add = StepWidget(model=self.model, step_number=step_number, app=self.app, board=self, logger=self.logger)  # TODO: seq_num parameter??
         # find the next free grid cell
         number_of_existing_steps = len(self.view.grid.get_children())
         row = number_of_existing_steps - 1
@@ -648,7 +657,7 @@ class StepWidget(Gtk.EventBox):
         self.detail_box = Gtk.Box()
         self.detail_box.set_orientation(Gtk.Orientation.VERTICAL)
         self.detail_box.connect('show', self.on_detail_box_show)
-        #self.detail_box.set_homogeneous(True)
+        # self.detail_box.set_homogeneous(True)
         Gtk.StyleContext.add_class(self.detail_box.get_style_context(), 'step-detail-box')  # for CSS styling
 
         self.vbox.pack_start(self.detail_box, True, True, 0)
@@ -658,7 +667,7 @@ class StepWidget(Gtk.EventBox):
         # area for the commands
         self.whole_description_box = Gtk.Grid()
         self.whole_description_box.set_column_homogeneous(True)
-        #self.whole_commands_box.set_orientation(Gtk.Orientation.HORIZONTAL)
+        # self.whole_commands_box.set_orientation(Gtk.Orientation.HORIZONTAL)
 
         # field for the description
         self.lbl_box_desc = Gtk.Box()
@@ -666,10 +675,10 @@ class StepWidget(Gtk.EventBox):
         self.desc_label = Gtk.Label.new()
         self.desc_label.set_text(_('Description'))
         self.lbl_box_desc.pack_start(self.desc_label, False, True, 0)
-        #self.detail_box.pack_start(self.lbl_box_desc, True, True, 0)
+        # self.detail_box.pack_start(self.lbl_box_desc, True, True, 0)
         self.desc_scrolled_window = Gtk.ScrolledWindow()
-        #self.desc_scrolled_window.set_size_request(50, 100)
-        #self.detail_box.pack_start(self.desc_scrolled_window, False, True, 0)
+        # self.desc_scrolled_window.set_size_request(50, 100)
+        # self.detail_box.pack_start(self.desc_scrolled_window, False, True, 0)
         self.desc_text_view = Gtk.TextView.new()
         self.desc_text_view.set_wrap_mode(Gtk.WrapMode.WORD)
         self.desc_text_view.set_accepts_tab(False)
@@ -685,14 +694,14 @@ class StepWidget(Gtk.EventBox):
         self.lbl_box_step_comment.pack_start(self.step_label_comment, False, False, 0)
         # Make the area where the real command is entered
         self.step_comment_scrolled_window = Gtk.ScrolledWindow()
-        #self.step_comment_scrolled_window.set_size_request(200, 100)
+        # self.step_comment_scrolled_window.set_size_request(200, 100)
         self.step_comment_view = GtkSource.View()
         self.step_comment_view.set_wrap_mode(Gtk.WrapMode.WORD)
         self.step_comment_view.set_show_line_numbers(False)
         self.step_comment_scrolled_window.add(self.step_comment_view)
         self.step_comment_buffer = self.step_comment_view.get_buffer()
 
-        #ADD everything to the whole grid
+        # ADD everything to the whole grid
         self.whole_description_box.set_column_spacing(10)
         self.whole_description_box.attach(self.lbl_box_desc, 0, 0, 3, 1)
         self.whole_description_box.attach(self.desc_scrolled_window, 0, 1, 3, 5)
@@ -742,7 +751,6 @@ class StepWidget(Gtk.EventBox):
         # self.commands_buffer.set_style_scheme(self.board.current_scheme)
         self.commands_scrolled_window.add(self.commands_view)
 
-
         self.whole_commands_box.pack_start(self.lbl_box_commands, False, False, 0)
         self.whole_commands_box.pack_start(self.commands_scrolled_window, True, True, 0)
         self.detail_box.pack_start(self.whole_commands_box, True, True, 0)
-- 
GitLab