stuff
This commit is contained in:
@@ -1,62 +1,65 @@
|
||||
from widgets import ActiveCustomerCard
|
||||
from gi.repository import Gtk
|
||||
import gi
|
||||
gi.require_version('Gtk', '3.0')
|
||||
from gi.repository import Gtk
|
||||
from widgets import ActiveCustomerCard
|
||||
|
||||
|
||||
class ActiveView:
|
||||
"""View for displaying active customer locations."""
|
||||
|
||||
|
||||
def __init__(self, callbacks):
|
||||
self.callbacks = callbacks
|
||||
self.widget = self._create_widget()
|
||||
|
||||
|
||||
def _create_widget(self):
|
||||
"""Create the main container for active locations."""
|
||||
# Main container
|
||||
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=12)
|
||||
|
||||
|
||||
# Scrolled window for content
|
||||
scrolled = Gtk.ScrolledWindow()
|
||||
scrolled.set_policy(Gtk.PolicyType.NEVER, Gtk.PolicyType.AUTOMATIC)
|
||||
scrolled.set_shadow_type(Gtk.ShadowType.NONE)
|
||||
vbox.pack_start(scrolled, True, True, 0)
|
||||
|
||||
|
||||
# Content box
|
||||
self.content_box = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=12)
|
||||
self.content_box = Gtk.Box(
|
||||
orientation=Gtk.Orientation.VERTICAL, spacing=12)
|
||||
scrolled.add(self.content_box)
|
||||
|
||||
|
||||
return vbox
|
||||
|
||||
|
||||
def update(self, customers):
|
||||
"""Update the view with new customer data.
|
||||
|
||||
|
||||
Args:
|
||||
customers: List of Customer objects with active locations to display
|
||||
"""
|
||||
# Clear existing content
|
||||
for child in self.content_box.get_children():
|
||||
child.destroy()
|
||||
|
||||
|
||||
if customers:
|
||||
# Add customer cards
|
||||
for customer in customers:
|
||||
customer_card = ActiveCustomerCard(customer, self.callbacks)
|
||||
self.content_box.pack_start(customer_card.widget, False, False, 0)
|
||||
self.content_box.pack_start(
|
||||
customer_card.widget, False, False, 0)
|
||||
else:
|
||||
# Show empty state message
|
||||
no_active_label = Gtk.Label()
|
||||
no_active_label.set_markup("<span alpha='50%'>No active locations</span>")
|
||||
no_active_label.set_markup(
|
||||
"<span alpha='50%'>No active locations</span>")
|
||||
no_active_label.set_margin_top(20)
|
||||
self.content_box.pack_start(no_active_label, False, False, 0)
|
||||
|
||||
|
||||
self.content_box.show_all()
|
||||
|
||||
|
||||
def set_visible(self, visible):
|
||||
"""Set visibility of the entire view."""
|
||||
self.widget.set_visible(visible)
|
||||
|
||||
|
||||
def clear(self):
|
||||
"""Clear all content from the view."""
|
||||
for child in self.content_box.get_children():
|
||||
child.destroy()
|
||||
child.destroy()
|
||||
|
||||
Reference in New Issue
Block a user