MCPcopy Create free account
hub / github.com/BuddySirJava/SSH-Studio / _add_custom_option_row

Method _add_custom_option_row

src/ui/host_editor.py:688–762  ·  view source on GitHub ↗

Adds a new row for a custom option to the list.

(self, key: str = "", value: str = "")

Source from the content-addressed store, hash-verified

686 child = self.custom_options_list.get_first_child()
687
688 def _add_custom_option_row(self, key: str = "", value: str = ""):
689 """Adds a new row for a custom option to the list."""
690 action_row = Adw.ActionRow()
691 action_row.set_title(key if key else _("New Custom Option"))
692 action_row.set_subtitle(value if value else _("Enter option name and value"))
693 action_row.set_activatable(False)
694 action_row.add_css_class("custom-option-row")
695
696 entry_container = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL)
697 entry_container.set_spacing(12)
698 entry_container.set_hexpand(True)
699 entry_container.set_margin_start(12)
700 entry_container.set_margin_end(12)
701
702 key_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
703 key_box.set_spacing(4)
704
705 key_label = Gtk.Label(label=_("Option Name"))
706 key_label.set_xalign(0)
707 key_label.add_css_class("dim-label")
708 key_label.add_css_class("caption")
709 key_box.append(key_label)
710
711 key_entry = Gtk.Entry()
712 key_entry.set_text(key)
713 key_entry.set_placeholder_text(_("e.g., Compression"))
714 key_entry.set_size_request(160, -1)
715 key_entry.add_css_class("custom-option-key")
716 key_entry.connect("changed", self._on_custom_option_key_changed, action_row)
717 key_box.append(key_entry)
718
719 value_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL)
720 value_box.set_spacing(4)
721 value_box.set_hexpand(True)
722
723 value_label = Gtk.Label(label=_("Value"))
724 value_label.set_xalign(0)
725 value_label.add_css_class("dim-label")
726 value_label.add_css_class("caption")
727 value_box.append(value_label)
728
729 value_entry = Gtk.Entry()
730 value_entry.set_text(value)
731 value_entry.set_placeholder_text(_("e.g., yes"))
732 value_entry.set_hexpand(True)
733 value_entry.add_css_class("custom-option-value")
734 value_entry.connect("changed", self._on_custom_option_value_changed, action_row)
735 value_box.append(value_entry)
736
737 entry_container.append(key_box)
738 entry_container.append(value_box)
739
740 remove_button = Gtk.Button()
741 remove_button.set_icon_name("user-trash-symbolic")
742 remove_button.add_css_class("flat")
743 remove_button.add_css_class("destructive-action")
744 remove_button.set_tooltip_text(_("Remove this custom option"))
745 remove_button.set_valign(Gtk.Align.CENTER)

Callers 2

_load_custom_optionsMethod · 0.95
_on_add_custom_optionMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected