65 lines
1.9 KiB
Python
65 lines
1.9 KiB
Python
# SPDX-License-Identifier: WTFPL
|
|
|
|
import os
|
|
import gi
|
|
gi.require_version("Gtk", "3.0")
|
|
from gi.repository import Gtk
|
|
|
|
from .view import View
|
|
from yms import gtkutils, combobox, treeview
|
|
from yms.model import cable
|
|
|
|
class CablesView(View):
|
|
|
|
def __init__(self, context):
|
|
super().__init__(context, _("Cables"), "cables.ui")
|
|
|
|
self.cable = cable.Cable(context.db) # current record
|
|
self.newrecord = False
|
|
|
|
self.lst_cables = Gtk.ListStore(int, str, str)
|
|
sql = (
|
|
"SELECT cableid, cablename, cablecond "
|
|
"FROM cable "
|
|
"WHERE vid=%s "
|
|
"ORDER BY cableid"
|
|
)
|
|
self.db.dcur.execute(sql, (context.vessel.vid,))
|
|
for row in self.db.dcur.fetchall():
|
|
data = (
|
|
row['cableid'],
|
|
row['cablename'],
|
|
row['cablecond']
|
|
)
|
|
self.lst_cables.append(data)
|
|
|
|
treeview.add_column(self.tree['cables'], _('ID'), 0)
|
|
treeview.add_column(self.tree['cables'], _('Name'), 1)
|
|
treeview.add_column(self.tree['cables'], _('Condition'), 2)
|
|
self.tree['cables'].set_model(self.lst_cables)
|
|
|
|
# buttons on list page
|
|
def on_but_new_clicked(self, widget):
|
|
self.topwidget.set_visible_child(self.box['cable_edit'])
|
|
|
|
def on_but_edit_clicked(self, widget):
|
|
self.topwidget.set_visible_child(self.box['cable_edit'])
|
|
|
|
def on_but_detail_clicked(self, widget):
|
|
self.topwidget.set_visible_child(self.box['cable_detail'])
|
|
|
|
# buttons on detail page
|
|
# edit2 uses edit callback
|
|
def on_but_close_clicked(self, widget):
|
|
self.topwidget.set_visible_child(self.box['cables'])
|
|
|
|
def on_but_delete_clicked(self, widget):
|
|
self.topwidget.set_visible_child(self.box['cables'])
|
|
|
|
# buttons on edit page
|
|
def on_but_save_clicked(self, widget):
|
|
pass
|
|
|
|
def on_but_cancel_clicked(self, widget):
|
|
self.topwidget.set_visible_child(self.box['cables'])
|