Work on native gui base features

This commit is contained in:
2026-09-09 15:56:34 +02:00
parent 25505757a6
commit 82dea5800d
11 changed files with 116 additions and 12 deletions
+3 -2
View File
@@ -5,6 +5,7 @@
<object class="GtkStack" id="topobject">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">8</property>
<child>
<object class="GtkNotebook" id="ntb_basedata">
<property name="visible">True</property>
@@ -309,7 +310,7 @@
</packing>
</child>
<child>
<object class="GtkComboBox" id="smb_shipyard">
<object class="GtkComboBox" id="cmb_shipyard">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
@@ -726,7 +727,7 @@
<property name="can-focus">True</property>
<property name="shadow-type">in</property>
<child>
<object class="GtkTreeView">
<object class="GtkTreeView" id="tvw_ddlists">
<property name="visible">True</property>
<property name="can-focus">True</property>
<child internal-child="selection">
+1
View File
@@ -5,6 +5,7 @@
<object class="GtkStack" id="topobject">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">8</property>
<child>
<object class="GtkBox" id="box_documents">
<property name="visible">True</property>
+1
View File
@@ -5,6 +5,7 @@
<object class="GtkStack" id="stk_equipment">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">8</property>
<child>
<object class="GtkBox" id="box_equipment">
<property name="visible">True</property>
+1
View File
@@ -5,6 +5,7 @@
<object class="GtkStack" id="topobject">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">8</property>
<child>
<object class="GtkBox" id="box_inventory">
<property name="visible">True</property>
+1
View File
@@ -8,6 +8,7 @@
<property name="window-position">center</property>
<property name="default-width">800</property>
<property name="default-height">600</property>
<property name="icon">../../icons/yms.svg</property>
<signal name="destroy" handler="on_destroy" swapped="no"/>
<child>
<object class="GtkNotebook" id="ntb_modules">
+1
View File
@@ -5,6 +5,7 @@
<object class="GtkStack" id="topobject">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">8</property>
<child>
<object class="GtkBox" id="box_maintenance">
<property name="visible">True</property>
+1
View File
@@ -5,6 +5,7 @@
<object class="GtkStack" id="topobject">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">8</property>
<child>
<object class="GtkBox" id="box_projects">
<property name="visible">True</property>
+1
View File
@@ -5,6 +5,7 @@
<object class="GtkStack" id="topobject">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">8</property>
<child>
<object class="GtkBox" id="box_provisions">
<property name="visible">True</property>
+54 -2
View File
@@ -5,6 +5,7 @@
<object class="GtkBox" id="topobject">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="margin-start">8</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="lbl_title">
@@ -33,7 +34,7 @@
</packing>
</child>
<child>
<object class="GtkNotebook">
<object class="GtkNotebook" id="ntb_status">
<property name="visible">True</property>
<property name="can-focus">True</property>
<child>
@@ -100,9 +101,60 @@ thread in "Segeln Forum"
<property name="tab-fill">False</property>
</packing>
</child>
<child>
<object class="GtkBox" id="box_config">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="lbl_config">
<property name="visible">True</property>
<property name="can-focus">False</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</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_config">
<property name="visible">True</property>
<property name="can-focus">True</property>
<property name="editable">False</property>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="position">2</property>
</packing>
</child>
<child type="tab">
<object class="GtkLabel">
<property name="visible">True</property>
<property name="can-focus">False</property>
<property name="label" translatable="yes">Config</property>
</object>
<packing>
<property name="position">2</property>
<property name="tab-fill">False</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">2</property>
</packing>
+40 -8
View File
@@ -48,25 +48,46 @@ class BaseView(View):
# prepare lists
self.lst_user = Gtk.ListStore(int, str)
self.db.cur.execute("SELECT userid, login FROM user WHERE userid > 0 ORDER BY login")
self.db.cur.execute("SELECT userid, login FROM user WHERE userid>0 ORDER BY login")
for row in self.db.cur.fetchall():
print(row)
self.lst_user.append(row)
treeview.add_column(self.tree['user'], 'ID', 0)
treeview.add_column(self.tree['user'], 'Login', 1)
self.tree['user'].set_model(self.lst_user)
# companies
"""
self.lst_companies = Gtk.ListStore(int, str, str, str)
self.db.cur.execute("SELECT compid, compname, comptype FROM company ORDER BY compname")
# list of dropdown lists
self.lst_lists = Gtk.ListStore(int, str, int)
# self.db.cur.execute("SELECT ddval, ddtext FROM dropdown WHERE ddid=0 AND ddval>0 ORDER BY ddval")
sql = (
"SELECT dd.ddval, dd.ddtext, COUNT(n.ddval) AS records "
"FROM dropdown AS dd LEFT JOIN dropdown AS n ON dd.ddval=n.ddid "
"WHERE dd.ddid=0 "
"GROUP BY dd.ddval, dd.ddtext "
"ORDER BY dd.ddval"
)
self.db.cur.execute(sql)
for row in self.db.cur.fetchall():
self.lst_user.append(row)
self.lst_lists.append(row)
treeview.add_column(self.tree['ddlists'], _('ID'), 0)
treeview.add_column(self.tree['ddlists'], _('List'), 1)
treeview.add_column(self.tree['ddlists'], _('Records'), 2)
self.tree['ddlists'].set_model(self.lst_lists)
# 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'], {-1: _("─── all ───")} | self.comptype, -1)
# 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]))
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)
"""
# combos
roles = {'captain': 'Captain', 'helmsman': 'Helmsman', 'sailor': 'Sailor'}
@@ -74,6 +95,17 @@ class BaseView(View):
langs = {'de': 'Deutsch', 'en': 'English'}
combobox.load_from_dict(self.combo['user_lang'], langs)
# shipyard
self.db.cur.execute("SELECT compid, compname FROM company WHERE comptype=3 ORDER BY compname")
shipyards = dict(self.db.cur.fetchall())
combobox.load_from_dict(self.combo['shipyard'], shipyards)
# default storage
self.lst_storage_dfl = Gtk.ListStore(int, str)
self.db.cur.execute("SELECT sid, sname FROM storage WHERE stype=0 ORDER BY sname")
storages = dict(self.db.cur.fetchall())
combobox.load_from_dict(self.combo['storage'], storages)
# load shape of vessel if available
if self.context.vessel.vid > 0:
self.db.cur.execute("SELECT shapefile FROM vessel WHERE vid=%s", (self.context.vessel.vid, ))
+12
View File
@@ -4,6 +4,7 @@ import os
import gi
gi.require_version("Gtk", "3.0")
from gi.repository import Gtk
import re
from yms import gtkutils, combobox, treeview
@@ -27,6 +28,17 @@ class StatusView:
treeview.add_column(self.tree['tables'], '# Records', 1)
self.tree['tables'].set_model(self.lst_tables)
# Load current config file
self.label['config'].set_label(context.cfg['cfgfile'])
cfgfile = os.path.expanduser(context.cfg['cfgfile'])
try:
with open(cfgfile, "r", encoding="utf-8") as f:
contents = f.read()
except OSError as e:
contents = f"Could not read file: {e}"
contents = re.sub(r'(^\s*pass\s*=\s*).*$', r'\1********', contents, flags=re.MULTILINE)
self.text ['config'].get_buffer().set_text(contents)
def get_table_counts(self):
# Detect all tables in database
sql= ("SELECT table_name "