Native gui make almost every data editable
This commit is contained in:
1 parent
b8ac8d0185
commit
1a6674c819
48 files changed
+2168
-737
No files matched your search
+27
-3
@@ -30,6 +30,10 @@ class View:
|
||||
self.builder.connect_signals(self)
|
||||
|
||||
self.topwidget = self.builder.get_object("topobject")
|
||||
self.infobar = self.builder.get_object("infobar")
|
||||
if self.infobar:
|
||||
self.infobar.set_revealed(False)
|
||||
|
||||
gtkutils.init_named_controls(self, self.builder)
|
||||
|
||||
def format_int(self, ival, separator=True, suffix=None, default=''):
|
||||
@@ -51,7 +55,23 @@ class View:
|
||||
def format_date(self, dval, default=''):
|
||||
if dval is None:
|
||||
return default
|
||||
return dval.strftime(self.context.datefmt)
|
||||
return dval.strftime(self.context.get_datefmt())
|
||||
|
||||
def format_datetime(self, dtval, default=''):
|
||||
# we do not use seconds!
|
||||
if dtval is None:
|
||||
return default
|
||||
return dtval.strftime(self.context.get_datefmt() + ' %H:%M')
|
||||
|
||||
def format_color(self, color, default=''):
|
||||
# alpha only for "no color"
|
||||
if not color or color.alpha == 0:
|
||||
return default
|
||||
else:
|
||||
r = round(color.red * 255)
|
||||
g = round(color.green * 255)
|
||||
b = round(color.blue * 255)
|
||||
return f"#{r:02X}{g:02X}{b:02X}"
|
||||
|
||||
def on_textview_keypress(self, widget, event):
|
||||
# Generic limit length function
|
||||
@@ -120,14 +140,18 @@ class View:
|
||||
context.add_class("invalid")
|
||||
|
||||
def set_color_from_entry(self, entry, colorbutton):
|
||||
# TODO this was a fast hack!
|
||||
text = entry.get_text().strip()
|
||||
if len(text) == 6:
|
||||
text = '#' + text
|
||||
rgba = Gdk.RGBA()
|
||||
if len(text) == 7 and rgba.parse(text):
|
||||
self.last_valid_rgb = text.lstrip('#')
|
||||
self.entry.set_text(text)
|
||||
entry.set_text(text.upper())
|
||||
colorbutton.set_rgba(rgba)
|
||||
self.set_entry_valid(entry, True)
|
||||
elif len(text) == 0:
|
||||
# set color to "no color" means: black with alpha=0
|
||||
colorbutton.set_rgba(Gdk.RGBA(0, 0, 0, 0))
|
||||
else:
|
||||
self.set_entry_valid(entry, False)
|
||||
|
||||
|
||||
Reference in new issue
Block a user