Move environment selector to URL bar, remove label, add tooltip
This commit is contained in:
parent
80fe2a33f0
commit
1582e9479b
@ -41,7 +41,6 @@ class RequestTabWidget(Gtk.Box):
|
|||||||
self.selected_environment_id = selected_environment_id
|
self.selected_environment_id = selected_environment_id
|
||||||
self.project_manager = None # Will be injected from window
|
self.project_manager = None # Will be injected from window
|
||||||
self.environment_dropdown = None # Will be created if project_id is set
|
self.environment_dropdown = None # Will be created if project_id is set
|
||||||
self.environment_selector_box = None # Will store the environment selector UI box
|
|
||||||
self.undefined_variables = set() # Track undefined variables for visual feedback
|
self.undefined_variables = set() # Track undefined variables for visual feedback
|
||||||
self._update_indicators_timeout_id = None # Debounce timer for indicator updates
|
self._update_indicators_timeout_id = None # Debounce timer for indicator updates
|
||||||
|
|
||||||
@ -60,11 +59,15 @@ class RequestTabWidget(Gtk.Box):
|
|||||||
|
|
||||||
# URL Input Section
|
# URL Input Section
|
||||||
url_clamp = Adw.Clamp(maximum_size=1000)
|
url_clamp = Adw.Clamp(maximum_size=1000)
|
||||||
url_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=12)
|
self.url_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=12)
|
||||||
url_box.set_margin_start(12)
|
self.url_box.set_margin_start(12)
|
||||||
url_box.set_margin_end(12)
|
self.url_box.set_margin_end(12)
|
||||||
url_box.set_margin_top(12)
|
self.url_box.set_margin_top(12)
|
||||||
url_box.set_margin_bottom(12)
|
self.url_box.set_margin_bottom(12)
|
||||||
|
|
||||||
|
# Environment Selector (only if project_id is set, added first)
|
||||||
|
if self.project_id:
|
||||||
|
self._build_environment_selector()
|
||||||
|
|
||||||
# Method Dropdown
|
# Method Dropdown
|
||||||
self.method_dropdown = Gtk.DropDown()
|
self.method_dropdown = Gtk.DropDown()
|
||||||
@ -74,27 +77,22 @@ class RequestTabWidget(Gtk.Box):
|
|||||||
self.method_dropdown.set_model(methods)
|
self.method_dropdown.set_model(methods)
|
||||||
self.method_dropdown.set_selected(0)
|
self.method_dropdown.set_selected(0)
|
||||||
self.method_dropdown.set_enable_search(False)
|
self.method_dropdown.set_enable_search(False)
|
||||||
url_box.append(self.method_dropdown)
|
self.url_box.append(self.method_dropdown)
|
||||||
|
|
||||||
# URL Entry
|
# URL Entry
|
||||||
self.url_entry = Gtk.Entry()
|
self.url_entry = Gtk.Entry()
|
||||||
self.url_entry.set_placeholder_text("Enter URL...")
|
self.url_entry.set_placeholder_text("Enter URL...")
|
||||||
self.url_entry.set_hexpand(True)
|
self.url_entry.set_hexpand(True)
|
||||||
url_box.append(self.url_entry)
|
self.url_box.append(self.url_entry)
|
||||||
|
|
||||||
# Send Button
|
# Send Button
|
||||||
self.send_button = Gtk.Button(label="Send")
|
self.send_button = Gtk.Button(label="Send")
|
||||||
self.send_button.add_css_class("suggested-action")
|
self.send_button.add_css_class("suggested-action")
|
||||||
url_box.append(self.send_button)
|
self.url_box.append(self.send_button)
|
||||||
|
|
||||||
url_clamp.set_child(url_box)
|
url_clamp.set_child(self.url_box)
|
||||||
self.append(url_clamp)
|
self.append(url_clamp)
|
||||||
|
|
||||||
# Environment Selector (only if project_id is set)
|
|
||||||
# Store reference for potential later insertion
|
|
||||||
if self.project_id:
|
|
||||||
self._show_environment_selector()
|
|
||||||
|
|
||||||
# Vertical Paned: Main Content | History Panel
|
# Vertical Paned: Main Content | History Panel
|
||||||
vpane = Gtk.Paned(orientation=Gtk.Orientation.VERTICAL)
|
vpane = Gtk.Paned(orientation=Gtk.Orientation.VERTICAL)
|
||||||
vpane.set_vexpand(True)
|
vpane.set_vexpand(True)
|
||||||
@ -595,36 +593,25 @@ class RequestTabWidget(Gtk.Box):
|
|||||||
return body
|
return body
|
||||||
|
|
||||||
def _build_environment_selector(self):
|
def _build_environment_selector(self):
|
||||||
"""Build environment selector UI. Returns None if no project_id."""
|
"""Build environment selector and add to URL box."""
|
||||||
if not self.project_id:
|
if not self.project_id or not hasattr(self, 'url_box'):
|
||||||
return None
|
return
|
||||||
|
|
||||||
# Create horizontal box for environment selector
|
# Create dropdown (compact, no label)
|
||||||
env_box = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=12)
|
|
||||||
env_box.set_margin_start(12)
|
|
||||||
env_box.set_margin_end(12)
|
|
||||||
env_box.set_margin_top(6)
|
|
||||||
env_box.set_margin_bottom(6)
|
|
||||||
|
|
||||||
# Label
|
|
||||||
label = Gtk.Label(label="Environment:")
|
|
||||||
label.add_css_class("dim-label")
|
|
||||||
env_box.append(label)
|
|
||||||
|
|
||||||
# Dropdown (will be populated when project_manager is injected)
|
|
||||||
self.environment_dropdown = Gtk.DropDown()
|
self.environment_dropdown = Gtk.DropDown()
|
||||||
self.environment_dropdown.set_enable_search(False)
|
self.environment_dropdown.set_enable_search(False)
|
||||||
env_box.append(self.environment_dropdown)
|
self.environment_dropdown.set_tooltip_text("Select environment for variable substitution")
|
||||||
|
|
||||||
# Connect signal
|
# Connect signal
|
||||||
self.environment_dropdown.connect("notify::selected", self._on_environment_changed)
|
self.environment_dropdown.connect("notify::selected", self._on_environment_changed)
|
||||||
|
|
||||||
|
# Add to URL box at the start (before method dropdown)
|
||||||
|
self.url_box.prepend(self.environment_dropdown)
|
||||||
|
|
||||||
# Populate if project_manager is already available
|
# Populate if project_manager is already available
|
||||||
if self.project_manager:
|
if self.project_manager:
|
||||||
self._populate_environment_dropdown()
|
self._populate_environment_dropdown()
|
||||||
|
|
||||||
return env_box
|
|
||||||
|
|
||||||
def _populate_environment_dropdown(self):
|
def _populate_environment_dropdown(self):
|
||||||
"""Populate environment dropdown with project's environments."""
|
"""Populate environment dropdown with project's environments."""
|
||||||
if not self.environment_dropdown or not self.project_manager or not self.project_id:
|
if not self.environment_dropdown or not self.project_manager or not self.project_id:
|
||||||
@ -670,18 +657,11 @@ class RequestTabWidget(Gtk.Box):
|
|||||||
def _show_environment_selector(self):
|
def _show_environment_selector(self):
|
||||||
"""Show environment selector (create if it doesn't exist)."""
|
"""Show environment selector (create if it doesn't exist)."""
|
||||||
# If selector already exists, nothing to do
|
# If selector already exists, nothing to do
|
||||||
if self.environment_selector_box:
|
if self.environment_dropdown:
|
||||||
return
|
return
|
||||||
|
|
||||||
# Create the selector
|
# Create and add the selector to URL box
|
||||||
self.environment_selector_box = self._build_environment_selector()
|
self._build_environment_selector()
|
||||||
|
|
||||||
# Insert it after the URL box (which is the first child)
|
|
||||||
# Get the first child (url_clamp) to insert after it
|
|
||||||
first_child = self.get_first_child()
|
|
||||||
if first_child:
|
|
||||||
# Insert after the first child
|
|
||||||
self.insert_child_after(self.environment_selector_box, first_child)
|
|
||||||
|
|
||||||
# Populate if project_manager is available
|
# Populate if project_manager is available
|
||||||
if self.project_manager:
|
if self.project_manager:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user