3 Commits
Author SHA1 Message Date
thooge ba6b090cce Translation update for native gui 2026-11-14 17:56:41 +01:00
thooge 47bc6fccb4 Added message function to views in native gui 2026-11-14 13:08:35 +01:00
thooge db74fb6970 Fixed vessel change code in native gui 2026-11-12 19:34:59 +01:00
26 changed files with 778 additions and 464 deletions

No files matched your search

+1 -1
View File
@@ -10,7 +10,7 @@ yms (0.3.0-1) unstable; urgency=medium
* webgui: set file access rights
* fix debian packaging
-- Thomas Hooge <thomas@hoogi.de> Wed, 11 Nov 2026 19:00:00 +0200
-- Thomas Hooge <thomas@hoogi.de> Wed, 11 Nov 2026 19:00:00 +0100
yms (0.2.2-1) unstable; urgency=medium
+27
View File
@@ -0,0 +1,27 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: YMS
Upstream-Contact: Thomas Hooge
Source: https://git.hoogi.de/thooge/YMS
Files: *
Copyright: 2020-2026 Thomas Hooge
License: WTFPL-2
Files: debian/*
Copyright: 2020-2026 Thomas Hooge
License: WTFPL-2
License: WTFPL-2
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2004 Sam Hocevar
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. You just DO WHAT THE FUCK YOU WANT TO.
+461 -366
View File
File diff suppressed because it is too large. Load diff
Binary file not shown.
+3 -2
View File
@@ -13,6 +13,7 @@ class Database:
self.cur = None
self.dcur = None
self.error = None
self.last_sql = None
def connect(self, dbuser, dbpass):
if self.conn:
@@ -63,7 +64,7 @@ class Database:
def last_error(self):
if not self.error:
return('UnknownType', 0, '')
return('NoError', 0, _('No error information available'))
etype = type(self.error).__name__
ecode = 0
@@ -74,7 +75,7 @@ class Database:
etext = str(self.error.args[1])
self.error = None
return(etype, ecode, etext)
return (etype, ecode, etext)
def load_enum(self, table, column):
"""
-4
View File
@@ -992,7 +992,6 @@
<object class="GtkSpinButton" id="spi_year_built">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">adj_year_built</property>
</object>
<packing>
@@ -1048,7 +1047,6 @@
<object class="GtkSpinButton" id="spi_belt_bow">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="text" translatable="yes">0</property>
<property name="input-purpose">number</property>
<property name="adjustment">adj_belt_bow</property>
<property name="digits">2</property>
@@ -1062,7 +1060,6 @@
<object class="GtkSpinButton" id="spi_belt_aft">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="text" translatable="yes">0</property>
<property name="input-purpose">number</property>
<property name="adjustment">adj_belt_aft</property>
<property name="digits">2</property>
@@ -1152,7 +1149,6 @@
<object class="GtkSpinButton" id="spi_beam">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="text" translatable="yes">0,00</property>
<property name="adjustment">adj_beam</property>
<property name="digits">2</property>
</object>
-6
View File
@@ -710,7 +710,6 @@
<property name="can-focus">True</property>
<property name="max-length">4</property>
<property name="width-chars">4</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">adj_width_x</property>
<property name="numeric">True</property>
</object>
@@ -725,7 +724,6 @@
<property name="can-focus">True</property>
<property name="max-length">4</property>
<property name="width-chars">4</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">adj_width_y</property>
<property name="numeric">True</property>
</object>
@@ -740,7 +738,6 @@
<property name="can-focus">True</property>
<property name="max-length">4</property>
<property name="width-chars">4</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">adj_width_z</property>
<property name="numeric">True</property>
</object>
@@ -851,7 +848,6 @@
<object class="GtkSpinButton" id="spi_weight_net">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">adj_weight_net</property>
</object>
<packing>
@@ -864,7 +860,6 @@
<object class="GtkSpinButton" id="spi_weight">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">adj_weight</property>
</object>
<packing>
@@ -877,7 +872,6 @@
<object class="GtkSpinButton" id="spi_price">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">adj_price</property>
</object>
<packing>
+3
View File
@@ -377,6 +377,9 @@
<property name="can-focus">False</property>
<property name="label" translatable="yes">Remarks</property>
<property name="yalign">0</property>
<style>
<class name="field-name"/>
</style>
</object>
<packing>
<property name="left-attach">0</property>
-3
View File
@@ -568,7 +568,6 @@
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="hexpand">True</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">adj_target</property>
</object>
<packing>
@@ -592,7 +591,6 @@
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="hexpand">True</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">adj_calories</property>
</object>
<packing>
@@ -616,7 +614,6 @@
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="hexpand">True</property>
<property name="text" translatable="yes">0,00</property>
<property name="adjustment">adj_price</property>
<property name="digits">2</property>
</object>
-3
View File
@@ -794,7 +794,6 @@
<property name="can-focus">True</property>
<property name="max-length">4</property>
<property name="width-chars">4</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">adj_width_x</property>
<property name="numeric">True</property>
</object>
@@ -809,7 +808,6 @@
<property name="can-focus">True</property>
<property name="max-length">4</property>
<property name="width-chars">4</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">adj_width_y</property>
<property name="numeric">True</property>
</object>
@@ -824,7 +822,6 @@
<property name="can-focus">True</property>
<property name="max-length">4</property>
<property name="width-chars">4</property>
<property name="text" translatable="yes">0</property>
<property name="adjustment">adj_width_z</property>
<property name="numeric">True</property>
</object>
+33 -20
View File
@@ -111,7 +111,7 @@ class BaseView(View):
self.tree['user'].set_model(self.lst_user)
# list of dropdown lists (static!)
self.lst_lists = Gtk.ListStore(int, str, int)
self.lst_lists = Gtk.ListStore(int, str, int, bool)
sql = (
"SELECT dd.ddval, dd.ddtext, FIND_IN_SET('locked', dd.flags) AS locked, "
"COUNT(n.ddval) AS records "
@@ -130,6 +130,7 @@ class BaseView(View):
else:
data.append(row['ddtext'])
data.append(row['records'])
data.append(row['locked'])
self.lst_lists.append(data)
treeview.create_columns(
self.tree['ddlists'],
@@ -151,8 +152,6 @@ class BaseView(View):
self.ddid_cur = None # Current selected dropdown entry
self.ddval_cur = None
self.ddid_iter = None # to easy update selected item
self.ddval_iter = None # to easy update selected item
self.dd_newrecord = False
# Settings date format selection list
@@ -457,6 +456,11 @@ class BaseView(View):
vessel.remarks = gtkutils.get_text_contents(self.text['vessel_remarks'])
vessel.save()
self.context.publish("vessel_modified", self.context.EVENT_UPD, (vessel.vid, ))
# refresh vessel selection list
model = self.combo['vessel'].get_model()
active = self.combo['vessel'].get_active()
model[active][1] = f"{vessel.vesselname} - {vessel.model}" if vessel.model else vessel.vesselname
# switch to display mode
self.stack['vessel'].set_visible_child(self.box['vessel'])
self.display_vessel(self.context.vessel)
@@ -495,22 +499,22 @@ class BaseView(View):
self.db.conn.commit()
def display_vessel(self, vessel):
self.label['vesselname'].set_text(vessel.vesselname)
self.label['vesselname'].set_text(vessel.vesselname or '')
self.label['model'].set_text(vessel.model or '')
self.label['shipyard'].set_text(str(vessel.shipyard))
self.label['shipyard'].set_text(self.dd_storage.get(vessel.shipyard, '-'))
self.label['year_built'].set_text(self.format_int(vessel.year_built, False, default='n/a'))
self.label['hull_number'].set_text(vessel.hull_number or '')
self.label['loa'].set_text(self.format_float(vessel.loa, 2, suffix="m"))
self.label['lwl'].set_text(self.format_float(vessel.lwl, 2, suffix="m"))
self.label['beam'].set_text(self.format_float(vessel.beam, 2, suffix="m"))
self.label['draught'].set_text(self.format_float(vessel.draught, 2, suffix="m"))
self.label['draught_min'].set_text(self.format_float(vessel.draught_min, 2, suffix="m"))
self.label['displacement'].set_text(self.format_int(vessel.displacement, 2, suffix="kg"))
self.label['ballast'].set_text(self.format_int(vessel.ballast, 2, suffix="kg"))
self.label['belt_bow'].set_text(self.format_float(vessel.beltpos_bow, 2, suffix="m"))
self.label['belt_aft'].set_text(self.format_float(vessel.beltpos_aft, 2, suffix="m"))
self.label['hull_shape'].set_text(vessel.shapefile or '')
self.label['storage_def'].set_text(str(vessel.sid_default))
self.label['loa'].set_text(self.format_float(vessel.loa, 2, suffix='m'))
self.label['lwl'].set_text(self.format_float(vessel.lwl, 2, suffix='m'))
self.label['beam'].set_text(self.format_float(vessel.beam, 2, suffix='m'))
self.label['draught'].set_text(self.format_float(vessel.draught, 2, suffix='m'))
self.label['draught_min'].set_text(self.format_float(vessel.draught_min, 2, suffix='m'))
self.label['displacement'].set_text(self.format_int(vessel.displacement, 2, suffix='kg'))
self.label['ballast'].set_text(self.format_int(vessel.ballast, 2, suffix='kg'))
self.label['belt_bow'].set_text(self.format_float(vessel.beltpos_bow, 2, suffix='m'))
self.label['belt_aft'].set_text(self.format_float(vessel.beltpos_aft, 2, suffix='m'))
self.label['hull_shape'].set_text(vessel.shapefile or '-')
self.label['storage_def'].set_text(self.dd_storage.get(vessel.sid_default, '-'))
self.label['remarks'].set_text(vessel.remarks or '')
def edit_vessel(self, vessel):
@@ -664,6 +668,9 @@ class BaseView(View):
self.entry['dd_text'].grab_focus()
def on_but_list_save_clicked(self, widget):
"""
Flags locked and fixed should not be overwritten!
"""
if self.dd_newrecord:
sql = (
"INSERT INTO dropdown (ddid, ddval, ddtext, ddshort, sort, color, flags) "
@@ -694,7 +701,7 @@ class BaseView(View):
self.entry['dd_short'].get_text(),
self.spin['dd_sort'].get_value_as_int(),
self.entry['dd_color'].get_text().lstrip('#'),
'' # TODO flags
'' # TODO flags: fixed must not be overwritten!
)
treeiter = self.lst_list.append(data)
selection = self.tree['ddlist'].get_selection()
@@ -759,16 +766,21 @@ class BaseView(View):
def on_tvw_ddlists_row_activated(self, widget, path, column):
# load single list
self.ddid_iter = widget.get_selection().get_selected()[1]
self.button['list_save'].set_sensitive(False)
if treeview.get_value(widget, 3) == True:
# List is locked!
self.lst_list.clear()
self.clear_dd_entry()
self.button['list_new'].set_sensitive(False)
return
self.ddid_cur = treeview.get_value(widget, 0)
self.ddval_cur = None
self.load_list_dropdown(self.ddid_cur)
self.clear_dd_entry()
self.button['list_save'].set_sensitive(False)
self.button['list_new'].set_sensitive(True)
def on_tvw_ddlist_row_activated(self, widget, path, column):
# load list entry details
self.ddval_iter = widget.get_selection().get_selected()[1]
self.ddval_cur = treeview.get_value(widget, 0)
sql = (
"SELECT ddtext, ddshort, sort, color, flags "
@@ -797,5 +809,6 @@ class BaseView(View):
self.check['dd_fixed'].set_active('fixed' in flags)
self.check['dd_locked'].set_active('locked' in flags)
self.button['list_delete'].set_sensitive(not 'fixed' in flags)
self.button['list_save'].set_sensitive(True)
self.dd_newrecord = False
+13 -4
View File
@@ -35,6 +35,7 @@ class BoxesView(View):
# subscribe to data change events
self.context.subscribe("storage_modified", self.storage_modified)
self.context.subscribe("dd_boxtype_modified", self.boxtype_modified)
self.context.subscribe("vessel_modified", self.vessel_modified)
def get_list_row(self):
return (
@@ -96,6 +97,11 @@ class BoxesView(View):
# not implemented
pass
def vessel_modified(self, eventtype, data):
self.tree['box'].get_selection().unselect_all()
self.load_list()
self.topwidget.set_visible_child(self.box['box'])
def clear_record(self):
self.entry['label'].set_text('')
combobox.activate_row(self.combo['storage'], 1)
@@ -219,22 +225,24 @@ class BoxesView(View):
def on_but_save_clicked(self, widget):
# check mandatory fields
if not self.entry['label'].get_text().strip():
# TODO error marker
self.show_message(_("Label is mandatory. Please enter one."), Gtk.MessageType.WARNING)
self.entry['label'].grab_focus()
return
self.save_record()
print(self.sbox)
if not self.sbox.save():
pass
(etype, ecode, etext) = self.context.db.last_error()
self.show_message(f"{etype} ({ecode}): {etext}", Gtk.MessageType.ERROR)
return
self.record_unlock()
if self.newrecord:
#self.load_list()
self.add_row()
self.context.publish("box_modified", self.context.EVENT_ADD, (self.sbox.pk_value, self.sbox.label))
else:
self.refresh_row()
self.context.publish("box_modified", self.context.EVENT_UPD, (self.sbox.pk_value, self.sbox.label))
self.newrecord = False
self.hide_message()
self.display_record()
self.topwidget.set_visible_child(self.box['box_detail'])
@@ -258,5 +266,6 @@ class BoxesView(View):
return False
def on_but_cancel_clicked(self, widget):
self.hide_message()
self.record_unlock()
self.topwidget.set_visible_child(self.box['box'])
+39 -12
View File
@@ -29,8 +29,8 @@ class CablesView(View):
self.dd_type = self.context.lookup.dropdown(Dropdown.CABLE_TYPE)
combobox.load_from_dict(self.combo['type'], {-1: _("─── none ───")} | self.dd_type)
# Cable tech type
self.dd_tech = self.context.lookup.dropdown(Dropdown.CABLE_TECHNAME)
combobox.load_from_dict(self.combo['techname'], {-1: _("─── none ───")} | self.dd_tech)
self.dd_techname = self.context.lookup.dropdown(Dropdown.CABLE_TECHNAME)
combobox.load_from_dict(self.combo['techname'], {-1: _("─── none ───")} | self.dd_techname)
# Supplier
self.dd_supplier = self.context.lookup.company(1)
combobox.load_from_dict(self.combo['supplier'], {-1: _("─── none ───")} | self.dd_supplier)
@@ -42,8 +42,10 @@ class CablesView(View):
combobox.load_from_dict(self.combo['condition'], self.dd_condition, 'unknown')
# subscribe to data change events
#self.context.subscribe("dd_type_modified", self.type_modified)
#self.context.subscribe("dd_techname_modified", self.techname_modified)
self.context.subscribe("dd_cabletype_modified", self.type_modified)
self.context.subscribe("dd_techname_modified", self.techname_modified)
self.context.subscribe("company_modified", self.company_modified)
self.context.subscribe("vessel_modified", self.vessel_modified)
def get_list_row(self):
return (
@@ -111,6 +113,30 @@ class CablesView(View):
# not implemented
pass
def company_modified(self, eventtype, data):
if data[1] == 1:
# supplier
self.dd_supplier[data[0]] = data[2]
lst = self.combo['supplier'].get_model()
elif data[1] == 2:
# manufacturer
self.dd_manufacturer[data[0]] = data[2]
lst = self.combo['manufacturer'].get_model()
else:
# all other
return
if eventtype == self.context.EVENT_UPD:
for row in lst:
if row[0] == data[0]:
row[1] = data[2]
elif eventtype == self.context.EVENT_ADD:
lst.append((data[0], data[2]))
def vessel_modified(self, eventtype, data):
self.tree['cables'].get_selection().unselect_all()
self.load_list()
self.topwidget.set_visible_child(self.box['cables'])
def display_record(self):
self.label['name'].set_text(self.cable.cablename or '')
if self.cable.cabletype:
@@ -118,7 +144,7 @@ class CablesView(View):
else:
self.label['type'].set_text('')
if self.cable.techname:
self.label['techname'].set_text(self.dd_tech[self.cable.techname])
self.label['techname'].set_text(self.dd_techname[self.cable.techname])
else:
self.label['techname'].set_text('')
self.label['length'].set_text(self.format_float(self.cable.length, suffix="m"))
@@ -130,8 +156,8 @@ class CablesView(View):
self.label['color'].set_markup(f'#{self.cable.color} <span foreground="#{self.cable.color}">●</span>')
else:
self.label['color'].set_text('')
self.label['supplier'].set_text(str(self.cable.supplier))
self.label['manufacturer'].set_text(str(self.cable.manufacturer))
self.label['supplier'].set_text(self.dd_supplier.get(self.cable.supplier, '-'))
self.label['manufacturer'].set_text(self.dd_manufacturer.get(self.cable.manufacturer, '-'))
self.label['condition'].set_text(self.cable.cablecond)
self.label['remarks'].set_text(self.cable.remarks or '')
@@ -255,18 +281,17 @@ class CablesView(View):
# name, type, length, conductors, xsection
cname = self.entry['name'].get_text().strip()
if not cname:
# TODO error marker
self.show_message(_("Name is mandatory. Please enter one."), Gtk.MessageType.WARNING)
self.entry['name'].grab_focus()
return
self.save_record()
print(self.cable)
if not self.cable.save():
print("ERROR saving cable")
# TODO error in infobox
print(self.context.db.last_error())
(etype, ecode, etext) = self.context.db.last_error()
self.show_message(f"{etype} ({ecode}): {etext}", Gtk.MessageType.ERROR)
return
self.record_unlock()
if self.newrecord:
#self.load_list()
self.add_row()
self.context.publish("cable_modified", self.context.EVENT_ADD,
(self.cable.pk_value, self.cable.cablename)
@@ -277,10 +302,12 @@ class CablesView(View):
(self.cable.pk_value, self.cable.cablename)
)
self.newrecord = False
self.hide_message()
self.display_record()
self.topwidget.set_visible_child(self.box['cable_detail'])
def on_but_cancel_clicked(self, widget):
self.hide_message()
self.record_unlock()
self.topwidget.set_visible_child(self.box['cables'])
+7 -3
View File
@@ -222,15 +222,17 @@ class CompaniesView(View):
compname = self.entry['compname'].get_text().strip()
# TODO type
if not compname:
# TODO error marker
self.show_message(_("Name is mandatory. Please enter one."), Gtk.MessageType.WARNING)
self.entry['compname'].grab_focus()
return
self.save_record()
print(self.comp)
if not self.comp.save():
pass
(etype, ecode, etext) = self.context.db.last_error()
self.show_message(f"{etype} ({ecode}): {etext}", Gtk.MessageType.ERROR)
return
self.record_unlock()
if self.newrecord:
#self.load_list()
self.add_row()
self.context.publish("company_modified", self.context.EVENT_ADD,
(self.comp.pk_value, self.comp.comptype, self.comp.compname)
@@ -241,9 +243,11 @@ class CompaniesView(View):
(self.comp.pk_value, self.comp.comptype, self.comp.compname)
)
self.newrecord = False
self.hide_message()
self.display_record()
self.topwidget.set_visible_child(self.box['comp_detail'])
def on_but_cancel_clicked(self, widget):
self.hide_message()
self.record_unlock()
self.topwidget.set_visible_child(self.box['companies'])
+33 -3
View File
@@ -49,6 +49,8 @@ class EquipmentView(View):
# subscribe to data change events
self.context.subscribe("dd_ecat_modified", self.category_modified)
self.context.subscribe("company_modified", self.company_modified)
self.context.subscribe("vessel_modified", self.vessel_modified)
def get_list_row(self):
return (
@@ -89,6 +91,11 @@ class EquipmentView(View):
def on_page_activated(self):
print("Equipment activated")
def vessel_modified(self, eventtype, data):
self.tree['equipment'].get_selection().unselect_all()
self.load_list()
self.topwidget.set_visible_child(self.box['equipment'])
def category_modified(self, eventtype, data):
self.dd_category[data[0]] = data[1]
lst = self.combo['category'].get_model()
@@ -103,6 +110,25 @@ class EquipmentView(View):
# not implemented
pass
def company_modified(self, eventtype, data):
if data[1] == 1:
# supplier
self.dd_supplier[data[0]] = data[2]
lst = self.combo['supplier'].get_model()
elif data[1] == 2:
# manufacturer
self.dd_manufacturer[data[0]] = data[2]
lst = self.combo['manufacturer'].get_model()
else:
# all other
return
if eventtype == self.context.EVENT_UPD:
for row in lst:
if row[0] == data[0]:
row[1] = data[2]
elif eventtype == self.context.EVENT_ADD:
lst.append((data[0], data[2]))
def clear_record(self):
self.equip.clear()
self.entry['name'].set_text('')
@@ -255,13 +281,15 @@ class EquipmentView(View):
def on_but_save_clicked(self, widget):
# check mandatory fields
if not self.entry['name'].get_text().strip():
# TODO error marker
self.show_message(_("Name is mandatory. Please enter one."), Gtk.MessageType.WARNING)
self.entry['name'].grab_focus()
return
self.save_record()
print(self.equip)
if not self.equip.save():
# TODO error handling
pass
(etype, ecode, etext) = self.context.db.last_error()
self.show_message(f"{etype} ({ecode}): {etext}", Gtk.MessageType.ERROR)
return
self.record_unlock()
if self.newrecord:
self.add_row()
@@ -275,10 +303,12 @@ class EquipmentView(View):
(self.equip.pk_value, self.equip.ename)
)
self.newrecord = False
self.hide_message()
self.display_record()
self.topwidget.set_visible_child(self.box['equip_detail'])
def on_but_cancel_clicked(self, widget):
self.hide_message()
self.record_unlock()
self.topwidget.set_visible_child(self.box['equipment'])
+15 -4
View File
@@ -43,6 +43,7 @@ class FusesView(View):
self.context.subscribe("cable_modified", self.cable_modified)
self.context.subscribe("dd_ftype_modified", self.ftype_modified)
self.context.subscribe("dd_location_modified", self.location_modified)
self.context.subscribe("vessel_modified", self.vessel_modified)
def get_list_row(self):
return (
@@ -138,6 +139,11 @@ class FusesView(View):
# not implemented
pass
def vessel_modified(self, eventtype, data):
self.tree['fuses'].get_selection().unselect_all()
self.load_list()
self.topwidget.set_visible_child(self.box['fuses'])
def clear_record(self):
self.fuse.clear()
self.spin['fnumber'].set_value(0)
@@ -283,7 +289,8 @@ class FusesView(View):
fnumber = self.spin['fnumber'].get_value_as_int()
current = self.spin['current'].get_value()
if (fnumber == 0) or (current == 0):
# TODO error marker
self.show_message(_("Fnumber and current are mandatory. Please enter them."), Gtk.MessageType.WARNING)
self.spin['fnumber'].grab_focus()
return
if self.newrecord:
# TODO check for duplicate number!
@@ -291,23 +298,27 @@ class FusesView(View):
self.context.db.cur.execute(sql, (fnumber,))
if self.context.db.cur.fetchone()[0] > 0:
# Duplicate fuse number
print("duplicate fuse number")
self.show_message(_("Duplicate fuse number. Please select a unused one."), Gtk.MessageType.WARNING)
self.entry['fnumber'].grab_focus()
return
self.save_record()
print(self.fuse)
if not self.fuse.save():
pass
(etype, ecode, etext) = self.context.db.last_error()
self.show_message(f"{etype} ({ecode}): {etext}", Gtk.MessageType.ERROR)
return
self.record_unlock()
if self.newrecord:
#self.load_list()
self.add_row()
self.newrecord = False
else:
self.refresh_row()
self.hide_message()
self.display_record()
self.topwidget.set_visible_child(self.box['fuse_detail'])
def on_but_cancel_clicked(self, widget):
self.hide_message()
self.record_unlock()
self.topwidget.set_visible_child(self.box['fuses'])
+13 -2
View File
@@ -60,6 +60,7 @@ class InventoryView(View):
self.context.subscribe("box_modified", self.box_modified)
self.context.subscribe("equipment_modified", self.equipment_modified)
self.context.subscribe("dd_invcat_modified", self.category_modified)
self.context.subscribe("vessel_modified", self.vessel_modified)
def load_list(self):
selected_id = treeview.get_value(self.tree['inventory'])
@@ -133,6 +134,11 @@ class InventoryView(View):
# not implemented
pass
def vessel_modified(self, eventtype, data):
self.tree['inventory'].get_selection().unselect_all()
self.load_list()
self.topwidget.set_visible_child(self.box['inventory'])
def on_page_activated(self):
print("Inventory activated")
@@ -313,21 +319,26 @@ class InventoryView(View):
def on_but_save_clicked(self, widget):
# check mandatory fields
if not self.entry['name'].get_text().strip():
# TODO error marker
self.show_message(_("Name is mandatory. Please enter one."), Gtk.MessageType.WARNING)
self.entry['name'].grab_focus()
return
self.save_record()
print(self.inv)
if not self.inv.save():
pass
(etype, ecode, etext) = self.context.db.last_error()
self.show_message(f"{etype} ({ecode}): {etext}", Gtk.MessageType.ERROR)
return
self.record_unlock()
if self.newrecord:
self.load_list()
self.newrecord = False
else:
pass
self.hide_message()
self.display_record()
self.topwidget.set_visible_child(self.box['inv_detail'])
def on_but_cancel_clicked(self, widget):
self.hide_message()
self.record_unlock()
self.topwidget.set_visible_child(self.box['inventory'])
+14 -4
View File
@@ -44,6 +44,9 @@ class MaintenanceView(View):
self.entry['completion'].set_placeholder_text(context.get_datefmt_placeholder())
self.dt_completion = DatePicker(self.entry['completion'], self.button['completion'], context.get_datefmt())
# subscribe to data change events
self.context.subscribe("vessel_modified", self.vessel_modified)
def get_list_row(self):
return (
self.maint.maintid,
@@ -76,6 +79,11 @@ class MaintenanceView(View):
# restore previous selected row
selection.select_iter(treeiter)
def vessel_modified(self, eventtype, data):
self.tree['maintenance'].get_selection().unselect_all()
self.load_list()
self.topwidget.set_visible_child(self.box['maintenance'])
def clear_record(self):
self.maint.clear()
self.entry['activities'].set_text('')
@@ -194,14 +202,14 @@ class MaintenanceView(View):
def on_but_save_clicked(self, widget):
# check mandatory fields
if not self.entry['activities'].get_text().strip():
# TODO error marker
self.show_message(_("Activities is mandatory. Please enter one."), Gtk.MessageType.WARNING)
self.entry['name'].grab_focus()
return
self.save_record()
print(self.maint)
if not self.maint.save():
print("Save error")
# TODO error in infobox
print(self.context.db.last_error())
(etype, ecode, etext) = self.context.db.last_error()
self.show_message(f"{etype} ({ecode}): {etext}", Gtk.MessageType.ERROR)
return
self.record_unlock()
if self.newrecord:
@@ -209,9 +217,11 @@ class MaintenanceView(View):
self.newrecord = False
else:
self.refresh_row()
self.hide_message()
self.display_record()
self.topwidget.set_visible_child(self.box['maint_detail'])
def on_but_cancel_clicked(self, widget):
self.hide_message()
self.record_unlock()
self.topwidget.set_visible_child(self.box['maintenance'])
+14 -7
View File
@@ -55,9 +55,11 @@ class MeasurementView(View):
self.entry['date'].set_placeholder_text(context.get_datefmt_placeholder())
DatePicker(self.entry['date'], self.button['date'], context.get_datefmt())
# subscribe to data change events
self.context.subscribe("dd_mcat_modified", self.category_modified)
self.context.subscribe("dd_unit_modified", self.unit_modified)
self.context.subscribe("equipment_modified", self.equipment_modified)
self.context.subscribe("vessel_modified", self.vessel_modified)
def get_list_row(self):
unit = self.dd_unit[self.measure.unit]
@@ -165,6 +167,11 @@ class MeasurementView(View):
# not implemented
pass
def vessel_modified(self, eventtype, data):
self.tree['measurement'].get_selection().unselect_all()
self.load_list()
self.topwidget.set_visible_child(self.box['measurement'])
def clear_record(self):
self.measure.clear()
self.entry['name'].set_text('')
@@ -312,11 +319,8 @@ class MeasurementView(View):
def on_but_save_clicked(self, widget):
# check mandatory fields
if not self.entry['name'].get_text().strip():
# TODO error marker
print("Save error mandatory fields missing")
self.infobar.set_message_type(Gtk.MessageType.WARNING)
self.infobar_label.set_text("Save error mandatory fields missing")
self.infobar.set_revealed(True)
self.show_message(_("Name is mandatory. Please enter one."), Gtk.MessageType.WARNING)
self.entry['name'].grab_focus()
return
else:
self.infobar_label.set_text('')
@@ -324,17 +328,20 @@ class MeasurementView(View):
self.save_record()
print(self.measure)
if not self.measure.save():
pass
(etype, ecode, etext) = self.context.db.last_error()
self.show_message(f"{etype} ({ecode}): {etext}", Gtk.MessageType.ERROR)
return
self.record_unlock()
if self.newrecord:
#self.load_list()
self.add_row()
self.newrecord = False
else:
self.refresh_row()
self.hide_message()
self.display_record()
self.topwidget.set_visible_child(self.box['measure_detail'])
def on_but_cancel_clicked(self, widget):
self.hide_message()
self.record_unlock()
self.topwidget.set_visible_child(self.box['measurement'])
+14 -5
View File
@@ -40,6 +40,9 @@ class ProjectsView(View):
self.entry['date_start'].set_placeholder_text(context.get_datefmt_placeholder())
DatePicker(self.entry['date_start'], self.button['date_start'], context.get_datefmt())
# subscribe to data change events
self.context.subscribe("vessel_modified", self.vessel_modified)
def get_list_row(self):
return (
self.project.projid,
@@ -82,6 +85,11 @@ class ProjectsView(View):
# restore previous selected row
selection.select_iter(treeiter)
def vessel_modified(self, eventtype, data):
self.tree['projects'].get_selection().unselect_all()
self.load_list()
self.topwidget.set_visible_child(self.box['projects'])
def clear_record(self):
self.project.clear()
self.entry['name'].set_text('')
@@ -191,25 +199,26 @@ class ProjectsView(View):
def on_but_save_clicked(self, widget):
# check mandatory fields
if not self.entry['name'].get_text().strip():
# TODO error marker
self.show_message(_("Name is mandatory. Please enter one."), Gtk.MessageType.WARNING)
self.entry['name'].grab_focus()
return
self.save_record()
print(self.project)
if not self.project.save():
print("Project save error")
# TODO error in infobox
print(self.context.db.last_error())
(etype, ecode, etext) = self.context.db.last_error()
self.show_message(f"{etype} ({ecode}): {etext}", Gtk.MessageType.ERROR)
return
self.record_unlock()
if self.newrecord:
#self.load_list()
self.add_row()
self.newrecord = False
else:
self.refresh_row()
self.hide_message()
self.display_record()
self.topwidget.set_visible_child(self.box['proj_detail'])
def on_but_cancel_clicked(self, widget):
self.hide_message()
self.record_unlock()
self.topwidget.set_visible_child(self.box['projects'])
+13 -3
View File
@@ -54,6 +54,7 @@ class ProvisionsView(View):
self.context.subscribe("box_modified", self.box_modified)
self.context.subscribe("dd_provcat_modified", self.category_modified)
self.context.subscribe("dd_provunit_modified", self.unit_modified)
self.context.subscribe("vessel_modified", self.vessel_modified)
def get_list_row(self):
return (
@@ -149,6 +150,11 @@ class ProvisionsView(View):
# not implemented
pass
def vessel_modified(self, eventtype, data):
self.tree['provisions'].get_selection().unselect_all()
self.load_list()
self.topwidget.set_visible_child(self.box['provisions'])
def clear_record(self):
self.prov.clear()
self.entry['name'].set_text('')
@@ -315,22 +321,26 @@ class ProvisionsView(View):
def on_but_save_clicked(self, widget):
# check mandatory fields
if not self.entry['name'].get_text().strip():
# TODO error marker
self.show_message(_("Name is mandatory. Please enter one."), Gtk.MessageType.WARNING)
self.entry['name'].grab_focus()
return
self.save_record()
print(self.prov)
if not self.prov.save():
pass
(etype, ecode, etext) = self.context.db.last_error()
self.show_message(f"{etype} ({ecode}): {etext}", Gtk.MessageType.ERROR)
return
self.record_unlock()
if self.newrecord:
#self.load_list()
self.add_row()
else:
self.refresh_row()
self.newrecord = False
self.hide_message()
self.display_record()
self.topwidget.set_visible_child(self.box['prov_detail'])
def on_but_cancel_clicked(self, widget):
self.hide_message()
self.record_unlock()
self.topwidget.set_visible_child(self.box['provisions'])
+6 -4
View File
@@ -57,9 +57,11 @@ class StatusView:
def vessel_modified(self, eventtype, data):
print(f"Vessel changed. New ID={data[0]}")
self.load_svg()
#? self.area['status'].queue_draw()
def load_svg(self):
if not self.context.vessel.shapefile:
self.svg = None
print("No Shapefile defined for current vessel")
return
shapefile = os.path.join(self.context.cfg['shapedir'], self.context.vessel.shapefile)
@@ -111,13 +113,13 @@ class StatusView:
print("No centerline with id='centerline' found!")
def on_drw_status_draw(self, area, cr):
if self.context.vessel.pk_value is None:
# no vessel defined
return
cr.set_source_rgb(0.92, 0.97, 1.0)
cr.paint()
if self.context.vessel.pk_value is None:
# no vessel defined, empty area
return False
if self.svg:
allocation = area.get_allocation()
scale_x = allocation.width / self.svg_width
+15 -3
View File
@@ -34,6 +34,9 @@ class StorageView(View):
self.dd_capaunit = self.context.lookup.enum('storage.capaunit')
combobox.load_from_dict(self.combo['capaunit'], {"-1": _("─── none ───")} | self.dd_capaunit)
# subscribe to data change events
self.context.subscribe("vessel_modified", self.vessel_modified)
def get_list_row(self):
return (
self.storage.sid,
@@ -67,6 +70,11 @@ class StorageView(View):
# restore previous selected row
selection.select_iter(treeiter)
def vessel_modified(self, eventtype, data):
self.tree['storage'].get_selection().unselect_all()
self.load_list()
self.topwidget.set_visible_child(self.box['storage'])
def clear_record(self):
self.storage.clear()
self.entry['sname'].set_text('')
@@ -189,21 +197,24 @@ class StorageView(View):
def on_but_save_clicked(self, widget):
# check mandatory fields
if not self.entry['sname'].get_text().strip():
# TODO error marker
self.show_message(_("Name is mandatory. Please enter one."), Gtk.MessageType.WARNING)
self.entry['sname'].grab_focus()
return
self.save_record()
print(self.storage)
if not self.storage.save():
pass
(etype, ecode, etext) = self.context.db.last_error()
self.show_message(f"{etype} ({ecode}): {etext}", Gtk.MessageType.ERROR)
return
self.record_unlock()
if self.newrecord:
#self.load_list()
self.add_row()
self.context.publish("storage_modified", self.context.EVENT_ADD, (self.storage.pk_value, self.storage.sname))
self.newrecord = False
else:
self.refresh_row()
self.context.publish("storage_modified", self.context.EVENT_UPD, (self.storage.pk_value, self.storage.sname))
self.hide_message()
self.display_record()
self.topwidget.set_visible_child(self.box['stor_detail'])
@@ -223,5 +234,6 @@ class StorageView(View):
return False
def on_but_cancel_clicked(self, widget):
self.hide_message()
self.record_unlock()
self.topwidget.set_visible_child(self.box['storage'])
+16 -3
View File
@@ -49,6 +49,9 @@ class TasksView(View):
self.entry['duedate'].set_placeholder_text(context.get_datefmt_placeholder())
self.dt_duedate = DatePicker(self.entry['duedate'], self.button['duedate'], context.get_datefmt())
# subscribe to data change events
self.context.subscribe("vessel_modified", self.vessel_modified)
def get_list_row(self):
return (
self.task.taskid,
@@ -89,6 +92,11 @@ class TasksView(View):
# restore previous selected row
selection.select_iter(treeiter)
def vessel_modified(self, eventtype, data):
self.tree['tasks'].get_selection().unselect_all()
self.load_list()
self.topwidget.set_visible_child(self.box['tasks'])
def clear_record(self):
self.task.clear()
self.entry['name'].set_text('')
@@ -117,7 +125,7 @@ class TasksView(View):
def edit_record(self):
self.entry['name'].set_text(self.task.taskname)
combobox.activate_row(self.combo['project'], self.task.projid)
combobox.activate_row(self.combo['project'], self.task.projid or -1)
combobox.activate_row(self.combo['priority'], self.task.priority)
self.entry['plandate'].set_text(self.format_date(self.task.plandate))
self.entry['duedate'].set_text(self.format_date(self.task.duedate))
@@ -208,12 +216,15 @@ class TasksView(View):
def on_but_save_clicked(self, widget):
# check mandatory fields
if not self.entry['name'].get_text().strip():
# TODO error marker
self.show_message(_("Name is mandatory. Please enter one."), Gtk.MessageType.WARNING)
self.entry['name'].grab_focus()
return
self.save_record()
print(self.task)
if not self.task.save():
pass
(etype, ecode, etext) = self.context.db.last_error()
self.show_message(f"{etype} ({ecode}): {etext}", Gtk.MessageType.ERROR)
return
self.record_unlock()
if self.newrecord:
self.load_list()
@@ -221,6 +232,7 @@ class TasksView(View):
else:
pass
# TODO aktuelle Listenzeile aktualisieren!
self.hide_message()
self.display_record()
self.topwidget.set_visible_child(self.box['task_detail'])
@@ -237,5 +249,6 @@ class TasksView(View):
pass
def on_but_cancel_clicked(self, widget):
self.hide_message()
self.record_unlock()
self.topwidget.set_visible_child(self.box['tasks'])
+36
View File
@@ -33,12 +33,48 @@ class View:
self.builder.connect_signals(self)
self.topwidget = self.builder.get_object("topobject")
# create infobar here, not statically in glade
# Messagetypes from Gtk.MessageType (INFO, WARNING, ERROR, QUESTION, OTHER)
self.infobar = self.builder.get_object("infobar")
if self.infobar:
self.infobar.set_no_show_all(True)
self.infobar.set_revealed(False)
self.infobar_label = Gtk.Label()
self.infobar.get_content_area().add(self.infobar_label)
self.infobar.set_show_close_button(True)
self.infobar.connect("response", self.on_infobar_response)
gtkutils.init_named_controls(self, self.builder)
def on_infobar_response(self, infobar, response_id):
self.hide_message()
def hide_message(self):
if not self.infobar.get_revealed():
# already hidden do nothing
return
# Start hide animation
self.infobar.set_revealed(False)
GLib.timeout_add(200, self.finish_hide_message)
def finish_hide_message(self):
# Animation helper
self.infobar_label.set_text('')
self.infobar.set_message_type(Gtk.MessageType.OTHER)
self.infobar.hide()
return GLib.SOURCE_REMOVE
def show_message(self, message, message_type):
# TODO what if already shown?
if not self.infobar:
print("internal error: this module has no infobar!")
self.infobar_label.set_text(message)
self.infobar_label.show()
self.infobar.set_message_type(message_type)
self.infobar.show()
self.infobar.set_revealed(True)
def record_lock(self, table, pk_value):
self._lock_token = self.context.db.lock_acquire(table, pk_value, self.user.user_id)
if self._lock_token is None:
+2 -2
View File
@@ -311,11 +311,11 @@ if __name__ == "__main__":
if not config.read(cfgfile):
create_config(context.cfg, cfgfile)
gtkutils.messagebox(
_("Configuration file '{}' not found.\n"
_("Configuration file '%s' not found.\n"
"Default configuration has been created.\n"
"Please edit that file according to your needs.\n\n"
"Then restart this program."
).format(cfgfile), title="YMS")
) % cfgfile, title="YMS")
else:
context.cfg['host'] = config.get('DB', 'host')
context.cfg['db'] = config.get('DB', 'db')