Native gui first steps: storage, box and companies are editable

This commit is contained in:
thooge committed 2026-10-21 17:16:55 +02:00
1 parent 1eea4058bf
commit 06a9834688
47 files changed
+3085 -849

No files matched your search

-1
View File
@@ -3,7 +3,6 @@ __pycache__/
*.txt
*.bak
*.pot
*.mo
compare_*
# Debian package build artifacts
+251 -222
View File
File diff suppressed because it is too large. Load diff
Binary file not shown.
+6 -5
View File
@@ -1,5 +1,6 @@
import MySQLdb
import secrets
from gettext import pgettext
class Database:
@@ -63,7 +64,6 @@ class Database:
def load_enum(self, table, column):
"""
TODO this is only an example! perhaps other keys needed
Load an enum directly from a database table and provide it as a
dictionary for use in, for example, selection lists.
"""
@@ -76,9 +76,10 @@ class Database:
row = self.cur.fetchone()
if not row:
return {}
enumvals = row[0].replace("'", "").split(",")
return {
i: _(value.strip("'"))
for i, value in enumerate(row[0].split(','), 1)
value: pgettext(f"{table}.{column}", value)
for value in enumvals
}
def lock_acquire(self, table, key, userid):
@@ -94,7 +95,7 @@ class Database:
return token
except self.conn.IntegrityError as e:
self.conn.rollback()
if e.errno != 1062:
if e.args[0] != 1062:
raise
# lazy locking: lock exists but is old, so we use it
sql = (
@@ -112,7 +113,7 @@ class Database:
def lock_refresh(self, token):
sql = (
"UPDATE recordlock "
"SET last_seen=current_timestamp() "
"SET last_seen=CURRENT_TIMESTAMP "
"WHERE token=%s"
)
self.cur.execute(sql, (token,))
+49
View File
@@ -1,3 +1,5 @@
# SPDX-License-Identifier: WTFPL
from gi.repository import Gtk
def init_named_controls(window, builder):
@@ -74,3 +76,50 @@ def get_text_contents(textview):
"""
buf = textview.get_buffer()
return buf.get_text(buf.get_start_iter(), buf.get_end_iter(), True)
class TouchPopup():
"""
A pop-up window that can be closed again with another click.
The pop-up features a title in bold, as well as a list of labels and values.
"""
#TODO finish converting to GTK3
def __init__(self, parent, title, data, width=None):
self.window = win = gtk.Window(Gtk.WindowType.POPUP)
win.set_position(Gtk.WindowPosition.MOUSE)
win.set_transient_for(parent)
win.set_modal(True)
if width:
win.set_size_request(width, -1)
#win.modify_bg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#feffd0"))
win.override_background_color(
Gtk.StateFlags.NORMAL,
Gdk.RGBA(1.0, 1.0, 0.816, 1.0) # #feffd0
)
frame = Gtk.Frame()
frame.set_shadow_type(Gtk.ShadowType.ETCHED_OUT)
frame.set_border_width(2)
win.add(frame)
vbox = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=0)
frame.add(vbox)
# Title
label = Gtk.Label("<b>" + title + "</b>")
label.set_use_markup(True)
label.set_alignment(0.0, 0.5)
vbox.pack_start(label)
# Data
sg = Gtk.SizeGroup(Gtk.SizeGroupMode.HORIZONTAL)
for d in data:
hbox = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=0)
vbox.pack_start(hbox)
label = Gtk.Label(d[0])
label.set_alignment(0.0, 0.5)
hbox.pack_start(label, False, False, 4)
sg.add_widget(label)
label = Gtk.Label(d[1])
label.set_alignment(0.0, 0.5)
hbox.pack_start(label)
win.add_events(Gdk.EventMask.BUTTON_PRESS_MASK)
win.connect('button-press-event', self.callback)
win.show_all()
def callback(self, window, event):
window.destroy()
+90 -22
View File
@@ -1,14 +1,21 @@
# SPDX-License-Identifier: WTFPL
"""
Dropdowns and database enums
from enum import IntEnum
dropdowns can change
"""
Dropdowns, Database enums and Table numbers
dropdowns contents can change
enums are static
TBD
- language
- dateformat
- dimensions (measurement)
"""
class Dropdown:
class Dropdown(IntEnum):
HULL_TYPE = 1
COMPANY_TYPE = 2
STORAGE_TYPE = 3
@@ -25,54 +32,73 @@ class Dropdown:
BBN_VESSELDATA = 14
MEASUREMENT_CATEGORY = 15
Dependencies = {
HULL_TYPE: (
DropdownDeps = {
Dropdown.HULL_TYPE: (
# unused
),
COMPANY_TYPE: (
Dropdown.COMPANY_TYPE: (
('company', 'comptype'),
('company', 'comptype2')
),
STORAGE_TYPE: (
Dropdown.STORAGE_TYPE: (
('storage', 'stype'),
),
EQUIPMENT_CATEGORY: (
Dropdown.EQUIPMENT_CATEGORY: (
('equipment', 'ecat'),
),
PROVISION_CATEGORY: (
Dropdown.PROVISION_CATEGORY: (
('provisions', 'provcat'),
),
PROVISION_UNIT: (
Dropdown.PROVISION_UNIT: (
('provisions', 'unit'),
),
FUSE_TYPE: (
Dropdown.FUSE_TYPE: (
('fuse', 'ftype'),
),
UNIT: (
Dropdown.UNIT: (
('measurement', 'unit'),
),
BOX_TYPE: (
Dropdown.BOX_TYPE: (
('box', 'boxtype'),
),
FUSE_BLOCK: (
Dropdown.FUSE_BLOCK: (
('fuse', 'location'),
),
CABLE_TYPE: (
Dropdown.CABLE_TYPE: (
('cable', 'cabletype'),
),
CABLE_TECHNAME: (
Dropdown.CABLE_TECHNAME: (
('cable', 'techname'),
),
INVENTORY_CATEGORY: (
Dropdown.INVENTORY_CATEGORY: (
('inventory', 'invcat'),
),
BBN_VESSELDATA: (
Dropdown.BBN_VESSELDATA: (
#unused
),
MEASUREMENT_CATEGORY: (
Dropdown.MEASUREMENT_CATEGORY: (
('measurement', 'mcat'),
)
}
}
class Table(IntEnum):
VESSEL = (1, "base")
USERS = (2, "base")
COMPANIES = (3, "companies")
STORAGE = (4, "storage")
BOXES = (5, "boxes")
EQUIPMENT = (6, "equipment")
#INVENTORY = (7, "inventory")
PROJECTS = (8, "projects")
CABLES = (9, "cables")
FUSES = (10, "fuses")
TAGS = (11, "tags")
def __new__(cls, value, module):
obj = int.__new__(cls, value)
obj._value_ = value
obj.module = module
return obj
class Lookup:
@@ -80,6 +106,7 @@ class Lookup:
self.db = db
self._enums = {}
self._dropdowns = {}
self._revision_ts = {} # tracking list revisions
def load(self):
self._load_enums()
@@ -87,7 +114,7 @@ class Lookup:
def _load_enums(self):
"""
TODO translation via gettext needed
translation via gettext from db schema
"""
db_enums = {
'cable.cablecond': ('cable', 'cablecond'),
@@ -98,8 +125,11 @@ class Lookup:
'document.doctype': ('document', 'doctype'),
'document.roleaccess': ('document', 'roleaccess'),
'dropdown.flags': ('dropdown', 'flags'),
'equipment.econd': ('equipment', 'econd'),
'equipment.flags': ('equipment', 'flags'),
'inventory.conttype': ('inventory', 'conttype'),
'inventory.invcond': ('inventory', 'invcond'),
'inventory.flags': ('inventory', 'flags'),
'maintenance.maintstate': ('maintenance', 'maintstate'),
'measurement.accuracy': ('measurement', 'accuracy'),
'note.notetype': ('note', 'notetype'),
@@ -138,12 +168,27 @@ class Lookup:
self._dropdowns[ddid] = {}
self._dropdowns[ddid][ddval] = ddtext
def reload_dropdown(self, ddid):
self._dropdowns[ddid] = {}
sql = (
"SELECT ddval, ddtext "
"FROM dropdown "
"WHERE ddid=%s "
"ORDER BY sort, ddval"
)
self.db.cur.execute(sql)
for ddval, ddtext in self.db.cur.fetchall():
self._dropdowns[ddid][ddval] = ddtext
def enum(self, name):
return self._enums[name]
def dropdown(self, ddid):
return self._dropdowns[ddid]
def iter_dropdowns(self):
yield from self._dropdowns.keys()
def user(self):
self.db.cur.execute("SELECT userid, displayname FROM user ORDER BY displayname")
return dict(self.db.cur.fetchall())
@@ -181,6 +226,19 @@ class Lookup:
storagelist[row[0]] = "{} ({}) - {}".format(row[1], row[2], row[3])
return storagelist
def box(self, vid):
boxlist = {}
sql = (
"SELECT b.boxid, b.label, b.content "
"FROM box AS b LEFT JOIN storage AS s USING (sid) "
"WHERE s.vid=%s OR s.vid IS NULL "
"ORDER BY b.label"
)
self.db.cur.execute(sql, (vid,))
for row in self.db.cur.fetchall():
boxlist[row[0]] = "{} - {}".format(row[1], row[2])
return boxlist
def equipment(self, vid):
sql = (
"SELECT eid, ename "
@@ -221,6 +279,16 @@ class Lookup:
self.db.cur.execute(sql, (vid,))
return dict(self.db.cur.fetchall())
def project(self, vid):
sql = (
"SELECT projid, projname "
"FROM project "
"WHERE vid=%s "
"ORDER BY projname"
)
self.db.cur.execute(sql, (vid,))
return dict(self.db.cur.fetchall())
def refresh(self):
# TODO ugly hack please improve
self._load_dropdowns()
+6
View File
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: WTFPL
from .dbrecord import DbRecord
from yms.lookup import Table
class Box(DbRecord):
@@ -12,3 +13,8 @@ class Box(DbRecord):
def __init__(self, db, boxid=None):
super().__init__(db, boxid)
self.title = _("Box({})")
def save(self, commit=True):
super().save(Table.BOXES)
if commit:
self.conn.commit()
+6
View File
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: WTFPL
from .dbrecord import DbRecord
from yms.lookup import Table
class Cable(DbRecord):
@@ -13,3 +14,8 @@ class Cable(DbRecord):
def __init__(self, db, cableid=None):
super().__init__(db, cableid)
self.title = _("Cable({})")
def save(self, commit=True):
super().save(Table.CABLES)
if commit:
self.conn.commit()
+12
View File
@@ -1,6 +1,13 @@
# SPDX-License-Identifier: WTFPL
from .dbrecord import DbRecord
from yms.lookup import Table
# names for fixed dropdown values
SUPPLIER = 1
MANUFACTURER = 2
SHIPYARD = 3
MISC = 9
class Company(DbRecord):
@@ -13,3 +20,8 @@ class Company(DbRecord):
def __init__(self, db, compid=None):
super().__init__(db, compid)
self.title = _("Company({})")
def save(self, commit=True):
super().save(Table.COMPANIES)
if commit:
self.conn.commit()
+12 -3
View File
@@ -62,12 +62,21 @@ class DbRecord:
self.clear()
return False
def save(self):
def save(self, rev_id=None):
self.last_update = datetime.now()
if self.pk_value is not None:
return self._update()
ret = self._update()
else:
return self._insert()
ret = self._insert()
if ret == True and rev_id is not None:
# set list change marker
sql = (
"INSERT INTO revision (revtype, revid, changed) "
"VALUES ('table', %s, NOW()) "
"ON DUPLICATE KEY UPDATE changed = NOW()"
)
self.cur.execute(sql, (rev_id,))
return ret
def _update(self):
sqlfield = []
+7 -1
View File
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: WTFPL
from .dbrecord import DbRecord
from yms.lookup import Table
class Equipment(DbRecord):
@@ -8,8 +9,13 @@ class Equipment(DbRecord):
pk_field = "eid"
fields = ('eid', 'vid', 'ename', 'shortname', 'model', 'ecat', 'serial',
'supplier', 'manufacturer', 'purchdate', 'price', 'weight', 'remarks',
'flags')
'econd', 'flags')
def __init__(self, db, eid=None):
super().__init__(db, eid)
self.title = _("Equipment({})")
def save(self, commit=True):
super().save(Table.EQUIPMENT)
if commit:
self.conn.commit()
+6
View File
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: WTFPL
from .dbrecord import DbRecord
from yms.lookup import Table
class Fuse(DbRecord):
@@ -12,3 +13,8 @@ class Fuse(DbRecord):
def __init__(self, db, fuseid=None):
super().__init__(db, fuseid)
self.title = _("Fuse({})")
def save(self, commit=True):
super().save(Table.FUSES)
if commit:
self.conn.commit()
+6
View File
@@ -1,6 +1,7 @@
# SPDX-License-Identifier: WTFPL
from .dbrecord import DbRecord
from yms.lookup import Table
class Project(DbRecord):
@@ -12,3 +13,8 @@ class Project(DbRecord):
def __init__(self, db, projid=None):
super().__init__(db, projid)
self.title = _("Project({})")
def save(self, commit=True):
super().save(Table.PROJECTS)
if commit:
self.conn.commit()
+8 -2
View File
@@ -1,6 +1,12 @@
# SPDX-License-Identifier: WTFPL
from .dbrecord import DbRecord
from yms.lookup import Table
# names for fixed dropdown values
GENERIC = 0
TANK = 1
EXT = 2
class Storage(DbRecord):
@@ -14,10 +20,10 @@ class Storage(DbRecord):
self.title = _("Storage({})")
def save(self, commit=True):
super().save()
super().save(Table.STORAGE)
if commit:
self.conn.commit()
def delete(self):
# there must be no assiciated data!
# there must be no associated data!
pass
+14
View File
@@ -104,6 +104,13 @@ class User(object):
# create mandatory settings
sql = "INSERT INTO settings (userid, sno, valint) VALUES (%s, 1, 0)"
self.cur.execute(sql, (newid,))
# set list change marker
sql = (
"INSERT INTO revision (revtype, revid, changed) "
"VALUES ('table', 2, NOW()) "
"ON DUPLICATE KEY UPDATE changed = NOW()"
)
self.db.cur.execute()
self.conn.commit()
return newid
@@ -112,6 +119,13 @@ class User(object):
self.cur.execute(sql, (self.user_id,))
sql = "DELETE FROM user WHERE userid=%s"
self.cur.execute(sql, (self.user_id,))
# set list change marker
sql = (
"INSERT INTO revision (revtype, revid, changed) "
"VALUES ('table', 2, NOW()) "
"ON DUPLICATE KEY UPDATE changed = NOW()"
)
self.db.cur.execute()
self.conn.commit()
def setpass(self, newpass):
+17 -3
View File
@@ -6,8 +6,8 @@ class Vessel(DbRecord):
table = "vessel"
pk_field = "vid"
fields = ('vid', 'vtype', 'vesselname', 'model', 'shipyard', 'loa', 'lwl',
'beam', 'draught', 'draught_min', 'displacement', 'ballast',
fields = ('vid', 'vtype', 'htype', 'vesselname', 'model', 'shipyard', 'hull_number',
'loa', 'lwl', 'beam', 'draught', 'draught_min', 'displacement', 'ballast',
'beltpos_aft', 'beltpos_bow', 'shapefile', 'sid_default', 'year_built',
'remarks')
@@ -32,8 +32,15 @@ class Vessel(DbRecord):
self.clear()
self.vid = self.pk_value
self.vesselname = f"Vessel #{self.pk_value}"
self.vtype = 1 # monohull
self.htype = 'mono'
self._insert()
# set list change marker
sql = (
"INSERT INTO revision (revtype, revid, changed) "
"VALUES ('table', 1, NOW()) "
"ON DUPLICATE KEY UPDATE changed = NOW()"
)
self.db.cur.execute()
self.conn.commit()
def save(self, commit=True):
@@ -44,3 +51,10 @@ class Vessel(DbRecord):
def delete(self):
# there must be no assiciated data!
pass
# set list change marker
sql = (
"INSERT INTO revision (revtype, revid, changed) "
"VALUES ('table', 1, NOW()) "
"ON DUPLICATE KEY UPDATE changed = NOW()"
)
self.db.cur.execute()
+190 -123
View File
@@ -17,7 +17,7 @@
<property name="step-increment">1</property>
<property name="page-increment">10</property>
</object>
<object class="GtkAdjustment" id="adj_belt_front">
<object class="GtkAdjustment" id="adj_belt_bow">
<property name="upper">100</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
@@ -74,34 +74,11 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Ghost</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<!-- n-columns=2 n-rows=17 -->
<object class="GtkGrid" id="grd_vessel_detail">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Name</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
@@ -110,7 +87,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
@@ -121,7 +98,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">3</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
@@ -132,7 +109,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">4</property>
<property name="top-attach">3</property>
</packing>
</child>
<child>
@@ -143,7 +120,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">8</property>
<property name="top-attach">7</property>
</packing>
</child>
<child>
@@ -154,7 +131,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">7</property>
<property name="top-attach">6</property>
</packing>
</child>
<child>
@@ -165,7 +142,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">6</property>
<property name="top-attach">5</property>
</packing>
</child>
<child>
@@ -176,7 +153,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">5</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
@@ -187,19 +164,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">10</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lbl_vesselname">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hexpand">True</property>
<property name="selectable">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
<property name="top-attach">9</property>
</packing>
</child>
<child>
@@ -211,7 +176,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">2</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
@@ -223,7 +188,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">3</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
@@ -235,7 +200,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">4</property>
<property name="top-attach">3</property>
</packing>
</child>
<child>
@@ -247,7 +212,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">5</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
@@ -259,7 +224,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">6</property>
<property name="top-attach">5</property>
</packing>
</child>
<child>
@@ -271,7 +236,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">7</property>
<property name="top-attach">6</property>
</packing>
</child>
<child>
@@ -283,7 +248,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">8</property>
<property name="top-attach">7</property>
</packing>
</child>
<child>
@@ -295,7 +260,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">10</property>
<property name="top-attach">9</property>
</packing>
</child>
<child>
@@ -321,7 +286,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">15</property>
<property name="top-attach">14</property>
</packing>
</child>
<child>
@@ -333,7 +298,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">15</property>
<property name="top-attach">14</property>
</packing>
</child>
<child>
@@ -344,7 +309,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">9</property>
<property name="top-attach">8</property>
</packing>
</child>
<child>
@@ -356,7 +321,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">9</property>
<property name="top-attach">8</property>
</packing>
</child>
<child>
@@ -367,7 +332,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">11</property>
<property name="top-attach">10</property>
</packing>
</child>
<child>
@@ -378,7 +343,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">12</property>
<property name="top-attach">11</property>
</packing>
</child>
<child>
@@ -390,7 +355,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">11</property>
<property name="top-attach">10</property>
</packing>
</child>
<child>
@@ -402,7 +367,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">12</property>
<property name="top-attach">11</property>
</packing>
</child>
<child>
@@ -413,7 +378,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">13</property>
<property name="top-attach">12</property>
</packing>
</child>
<child>
@@ -451,7 +416,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">13</property>
<property name="top-attach">12</property>
</packing>
</child>
<child>
@@ -462,7 +427,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">14</property>
<property name="top-attach">13</property>
</packing>
</child>
<child>
@@ -474,14 +439,37 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">14</property>
<property name="top-attach">13</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Hull number</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">15</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lbl_hull_number">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hexpand">True</property>
<property name="selectable">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">15</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">0</property>
</packing>
</child>
<child>
@@ -536,7 +524,7 @@
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="position">1</property>
</packing>
</child>
</object>
@@ -552,7 +540,7 @@
<property name="orientation">vertical</property>
<property name="spacing">4</property>
<child>
<object class="GtkLabel" id="lbl_vessel">
<object class="GtkLabel" id="lbl_vesselname">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Ghost</property>
@@ -564,7 +552,7 @@
</packing>
</child>
<child>
<!-- n-columns=2 n-rows=16 -->
<!-- n-columns=4 n-rows=14 -->
<object class="GtkGrid" id="grd_vessel_editor">
<property name="visible">True</property>
<property name="can-focus">False</property>
@@ -598,6 +586,7 @@
<packing>
<property name="left-attach">1</property>
<property name="top-attach">0</property>
<property name="width">3</property>
</packing>
</child>
<child>
@@ -619,6 +608,7 @@
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
<property name="width">3</property>
</packing>
</child>
<child>
@@ -629,7 +619,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">3</property>
<property name="top-attach">5</property>
</packing>
</child>
<child>
@@ -639,18 +629,7 @@
<property name="label" translatable="yes">LWL</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Beam</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="left-attach">2</property>
<property name="top-attach">5</property>
</packing>
</child>
@@ -662,7 +641,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">6</property>
<property name="top-attach">7</property>
</packing>
</child>
<child>
@@ -672,7 +651,7 @@
<property name="label" translatable="yes">Draught, min</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="left-attach">2</property>
<property name="top-attach">7</property>
</packing>
</child>
@@ -685,7 +664,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">3</property>
<property name="top-attach">5</property>
</packing>
</child>
<child>
@@ -696,19 +675,7 @@
<property name="digits">2</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spi_beam">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="adjustment">adj_beam</property>
<property name="digits">2</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="left-attach">3</property>
<property name="top-attach">5</property>
</packing>
</child>
@@ -721,7 +688,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">6</property>
<property name="top-attach">7</property>
</packing>
</child>
<child>
@@ -732,7 +699,7 @@
<property name="digits">2</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="left-attach">3</property>
<property name="top-attach">7</property>
</packing>
</child>
@@ -754,8 +721,8 @@
<property name="label" translatable="yes">Ballast</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">9</property>
<property name="left-attach">2</property>
<property name="top-attach">8</property>
</packing>
</child>
<child>
@@ -776,8 +743,8 @@
<property name="adjustment">adj_ballast</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">9</property>
<property name="left-attach">3</property>
<property name="top-attach">8</property>
</packing>
</child>
<child>
@@ -785,10 +752,11 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Remarks</property>
<property name="yalign">0</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">15</property>
<property name="top-attach">13</property>
</packing>
</child>
<child>
@@ -798,7 +766,8 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">14</property>
<property name="top-attach">12</property>
<property name="width">3</property>
</packing>
</child>
<child>
@@ -809,7 +778,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">14</property>
<property name="top-attach">12</property>
</packing>
</child>
<child>
@@ -836,7 +805,8 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">15</property>
<property name="top-attach">13</property>
<property name="width">3</property>
</packing>
</child>
<child>
@@ -847,7 +817,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
<property name="top-attach">3</property>
</packing>
</child>
<child>
@@ -859,7 +829,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">2</property>
<property name="top-attach">3</property>
</packing>
</child>
<child>
@@ -870,7 +840,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">13</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
@@ -880,7 +850,8 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">13</property>
<property name="top-attach">4</property>
<property name="width">3</property>
</packing>
</child>
<child>
@@ -891,7 +862,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">12</property>
<property name="top-attach">11</property>
</packing>
</child>
<child>
@@ -901,21 +872,22 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">12</property>
<property name="top-attach">11</property>
<property name="width">3</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spi_belt_front">
<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_front</property>
<property name="adjustment">adj_belt_bow</property>
<property name="digits">2</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">10</property>
<property name="top-attach">9</property>
</packing>
</child>
<child>
@@ -928,8 +900,8 @@
<property name="digits">2</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">11</property>
<property name="left-attach">3</property>
<property name="top-attach">9</property>
</packing>
</child>
<child>
@@ -940,7 +912,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">10</property>
<property name="top-attach">9</property>
</packing>
</child>
<child>
@@ -950,10 +922,105 @@
<property name="label" translatable="yes">Belt position, aft</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">11</property>
<property name="left-attach">2</property>
<property name="top-attach">9</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Hull number</property>
</object>
<packing>
<property name="left-attach">2</property>
<property name="top-attach">3</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="ent_hull_number">
<property name="visible">True</property>
<property name="can-focus">True</property>
</object>
<packing>
<property name="left-attach">3</property>
<property name="top-attach">3</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Hull type</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">10</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="cmb_htype">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">10</property>
<property name="width">3</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Beam</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">6</property>
</packing>
</child>
<child>
<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>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">6</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Vessel type</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="cmb_vtype">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">2</property>
<property name="width">3</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">True</property>
@@ -1099,13 +1166,13 @@
</packing>
</child>
<child>
<object class="GtkBox">
<object class="GtkBox" id="box_user_edit">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<!-- n-columns=3 n-rows=10 -->
<object class="GtkGrid">
<object class="GtkGrid" id="grd_user_editor">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
+109 -44
View File
@@ -237,7 +237,7 @@
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="lbl_title_details">
<object class="GtkLabel" id="lbl_title_detail">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Box Details</property>
@@ -252,7 +252,7 @@
</packing>
</child>
<child>
<!-- n-columns=2 n-rows=8 -->
<!-- n-columns=2 n-rows=9 -->
<object class="GtkGrid" id="grd_details">
<property name="visible">True</property>
<property name="can-focus">False</property>
@@ -287,7 +287,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">7</property>
<property name="top-attach">8</property>
</packing>
</child>
<child>
@@ -300,7 +300,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">7</property>
<property name="top-attach">8</property>
</packing>
</child>
<child>
@@ -311,7 +311,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
@@ -322,7 +322,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
@@ -333,7 +333,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
<property name="top-attach">3</property>
</packing>
</child>
<child>
@@ -344,7 +344,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">3</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
@@ -355,7 +355,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">4</property>
<property name="top-attach">5</property>
</packing>
</child>
<child>
@@ -366,7 +366,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">2</property>
<property name="top-attach">3</property>
</packing>
</child>
<child>
@@ -377,7 +377,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">3</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
@@ -388,7 +388,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">4</property>
<property name="top-attach">5</property>
</packing>
</child>
<child>
@@ -399,7 +399,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">5</property>
<property name="top-attach">6</property>
</packing>
</child>
<child>
@@ -410,7 +410,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">5</property>
<property name="top-attach">6</property>
</packing>
</child>
<child>
@@ -421,7 +421,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">6</property>
<property name="top-attach">7</property>
</packing>
</child>
<child>
@@ -432,7 +432,29 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">6</property>
<property name="top-attach">7</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lbl_lb_content1">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Storage</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lbl_storage">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hexpand">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
</packing>
</child>
</object>
@@ -526,7 +548,7 @@
</packing>
</child>
<child>
<!-- n-columns=7 n-rows=9 -->
<!-- n-columns=7 n-rows=10 -->
<object class="GtkGrid" id="grd_editor">
<property name="visible">True</property>
<property name="can-focus">False</property>
@@ -537,6 +559,9 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Label</property>
<attributes>
<attribute name="weight" value="semibold"/>
</attributes>
</object>
<packing>
<property name="left-attach">0</property>
@@ -551,7 +576,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
<property name="top-attach">2</property>
</packing>
</child>
<child>
@@ -572,7 +597,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
<property name="top-attach">2</property>
<property name="width">6</property>
</packing>
</child>
@@ -584,7 +609,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">3</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
@@ -597,7 +622,7 @@
</object>
<packing>
<property name="left-attach">2</property>
<property name="top-attach">3</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
@@ -610,7 +635,7 @@
</object>
<packing>
<property name="left-attach">4</property>
<property name="top-attach">3</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
@@ -625,7 +650,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">3</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
@@ -640,7 +665,7 @@
</object>
<packing>
<property name="left-attach">3</property>
<property name="top-attach">3</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
@@ -655,7 +680,7 @@
</object>
<packing>
<property name="left-attach">5</property>
<property name="top-attach">3</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
@@ -666,7 +691,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">5</property>
<property name="top-attach">6</property>
</packing>
</child>
<child>
@@ -677,7 +702,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">6</property>
<property name="top-attach">7</property>
</packing>
</child>
<child>
@@ -685,10 +710,11 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Remarks</property>
<property name="yalign">0</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">8</property>
<property name="top-attach">9</property>
</packing>
</child>
<child>
@@ -705,7 +731,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">8</property>
<property name="top-attach">9</property>
<property name="width">6</property>
</packing>
</child>
@@ -717,7 +743,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">7</property>
<property name="top-attach">8</property>
</packing>
</child>
<child>
@@ -730,7 +756,7 @@
</object>
<packing>
<property name="left-attach">6</property>
<property name="top-attach">3</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
@@ -741,7 +767,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">2</property>
<property name="top-attach">3</property>
</packing>
</child>
<child>
@@ -751,7 +777,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">2</property>
<property name="top-attach">3</property>
<property name="width">6</property>
</packing>
</child>
@@ -764,7 +790,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">7</property>
<property name="top-attach">8</property>
<property name="width">3</property>
</packing>
</child>
@@ -777,7 +803,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">6</property>
<property name="top-attach">7</property>
<property name="width">3</property>
</packing>
</child>
@@ -790,7 +816,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">5</property>
<property name="top-attach">6</property>
<property name="width">3</property>
</packing>
</child>
@@ -802,24 +828,63 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">4</property>
<property name="top-attach">5</property>
</packing>
</child>
<child>
<object class="GtkButton" id="but_color">
<property name="label" translatable="yes">#FFFFFF</property>
<object class="GtkEntry" id="ent_color">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="relief">half</property>
<signal name="clicked" handler="on_but_color_clicked" swapped="no"/>
<signal name="activate" handler="on_ent_color_activate" swapped="no"/>
<signal name="focus-out-event" handler="on_ent_color_focus_out_event" swapped="no"/>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">4</property>
<property name="width">3</property>
<property name="top-attach">5</property>
</packing>
</child>
<child>
<object class="GtkColorButton" id="but_color">
<property name="width-request">64</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="show-editor">True</property>
<signal name="color-set" handler="on_but_color_set" swapped="no"/>
</object>
<packing>
<property name="left-attach">2</property>
<property name="top-attach">5</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Storage</property>
<attributes>
<attribute name="weight" value="semibold"/>
</attributes>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">1</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="cmb_storage">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">1</property>
<property name="width">6</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
+41 -10
View File
@@ -666,6 +666,7 @@
<property name="label" translatable="yes">Name</property>
<attributes>
<attribute name="weight" value="semibold"/>
<attribute name="foreground" value="#000000000000"/>
</attributes>
</object>
<packing>
@@ -691,6 +692,7 @@
<property name="label" translatable="yes">Type</property>
<attributes>
<attribute name="weight" value="semibold"/>
<attribute name="foreground" value="#000000000000"/>
</attributes>
</object>
<packing>
@@ -716,6 +718,7 @@
<property name="label" translatable="yes">Length</property>
<attributes>
<attribute name="weight" value="semibold"/>
<attribute name="foreground" value="#000000000000"/>
</attributes>
</object>
<packing>
@@ -730,6 +733,7 @@
<property name="label" translatable="yes">Conductors</property>
<attributes>
<attribute name="weight" value="semibold"/>
<attribute name="foreground" value="#000000000000"/>
</attributes>
</object>
<packing>
@@ -755,6 +759,7 @@
<property name="label" translatable="yes">Cross section</property>
<attributes>
<attribute name="weight" value="semibold"/>
<attribute name="foreground" value="#000000000000"/>
</attributes>
</object>
<packing>
@@ -906,16 +911,6 @@
<property name="top-attach">7</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="ent_color">
<property name="visible">True</property>
<property name="can-focus">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">8</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="cmb_supplier">
<property name="visible">True</property>
@@ -963,6 +958,42 @@
<property name="top-attach">12</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="spacing">4</property>
<child>
<object class="GtkEntry" id="ent_color">
<property name="visible">True</property>
<property name="can-focus">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkColorButton" id="but_color">
<property name="width-request">64</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="show-editor">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">8</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
+11 -2
View File
@@ -421,6 +421,7 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Remarks</property>
<property name="yalign">0</property>
</object>
<packing>
<property name="left-attach">0</property>
@@ -540,9 +541,17 @@
</packing>
</child>
<child>
<object class="GtkTextView">
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="vexpand">True</property>
<property name="shadow-type">in</property>
<child>
<object class="GtkTextView" id="txt_remarks">
<property name="visible">True</property>
<property name="can-focus">True</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">1</property>
@@ -626,7 +635,7 @@
</child>
<child>
<!-- n-columns=2 n-rows=16 -->
<object class="GtkGrid" id="grd_detail">
<object class="GtkGrid" id="grd_details">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
+228 -6
View File
@@ -2,6 +2,159 @@
<!-- Generated with glade 3.40.0 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<object class="GtkDialog">
<property name="can-focus">False</property>
<property name="type-hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox" id="dlg_upload">
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can-focus">False</property>
<property name="layout-style">end</property>
<child>
<placeholder/>
</child>
<child>
<object class="GtkButton" id="but_upload_close">
<property name="label" translatable="yes">Close</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</child>
</object>
<object class="GtkDialog" id="dlg_scanner">
<property name="can-focus">False</property>
<property name="type-hint">dialog</property>
<child internal-child="vbox">
<object class="GtkBox">
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">2</property>
<child internal-child="action_area">
<object class="GtkButtonBox">
<property name="can-focus">False</property>
<property name="layout-style">end</property>
<child>
<object class="GtkButton" id="but_scan_preview">
<property name="label" translatable="yes">Preview</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="but_scan_scan">
<property name="label" translatable="yes">Scan</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="but_scan_close">
<property name="label" translatable="yes">Close</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkImage">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkEntry">
<property name="visible">True</property>
<property name="can-focus">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
<object class="GtkStack" id="topobject">
<property name="visible">True</property>
<property name="can-focus">False</property>
@@ -226,7 +379,7 @@
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel">
<object class="GtkLabel" id="lbl_title_detail">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Document Details</property>
@@ -561,7 +714,7 @@
</packing>
</child>
<child>
<!-- n-columns=2 n-rows=4 -->
<!-- n-columns=2 n-rows=5 -->
<object class="GtkGrid" id="grd_editor">
<property name="visible">True</property>
<property name="can-focus">False</property>
@@ -609,7 +762,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">3</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
@@ -638,7 +791,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">3</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
@@ -646,6 +799,9 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Document type</property>
<attributes>
<attribute name="weight" value="semibold"/>
</attributes>
</object>
<packing>
<property name="left-attach">0</property>
@@ -662,6 +818,30 @@
<property name="top-attach">0</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Access level</property>
<attributes>
<attribute name="weight" value="semibold"/>
</attributes>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">3</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="cmb_accesslevel">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">3</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
@@ -669,10 +849,22 @@
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkDrawingArea">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButtonBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="spacing">2</property>
<property name="layout-style">end</property>
<child>
<object class="GtkButton" id="but_save">
@@ -685,7 +877,7 @@
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
<property name="position">0</property>
</packing>
</child>
<child>
@@ -696,17 +888,47 @@
<property name="receives-default">True</property>
<signal name="clicked" handler="on_but_cancel_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkButton" id="but_upload">
<property name="label" translatable="yes">Upload</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<signal name="clicked" handler="on_but_upload_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="secondary">True</property>
</packing>
</child>
<child>
<object class="GtkButton" id="but_scan">
<property name="label" translatable="yes">Scan</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<signal name="clicked" handler="on_but_scan_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">3</property>
<property name="secondary">True</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
<property name="position">3</property>
</packing>
</child>
</object>
+94 -22
View File
@@ -334,7 +334,7 @@
</packing>
</child>
<child>
<!-- n-columns=2 n-rows=12 -->
<!-- n-columns=2 n-rows=13 -->
<object class="GtkGrid" id="grd_details">
<property name="visible">True</property>
<property name="can-focus">False</property>
@@ -457,7 +457,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">11</property>
<property name="top-attach">12</property>
</packing>
</child>
<child>
@@ -545,7 +545,7 @@
</packing>
</child>
<child>
<object class="GtkLabel" id="lbl_date_purch">
<object class="GtkLabel" id="lbl_purchdate">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hexpand">True</property>
@@ -591,7 +591,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">11</property>
<property name="top-attach">12</property>
</packing>
</child>
<child>
@@ -617,6 +617,29 @@
<property name="top-attach">10</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lbl_lb_condition">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Condition</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">11</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lbl_condition">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hexpand">True</property>
<property name="selectable">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">11</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
@@ -672,6 +695,21 @@
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="but_convert">
<property name="label" translatable="yes">Convert</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<signal name="clicked" handler="on_but_convert_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">3</property>
<property name="secondary">True</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
@@ -692,7 +730,7 @@
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel">
<object class="GtkLabel" id="lbl_title_edit">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Edit Equipment</property>
@@ -707,7 +745,7 @@
</packing>
</child>
<child>
<!-- n-columns=2 n-rows=11 -->
<!-- n-columns=2 n-rows=12 -->
<object class="GtkGrid" id="grd_editor">
<property name="visible">True</property>
<property name="can-focus">False</property>
@@ -716,6 +754,9 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Name</property>
<attributes>
<attribute name="weight" value="semibold"/>
</attributes>
</object>
<packing>
<property name="left-attach">0</property>
@@ -820,7 +861,7 @@
</packing>
</child>
<child>
<object class="GtkComboBox">
<object class="GtkComboBox" id="cmb_manufacturer">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
@@ -886,14 +927,15 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Remarks</property>
<property name="yalign">0</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">10</property>
<property name="top-attach">11</property>
</packing>
</child>
<child>
<object class="GtkComboBox">
<object class="GtkComboBox" id="cmb_supplier">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
@@ -903,7 +945,7 @@
</packing>
</child>
<child>
<object class="GtkComboBox">
<object class="GtkComboBox" id="cmb_category">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
@@ -913,17 +955,7 @@
</packing>
</child>
<child>
<object class="GtkEntry">
<property name="visible">True</property>
<property name="can-focus">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">10</property>
</packing>
</child>
<child>
<object class="GtkSpinButton">
<object class="GtkSpinButton" id="spi_weight">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="adjustment">adj_weight</property>
@@ -935,7 +967,7 @@
</packing>
</child>
<child>
<object class="GtkSpinButton">
<object class="GtkSpinButton" id="spi_price">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="adjustment">adj_price</property>
@@ -946,6 +978,46 @@
<property name="top-attach">6</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="hexpand">True</property>
<property name="vexpand">True</property>
<property name="shadow-type">in</property>
<child>
<object class="GtkTextView" id="txt_remarks">
<property name="visible">True</property>
<property name="can-focus">True</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">11</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Condition</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">10</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="cmb_condition">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">10</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
+2 -1
View File
@@ -252,7 +252,7 @@
</child>
<child>
<!-- n-columns=2 n-rows=8 -->
<object class="GtkGrid">
<object class="GtkGrid" id="grd_details">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="row-spacing">4</property>
@@ -637,6 +637,7 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Remarks</property>
<property name="yalign">0</property>
</object>
<packing>
<property name="left-attach">0</property>
+128 -19
View File
@@ -257,7 +257,7 @@
</packing>
</child>
<child>
<!-- n-columns=2 n-rows=12 -->
<!-- n-columns=2 n-rows=13 -->
<object class="GtkGrid" id="grd_details">
<property name="visible">True</property>
<property name="can-focus">False</property>
@@ -380,7 +380,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">11</property>
<property name="top-attach">12</property>
</packing>
</child>
<child>
@@ -514,7 +514,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">11</property>
<property name="top-attach">12</property>
</packing>
</child>
<child>
@@ -540,6 +540,29 @@
<property name="top-attach">10</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lbl_lb_category1">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Flags</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">11</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lbl_flags">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hexpand">True</property>
<property name="selectable">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">11</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
@@ -595,6 +618,21 @@
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="but_convert">
<property name="label" translatable="yes">Convert</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<signal name="clicked" handler="on_but_convert_clicked" swapped="no"/>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">3</property>
<property name="secondary">True</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
@@ -631,7 +669,7 @@
</packing>
</child>
<child>
<!-- n-columns=2 n-rows=12 -->
<!-- n-columns=2 n-rows=13 -->
<object class="GtkGrid" id="grd_editor">
<property name="visible">True</property>
<property name="can-focus">False</property>
@@ -655,7 +693,7 @@
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Type</property>
<property name="label" translatable="yes">Container</property>
<attributes>
<attribute name="weight" value="semibold"/>
</attributes>
@@ -761,10 +799,11 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Remarks</property>
<property name="yalign">0</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">11</property>
<property name="top-attach">12</property>
</packing>
</child>
<child>
@@ -779,17 +818,7 @@
</packing>
</child>
<child>
<object class="GtkEntry" id="ent_remarks">
<property name="visible">True</property>
<property name="can-focus">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">11</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="cmb_type">
<object class="GtkComboBox" id="cmb_conttype">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
@@ -799,7 +828,7 @@
</packing>
</child>
<child>
<object class="GtkComboBox" id="cmd_storage">
<object class="GtkComboBox" id="cmb_storage">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
@@ -839,7 +868,7 @@
</packing>
</child>
<child>
<object class="GtkEntry" id="ent_date">
<object class="GtkEntry" id="ent_purchdate">
<property name="visible">True</property>
<property name="can-focus">True</property>
</object>
@@ -904,6 +933,86 @@
<property name="top-attach">10</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Flags</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">11</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="shadow-type">in</property>
<child>
<object class="GtkTextView" id="txt_remarks">
<property name="visible">True</property>
<property name="can-focus">True</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">12</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
<object class="GtkCheckButton" id="chk_ordered">
<property name="label" translatable="yes">ordered</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="chk_removed">
<property name="label" translatable="yes">removed</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkCheckButton" id="chk_deleted">
<property name="label" translatable="yes">deleted</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">False</property>
<property name="draw-indicator">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">11</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
+1 -1
View File
@@ -4,7 +4,7 @@
<requires lib="gtk+" version="3.24"/>
<object class="GtkWindow" id="wnd_main">
<property name="can-focus">False</property>
<property name="title" translatable="yes">YMS</property>
<property name="title">YMS</property>
<property name="window-position">center</property>
<property name="default-width">800</property>
<property name="default-height">600</property>
+18
View File
@@ -2,6 +2,21 @@
<!-- Generated with glade 3.40.0 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<object class="GtkAdjustment" id="adj_interval">
<property name="upper">100</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
</object>
<object class="GtkAdjustment" id="adj_last">
<property name="upper">100</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
</object>
<object class="GtkAdjustment" id="adj_series">
<property name="upper">100</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
</object>
<object class="GtkStack" id="topobject">
<property name="visible">True</property>
<property name="can-focus">False</property>
@@ -666,6 +681,7 @@
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="hexpand">True</property>
<property name="adjustment">adj_series</property>
</object>
<packing>
<property name="left-attach">1</property>
@@ -677,6 +693,7 @@
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="hexpand">True</property>
<property name="adjustment">adj_interval</property>
</object>
<packing>
<property name="left-attach">1</property>
@@ -688,6 +705,7 @@
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="hexpand">True</property>
<property name="adjustment">adj_last</property>
</object>
<packing>
<property name="left-attach">1</property>
+78 -11
View File
@@ -236,7 +236,7 @@
</packing>
</child>
<child>
<!-- n-columns=2 n-rows=10 -->
<!-- n-columns=2 n-rows=11 -->
<object class="GtkGrid" id="grd_details">
<property name="visible">True</property>
<property name="can-focus">False</property>
@@ -361,7 +361,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">9</property>
<property name="top-attach">10</property>
</packing>
</child>
<child>
@@ -447,7 +447,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">9</property>
<property name="top-attach">10</property>
</packing>
</child>
<child>
@@ -458,7 +458,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">8</property>
<property name="top-attach">9</property>
</packing>
</child>
<child>
@@ -468,6 +468,29 @@
<property name="hexpand">True</property>
<property name="selectable">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">9</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Date</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">8</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="lbl_date">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hexpand">True</property>
<property name="selectable">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">8</property>
@@ -566,7 +589,7 @@
</packing>
</child>
<child>
<!-- n-columns=2 n-rows=9 -->
<!-- n-columns=2 n-rows=11 -->
<object class="GtkGrid" id="grd_editor">
<property name="visible">True</property>
<property name="can-focus">False</property>
@@ -652,7 +675,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">6</property>
<property name="top-attach">7</property>
</packing>
</child>
<child>
@@ -663,7 +686,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">7</property>
<property name="top-attach">8</property>
</packing>
</child>
<child>
@@ -671,10 +694,11 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Note</property>
<property name="yalign">0</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">8</property>
<property name="top-attach">10</property>
</packing>
</child>
<child>
@@ -743,7 +767,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">6</property>
<property name="top-attach">7</property>
</packing>
</child>
<child>
@@ -754,7 +778,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">7</property>
<property name="top-attach">8</property>
</packing>
</child>
<child>
@@ -773,7 +797,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">8</property>
<property name="top-attach">10</property>
</packing>
</child>
<child>
@@ -786,6 +810,49 @@
<property name="top-attach">5</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Category</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">9</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="cmb_category">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="hexpand">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">9</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Unit</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">6</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="cmb_unit">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">6</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
+94 -12
View File
@@ -2,6 +2,26 @@
<!-- Generated with glade 3.40.0 -->
<interface>
<requires lib="gtk+" version="3.24"/>
<object class="GtkAdjustment" id="adj_number">
<property name="upper">100</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
</object>
<object class="GtkAdjustment" id="adj_weight">
<property name="upper">100</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
</object>
<object class="GtkAdjustment" id="adj_weight_net">
<property name="upper">100</property>
<property name="step-increment">1</property>
<property name="page-increment">10</property>
</object>
<object class="GtkImage" id="img_calendar">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="icon-name">x-office-calendar-symbolic</property>
</object>
<object class="GtkStack" id="topobject">
<property name="visible">True</property>
<property name="can-focus">False</property>
@@ -227,7 +247,7 @@
</packing>
</child>
<child>
<!-- n-columns=2 n-rows=10 -->
<!-- n-columns=2 n-rows=11 -->
<object class="GtkGrid" id="grd_editor">
<property name="visible">True</property>
<property name="can-focus">False</property>
@@ -409,6 +429,7 @@
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="hexpand">True</property>
<property name="adjustment">adj_number</property>
</object>
<packing>
<property name="left-attach">1</property>
@@ -420,6 +441,8 @@
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="hexpand">True</property>
<property name="adjustment">adj_weight</property>
<property name="digits">2</property>
</object>
<packing>
<property name="left-attach">1</property>
@@ -431,23 +454,14 @@
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="hexpand">True</property>
<property name="adjustment">adj_weight_net</property>
<property name="digits">2</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">6</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="ent_storedate">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="hexpand">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">8</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="ent_shelflife">
<property name="visible">True</property>
@@ -459,6 +473,74 @@
<property name="top-attach">9</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Remarks</property>
<property name="yalign">0</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">10</property>
</packing>
</child>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="shadow-type">in</property>
<child>
<object class="GtkTextView" id="txt_remarks">
<property name="visible">True</property>
<property name="can-focus">True</property>
</object>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">10</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box_storedate">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="spacing">2</property>
<child>
<object class="GtkEntry" id="ent_storedate">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="hexpand">True</property>
<property name="width-chars">12</property>
<property name="max-width-chars">10</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkButton" id="but_storedate">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="image">img_calendar</property>
<property name="always-show-image">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">8</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
+24 -4
View File
@@ -231,7 +231,7 @@
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel">
<object class="GtkLabel" id="lbl_title_detail">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Storage Details</property>
@@ -247,7 +247,7 @@
</child>
<child>
<!-- n-columns=2 n-rows=8 -->
<object class="GtkGrid" id="grd_detail">
<object class="GtkGrid" id="grd_details">
<property name="visible">True</property>
<property name="can-focus">False</property>
<child>
@@ -895,10 +895,30 @@
</packing>
</child>
<child>
<placeholder/>
<object class="GtkColorButton" id="but_color">
<property name="width-request">64</property>
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="receives-default">True</property>
<property name="show-editor">True</property>
<signal name="color-set" handler="on_but_color_set" swapped="no"/>
</object>
<packing>
<property name="left-attach">3</property>
<property name="top-attach">6</property>
</packing>
</child>
<child>
<placeholder/>
<object class="GtkEntry" id="ent_color">
<property name="visible">True</property>
<property name="can-focus">True</property>
<signal name="activate" handler="on_ent_color_activate" swapped="no"/>
<signal name="focus-out-event" handler="on_ent_color_focus_out_event" swapped="no"/>
</object>
<packing>
<property name="left-attach">2</property>
<property name="top-attach">6</property>
</packing>
</child>
<child>
<placeholder/>
+97 -13
View File
@@ -320,7 +320,7 @@
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel">
<object class="GtkLabel" id="lbl_title_detail">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Task Details</property>
@@ -664,7 +664,7 @@
</packing>
</child>
<child>
<!-- n-columns=2 n-rows=8 -->
<!-- n-columns=2 n-rows=10 -->
<object class="GtkGrid" id="grd_editor">
<property name="visible">True</property>
<property name="can-focus">False</property>
@@ -675,6 +675,9 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Name</property>
<attributes>
<attribute name="weight" value="semibold"/>
</attributes>
</object>
<packing>
<property name="left-attach">0</property>
@@ -682,7 +685,7 @@
</packing>
</child>
<child>
<object class="GtkEntry" id="ent_title">
<object class="GtkEntry" id="ent_name">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="hexpand">True</property>
@@ -697,10 +700,13 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Responsible</property>
<attributes>
<attribute name="weight" value="semibold"/>
</attributes>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">6</property>
<property name="top-attach">8</property>
</packing>
</child>
<child>
@@ -712,7 +718,7 @@
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">7</property>
<property name="top-attach">9</property>
</packing>
</child>
<child>
@@ -731,7 +737,7 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">7</property>
<property name="top-attach">9</property>
</packing>
</child>
<child>
@@ -741,11 +747,11 @@
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">6</property>
<property name="top-attach">8</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="ent_filename">
<object class="GtkEntry" id="ent_plandate">
<property name="visible">True</property>
<property name="can-focus">True</property>
</object>
@@ -755,7 +761,7 @@
</packing>
</child>
<child>
<object class="GtkComboBox" id="cmb_doctype">
<object class="GtkComboBox" id="cmb_project">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
@@ -780,6 +786,9 @@
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Priority</property>
<attributes>
<attribute name="weight" value="semibold"/>
</attributes>
</object>
<packing>
<property name="left-attach">0</property>
@@ -808,16 +817,91 @@
</packing>
</child>
<child>
<placeholder/>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Due Date</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
<placeholder/>
<object class="GtkEntry" id="ent_duedate">
<property name="visible">True</property>
<property name="can-focus">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">4</property>
</packing>
</child>
<child>
<placeholder/>
<object class="GtkComboBox" id="cmb_status">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">7</property>
</packing>
</child>
<child>
<placeholder/>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Status</property>
<attributes>
<attribute name="weight" value="semibold"/>
</attributes>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">7</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Started</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">5</property>
</packing>
</child>
<child>
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Finished</property>
</object>
<packing>
<property name="left-attach">0</property>
<property name="top-attach">6</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="ent_started">
<property name="visible">True</property>
<property name="can-focus">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">5</property>
</packing>
</child>
<child>
<object class="GtkEntry" id="ent_finished">
<property name="visible">True</property>
<property name="can-focus">True</property>
</object>
<packing>
<property name="left-attach">1</property>
<property name="top-attach">6</property>
</packing>
</child>
</object>
<packing>
+62 -12
View File
@@ -12,6 +12,8 @@ from gi.repository import GLib, Gtk, Gdk, Rsvg
from datetime import datetime
import subprocess
import locale
import xml.etree.ElementTree as ET
import json
from .view import View
from yms import gtkutils, combobox, treeview
@@ -76,19 +78,29 @@ class BaseView(View):
self.context.vessel.vesselname = "Ghost"
# default storage for current vessel
sql = "SELECT sid, sname FROM storage WHERE stype=0 AND vid=%s ORDER BY sname"
self.db.cur.execute(sql, (self.context.vessel.vid,))
storages = dict(self.db.cur.fetchall())
#sql = "SELECT sid, sname FROM storage WHERE stype=0 AND vid=%s ORDER BY sname"
#self.db.cur.execute(sql, (self.context.vessel.vid,))
#storages = dict(self.db.cur.fetchall())
storages = self.context.lookup.storage(self.context.vessel.vid)
combobox.load_from_dict(self.combo['storage'], {-1: _("─── none ───")} | storages)
# Hull types
self.dd_htype = self.context.lookup.enum('vessel.htype')
combobox.load_from_dict(self.combo['htype'], self.dd_htype)
# List of available shapes for combobox selection
shapes = self.load_shapes()
combobox.load_from_dict(self.combo['hull_shape'], {"-1": _("─── none ───")} | shapes)
# get list of vessels
vessellist = {}
self.db.dcur.execute("SELECT vid, vesselname, model FROM vessel ORDER BY vid")
for row in self.db.dcur.fetchall():
vessellist[row['vid']] = (
row['vesselname'] if row['model'] is None
else row['vesselname'] + " - " + row['model']
)
#vessellist = {}
#self.db.dcur.execute("SELECT vid, vesselname, model FROM vessel ORDER BY vid")
#for row in self.db.dcur.fetchall():
# vessellist[row['vid']] = (
# row['vesselname'] if row['model'] is None
# else row['vesselname'] + " - " + row['model']
# )
vessellist = self.context.lookup.vessel()
combobox.load_from_dict(self.combo['vessel'], vessellist, self.context.vessel.vid)
# vessel load triggered from combobox init
@@ -138,6 +150,7 @@ class BaseView(View):
#viewport.height = 240
#self._svg.render_document(ctx, viewport)
# WIP generic remarks handling
self.text['vessel_remarks'].set_size_request(200, 70)
@@ -149,6 +162,36 @@ class BaseView(View):
storages = dict(self.db.cur.fetchall())
combobox.refresh_dict(self.combo['storage'], {-1: _("─── none ───")} | storages)
def load_shapes(self):
# TODO / WIP process shapeindex
# returns dict of filename: title
indexfile = os.path.join(self.context.cfg['docpath'], "shapeindex.json")
if os.path.isfile(indexfile):
# load json
with open(indexfile, "r", encoding="utf-8") as fh:
sflist = json.load(fh)
print("Shapefile found and loaded")
else:
# create shapeindex (first simple version)
sflist = {}
for fname in os.listdir(self.context.cfg['shapedir']):
if fname.lower().endswith(".svg"):
shapefile = os.path.join(self.context.cfg['shapedir'], fname)
try:
root = ET.parse(shapefile).getroot()
title_element = root.find("{http://www.w3.org/2000/svg}title")
if title_element is not None and title_element.text:
title = title_element.text.strip()
else:
title = os.path.splitext(fname)[0]
except ET.ParseError:
title = os.path.splitext(fname)[0]
sflist[fname] = title
with open(indexfile, "w", encoding="utf-8") as fh:
json.dump(sflist, fh, ensure_ascii=False, indent=4)
print("Created new shapeindex file")
return sflist
def find_usb_sticks(self):
result = []
for name in os.listdir("/sys/block"):
@@ -304,7 +347,6 @@ class BaseView(View):
self.stack['vessel'].set_visible_child(self.box['vessel_edit'])
def on_but_vessel_save_clicked(self, widget):
print("Save vessel")
vessel = self.context.vessel
vessel.vesselname = self.entry['vesselname'].get_text()
vessel.model = self.entry['model'].get_text()
@@ -316,6 +358,9 @@ class BaseView(View):
vessel.draught_min = self.spin['draught_min'].get_value()
vessel.displacement = self.spin['displacement'].get_value_as_int()
vessel.ballast = self.spin['ballast'].get_value_as_int()
vessel.beltpos_bow = self.spin['belt_bow'].get_value()
vessel.beltpos_aft = self.spin['belt_aft'].get_value()
vessel.shapefile = combobox.get_list_value(self.combo['hull_shape'])
vessel.remarks = gtkutils.get_text_contents(self.text['vessel_remarks'])
vessel.save()
self.stack['vessel'].set_visible_child(self.box['vessel'])
@@ -337,6 +382,7 @@ class BaseView(View):
self.label['model'].set_text(vessel.model or '')
self.label['shipyard'].set_text(str(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"))
@@ -361,9 +407,13 @@ class BaseView(View):
self.spin['draught_min'].set_value(vessel.draught_min or 0)
self.spin['displacement'].set_value(vessel.displacement or 0)
self.spin['ballast'].set_value(vessel.ballast or 0)
self.text['vessel_remarks'].get_buffer().set_text(vessel.remarks or '')
self.spin['belt_bow'].set_value(vessel.beltpos_bow or 0)
self.spin['belt_aft'].set_value(vessel.beltpos_aft or 0)
combobox.activate_row(self.combo['shipyard'], vessel.shipyard or -1)
self.entry['hull_number'].set_text(vessel.hull_number or '')
combobox.activate_row(self.combo['hull_shape'], vessel.shapefile or "-1")
combobox.activate_row(self.combo['storage'], vessel.sid_default or -1)
self.text['vessel_remarks'].get_buffer().set_text(vessel.remarks or '')
def display_user(self, user):
self.entry['user_login'].set_text(user.login)
+94 -23
View File
@@ -19,15 +19,7 @@ class BoxesView(View):
self.newrecord = False
self.lst_box = Gtk.ListStore(int, str, str, str)
sql = (
"SELECT b.boxid, b.label, b.content, b.remarks "
"FROM box AS b JOIN storage AS s USING (sid) "
"WHERE s.vid=%s "
"ORDER BY b.label"
)
self.db.cur.execute(sql, (context.vessel.vid,))
for row in self.db.cur.fetchall():
self.lst_box.append(row)
self.load_list()
treeview.add_column(self.tree['box'], _('ID'), 0)
treeview.add_column(self.tree['box'], _('Label'), 1)
@@ -35,25 +27,53 @@ class BoxesView(View):
treeview.add_column(self.tree['box'], _('Remarks'), 3)
self.tree['box'].set_model(self.lst_box)
self.dd_storage = self.context.lookup.storage(context.vessel.vid)
combobox.load_from_dict(self.combo['storage'], {-1: _("─── none ───")} | self.dd_storage)
self.dd_boxtype = self.context.lookup.dropdown(Dropdown.BOX_TYPE)
combobox.load_from_dict(self.combo['type'], self.dd_boxtype)
combobox.load_from_dict(self.combo['type'], {-1: _("─── none ───")} | self.dd_boxtype)
def load_list(self):
pass
selected_id = treeview.get_value(self.tree['box'])
self.lst_box.clear()
sql = (
"SELECT b.boxid, b.label, b.content, b.remarks "
"FROM box AS b JOIN storage AS s USING (sid) "
"WHERE s.vid=%s "
"ORDER BY b.label"
)
self.db.cur.execute(sql, (self.context.vessel.vid,))
selection = self.tree['box'].get_selection()
for row in self.db.cur.fetchall():
treeiter = self.lst_box.append(row)
if row[0] == selected_id:
# restore previous selected row
selection.select_iter(treeiter)
def clear_record(self):
self.entry['label'].set_text('')
combobox.activate_row(self.combo['storage'], 0)
combobox.activate_row(self.combo['type'], -1)
self.entry['content'].set_text('')
self.spin['wx'].set_value(0)
self.spin['wy'].set_value(0)
self.spin['wz'].set_value(0)
self.entry['color'].set_text('#000000')
rgba = Gdk.RGBA()
rgba.parse('#000000')
self.button['color'].set_rgba(rgba)
self.spin['price'].set_value(0)
self.spin['weight'].set_value(0)
self.spin['weight_net'].set_value(0)
self.text['remarks'].get_buffer().set_text('')
def display_record(self):
self.label['label'].set_text(self.sbox.label)
# storage sid
self.label['content'].set_text(self.sbox.content or '')
if self.sbox.boxtype > 0:
self.label['type'].set_text(self.dd_boxtype[self.sbox.boxtype])
else:
self.label['type'].set_text('')
self.label['color'].set_text(self.sbox.color or '')
if self.sbox.color:
self.label['color'].set_markup(f'#{self.sbox.color} <span foreground="#{self.sbox.color}">●</span>')
@@ -66,23 +86,50 @@ class BoxesView(View):
def edit_record(self):
self.entry['label'].set_text(self.sbox.label)
combobox.activate_row(self.combo['storage'], self.sbox.sid)
combobox.activate_row(self.combo['type'], self.sbox.boxtype)
self.entry['content'].set_text(self.sbox.content or '')
self.spin['wx'].set_value(self.sbox.wx or 0)
self.spin['wy'].set_value(self.sbox.wy or 0)
self.spin['wz'].set_value(self.sbox.wz or 0)
self.entry['color'].set_text('#' + self.sbox.color)
rgba = Gdk.RGBA()
rgba.parse('#' + self.sbox.color)
self.button['color'].set_rgba(rgba)
self.spin['price'].set_value(self.sbox.price or 0)
self.spin['weight'].set_value(self.sbox.weight or 0)
self.spin['weight_net'].set_value(self.sbox.weight_net or 0)
self.text['remarks'].get_buffer().set_text(self.sbox.remarks or '')
def save_record(self):
# fields must have been validated beforehand
self.sbox.label = self.entry['label'].get_text()
self.sbox.sid = combobox.get_list_value(self.combo['storage'])
self.sbox.boxtype = combobox.get_list_value(self.combo['type'])
self.sbox.content = self.entry['content'].get_text()
self.sbox.wx = int(self.spin['wx'].get_value())
self.sbox.wy = int(self.spin['wy'].get_value())
self.sbox.wz = int(self.spin['wz'].get_value())
self.sbox.color = self.entry['color'].get_text().lstrip('#')
self.sbox.price = self.spin['price'].get_value()
self.sbox.weight = self.spin['weight'].get_value()
self.sbox.weight_net = self.spin['weight_net'].get_value()
self.sbox.remarks = gtkutils.get_text_contents(self.text['remarks'])
# buttons on list page
def on_but_new_clicked(self, widget):
self.newrecord = True
self.label['title_edit'].set_text("Add new Box")
self.label['title_edit'].set_text(_("Add new Box"))
self.clear_record()
self.topwidget.set_visible_child(self.box['box_edit'])
def on_but_edit_clicked(self, widget):
self.newrecord = False
self.label['title_edit'].set_text("Edit Box")
sid = treeview.get_value(self.tree['box'], 0)
self.sbox.load(sid)
self.label['title_edit'].set_text(_("Edit Box"))
boxid = treeview.get_value(self.tree['box'], 0)
if not boxid:
return
self.sbox.load(boxid)
self.edit_record()
self.topwidget.set_visible_child(self.box['box_edit'])
@@ -105,24 +152,48 @@ class BoxesView(View):
# buttons on detail page
# edit2 uses edit callback
def on_but_close_clicked(self, widget):
boxid = treeview.get_value(self.tree['box'], 0)
if not boxid:
return
self.topwidget.set_visible_child(self.box['box'])
def on_but_delete_clicked(self, widget):
answer = gtkutils.questionbox(
_("Delete box!\n"
"Are you sure?"), title="YMS"
)
if answer == False:
return
self.topwidget.set_visible_child(self.box['box'])
self.newrecord = False
# buttons on edit page
def on_but_save_clicked(self, widget):
print("save not implemented yet")
# check mandatory fields
if not self.entry['label'].get_text().strip():
# TODO error marker
return
self.save_record()
print(self.sbox)
self.sbox.save()
if self.newrecord:
self.load_list()
self.newrecord = False
self.display_record()
self.topwidget.set_visible_child(self.box['box_detail'])
def on_but_color_set(self, button):
rgba = button.get_rgba()
r = round(rgba.red * 255)
g = round(rgba.green * 255)
b = round(rgba.blue * 255)
#self.last_valid_rgb = f"{r:02X}{g:02X}{b:02X}"
self.entry['color'].set_text(f"#{r:02X}{g:02X}{b:02X}")
def on_ent_color_activate(self, entry):
self.set_color_from_entry(entry)
def on_ent_color_focus_out_event(self, entry, event):
self.set_color_from_entry(entry)
return False
def on_but_cancel_clicked(self, widget):
self.topwidget.set_visible_child(self.box['box'])
self.newrecord = False
def on_but_color_clicked(self, widget):
pass
+67 -24
View File
@@ -40,6 +40,59 @@ class CablesView(View):
self.dd_type = self.context.lookup.dropdown(Dropdown.CABLE_TYPE)
self.dd_tech = self.context.lookup.dropdown(Dropdown.CABLE_TECHNAME)
def display_record(self):
self.label['name'].set_text(self.cable.cablename)
self.label['type'].set_text(self.dd_type[self.cable.cabletype])
if self.cable.techname:
self.label['techname'].set_text(self.dd_tech[self.cable.techname])
else:
self.label['techname'].set_text('')
self.label['length'].set_text(self.format_int(self.cable.length))
self.label['conductors'].set_text(self.format_int(self.cable.conductors))
self.label['diameter'].set_text(self.format_float(self.cable.diameter, 1))
self.label['xsection'].set_text(self.format_float(self.cable.xsection, 1))
self.label['weight'].set_text(self.format_float(self.cable.weight))
if self.cable.color:
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['condition'].set_text(self.cable.cablecond)
self.label['remarks'].set_text(self.cable.remarks or '')
def edit_record(self):
# fill UI fields from database record
self.entry['name'].set_text(self.cable.cablename)
combobox.activate_row(self.combo['type'], self.cable.cabletype)
combobox.activate_row(self.combo['techname'], self.cable.techname)
self.spin['length'].set_value(self.cable.length or 0)
self.spin['consuctors'].set_value(self.cable.conductors or 0)
self.spin['diameter'].set_value(self.cable.diameter or 0)
self.spin['xsection'].set_value(self.cable.xsection or 0)
self.spin['weight'].set_value(self.cable.weight or 0)
self.entry['color'].set_text('#' + self.cable.color)
rgba = Gdk.RGBA()
rgba.parse('#' + self.cable.color)
self.button['color'].set_rgba(rgba)
combobox.activate_row(self.combo['supplier'], self.cable.supplier)
combobox.activate_row(self.combo['manufacturer'], self.cable.manufacturer)
combobox.activate_row(self.combo['consition'], self.cable.cablecond)
self.text['remarks'].get_buffer().set_text(self.sbox.remarks or '')
def save_record(self):
# fields must have been validated beforehand
self.cable.cablename = self.entry['name'].get_text().strip()
self.cable.cabletype = combobox.get_list_value(self.combo['type'])
self.cable.length = int(self.spin['length'].get_value())
self.cable.conductors = int(self.spin['conductors'].get_value())
self.cable.diameter = self.spin['diameter'].get_value()
self.cable.xsection = self.spin['xsection'].get_value()
self.cable.weight = int(self.spin['weight'].get_value())
self.cable.supplier = combobox.get_list_value(self.combo['supplier'])
self.cable.manufacturer = combobox.get_list_value(self.combo['manufacturer'])
self.cable.condition = combobox.get_list_value(self.combo['condition'])
# buttons on list page
def on_but_new_clicked(self, widget):
self.topwidget.set_visible_child(self.box['cable_edit'])
@@ -68,35 +121,25 @@ class CablesView(View):
self.topwidget.set_visible_child(self.box['cables'])
def on_but_delete_clicked(self, widget):
answer = gtkutils.questionbox(
_("Delete cable!\n"
"Are you sure?"), title="YMS"
)
if answer == False:
return
self.topwidget.set_visible_child(self.box['cables'])
# buttons on edit page
def on_but_save_clicked(self, widget):
pass
# check mandatory fields:
# name, type, length, conductors, xsection
cname = self.entry['name'].get_text().strip()
if not cname:
# TODO error marker
return
self.save_record()
print(self.cable)
def on_but_cancel_clicked(self, widget):
self.topwidget.set_visible_child(self.box['cables'])
def display_record(self):
self.label['name'].set_text(self.cable.cablename)
self.label['type'].set_text(self.dd_type[self.cable.cabletype])
if self.cable.techname:
self.label['techname'].set_text(self.dd_tech[self.cable.techname])
else:
self.label['techname'].set_text('')
self.label['length'].set_text(self.format_int(self.cable.length))
self.label['conductors'].set_text(self.format_int(self.cable.conductors))
self.label['diameter'].set_text(self.format_float(self.cable.diameter, 1))
self.label['xsection'].set_text(self.format_float(self.cable.xsection, 1))
self.label['weight'].set_text(self.format_float(self.cable.weight))
if self.cable.color:
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['condition'].set_text(self.cable.cablecond)
self.label['remarks'].set_text(self.cable.remarks or '')
def edit_record(self):
pass
+75 -12
View File
@@ -18,29 +18,42 @@ class CompaniesView(View):
self.newrecord = False
# company types
self.db.cur.execute("SELECT ddval, ddtext FROM dropdown WHERE ddid=2 ORDER BY ddval")
self.comptype = dict(self.db.cur.fetchall())
combobox.load_from_dict(self.combo['flt_type'], {-2: _("─── all ───")} | self.comptype, -2)
self.dd_comptype = self.context.lookup.dropdown(Dropdown.COMPANY_TYPE)
combobox.load_from_dict(self.combo['comptype'], self.dd_comptype)
combobox.load_from_dict(self.combo['comptype2'], self.dd_comptype)
combobox.load_from_dict(self.combo['flt_type'], {-2: _("─── all ───"), -1: _("─── none ───")} | self.dd_comptype, -2)
combobox.load_from_dict(self.combo['comptype'], self.dd_comptype, company.SUPPLIER)
combobox.load_from_dict(self.combo['comptype2'], {-1: _("─── none ───")} | self.dd_comptype)
self.dd_flags = context.lookup.enum('company.flags')
# companies
self.lst_companies = Gtk.ListStore(int, str, str, str)
self.db.cur.execute("SELECT compid, compname, comptype, remarks FROM company ORDER BY compname")
for row in self.db.cur.fetchall():
self.lst_companies.append((row[0], row[1], self.comptype[row[2]], row[3]))
self.load_list()
treeview.add_column(self.tree['companies'], _('ID'), 0)
treeview.add_column(self.tree['companies'], _('Name'), 1)
treeview.add_column(self.tree['companies'], _('Type'), 2)
treeview.add_column(self.tree['companies'], _('Remarks'), 3)
self.tree['companies'].set_model(self.lst_companies)
def load_list(self):
selected_id = treeview.get_value(self.tree['companies'])
self.lst_companies.clear()
sql = (
"SELECT compid, compname, comptype, remarks "
"FROM company "
"WHERE compid >= 0 "
"ORDER BY compname"
)
self.db.cur.execute(sql)
selection = self.tree['companies'].get_selection()
for row in self.db.cur.fetchall():
treeiter = self.lst_companies.append((row[0], row[1], self.dd_comptype[row[2]], row[3]))
if row[0] == selected_id:
# restore previous selected row
selection.select_iter(treeiter)
def clear_record(self):
self.entry['name'].set_text('')
self.entry['compname'].set_text('')
self.entry['shortname'].set_text('')
self.entry['street'].set_text('')
self.entry['zip'].set_text('')
@@ -52,7 +65,7 @@ class CompaniesView(View):
self.entry['web'].set_text('')
self.entry['customerno'].set_text('')
self.entry['contractno'].set_text('')
combobox.activate_row(self.combo['comptype'], -1)
combobox.activate_row(self.combo['comptype'], company.SUPPLIER)
combobox.activate_row(self.combo['comptype2'], -1)
def display_record(self):
@@ -76,6 +89,8 @@ class CompaniesView(View):
self.entry['compname'].set_text(self.comp.compname)
# Type self.dd_comptype.get(self.comp.comptype, -1)
# Type2 self.dd_comptype.get(self.comp.comptype2, -1)
combobox.activate_row(self.combo['comptype'], self.comp.comptype)
combobox.activate_row(self.combo['comptype2'], self.comp.comptype2)
self.entry['shortname'].set_text(self.comp.shortname or '')
self.entry['street'].set_text(self.comp.street or '')
self.entry['zip'].set_text(self.comp.zip or '')
@@ -87,15 +102,44 @@ class CompaniesView(View):
self.entry['web'].set_text(self.comp.web or '')
self.entry['customerno'].set_text(self.comp.customerno or '')
self.entry['contractno'].set_text(self.comp.contractno or '')
self.text['remarks'].get_buffer().set_text(self.comp.remarks or '')
def save_record(self):
# fields must have been validated beforehand
self.comp.compname = self.entry['compname'].get_text()
self.comp.comptype = combobox.get_list_value(self.combo['comptype'])
self.comp.comptype2 = combobox.get_list_value(self.combo['comptype2'])
if self.comp.comptype2 < 0:
self.comp.comptype2 = None
self.comp.shortname = self.entry['shortname'].get_text()
self.comp.street = self.entry['street'].get_text()
self.comp.zip = self.entry['zip'].get_text()
self.comp.city = self.entry['city'].get_text()
self.comp.country = self.entry['country'].get_text()
self.comp.contact = self.entry['contact'].get_text()
self.comp.phone = self.entry['phone'].get_text()
self.comp.email = self.entry['email'].get_text()
self.comp.web = self.entry['web'].get_text()
self.comp.customerno = self.entry['customerno'].get_text()
self.comp.conractno = self.entry['contractno'].get_text()
self.comp.remarks = gtkutils.get_text_contents(self.text['remarks'])
# buttons on list page
def on_but_new_clicked(self, widget):
self.newrecord = True
self.label['title_edit'].set_text(_("Add new Company"))
self.clear_record()
self.topwidget.set_visible_child(self.box['comp_edit'])
def on_but_edit_clicked(self, widget):
self.newrecord = False
compid = treeview.get_value(self.tree['companies'], 0)
if not compid:
return
self.comp.load(compid)
self.edit_record()
self.label['title_edit'].set_text(_("Edit Company"))
self.topwidget.set_visible_child(self.box['comp_edit'])
def on_but_detail_clicked(self, widget):
@@ -118,11 +162,30 @@ class CompaniesView(View):
self.topwidget.set_visible_child(self.box['companies'])
def on_but_delete_clicked(self, widget):
answer = gtkutils.questionbox(
_("Delete company!\n"
"Are you sure?"), title="YMS"
)
if answer == False:
return
self.topwidget.set_visible_child(self.box['companies'])
# buttons on edit page
def on_but_save_clicked(self, widget):
pass
# check mandatory fields:
compname = self.entry['compname'].get_text().strip()
# TODO type
if not compname:
# TODO error marker
return
self.save_record()
print(self.comp)
self.comp.save()
if self.newrecord:
self.load_list()
self.newrecord = False
self.display_record()
self.topwidget.set_visible_child(self.box['comp_detail'])
def on_but_cancel_clicked(self, widget):
self.topwidget.set_visible_child(self.box['companies'])
+130 -34
View File
@@ -3,6 +3,7 @@
import os
from gi.repository import GLib, Gtk, Gdk, GdkPixbuf, Rsvg
import fitz
import sane
from .view import View
from yms import gtkutils, combobox, treeview
@@ -17,6 +18,10 @@ class DocumentsView(View):
self.doc = document.Document(context.db) # current record
self.newrecord = False
self.scandialog = self.builder.get_object("dlg_scanner")
print(self.scandialog)
# TODO self.uploaddialog = self.builder.get_object("dlg_upload")
self.lst_documents = Gtk.ListStore(int, str, str, str, int)
sql = (
"SELECT d.docid, d.doctype, d.filename, d.title, COUNT(r.drid) AS refcount "
@@ -35,41 +40,20 @@ class DocumentsView(View):
treeview.add_column(self.tree['documents'], _('References'), 3)
self.tree['documents'].set_model(self.lst_documents)
# buttons on list page
def on_but_new_clicked(self, widget):
self.topwidget.set_visible_child(self.box['doc_edit'])
# Status
self.dd_type = self.context.lookup.enum('document.doctype')
combobox.load_from_dict(self.combo['doctype'], self.dd_type)
# Roleaccess
self.dd_access = self.context.lookup.enum('document.roleaccess')
combobox.load_from_dict(self.combo['accesslevel'], self.dd_access)
def on_but_edit_clicked(self, widget):
self.topwidget.set_visible_child(self.box['doc_edit'])
def on_but_detail_clicked(self, widget):
docid = treeview.get_value(self.tree['documents'], 0)
self.doc.load(docid)
self.display_record()
self.topwidget.set_visible_child(self.box['doc_detail'])
self.button['close'].grab_focus()
def on_tvw_documents_row_activated(self, widget, path, column):
docid = treeview.get_value(widget, 0)
self.doc.load(docid)
self.display_record()
self.topwidget.set_visible_child(self.box['doc_detail'])
self.button['close'].grab_focus()
# buttons on detail page
# edit2 uses edit callback
def on_but_close_clicked(self, widget):
self.topwidget.set_visible_child(self.box['documents'])
def on_but_delete_clicked(self, widget):
self.topwidget.set_visible_child(self.box['documents'])
# 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['documents'])
def clear_record(self):
self.doc.clear()
combobox.activate_row(self.combo['doctype'], 'generic')
self.entry['title'].set_text('')
self.entry['filename'].set_text('')
combobox.activate_row(self.combo['accesslevel'], 'captain')
self.text['remarks'].get_buffer().set_text('')
def pdf_to_pixbuf(self, filename, max_width=400, max_height=400):
doc = fitz.open(filename)
@@ -135,4 +119,116 @@ class DocumentsView(View):
self.image['preview'].clear()
def edit_record(self):
combobox.activate_row(self.combo['doctype'], self.doc.doctype)
self.entry['title'].set_text(self.doc.title or '')
self.entry['filename'].set_text(self.doc.filename or '')
def save_record(self):
# fields must have been validated beforehand
self.doc.doctype = combobox.get_list_value(self.combo['type'])
self.doc.title = self.entry['title'].get_text()
self.doc.filename = self.entry['filename'].get_text()
self.doc.remarks = gtkutils.get_text_contents(self.text['remarks'])
# buttons on list page
def on_but_new_clicked(self, widget):
self.newrecord = True
self.label['title_edit'].set_text(_("Add new Document"))
self.clear_record()
self.topwidget.set_visible_child(self.box['doc_edit'])
def on_but_edit_clicked(self, widget):
self.newrecord = False
docid = treeview.get_value(self.tree['documents'], 0)
if docid is None:
return
self.doc.load(docid)
self.edit_record()
self.topwidget.set_visible_child(self.box['doc_edit'])
def on_but_detail_clicked(self, widget):
docid = treeview.get_value(self.tree['documents'], 0)
if docid is None:
return
self.doc.load(docid)
self.display_record()
self.topwidget.set_visible_child(self.box['doc_detail'])
self.button['close'].grab_focus()
def on_tvw_documents_row_activated(self, widget, path, column):
docid = treeview.get_value(widget, 0)
self.doc.load(docid)
self.display_record()
self.topwidget.set_visible_child(self.box['doc_detail'])
self.button['close'].grab_focus()
# buttons on detail page
# edit2 uses edit callback
def on_but_close_clicked(self, widget):
self.topwidget.set_visible_child(self.box['documents'])
def on_but_delete_clicked(self, widget):
answer = gtkutils.questionbox(
_("Delete document!\n"
"Are you sure?"), title="YMS"
)
if answer == False:
return
self.topwidget.set_visible_child(self.box['documents'])
def scan_progress(self, current_line, total_lines):
print(f"Fortschritt: {current_line} / {total_lines}")
# buttons on edit page
def on_but_scan_clicked(self, widget):
"""
# python sane
tl-x: X-Koordinate der linken oberen Ecke
tl-y: Y-Koordinate der linken oberen Ecke
br-x: X-Koordinate der rechten unteren Ecke
br-y: Y-Koordinate der rechten unteren Ecke
verfügbarer bereich ist über constraints ermittelbar
verfügbare resolution auch über constraints
verfügbare modes auch über constraints
Einheit: sane.UNIT_MM
scanner.tl_x = 10.0
scanner.tl_y = 10.0
scanner.br_x = 100.0
scanner.br_y = 150.0
"""
response = self.scandialog.run()
self.scandialog.hide()
if response == Gtk.ResponseType.OK:
print("OK")
else:
print("Not OK")
# sane.init()
# devices = sane.get_devices()
# if more than one device: Show device selector
# device_name = devices[0][0]
# scanner = sane.open(device_name)
# scanner.get_options()
# Options: index, name, title, desc, opt_type, unit, size, cap, constraint
# option.is_active()
# option.is_settable()
# scanner.get_parameters()
# format, last_frame, (pixels_per_line, lines), depth = scanner.get_parameters()
# scanner.mode = "Color"
# scanner.resolution = 150
# image = scanner.scan(progress=self.scan_progress)
# image.save("scan.png")
# scanner.close()
# sane.exit()
pass
def on_but_upload_clicked(self, widget):
pass
def on_but_save_clicked(self, widget):
print(self.doc)
def on_but_cancel_clicked(self, widget):
self.topwidget.set_visible_child(self.box['documents'])
+144 -33
View File
@@ -2,6 +2,7 @@
import os
from gi.repository import GLib, Gtk, Gdk
from dateutil.parser import parse
from .view import View
from yms import gtkutils, combobox, treeview
@@ -18,16 +19,7 @@ class EquipmentView(View):
self.newrecord = False
self.lst_equipment = Gtk.ListStore(int, str, str, str, str, str, str)
sql = (
"SELECT e.eid, e.ename, c.compname, e.model, e.serial, "
"DATE_FORMAT(e.purchdate, '{}'), e.remarks "
"FROM equipment AS e LEFT OUTER JOIN company AS c ON (e.manufacturer=c.compid) "
"WHERE e.vid=%s "
"ORDER BY e.ename"
).format("%%d.%%m.%%Y") # TODO format from settings via mapping
self.db.cur.execute(sql, (context.vessel.vid,))
for row in self.db.cur.fetchall():
self.lst_equipment.append(row)
self.load_list()
treeview.add_column(self.tree['equipment'], _('ID'), 0)
treeview.add_column(self.tree['equipment'], _('Name'), 1)
@@ -38,23 +30,132 @@ class EquipmentView(View):
treeview.add_column(self.tree['equipment'], _('Remarks'), 6)
self.tree['equipment'].set_model(self.lst_equipment)
# Supplier
self.dd_supplier = self.context.lookup.company(1)
combobox.load_from_dict(self.combo['supplier'], {-1: _("─── none ───")} | self.dd_supplier)
# Manufacturer
self.dd_manufacturer = self.context.lookup.company(2)
combobox.load_from_dict(self.combo['manufacturer'], {-1: _("─── none ───")} | self.dd_manufacturer)
# Category
self.dd_category = self.context.lookup.dropdown(Dropdown.EQUIPMENT_CATEGORY)
#combobox.load_from_dict(self.combo['unit'], self.dd_unit)
combobox.load_from_dict(self.combo['category'], {-1: _("─── none ───")} | self.dd_category)
# Condition
self.dd_condition = self.context.lookup.enum('equipment.econd')
combobox.load_from_dict(self.combo['condition'], self.dd_condition, 'unknown')
def load_list(self):
self.lst_equipment.clear()
sql = (
"SELECT e.eid, e.ename, c.compname, e.model, e.serial, "
"DATE_FORMAT(e.purchdate, '{}'), e.remarks "
"FROM equipment AS e LEFT OUTER JOIN company AS c ON (e.manufacturer=c.compid) "
"WHERE e.vid=%s "
"ORDER BY e.ename"
).format(self.context.datefmt.replace('%', '%%'))
# ).format("%%d.%%m.%%Y") # TODO format from settings via mapping
self.db.cur.execute(sql, (self.context.vessel.vid,))
for row in self.db.cur.fetchall():
self.lst_equipment.append(row)
def clear_record(self):
self.equip.clear()
self.entry['name'].set_text('')
self.entry['shortname'].set_text('')
combobox.activate_row(self.combo['manufacturer'], -1)
self.entry['model'].set_text('')
self.entry['serial'].set_text('')
self.spin['weight'].set_value(0)
self.spin['price'].set_value(0)
self.entry['purchdate'].set_text('')
combobox.activate_row(self.combo['supplier'], -1)
combobox.activate_row(self.combo['category'], -1)
combobox.activate_row(self.combo['condition'], 'unknown')
self.text['remarks'].get_buffer().set_text('')
def display_record(self):
print(self.equip)
self.label['name'].set_text(self.equip.ename)
self.label['shortname'].set_text(self.equip.shortname or '')
if self.equip.manufacturer:
self.label['manufacturer'].set_text(self.dd_manufacturer[self.equip.manufacturer])
else:
self.label['manufacturer'].set_text('')
self.label['model'].set_text(self.equip.model or '')
self.label['serial'].set_text(self.equip.serial or '')
self.label['weight'].set_text(self.format_float(self.equip.weight, 2, suffix='kg'))
self.label['price'].set_text(self.format_float(self.equip.price, 2, suffix='€'))
self.label['purchdate'].set_text(self.format_date(self.equip.purchdate))
if self.equip.supplier:
self.label['supplier'].set_text(self.dd_supplier[self.equip.supplier])
else:
self.label['supplier'].set_text('')
if self.equip.ecat:
self.label['category'].set_text(self.dd_category[self.equip.ecat])
else:
self.label['category'].set_text('')
self.label['flags'].set_text(self.equip.flags or '')
self.label['remarks'].set_text(self.equip.remarks or '')
def edit_record(self):
self.entry['name'].set_text(self.equip.ename)
self.entry['shortname'].set_text(self.equip.shortname or '')
combobox.activate_row(self.combo['manufacturer'], self.equip.manufacturer or -1)
self.entry['model'].set_text(self.equip.model or '')
self.entry['serial'].set_text(self.equip.serial or '')
self.spin['weight'].set_value(self.equip.weight or 0)
self.spin['price'].set_value(self.equip.price or 0)
self.entry['purchdate'].set_text(self.format_date(self.equip.purchdate))
self.text['remarks'].get_buffer().set_text(self.equip.remarks or '')
combobox.activate_row(self.combo['supplier'], self.equip.supplier or -1)
combobox.activate_row(self.combo['category'], self.equip.ecat or -1)
combobox.activate_row(self.combo['condition'], self.equip.econd or 'unknown')
self.text['remarks'].get_buffer().set_text(self.equip.remarks or '')
print("Edit record")
print(self.equip)
def save_record(self):
# fields must have been validated beforehand
print(self.equip)
self.equip.ename = self.entry['name'].get_text()
self.equip.shortname = self.entry['shortname'].get_text()
self.equip.manufacturer = combobox.get_list_value(self.combo['manufacturer'])
if self.equip.manufacturer < 0:
self.equip.manufacturer = None
self.equip.model = self.entry['model'].get_text()
self.equip.serial = self.entry['serial'].get_text()
self.equip.weight = self.spin['weight'].get_value()
self.equip.price = self.spin['price'].get_value()
self.equip.supplier = combobox.get_list_value(self.combo['supplier'])
if self.equip.supplier < 0:
self.equip.supplier = None
self.equip.ecat = combobox.get_list_value(self.combo['category'])
if self.equip.ecat < 0:
self.equip.ecat = None
self.equip.remarks = gtkutils.get_text_contents(self.text['remarks'])
print(self.equip)
# buttons on list page
def on_but_new_clicked(self, widget):
self.newrecord = True
self.label['title_editor'].set_text(_("Add new Equipment"))
self.label['title_edit'].set_text(_("Add new Equipment"))
self.clear_record()
self.equip.vid = self.context.vessel.vid
self.topwidget.set_visible_child(self.box['equip_edit'])
def on_but_edit_clicked(self, widget):
self.newrecord = False
eid = treeview.get_value(self.tree['equipment'], 0)
if eid is None:
return
self.label['title_edit'].set_text(_("Edit Equipment"))
self.equip.load(eid)
self.edit_record()
self.topwidget.set_visible_child(self.box['equip_edit'])
def on_but_detail_clicked(self, widget):
eid = treeview.get_value(self.tree['equipment'], 0)
if eid is None:
return
self.equip.load(eid)
self.display_record()
self.topwidget.set_visible_child(self.box['equip_detail'])
@@ -71,34 +172,44 @@ class EquipmentView(View):
def on_but_close_clicked(self, widget):
self.topwidget.set_visible_child(self.box['equipment'])
def on_but_convert_clicked(self, widget):
# convert equipment to inventory
answer = gtkutils.questionbox(
_("Convert equipment to inventory?\n"
"Some properties will be lost!\n\n"
"Are you sure?"), title="YMS"
)
if answer == False:
return
# TODO
def on_but_delete_clicked(self, widget):
answer = gtkutils.questionbox(
_("Delete equipment!\n"
"Are you sure?"), title="YMS"
)
if answer == False:
return
self.topwidget.set_visible_child(self.box['equipment'])
# buttons on edit page
def on_but_save_clicked(self, widget):
# check mandatory fields
if not self.entry['name'].get_text().strip():
# TODO error marker
return
self.save_record()
print(self.equip)
self.equip.save()
if self.newrecord:
self.load_list()
else:
pass
# TODO aktuelle Listenzeile aktualisieren!
self.newrecord = False
self.display_record()
self.topwidget.set_visible_child(self.box['equip_detail'])
def on_but_cancel_clicked(self, widget):
self.topwidget.set_visible_child(self.box['equipment'])
def display_record(self):
print(self.equip)
self.label['name'].set_text(self.equip.ename)
self.label['shortname'].set_text(self.equip.shortname or '')
#lookup self.label['manufacturer'].set_text(self.equip.manufacturer)
self.label['model'].set_text(self.equip.model or '')
self.label['serial'].set_text(self.equip.serial or '')
self.label['weight'].set_text(self.format_float(self.equip.weight, 2, suffix='kg'))
self.label['price'].set_text(self.format_float(self.equip.price, 2, suffix='€'))
self.label['date_purch'].set_text(self.equip.purchdate or '')
#lookup self.label['supplier'].set_text(self.equip.supplier)
self.label['category'].set_text(self.dd_category[self.equip.ecat])
self.label['flags'].set_text(self.equip.flags or '')
self.label['remarks'].set_text(self.equip.remarks or '')
def edit_record(self):
self.entry['sname'].set_text(self.storage.sname)
self.spin['x'].set_value(self.storage.x)
self.spin['y'].set_value(self.storage.y)
self.spin['z'].set_value(self.storage.z)
self.text['remarks'].get_buffer().set_text(self.storage.remarks or '')
+66 -13
View File
@@ -39,13 +39,72 @@ class FusesView(View):
treeview.add_column(self.tree['fuses'], _('Description'), 3)
self.tree['fuses'].set_model(self.lst_fuses)
self.dd_type = self.context.lookup.dropdown(Dropdown.FUSE_TYPE)
# Fuse Type
self.dd_ftype = self.context.lookup.dropdown(Dropdown.FUSE_TYPE)
combobox.load_from_dict(self.combo['ftype'], self.dd_ftype)
# Cables
self.dd_cable = self.context.lookup.cable(context.vessel.vid)
combobox.load_from_dict(self.combo['cable'], {-1: _("─── none ───")} | self.dd_cable)
# Equipment
self.dd_equipment = self.context.lookup.equipment(context.vessel.vid)
combobox.load_from_dict(self.combo['equipment'], {-1: _("─── none ───")} | self.dd_equipment)
def clear_record(self):
self.fuse.clear()
self.spin['fnumber'].set_value(0)
self.entry['description'].set_text('')
combobox.activate_row(self.combo['ftype'], -1)
self.spin['current'].set_value(0)
combobox.activate_row(self.combo['cable'], -1)
combobox.activate_row(self.combo['equipment'], -1)
self.entry['location'].set_text('')
self.text['remarks'].get_buffer().set_text('')
def display_record(self):
self.label['fnumber'].set_text(f"F{self.fuse.fnumber}")
self.label['type'].set_text(self.dd_type[self.fuse.ftype])
self.label['current'].set_text(self.format_float(self.fuse.current, 2, suffix="A"))
self.label['cable'].set_text(str(self.fuse.cableid))
self.label['equipment'].set_text(str(self.fuse.eid))
self.label['location'].set_text(str(self.fuse.location))
self.label['description'].set_text(str(self.fuse.description or ''))
self.label['remarks'].set_text(str(self.fuse.remarks or ''))
def edit_record(self):
self.spin['fnumber'].set_value(self.fuse.fnumber)
self.entry['description'].set_text(self.fuse.description)
combobox.activate_row(self.combo['ftype'], self.fuse.ftype)
self.spin['current'].set_value(self.fuse.current)
combobox.activate_row(self.combo['cable'], self.fuse.cableid)
combobox.activate_row(self.combo['equipment'], self.fuse.eid)
self.entry['location'].set_text(self.fuse.location)
self.text['remarks'].get_buffer().set_text(self.prov.remarks or '')
def save_record(self):
# fields must have been validated beforehand
self.fuse.number = int(self.spin['fnumber'].get_value())
self.fuse.description = self.entry['description'].get_text()
self.fuse.ftype = combobox.get_list_value(self.combo['ftype'])
self.fuse.cableid = combobox.get_list_value(self.combo['cable'])
self.fuse.eid = combobox.get_list_value(self.combo['equipment'])
self.fuse.location = self.entry['location'].get_text()
self.fuse.remarks = gtkutils.get_text_contents(self.text['remarks'])
# buttons on list page
def on_but_new_clicked(self, widget):
self.newrecord = True
self.label['title_edit'].set_text(_("Add new Fuse"))
self.clear_record()
self.topwidget.set_visible_child(self.box['fuse_edit'])
def on_but_edit_clicked(self, widget):
self.newrecord = False
fuseid = treeview.get_value(self.tree['fuses'], 0)
if fuseid is None:
return
self.label['title_edit'].set_text(_("Edit Fuse"))
self.fuse.load(fuseid)
self.edit_record()
self.topwidget.set_visible_child(self.box['fuse_edit'])
def on_but_detail_clicked(self, widget):
@@ -70,6 +129,12 @@ class FusesView(View):
self.topwidget.set_visible_child(self.box['fuses'])
def on_but_delete_clicked(self, widget):
answer = gtkutils.questionbox(
_("Delete fuse!\n"
"Are you sure?"), title="YMS"
)
if answer == False:
return
self.topwidget.set_visible_child(self.box['fuses'])
# buttons on edit page
@@ -79,15 +144,3 @@ class FusesView(View):
def on_but_cancel_clicked(self, widget):
self.topwidget.set_visible_child(self.box['fuses'])
def display_record(self):
self.label['fnumber'].set_text(f"F{self.fuse.fnumber}")
self.label['type'].set_text(self.dd_type[self.fuse.ftype])
self.label['current'].set_text(self.format_float(self.fuse.current, 2, suffix="A"))
self.label['cable'].set_text(str(self.fuse.cableid))
self.label['equipment'].set_text(str(self.fuse.eid))
self.label['location'].set_text(str(self.fuse.location))
self.label['description'].set_text(str(self.fuse.description or ''))
self.label['remarks'].set_text(str(self.fuse.remarks or ''))
def edit_record(self):
pass
+209 -49
View File
@@ -1,12 +1,16 @@
# SPDX-License-Identifier: WTFPL
import os
from gi.repository import GLib, Gtk, Gdk
from dateutil.parser import parse
from .view import View
from yms import gtkutils, combobox, treeview
from yms.lookup import Dropdown
from yms.model import inventory
from yms.model import equipment
class InventoryView(View):
@@ -15,22 +19,14 @@ class InventoryView(View):
self.inv = inventory.Inventory(context.db) # current record
self.newrecord = False
self.token = None # record locking
self.timer_id = None
# Inventory gets vessel assignment via
# - storage direct
# - or via box which is assigned to a storage
self.lst_inventory = Gtk.ListStore(int, str, str, int, str, str)
sql = (
"SELECT i.invid, i.invname, s.sname AS container, i.number, i.invcond, i.remarks "
"FROM inventory AS i JOIN storage AS s ON (i.conttype='storage' AND i.sid=s.sid) "
"WHERE s.vid=%s "
"UNION SELECT i.invid, i.invname, b.label AS container, i.number, i.invcond, i.remarks "
"FROM inventory AS i JOIN box AS b ON (i.conttype='box' AND i.boxid=b.boxid) JOIN storage AS s ON (b.sid=s.sid) "
"WHERE s.vid=%s"
)
self.db.cur.execute(sql, (context.vessel.vid, context.vessel.vid))
for row in self.db.cur.fetchall():
self.lst_inventory.append(row)
self.load_list()
treeview.add_column(self.tree['inventory'], _('ID'), 0)
treeview.add_column(self.tree['inventory'], _('Name'), 1)
@@ -40,42 +36,60 @@ class InventoryView(View):
treeview.add_column(self.tree['inventory'], _('Remarks'), 5)
self.tree['inventory'].set_model(self.lst_inventory)
# Container type
self.dd_conttype = self.context.lookup.enum('inventory.conttype')
combobox.load_from_dict(self.combo['conttype'], self.dd_conttype)
# Inventory category
self.dd_category = self.context.lookup.dropdown(Dropdown.INVENTORY_CATEGORY)
combobox.load_from_dict(self.combo['category'], {-1: _("─── none ───")} | self.dd_category)
# Storage
self.dd_storage = self.context.lookup.storage(context.vessel.vid)
combobox.load_from_dict(self.combo['storage'], {-1: _("─── none ───")} | self.dd_storage)
# Box
self.dd_box = self.context.lookup.box(context.vessel.vid)
combobox.load_from_dict(self.combo['box'], {-1: _("─── none ───")} | self.dd_box)
# Equipment
self.dd_equipment = self.context.lookup.equipment(context.vessel.vid)
combobox.load_from_dict(self.combo['equipment'], {-1: _("─── none ───")} | self.dd_equipment)
# Condition
self.dd_condition = self.context.lookup.enum('inventory.invcond')
combobox.load_from_dict(self.combo['condition'], {"-1": _("─── none ───")} | self.dd_condition)
# buttons on list page
def on_but_new_clicked(self, widget):
self.topwidget.set_visible_child(self.box['inv_edit'])
def load_list(self):
self.lst_inventory.clear()
sql = (
"SELECT i.invid, i.invname, s.sname AS container, i.number, i.invcond, i.remarks "
"FROM inventory AS i JOIN storage AS s ON (i.conttype='storage' AND i.sid=s.sid) "
"WHERE s.vid=%s "
"UNION SELECT i.invid, i.invname, b.label AS container, i.number, i.invcond, i.remarks "
"FROM inventory AS i JOIN box AS b ON (i.conttype='box' AND i.boxid=b.boxid) JOIN storage AS s ON (b.sid=s.sid) "
"WHERE s.vid=%s"
)
self.db.cur.execute(sql, (self.context.vessel.vid, self.context.vessel.vid))
for row in self.db.cur.fetchall():
self.lst_inventory.append(row)
def on_but_edit_clicked(self, widget):
self.topwidget.set_visible_child(self.box['inv_edit'])
def lock_timer(self):
self.context.db.lock_refresh(self.token)
return True # continue timer
def on_but_detail_clicked(self, widget):
invid = treeview.get_value(self.tree['inventory'], 0)
self.inv.load(invid)
self.display_record()
self.topwidget.set_visible_child(self.box['inv_detail'])
self.button['close'].grab_focus()
def on_page_activated(self):
print("Inventory activated")
def on_tvw_inventory_row_activated(self, widget, path, column):
invid = treeview.get_value(widget, 0)
self.inv.load(invid)
self.display_record()
self.topwidget.set_visible_child(self.box['inv_detail'])
# buttons on detail page
# edit2 uses edit callback
def on_but_close_clicked(self, widget):
self.topwidget.set_visible_child(self.box['inventory'])
def on_but_delete_clicked(self, widget):
self.topwidget.set_visible_child(self.box['inventory'])
# 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['inventory'])
def clear_record(self):
self.inv.clear()
self.entry['name'].set_text('')
combobox.activate_row(self.combo['conttype'], -1)
combobox.activate_row(self.combo['storage'], -1)
combobox.activate_row(self.combo['box'], -1)
combobox.activate_row(self.combo['equipment'], -1)
self.spin['number'].set_value(1)
self.spin['weight'].set_value(0)
self.spin['price'].set_value(0)
self.entry['purchdate'].set_text('')
combobox.activate_row(self.combo['condition'], 'unknown')
combobox.activate_row(self.combo['category'], -1)
self.text['remarks'].get_buffer().set_text('')
def display_record(self):
# TODO nice formatting
@@ -93,13 +107,159 @@ class InventoryView(View):
self.label['category'].set_text(self.dd_category[self.inv.icat])
else:
self.label['category'].set_text('')
self.label['flags'].set_text(self.inv.flags)
self.label['remarks'].set_text(self.inv.remarks or '')
def edit_record(self):
self.entry['user_login'].set_text(user.login)
self.entry['user_displayname'].set_text(user.displayname)
combobox.activate_row(self.combo['user_role'], user.role)
combobox.activate_row(self.combo['user_lang'], user.language)
self.check['user_locked'].set_active('locked' in user.flags)
self.check['user_deleted'].set_active('deleted' in user.flags)
self.entry['user_pass'].set_text('')
self.entry['name'].set_text(self.inv.invname)
combobox.activate_row(self.combo['conttype'], self.inv.conttype)
combobox.activate_row(self.combo['storage'], self.inv.sid)
combobox.activate_row(self.combo['box'], self.inv.boxid)
combobox.activate_row(self.combo['equipment'], self.inv.eid)
self.spin['number'].set_value(self.inv.number)
self.spin['weight'].set_value(self.inv.weight or 0)
self.spin['price'].set_value(self.inv.price or 0)
self.entry['purchdate'].set_text(self.inv.purchdate or '')
combobox.activate_row(self.combo['condition'], self.inv.invcond)
combobox.activate_row(self.combo['category'], self.inv.icat)
flags = self.inv.flags.split(',')
for flag in self.context.lookup.enum('inventory.flags'):
self.check[flag].set_active(flag in flags)
self.text['remarks'].get_buffer().set_text(self.inv.remarks or '')
def save_record(self):
# fields must have been validated beforehand
self.inv.invname = self.entry['name'].get_text()
self.inv.conttype = combobox.get_list_value(self.combo['conttype'])
self.inv.sid = combobox.get_list_value(self.combo['storage'])
if self.inv.sid < 0:
self.inv.sid = None
self.inv.boxid = combobox.get_list_value(self.combo['box'])
if self.inv.boxid < 0:
self.inv.boxid = None
self.inv.eid = combobox.get_list_value(self.combo['equipment'])
if self.inv.eid < 0:
self.inv.eid = None
self.inv.number = self.spin['number'].get_value()
self.inv.weight = self.spin['weight'].get_value()
self.inv.price = self.spin['price'].get_value()
try:
# TODO respect configured date format
self.inv.purchdate = parse(self.entry['purchdate'].get_text(), dayfirst=True)
except ValueError:
self.inv.purchdate = None
self.inv.invcond = combobox.get_list_value(self.combo['condition'])
self.inv.icat = combobox.get_list_value(self.combo['category'])
# TODO this could be a generic function operating on a list
# of check controls
flags = []
if self.check['ordered'].get_active(): flags.append('ordered')
if self.check['removed'].get_active(): flags.append('removed')
if self.check['deleted'].get_active(): flags.append('deleted')
self.inv.flags = ','.join(flags)
self.inv.remarks = gtkutils.get_text_contents(self.text['remarks'])
# buttons on list page
def on_but_new_clicked(self, widget):
self.newrecord = True
self.label['title_edit'].set_text(_("Add new Inventory"))
self.clear_record()
self.topwidget.set_visible_child(self.box['inv_edit'])
def on_but_edit_clicked(self, widget):
invid = treeview.get_value(self.tree['inventory'], 0)
if invid is None:
return
self.token = self.context.db.lock_acquire('inventory', invid, self.user.user_id)
if self.token is None:
gtkutils.messagebox(
_("Record is locked!\n"
"Edit prohibited."), title="YMS"
)
return
self.timer_id = GLib.timeout_add(120000, self.lock_timer) # 2 minutes lock refresh timer
self.newrecord = False
self.label['title_edit'].set_text(_("Edit Inventory"))
self.inv.load(invid)
self.edit_record()
self.topwidget.set_visible_child(self.box['inv_edit'])
# TODO start timer to refresh record lock
def on_but_detail_clicked(self, widget):
invid = treeview.get_value(self.tree['inventory'], 0)
self.inv.load(invid)
print(self.inv)
self.display_record()
self.topwidget.set_visible_child(self.box['inv_detail'])
self.button['close'].grab_focus()
def on_tvw_inventory_row_activated(self, widget, path, column):
invid = treeview.get_value(widget, 0)
self.inv.load(invid)
self.display_record()
self.topwidget.set_visible_child(self.box['inv_detail'])
# buttons on detail page
# edit2 uses edit callback
def on_but_close_clicked(self, widget):
self.topwidget.set_visible_child(self.box['inventory'])
def on_but_convert_clicked(self, widget):
# convert equipment to inventory
answer = gtkutils.questionbox(
_("Convert inventory to equipment?\n"
"Some properties will be lost!\n\n"
"Are you sure?"), title="YMS"
)
if answer == False:
return
# TODO / WIP
"""
lost fields: icat number conttype sid boxid
"""
equip = equipment.Equipment(self.context.db)
equip.ename = self.inv.name
equip.shortname = ''
equip.manufacturer = None
equip.model = ''
equip.serial = ''
equip.weight = self.inv.weight
equip.price = self.inv.price
equip.purchdate = self.inv.purchdate
equip.supplier = None
equip.ecat = None
equip.econd = self.inv.invcond
equip.remarks = self.inv.remarks
equip.flags = self.inv.flags
print(equip)
def on_but_delete_clicked(self, widget):
answer = gtkutils.questionbox(
_("Delete inventory!\n"
"Are you sure?"), title="YMS"
)
if answer == False:
return
self.topwidget.set_visible_child(self.box['inventory'])
# buttons on edit page
def on_but_save_clicked(self, widget):
# check mandatory fields
if not self.entry['name'].get_text().strip():
# TODO error marker
return
self.save_record()
print(self.inv)
self.inv.save()
self.context.db.conn.commit()
def on_but_cancel_clicked(self, widget):
if not self.newrecord:
if self.timer_id is not None:
# remove locking timer
GLib.source_remove(self.timer_id)
self.timer_id = None
if not self.token is None:
if not self.context.db.lock_release(self.token):
print("Error while releasing lock!")
self.topwidget.set_visible_child(self.box['inventory'])
+66 -16
View File
@@ -32,11 +32,64 @@ class MaintenanceView(View):
treeview.add_column(self.tree['maintenance'], _('Remarks'), 3)
self.tree['maintenance'].set_model(self.lst_maintenance)
def clear_record(self):
self.maint.clear()
self.entry['activities'].set_text('')
combobox.activate_row(self.combo['equipment'], -1)
self.spin['series'].set_value(0)
self.spin['interval'].set_value(0)
self.spin['last'].set_value(0)
self.entry['plandate'].set_text('')
self.entry['completion'].set_text('')
combobox.activate_row(self.combo['status'], 'new')
self.text['remarks'].get_buffer().set_text('')
def display_record(self):
self.label['activities'].set_text(self.maint.activities)
self.label['equipment'].set_text(str(self.maint.eid))
self.label['series'].set_text(str(self.maint.series))
self.label['interval'].set_text(self.format_int(self.maint.interval_hours))
self.label['last'].set_text(self.format_int(self.maint.last_hours))
self.label['plandate'].set_text(self.format_date(self.maint.plan_date))
self.label['completion'].set_text(self.format_date(self.maint.completion_date))
self.label['status'].set_text(self.maint.maintstate)
self.label['remarks'].set_text(self.maint.remarks or '')
def edit_record(self):
self.entry['activities'].set_text(self.maint.activities)
combobox.activate_row(self.combo['equipment'], self.maint.eid)
self.spin['series'].set_value(self.maint.series or 0)
self.spin['interval'].set_value(self.maint.interval_hours or 0)
self.spin['last'].set_value(self.maint.last_hours or 0)
self.entry['plandate'].set_text(self.maint.plan_date)
self.entry['completion'].set_text(self.maint.completion_date)
combobox.activate_row(self.combo['status'], self.maint.maintstate)
self.text['remarks'].get_buffer().set_text(self.maint.remarks or '')
def save_record(self):
# fields must have been validated beforehand
self.maint.activities = self.entry['activities'].get_text()
self.maint.eid = combobox.get_list_value(self.combo['equipment'])
self.maint.series = int(self.spin['series'].get_value())
self.maint.interval_hours = int(self.spin['interval'].get_value())
self.maint.last_hours = int(self.spin['last'].get_value())
self.maint.plan_date = self.entry['plandate'].get_text()
self.maint.completion_date = self.entry['completion'].get_text()
self.maint.maintstate = combobox.get_list_value(self.combo['status'])
self.maint.remarks = gtkutils.get_text_contents(self.text['remarks'])
# buttons on list page
def on_but_new_clicked(self, widget):
self.topwidget.set_visible_child(self.box['maint_edit'])
def on_but_edit_clicked(self, widget):
self.newrecord = False
self.label['title_edit'].set_text(_("Edit Maintenance"))
maintid = treeview.get_value(self.tree['maintenance'], 0)
if not maintid:
return
self.maint.load(maintid)
self.edit_record()
self.topwidget.set_visible_child(self.box['maint_edit'])
def on_but_detail_clicked(self, widget):
@@ -61,26 +114,23 @@ class MaintenanceView(View):
self.topwidget.set_visible_child(self.box['maintenance'])
def on_but_delete_clicked(self, widget):
answer = gtkutils.questionbox(
_("Delete maintenance!\n"
"Are you sure?"), title="YMS"
)
if answer == False:
return
self.topwidget.set_visible_child(self.box['maintenance'])
# buttons on edit page
def on_but_save_clicked(self, widget):
pass
# check mandatory fields
if not self.entry['activities'].get_text().strip():
# TODO error marker
return
self.save_record()
print(self.maint)
self.maint.save()
def on_but_cancel_clicked(self, widget):
self.topwidget.set_visible_child(self.box['maintenance'])
def display_record(self):
self.label['activities'].set_text(self.maint.activities)
self.label['equipment'].set_text(str(self.maint.eid))
self.label['series'].set_text(str(self.maint.series))
self.label['interval'].set_text(self.format_int(self.maint.interval_hours))
self.label['last'].set_text(self.format_int(self.maint.last_hours))
self.label['plandate'].set_text(self.format_date(self.maint.plan_date))
self.label['completion'].set_text(self.format_date(self.maint.completion_date))
self.label['status'].set_text(self.maint.maintstate)
self.label['remarks'].set_text(self.maint.remarks or '')
def edit_record(self):
pass
+96 -8
View File
@@ -16,8 +16,26 @@ class MeasurementView(View):
self.measure = measurement.Measurement(context.db) # current record
self.newrecord = False
# dimensions
self.dd_dimensions = { 1: "1D", 2: "2D", 3: "3D"}
combobox.load_from_dict(self.combo['dimensions'], self.dd_dimensions, 1)
# accuracy
self.dd_accuracy = self.context.lookup.enum('measurement.accuracy')
combobox.load_from_dict(self.combo['accuracy'], {"-1": _("─── none ───")} | self.dd_accuracy)
# measurement units
self.dd_unit = self.context.lookup.dropdown(Dropdown.UNIT)
print("Unit: {self.dd_unit}")
combobox.load_from_dict(self.combo['unit'], self.dd_unit, 1)
# equipment
self.dd_equipment = self.context.lookup.equipment(context.vessel.vid)
combobox.load_from_dict(self.combo['equipment'], {-1: _("─── none ───")} | self.dd_equipment)
# category
self.dd_category = self.context.lookup.dropdown(Dropdown.MEASUREMENT_CATEGORY)
combobox.load_from_dict(self.combo['category'], {-1: _("─── none ───")} | self.dd_category)
self.lst_measurement = Gtk.ListStore(int, str, str, str, str, str)
sql = (
@@ -56,11 +74,76 @@ class MeasurementView(View):
treeview.add_column(self.tree['measurement'], _('Note'), 5)
self.tree['measurement'].set_model(self.lst_measurement)
def clear_record(self):
self.measure.clear()
self.entry['name'].set_text('')
combobox.activate_row(self.combo['dimensions'], -1)
self.spin['val1'].set_value(0)
self.spin['val2'].set_value(0)
self.spin['val3'].set_value(0)
combobox.activate_row(self.combo['accuracy'], 'unknown')
self.entry['date'].set_text('')
combobox.activate_row(self.combo['equipment'], -1)
combobox.activate_row(self.combo['category'], -1)
self.text['note'].get_buffer().set_text('')
def display_record(self):
self.label['name'].set_text(self.measure.mname)
self.label['dimensions'].set_text(self.measure.nval)
self.label['val1'].set_text(self.measure.val1)
if self.measure.nval >= 2:
self.label['val2'].set_text(self.measure.val2 or '')
else:
self.label['val2'].set_text('n/a')
if self.measure.nval == 3:
self.label['val3'].set_text(self.measure.val3 or '')
else:
self.label['val3'].set_text('n/a')
# TODO
# unit
# accuracy
# category
def edit_record(self):
self.entry['name'].set_text(self.measure.mname)
combobox.activate_row(self.combo['dimensions'], self.measure.nval)
self.spin['val1'].set_value(self.measure.val1)
self.spin['val2'].set_value(self.measure.val2 or 0)
self.spin['val3'].set_value(self.measure.val3 or 0)
combobox.activate_row(self.combo['accuracy'], self.measure.accuracy)
self.entry['date'].set_text(self.measure.mdate)
combobox.activate_row(self.combo['equipment'], self.measure.eid)
combobox.activate_row(self.combo['category'], self.measure.mcat)
self.text['note'].get_buffer().set_text(self.task.note or '')
def save_record(self):
# fields must have been validated beforehand
self.measure.mname = self.entry['name'].get_text()
self.measure.nval = combobox.get_list_value(self.combo['dimensions'])
self.measure.val1 = int(self.spin['val1'].get_value())
self.measure.val2 = int(self.spin['val2'].get_value())
self.measure.val3 = int(self.spin['val3'].get_value())
self.measure.accuracy = combobox.get_list_value(self.combo['accurace'])
self.measure.mdate = self.entry['date'].get_text()
self.measure.eid = combobox.get_list_value(self.combo['equipment'])
self.measure.mcat = combobox.get_list_value(self.combo['category'])
self.measure.note = gtkutils.get_text_contents(self.text['note'])
# buttons on list page
def on_but_new_clicked(self, widget):
self.newrecord = True
self.label['title_edit'].set_text(_("Add new Measurement"))
self.clear_record()
self.topwidget.set_visible_child(self.box['measure_edit'])
def on_but_edit_clicked(self, widget):
self.newrecord = False
self.label['title_edit'].set_text(_("Edit Measurement"))
mid = treeview.get_value(self.tree['measurement'], 0)
if not mid:
return
self.measure.load(mid)
self.edit_record()
self.topwidget.set_visible_child(self.box['measure_edit'])
def on_but_detail_clicked(self, widget):
@@ -85,18 +168,23 @@ class MeasurementView(View):
self.topwidget.set_visible_child(self.box['measurement'])
def on_but_delete_clicked(self, widget):
answer = gtkutils.questionbox(
_("Delete measurement!\n"
"Are you sure?"), title="YMS"
)
if answer == False:
return
self.topwidget.set_visible_child(self.box['measurement'])
# buttons on edit page
def on_but_save_clicked(self, widget):
pass
# check mandatory fields
if not self.entry['mname'].get_text().strip():
# TODO error marker
return
self.save_record()
print(self.measure)
self.measure.save()
def on_but_cancel_clicked(self, widget):
self.topwidget.set_visible_child(self.box['measurement'])
def display_record(self):
self.label['name'].set_text(self.measure.mname)
self.label['note'].set_text(self.measure.note or '')
def edit_record(self):
pass
+66 -14
View File
@@ -43,14 +43,67 @@ class ProjectsView(View):
treeview.add_column(self.tree['projects'], _('Remarks'), 5)
self.tree['projects'].set_model(self.lst_projects)
# Responsible
self.dd_user = context.lookup.user()
combobox.load_from_dict(self.combo['responsible'], self.dd_user)
# Status
self.dd_state = self.context.lookup.enum('project.projstate')
combobox.load_from_dict(self.combo['status'], self.dd_state)
def clear_record(self):
self.project.clear()
self.entry['name'].set_text('')
combobox.activate_row(self.combo['responsible'], 0)
self.entry['date_start'].set_text('')
self.spin['costs_plan'].set_value(0)
self.spin['costs_final'].set_value(0)
combobox.activate_row(self.combo['status'], 'new')
self.text['remarks'].get_buffer().set_text('')
def display_record(self):
self.label['name'].set_text(self.project.projname)
self.label['responsible'].set_text(self.dd_user[self.project.responsible])
self.label['date_start'].set_text(self.format_date(self.project.startdate))
self.label['duration'].set_text(self.format_int(self.project.duration, suffix="Days"))
self.label['costs_plan'].set_text(self.format_float(self.project.costs_plan, 2, suffix="€"))
self.label['costs_final'].set_text(self.format_float(self.project.costs_final, 2, suffix="€"))
self.label['status'].set_text(self.project.projstate)
self.label['remarks'].set_text(self.project.remarks or '')
def edit_record(self):
self.entry['name'].set_text(self.project.projname)
combobox.activate_row(self.combo['responsible'], self.project.responsible)
self.entry['date_start'].set_text(self.project.startdate)
self.spin['costs_plan'].set_value(self.project.costs_plan)
self.spin['costs_final'].set_value(self.project.costs_final)
combobox.activate_row(self.combo['status'], self.project.projstate)
self.text['remarks'].get_buffer().set_text(self.project.remarks or '')
def save_record(self):
# fields must have been validated beforehand
self.project.projname = self.entry['name'].get_text()
self.project.responsible = combobox.get_list_value(self.combo['responsible'])
self.project.costs_plan = int(self.spin['costs_plan'].get_value())
self.project.costs_final = int(self.spin['costs_final'].get_value())
self.project.projstate = combobox.get_list_value(self.combo['status'])
self.project.remarks = gtkutils.get_text_contents(self.text['remarks'])
# buttons on list page
def on_but_new_clicked(self, widget):
self.newrecord = True
self.label['title_edit'].set_text(_("Add new Project"))
self.clear_record()
self.topwidget.set_visible_child(self.box['proj_edit'])
def on_but_edit_clicked(self, widget):
self.newrecord = False
self.label['title_edit'].set_text(_("Edit Project"))
projid = treeview.get_value(self.tree['projects'], 0)
if not projidid:
return
self.measure.load(mid)
self.edit_record()
self.topwidget.set_visible_child(self.box['proj_edit'])
def on_but_detail_clicked(self, widget):
@@ -75,24 +128,23 @@ class ProjectsView(View):
self.topwidget.set_visible_child(self.box['projects'])
def on_but_delete_clicked(self, widget):
answer = gtkutils.questionbox(
_("Delete project!\n"
"Are you sure?"), title="YMS"
)
if answer == False:
return
self.topwidget.set_visible_child(self.box['projects'])
# buttons on edit page
def on_but_save_clicked(self, widget):
pass
# check mandatory fields
if not self.entry['projname'].get_text().strip():
# TODO error marker
return
self.save_record()
print(self.project)
self.project.save()
def on_but_cancel_clicked(self, widget):
self.topwidget.set_visible_child(self.box['projects'])
def display_record(self):
self.label['name'].set_text(self.project.projname)
self.label['responsible'].set_text(self.dd_user[self.project.responsible])
self.label['date_start'].set_text(self.format_date(self.project.startdate))
self.label['duration'].set_text(self.format_int(self.project.duration, suffix="Days"))
self.label['costs_plan'].set_text(self.format_float(self.project.costs_plan, 2, suffix="€"))
self.label['costs_final'].set_text(self.format_float(self.project.costs_final, 2, suffix="€"))
self.label['status'].set_text(self.project.projstate)
self.label['remarks'].set_text(self.project.remarks or '')
def edit_record(self):
pass
+81 -19
View File
@@ -2,8 +2,10 @@
import os
from gi.repository import Gtk
from dateutil.parser import parse
from datetime import datetime
from .view import View
from .view import View, DatePicker
from yms import gtkutils, combobox, treeview
from yms.model import provision
@@ -44,15 +46,72 @@ class ProvisionsView(View):
treeview.add_column(self.tree['provisions'], _('Best before'), 5)
self.tree['provisions'].set_model(self.lst_provisions)
# TODO Date format
self.entry['storedate'].set_placeholder_text("TT.MM.JJJJ")
self.dt_storedate = DatePicker(self.entry['storedate'], self.button['storedate'], context.datefmt)
def clear_record(self):
self.prov.clear()
def display_record(self):
self.label['name'].set_text(self.prov.provname)
self.label['category'].set_text(str(self.prov.provcat))
self.label['storage'].set_text(str(self.prov.sid))
self.label['box'].set_text(str(self.prov.boxid))
self.label['number'].set_text(str(self.prov.number))
self.label['unit'].set_text(str(self.prov.unit))
self.label['target'].set_text(str(self.prov.target))
self.label['weight'].set_text(self.format_float(self.prov.weight, 2, suffix='kg'))
self.label['weight_net'].set_text(self.format_float(self.prov.weight_net, 2, suffix='kg'))
self.label['price'].set_text(self.format_float(self.prov.price, 2, suffix='€'))
self.label['remarks'].set_text(self.prov.remarks or '')
def edit_record(self):
self.entry['name'].set_text(self.prov.provname)
combobox.activate_row(self.combo['category'], self.prov.provcat)
combobox.activate_row(self.combo['storage'], self.prov.sid)
combobox.activate_row(self.combo['box'], self.prov.boxid)
self.spin['number'].set_value(self.prov.number)
self.spin['weight'].set_value(self.prov.weight or 0)
self.spin['weight_net'].set_value(self.prov.weight_net or 0)
combobox.activate_row(self.combo['unit'], self.prov.unit)
self.entry['storedate'].set_text(self.prov.storedate or '')
self.entry['shelflife'].set_text(self.prov.shelflife or '')
self.text['remarks'].get_buffer().set_text(self.prov.remarks or '')
def save_record(self):
# fields must have been validated beforehand
self.prov.provname = self.entry['name'].get_text()
self.prov.provcat = combobox.get_list_value(self.combo['category'])
self.prov.sid = combobox.get_list_value(self.combo['storage'])
self.prov.boxid = combobox.get_list_value(self.combo['box'])
self.prov.number = int(self.spin['number'].get_value())
self.prov.weight = self.spin['weight'].get_value()
self.prov.weight_net = self.spin['wehigt_net'].get_value()
self.prov.unit = combobox.get_list_value(self.combo['unit'])
self.prov.storedate = self.entry['storedate'].get_text()
self.prov.shelflife = self.entry['shelflife'].get_text()
self.prov.remarks = gtkutils.get_text_contents(self.text['remarks'])
def load_dropdown(self):
self.db.cur.execute("SELECT ddval, ddtext FROM dropdown WHERE ddid=6 ORDER BY ddval")
self.prov_unit = dict(self.db.cur.fetchall())
# buttons on list page
def on_but_new_clicked(self, widget):
self.newrecord = True
self.label['title_edit'].set_text(_("Add new Provision"))
self.clear_record()
self.topwidget.set_visible_child(self.box['prov_edit'])
def on_but_edit_clicked(self, widget):
self.newrecord = False
self.label['title_edit'].set_text(_("Edit Provision"))
provid = treeview.get_value(self.tree['provisions'], 0)
if not provid:
return
self.prov.load(provid)
self.edit_record()
self.topwidget.set_visible_child(self.box['prov_edit'])
def on_but_detail_clicked(self, widget):
@@ -75,28 +134,31 @@ class ProvisionsView(View):
self.topwidget.set_visible_child(self.box['provisions'])
def on_but_delete_clicked(self, widget):
answer = gtkutils.questionbox(
_("Delete provision!\n"
"Are you sure?"), title="YMS"
)
if answer == False:
return
self.topwidget.set_visible_child(self.box['provisions'])
# buttons on edit page
def on_but_storedate_clicked(self, widget):
try:
curdate = parse(self.entry['storedate'].get_text())
except:
curdate = datetime.date.today()
selected_date = self.calendar_dialog(None, self.entry['storedate'], curdate)
self.entry['storedate'].set_text(self.format_date(selected_date, curdate))
def on_but_save_clicked(self, widget):
pass
# check mandatory fields
if not self.entry['provname'].get_text().strip():
# TODO error marker
return
self.save_record()
print(self.prov)
self.prov.save()
def on_but_cancel_clicked(self, widget):
self.topwidget.set_visible_child(self.box['provisions'])
def display_record(self):
print(self.prov)
self.label['name'].set_text(self.prov.provname)
self.label['category'].set_text(str(self.prov.provcat))
self.label['storage'].set_text(str(self.prov.sid))
self.label['box'].set_text(str(self.prov.boxid))
self.label['number'].set_text(str(self.prov.number))
self.label['unit'].set_text(str(self.prov.unit))
self.label['target'].set_text(str(self.prov.target))
self.label['weight'].set_text(self.format_float(self.prov.weight, 2, suffix='kg'))
self.label['weight_net'].set_text(self.format_float(self.prov.weight_net, 2, suffix='kg'))
self.label['price'].set_text(self.format_float(self.prov.price, 2, suffix='€'))
self.label['remarks'].set_text(self.prov.remarks or '')
def edit_record(self):
pass
+6 -2
View File
@@ -105,6 +105,10 @@ 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()
@@ -136,9 +140,9 @@ class StatusView:
# Detect all tables in database
sql= ("SELECT table_name "
"FROM information_schema.tables "
"WHERE table_schema='yms' AND table_type='BASE TABLE' "
"WHERE table_schema=%s AND table_type='BASE TABLE' "
"ORDER BY table_name")
self.context.db.cur.execute(sql)
self.context.db.cur.execute(sql, (self.context.db.schema,))
tables = [row[0] for row in self.context.db.cur.fetchall()]
# Loop over tables and get current record count
records = []
+74 -27
View File
@@ -17,6 +17,8 @@ class StorageView(View):
self.storage = storage.Storage(context.db) # current record
self.newrecord = False
self.last_valid_rgb = "#3498DB"
self.lst_storage = Gtk.ListStore(int, str, str, str)
self.load_list()
@@ -27,28 +29,38 @@ class StorageView(View):
self.tree['storage'].set_model(self.lst_storage)
self.dd_stype = self.context.lookup.dropdown(Dropdown.STORAGE_TYPE)
combobox.load_from_dict(self.combo['type'], self.dd_stype)
combobox.load_from_dict(self.combo['type'], self.dd_stype, storage.GENERIC)
self.dd_unit = self.context.lookup.enum('storage.capaunit')
combobox.load_from_dict(self.combo['unit'], self.dd_unit)
combobox.load_from_dict(self.combo['unit'], {"-1": _("─── none ───")} | self.dd_unit)
def add_row(self):
pass
def refresh_row(self):
pass
treeview.set_value(self.tree['storage'], 1, self.storage.name)
position = f"({self.storage.x}, {self.storage.y}, {self.storage.z})"
treeview.set_value(self.tree['storage'], 2, position)
treeview.set_value(self.tree['storage'], 3, self.storage.remarks)
def load_list(self):
selected_id = treeview.get_value(self.tree['storage'])
self.lst_storage.clear()
sql = (
"SELECT sid, sname, CONCAT(x, ',', y, ',', z) AS position, remarks "
"SELECT sid, sname, CONCAT(x, ',', y, ',', z) AS position, "
" IF(CHAR_LENGTH(remarks)>40, CONCAT(LEFT(remarks, 40), '\u2026'), remarks) AS remarks "
"FROM storage "
"WHERE vid=%s "
"ORDER BY sname"
)
self.db.cur.execute(sql, (self.context.vessel.vid,))
selection = self.tree['storage'].get_selection()
for row in self.db.cur.fetchall():
self.lst_storage.append(row)
treeiter = self.lst_storage.append(row)
if row[0] == selected_id:
# restore previous selected row
selection.select_iter(treeiter)
def clear_record(self):
self.storage.clear()
@@ -61,8 +73,8 @@ class StorageView(View):
self.spin['wz'].set_value(0)
self.spin['angle'].set_value(0)
self.spin['capacity'].set_value(0)
combobox.activate_row(self.combo['type'], -1)
combobox.activate_row(self.combo['unit'], -1)
combobox.activate_row(self.combo['type'], storage.GENERIC)
combobox.activate_row(self.combo['unit'], "-1")
self.text['remarks'].get_buffer().set_text('')
def display_record(self):
@@ -79,6 +91,7 @@ class StorageView(View):
self.label['remarks'].set_text(self.storage.remarks or '')
def edit_record(self):
self.last_valid_rgb = self.storage.color
self.entry['sname'].set_text(self.storage.sname)
self.spin['x'].set_value(self.storage.x)
self.spin['y'].set_value(self.storage.y)
@@ -87,17 +100,38 @@ class StorageView(View):
self.spin['wy'].set_value(self.storage.wy)
self.spin['wz'].set_value(self.storage.wz)
self.spin['angle'].set_value(self.storage.angle)
self.spin['capacity'].set_value(self.storage.capacity)
self.spin['capacity'].set_value(self.storage.capacity or 0)
combobox.activate_row(self.combo['type'], self.storage.stype)
combobox.activate_row(self.combo['unit'], self.storage.capaunit)
# flags
combobox.activate_row(self.combo['unit'], self.storage.capaunit or -1)
self.entry['color'].set_text('#' + (self.storage.color or '000000'))
rgba = Gdk.RGBA()
rgba.parse('#' + (self.storage.color or '000000'))
self.button['color'].set_rgba(rgba)
self.text['remarks'].get_buffer().set_text(self.storage.remarks or '')
def save_record(self):
# fields must have been validated beforehand
self.storage.sname = self.entry['sname'].get_text()
self.storage.stype = combobox.get_list_value(self.combo['type'])
self.storage.x = self.spin['x'].get_value_as_int()
self.storage.y = self.spin['y'].get_value_as_int()
self.storage.z = self.spin['z'].get_value_as_int()
self.storage.wx = self.spin['wx'].get_value_as_int()
self.storage.wy = self.spin['wy'].get_value_as_int()
self.storage.wz = self.spin['wz'].get_value_as_int()
self.storage.angle = self.spin['angle'].get_value_as_int()
self.storage.capacity = self.spin['capacity'].get_value_as_int()
self.storage.capaunit = combobox.get_list_value(self.combo['unit'])
if self.storage.capaunit == '-1':
self.storage.capaunit = None
self.storage.color = self.entry['color'].get_text().lstrip('#')
self.storage.remarks = gtkutils.get_text_contents(self.text['remarks'])
# buttons on list page
def on_but_new_clicked(self, widget):
self.newrecord = True
self.label['title_edit'].set_text("Add new Storage")
self.clear_record()
self.label['title_edit'].set_text(_("Add new Storage"))
self.storage.vid = self.context.vessel.vid
self.topwidget.set_visible_child(self.box['stor_edit'])
@@ -106,7 +140,7 @@ class StorageView(View):
if sid is None:
return
self.newrecord = False
self.label['title_edit'].set_text("Edit Storage")
self.label['title_edit'].set_text(_("Edit Storage"))
self.storage.load(sid)
self.edit_record()
self.topwidget.set_visible_child(self.box['stor_edit'])
@@ -133,34 +167,47 @@ class StorageView(View):
self.topwidget.set_visible_child(self.box['storage'])
def on_but_delete_clicked(self, widget):
answer = gtkutils.questionbox(
_("Delete storage!\n"
"Are you sure?"), title="YMS"
)
if answer == False:
return
self.topwidget.set_visible_child(self.box['storage'])
self.newrecord = False
# buttons on edit page
def on_but_save_clicked(self, widget):
# check mandatory fields
sname = self.entry['sname'].get_text().strip()
if not sname:
if not self.entry['sname'].get_text().strip():
# TODO error marker
return
# get fields from ui form
self.storage.sname = sname
self.storage.stype = combobox.get_list_value(self.combo['type'])
self.storage.x = self.spin['x'].get_value()
self.storage.y = self.spin['y'].get_value()
self.storage.z = self.spin['z'].get_value()
self.storage.wx = self.spin['wx'].get_value()
self.storage.wy = self.spin['wy'].get_value()
self.storage.wz = self.spin['wz'].get_value()
self.storage.angle = self.spin['angle'].get_value()
self.storage.capacity = self.spin['capacity'].get_value()
self.storage.capaunit = combobox.get_list_value(self.combo['unit'])
self.storage.remarks = gtkutils.get_text_contents(self.text['remarks'])
self.save_record()
print(self.storage)
self.storage.save()
if self.newrecord:
self.load_list()
else:
pass
# TODO aktuelle Listenzeile aktualisieren!
self.newrecord = False
self.topwidget.set_visible_child(self.box['storage'])
self.display_record()
self.topwidget.set_visible_child(self.box['stor_detail'])
def on_but_color_set(self, button):
rgba = button.get_rgba()
r = round(rgba.red * 255)
g = round(rgba.green * 255)
b = round(rgba.blue * 255)
self.last_valid_rgb = f"{r:02X}{g:02X}{b:02X}"
self.entry['color'].set_text(f"#{r:02X}{g:02X}{b:02X}")
def on_ent_color_activate(self, entry):
self.set_color_from_entry(entry)
def on_ent_color_focus_out_event(self, entry, event):
self.set_color_from_entry(entry)
return False
def on_but_cancel_clicked(self, widget):
self.topwidget.set_visible_child(self.box['storage'])
+83 -10
View File
@@ -42,11 +42,81 @@ class TasksView(View):
treeview.add_column(self.tree['tasks'], _('Responsible'), 4)
self.tree['tasks'].set_model(self.lst_tasks)
# Project
self.dd_project = context.lookup.project(self.context.vessel.vid)
combobox.load_from_dict(self.combo['project'], {-1: _("─── none ───")} | self.dd_project)
# Priority
self.dd_priority = self.context.lookup.enum('task.priority')
combobox.load_from_dict(self.combo['priority'], self.dd_priority)
# Status
self.dd_state = self.context.lookup.enum('task.taskstate')
combobox.load_from_dict(self.combo['status'], self.dd_state)
# Responsible
self.dd_user = context.lookup.user()
combobox.load_from_dict(self.combo['responsible'], self.dd_user)
def clear_record(self):
self.task.clear()
self.entry['name'].set_text('')
combobox.activate_row(self.combo['project'], -1)
combobox.activate_row(self.combo['priority'], -1)
self.entry['plandate'].set_text('')
self.entry['duedate'].set_text('')
self.entry['started'].set_text('')
self.entry['finished'].set_text('')
combobox.activate_row(self.combo['status'], 'new')
combobox.activate_row(self.combo['responsible'], 0)
self.text['remarks'].get_buffer().set_text('')
def display_record(self):
self.label['name'].set_text(self.task.taskname)
self.label['responsible'].set_text('')
self.label['status'].set_text(self.task.taskstate)
self.label['remarks'].set_text(self.task.remarks or '')
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['priority'], self.task.priority)
self.entry['plandate'].set_text(self.task.plandate)
self.entry['duedate'].set_text(self.task.duedate)
self.entry['started'].set_text(self.task.started)
self.entry['finished'].set_text(self.task.finsihed)
combobox.activate_row(self.combo['taskstate'], self.task.taskstate)
combobox.activate_row(self.combo['responsible'], self.task.responsible)
self.text['remarks'].get_buffer().set_text(self.task.remarks or '')
def save_record(self):
# fields must have been validated beforehand
self.task.taskname = self.entry['name'].get_text()
self.task.projid = combobox.get_list_value(self.combo['project'])
self.task.priority = combobox.get_list_value(self.combo['project'])
self.task.plandate = self.entry['plandate'].get_text()
self.task.duedate = self.entry['duedate'].get_text()
self.task.started = self.entry['started'].get_text()
self.task.finished = self.entry['finished'].get_text()
self.task.taskstate = combobox.get_list_value(self.combo['taskstate'])
self.task.resposible = combobox.get_list_value(self.combo['responsible'])
self.project.remarks = gtkutils.get_text_contents(self.text['remarks'])
# buttons on list page
def on_but_new_clicked(self, widget):
self.newrecord = True
self.label['title_edit'].set_text(_("Add new Task"))
self.clear_record()
self.topwidget.set_visible_child(self.box['task_edit'])
def on_but_edit_clicked(self, widget):
self.newrecord = False
self.label['title_edit'].set_text(_("Edit Task"))
taskid = treeview.get_value(self.tree['tasks'], 0)
if not taskid:
return
self.task.load(taskid)
self.edit_record()
self.topwidget.set_visible_child(self.box['task_edit'])
def on_but_detail_clicked(self, widget):
@@ -70,20 +140,23 @@ class TasksView(View):
self.topwidget.set_visible_child(self.box['tasks'])
def on_but_delete_clicked(self, widget):
answer = gtkutils.questionbox(
_("Delete task!\n"
"Are you sure?"), title="YMS"
)
if answer == False:
return
self.topwidget.set_visible_child(self.box['tasks'])
# buttons on edit page
def on_but_save_clicked(self, widget):
pass
# check mandatory fields
if not self.entry['taskname'].get_text().strip():
# TODO error marker
return
self.save_record()
print(self.task)
self.task.save()
def on_but_cancel_clicked(self, widget):
self.topwidget.set_visible_child(self.box['tasks'])
def display_record(self):
self.label['name'].set_text(self.task.taskname)
self.label['responsible'].set_text('')
self.label['status'].set_text(self.task.taskstate)
self.label['remarks'].set_text(self.task.remarks or '')
def edit_record(self):
pass
+105 -7
View File
@@ -2,12 +2,14 @@
"""
Generic view object
- with own glade ui file
SPDX-License-Identifier: WTFPL
"""
import os
import locale
from gi.repository import GLib, Gtk, Gdk
from datetime import date, datetime
from yms import gtkutils
class View:
@@ -18,12 +20,31 @@ class View:
self.vessel = context.vessel
self.user = context.user
self._title = title
builder = Gtk.Builder()
builder.set_translation_domain(context.textdomain)
builder.add_from_file(os.path.join(context.ui_path, ui_file))
builder.connect_signals(self)
self.topwidget = builder.get_object("topobject")
gtkutils.init_named_controls(self, builder)
locale.bindtextdomain(context.textdomain, context.localedir)
locale.textdomain(context.textdomain)
self.builder = Gtk.Builder()
self.builder.set_translation_domain(context.textdomain)
self.builder.add_from_file(os.path.join(context.ui_path, ui_file))
self.builder.connect_signals(self)
self.topwidget = self.builder.get_object("topobject")
gtkutils.init_named_controls(self, self.builder)
css = Gtk.CssProvider()
css.load_from_data(b"""
.invalid {
color: #cc0000;
background-color: #ffdddd;
}
""")
Gtk.StyleContext.add_provider_for_screen(
Gdk.Screen.get_default(),
css,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION
)
def format_int(self, ival, separator=True, suffix=None, default=''):
if ival is None:
@@ -104,3 +125,80 @@ class View:
buf.delete(sel_start, sel_end)
buf.insert_at_cursor(text)
return True
def set_entry_valid(self, entry, valid):
context = entry.get_style_context()
if valid:
context.remove_class("invalid")
else:
context.add_class("invalid")
def set_color_from_entry(self, entry):
text = entry.get_text().strip()
rgba = Gdk.RGBA()
if len(text) == 7 and rgba.parse(text):
self.last_valid_rgb = text.lstrip('#')
self.entry['color'].set_text(text)
self.button['color'].set_rgba(rgba)
self.set_entry_valid(self.entry['color'], True)
else:
self.set_entry_valid(self.entry['color'], False)
class DatePicker:
def __init__(self, entry, button, datefmt='"%d.%m.%Y"'):
self.entry = entry
self.button = button
self.datefmt = datefmt
self.popover = Gtk.Popover.new(self.button)
self.popover.set_position(Gtk.PositionType.BOTTOM)
content = Gtk.Box(orientation=Gtk.Orientation.VERTICAL, spacing=8)
content.set_border_width(10)
self.calendar = Gtk.Calendar()
self.calendar.set_display_options(
Gtk.CalendarDisplayOptions.SHOW_HEADING
| Gtk.CalendarDisplayOptions.SHOW_DAY_NAMES
| Gtk.CalendarDisplayOptions.SHOW_WEEK_NUMBERS
)
content.pack_start(self.calendar, True, True, 0)
buttons = Gtk.Box(orientation=Gtk.Orientation.HORIZONTAL, spacing=6)
buttons.set_halign(Gtk.Align.END)
self.but_cancel = Gtk.Button(label="Abbrechen")
self.but_apply = Gtk.Button(label="Übernehmen")
buttons.pack_start(self.but_cancel, False, False, 0)
buttons.pack_start(self.but_apply, False, False, 0)
content.pack_start(buttons, False, False, 0)
self.popover.add(content)
self.button.connect("clicked", self._on_open)
self.but_apply.connect("clicked", self._on_apply)
self.but_cancel.connect("clicked", self._on_cancel)
self.popover.show_all()
self.popover.hide()
def get_date(self):
"""Liefert datetime.date oder None bei ungültiger Eingabe."""
try:
return datetime.strptime(self.entry.get_text().strip(), self.datefmt).date()
except ValueError:
return None
def set_date(self, value):
"""Setzt das Datum mit einem datetime.date-Objekt."""
if isinstance(value, date):
self.entry.set_text(value.strftime(self.datefmt))
def _on_open(self, button):
selected = self.get_date() or date.today()
self.calendar.select_month(
selected.month - 1,
selected.year
)
self.calendar.select_day(selected.day)
self.popover.show_all()
def _on_apply(self, button):
year, month, day = self.calendar.get_date()
self.set_date(date(year, month + 1, day))
self.popover.popdown()
def _on_cancel(self, button):
self.popover.popdown()
+56 -19
View File
@@ -37,7 +37,7 @@ from yms import database
from yms import gtkutils, combobox, treeview
from yms.model import user
from yms.model import vessel
from yms.lookup import Lookup
from yms.lookup import Lookup, Table
from yms.view.base import BaseView
from yms.view.storage import StorageView
@@ -90,7 +90,8 @@ class AppContext:
self.user = None
self.vessel = None
self.ui_path = os.path.join(self.get_sharepath(), "yms", "ui")
self.textdomain = "ymsgui"
self.textdomain = "ymsgui" # static here for early initialization
self.localedir = "locale"
self.datefmt = '%d.%m.%Y'
# system settings stored in database
self.curr_sym = '€'
@@ -131,7 +132,17 @@ class AppContext:
class Frontend:
def __init__(self, context):
self.initializing = True
self.context = context
self.db = context.db
builder = Gtk.Builder()
builder.set_translation_domain(context.textdomain)
ui_path = os.path.join(context.ui_path)
builder.add_from_file(os.path.join(ui_path, "main.ui"))
builder.connect_signals(self)
self.window = builder.get_object("wnd_main")
self.notebook = builder.get_object("ntb_modules")
self.modules = {
"base": BaseView(context),
"storage": StorageView(context),
@@ -149,34 +160,61 @@ class Frontend:
"documents": DocumentsView(context),
"status": StatusView(context)
}
builder = Gtk.Builder()
builder.set_translation_domain(context.textdomain)
ui_path = os.path.join(context.ui_path)
builder.add_from_file(os.path.join(ui_path, "main.ui"))
builder.connect_signals(self)
self.window = builder.get_object("wnd_main")
self.notebook = builder.get_object("ntb_modules")
self.moduleindex = {}
for module in self.modules.values():
self.notebook.append_page(module.topwidget, Gtk.Label(label=module._title))
pageno = self.notebook.append_page(module.topwidget, Gtk.Label(label=module._title))
self.moduleindex[pageno] = module
self.db_poll_ts = context.db.get_timestamp()
GLib.timeout_add_seconds(30, self.db_change_poller)
self.initializing = False
def run(self):
#self.label['vessel'].set_text(self._vessel.vesselname)
self.window.show_all()
Gtk.main()
def db_change_poller(self):
# get all list ids which changes since last query
print("db list change poller")
#sql = "SELECT revid FROM revision WHERE changed>%s"
# dynamic combobox data refresh
# look for dropdown entries newer than last check
sql = "SELECT revid FROM revision WHERE revtype='dropdown' AND changed>%s"
self.db.cur.execute(sql, (self.db_poll_ts,))
for row in self.db.cur.fetchall():
print(f"refresh dropdown list no.{row[0]}")
self.lookup.reload_dropdown(row[0])
# look for table list entries newer than last check
sql = "SELECT revid FROM revision WHERE revtype='table' AND changed>%s"
self.db.cur.execute(sql, (self.db_poll_ts,))
for row in self.db.cur.fetchall():
print(f"refresh table based list #{row[0]}")
# TODO get module name für changes in table
modulemap = {
#Table.VESSEL: "base",
#Table.USERS: "base",
Table.COMPANIES: "companies",
Table.STORAGE: "storage",
Table.BOXES: "box",
Table.EQUIPMENT: "equipment",
##Table.INVENTORY: "inventory"
Table.PROJECTS: "projects",
Table.CABLES: "cables",
Table.FUSES: "fuses",
Table.TAGS: "tags"
}
# execute method from module
self.modules[modulemap[row[0]]].load_list()
self.db_poll_ts = self.db.get_timestamp()
return True
def on_ntb_modules_switch_page(self, notebook, page, page_num):
print("Neue Seite:", page_num)
# TODO here re-load lists
# signal handler: call view method for e.g. list refresh
if self.initializing:
return
callback = getattr(self.moduleindex[page_num], "on_page_activated", None)
if callable(callback):
callback()
def on_destroy(self, widget, data=None):
Gtk.main_quit()
@@ -199,11 +237,10 @@ def create_config(cfg, cfgfile):
if __name__ == "__main__":
context = AppContext()
locale.setlocale(locale.LC_ALL, '')
gettext.bindtextdomain(context.textdomain, 'locale')
gettext.bindtextdomain(context.textdomain, context.localedir)
gettext.textdomain(context.textdomain)
gettext.install(context.textdomain, 'locale')
gettext.install(context.textdomain, context.localedir)
config = configparser.ConfigParser()
cfgfile = os.path.expanduser(context.cfg['cfgfile'])