mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-18 22:36:33 +00:00
Add new base time feature
The log view context menu gains a new action "Set base time", which changes the time column to show the delta to the selected row.
This commit is contained in:
parent
d71d09759b
commit
097cacebbd
4 changed files with 60 additions and 14 deletions
|
@ -35,6 +35,20 @@ def time_args (ts):
|
|||
secs % 60,
|
||||
ts % SECOND,)
|
||||
|
||||
def time_diff_args (time_diff):
|
||||
|
||||
if time_diff >= 0:
|
||||
sign = "+"
|
||||
else:
|
||||
sign = "-"
|
||||
|
||||
secs = abs (time_diff) // SECOND
|
||||
|
||||
return "%s%02i:%02i.%09i" % (sign,
|
||||
secs // 60,
|
||||
secs % 60,
|
||||
abs (time_diff) % SECOND,)
|
||||
|
||||
def time_args_no_hours (ts):
|
||||
|
||||
secs = ts // SECOND
|
||||
|
|
|
@ -96,14 +96,18 @@ class TextColumn (SizedColumn):
|
|||
elif not self.get_modify_func:
|
||||
column.add_attribute (cell, "text", self.id)
|
||||
else:
|
||||
self.update_modify_func (column, cell)
|
||||
|
||||
column.props.resizable = True
|
||||
|
||||
def update_modify_func (self, column, cell):
|
||||
|
||||
modify_func = self.get_modify_func ()
|
||||
id_ = self.id
|
||||
def cell_data_func (column, cell, model, tree_iter):
|
||||
cell.props.text = modify_func (model.get (tree_iter, id_)[0])
|
||||
column.set_cell_data_func (cell, cell_data_func)
|
||||
|
||||
column.props.resizable = True
|
||||
|
||||
def compute_default_size (self, view, model):
|
||||
|
||||
values = self.get_values_for_size ()
|
||||
|
@ -137,9 +141,21 @@ class TimeColumn (TextColumn):
|
|||
id = LazyLogModel.COL_TIME
|
||||
font_family = "monospace"
|
||||
|
||||
@staticmethod
|
||||
def get_modify_func ():
|
||||
def __init__ (self, *a, **kw):
|
||||
|
||||
self.base_time = 0
|
||||
|
||||
TextColumn.__init__ (self, *a, **kw)
|
||||
|
||||
def get_modify_func (self):
|
||||
|
||||
if self.base_time:
|
||||
time_diff_args = Data.time_diff_args
|
||||
base_time = self.base_time
|
||||
def format_time (value):
|
||||
# TODO: Hard coded to omit trailing zeroes, see below.
|
||||
return time_diff_args (value - base_time)[:-3]
|
||||
else:
|
||||
time_args = Data.time_args
|
||||
def format_time (value):
|
||||
# TODO: This is hard coded to omit hours as well as the last 3
|
||||
|
@ -155,6 +171,14 @@ class TimeColumn (TextColumn):
|
|||
|
||||
return values
|
||||
|
||||
def set_base_time (self, base_time):
|
||||
|
||||
self.base_time = base_time
|
||||
|
||||
column = self.view_column
|
||||
cell = column.get_cell_renderers ()[0]
|
||||
self.update_modify_func (column, cell)
|
||||
|
||||
class LevelColumn (TextColumn):
|
||||
|
||||
name = "level"
|
||||
|
|
|
@ -225,6 +225,7 @@ class Window (object):
|
|||
("show-hidden-lines", None, _("Show hidden lines")),
|
||||
("edit-copy-line", gtk.STOCK_COPY, _("Copy line"), "<Ctrl>C"),
|
||||
("edit-copy-message", gtk.STOCK_COPY, _("Copy message"), ""),
|
||||
("set-base-time", None, _("Set base time")),
|
||||
("hide-log-level", None, _("Hide log level")),
|
||||
("hide-log-category", None, _("Hide log category")),
|
||||
("hide-log-object", None, _("Hide object")),
|
||||
|
@ -292,7 +293,7 @@ class Window (object):
|
|||
for action_name in ("new-window", "open-file", "reload-file",
|
||||
"close-window", "cancel-load",
|
||||
"hide-before-line", "hide-after-line", "show-hidden-lines",
|
||||
"edit-copy-line", "edit-copy-message",
|
||||
"edit-copy-line", "edit-copy-message", "set-base-time",
|
||||
"hide-log-level", "hide-log-category", "hide-log-object",
|
||||
"hide-filename", "show-about",):
|
||||
name = action_name.replace ("-", "_")
|
||||
|
@ -627,6 +628,12 @@ class Window (object):
|
|||
|
||||
self.actions.show_hidden_lines.props.sensitive = True
|
||||
|
||||
def handle_set_base_time_action_activate (self, action):
|
||||
|
||||
row = self.get_active_line ()
|
||||
time_column = self.column_manager.find_item (name = "time")
|
||||
time_column.set_base_time (row[LogModelBase.COL_TIME])
|
||||
|
||||
def handle_hide_log_level_action_activate (self, action):
|
||||
|
||||
row = self.get_active_line ()
|
||||
|
|
|
@ -55,6 +55,7 @@
|
|||
</menu>
|
||||
<placeholder name="LogViewContextMenuAdditions"/>
|
||||
<separator/>
|
||||
<menuitem name="ViewContextMenuSetBaseTime" action="set-base-time"/>
|
||||
<menuitem name="ViewContextMenuHideLevel" action="hide-log-level"/>
|
||||
<menuitem name="ViewContextMenuHideCategory" action="hide-log-category"/>
|
||||
<menuitem name="ViewContextMenuHideObject" action="hide-log-object"/>
|
||||
|
|
Loading…
Reference in a new issue