debug-viewer: Added filter for function

https://bugzilla.gnome.org/show_bug.cgi?id=793241
This commit is contained in:
Xabier Rodriguez Calvar 2018-02-07 09:52:26 +01:00 committed by Nicolas Dufresne
parent d8f7969e41
commit 8c93cc156f
3 changed files with 34 additions and 0 deletions

View file

@ -77,6 +77,18 @@ class ObjectFilter (Filter):
self.filter_func = object_filter_func self.filter_func = object_filter_func
class FunctionFilter (Filter):
def __init__(self, function_, all_but_this=False):
col_id = LogModelBase.COL_FUNCTION
comparison_function = get_comparison_function(all_but_this)
def function_filter_func(row):
return comparison_function(row[col_id], function_)
self.filter_func = function_filter_func
class FilenameFilter (Filter): class FilenameFilter (Filter):
def __init__(self, filename, all_but_this=False): def __init__(self, filename, all_but_this=False):

View file

@ -39,6 +39,7 @@ from GstDebugViewer.GUI.columns import LineViewColumnManager, ViewColumnManager
from GstDebugViewer.GUI.filters import (CategoryFilter, from GstDebugViewer.GUI.filters import (CategoryFilter,
DebugLevelFilter, DebugLevelFilter,
FilenameFilter, FilenameFilter,
FunctionFilter,
ObjectFilter) ObjectFilter)
from GstDebugViewer.GUI.models import (FilteredLogModel, from GstDebugViewer.GUI.models import (FilteredLogModel,
LazyLogModel, LazyLogModel,
@ -291,6 +292,9 @@ class Window (object):
("hide-log-object", None, _("Hide object")), ("hide-log-object", None, _("Hide object")),
("show-only-log-object", None, _( ("show-only-log-object", None, _(
"Show only object")), "Show only object")),
("hide-log-function", None, _("Hide function")),
("show-only-log-function", None, _(
"Show only function")),
("hide-filename", None, _("Hide filename")), ("hide-filename", None, _("Hide filename")),
("show-only-filename", None, _("Show only filename"))]) ("show-only-filename", None, _("Show only filename"))])
group.props.sensitive = False group.props.sensitive = False
@ -827,6 +831,13 @@ class Window (object):
object_ = row[LogModelBase.COL_OBJECT] object_ = row[LogModelBase.COL_OBJECT]
self.add_model_filter(ObjectFilter(object_)) self.add_model_filter(ObjectFilter(object_))
@action
def handle_hide_log_function_action_activate(self, action):
row = self.get_active_line()
object_ = row[LogModelBase.COL_FUNCTION]
self.add_model_filter(FunctionFilter(object_))
@action @action
def handle_hide_filename_action_activate(self, action): def handle_hide_filename_action_activate(self, action):
@ -864,6 +875,13 @@ class Window (object):
object_ = row[LogModelBase.COL_OBJECT] object_ = row[LogModelBase.COL_OBJECT]
self.add_model_filter(ObjectFilter(object_, True)) self.add_model_filter(ObjectFilter(object_, True))
@action
def handle_show_only_log_function_action_activate(self, action):
row = self.get_active_line()
object_ = row[LogModelBase.COL_FUNCTION]
self.add_model_filter(FunctionFilter(object_, True))
@action @action
def handle_show_only_filename_action_activate(self, action): def handle_show_only_filename_action_activate(self, action):

View file

@ -31,6 +31,8 @@
<menuitem name="ViewContextMenuShowOnlyCategory" action="show-only-log-category"/> <menuitem name="ViewContextMenuShowOnlyCategory" action="show-only-log-category"/>
<menuitem name="ViewContextMenuHideObject" action="hide-log-object"/> <menuitem name="ViewContextMenuHideObject" action="hide-log-object"/>
<menuitem name="ViewContextMenuShowOnlyObject" action="show-only-log-object"/> <menuitem name="ViewContextMenuShowOnlyObject" action="show-only-log-object"/>
<menuitem name="ViewContextMenuHideFunction" action="hide-log-function"/>
<menuitem name="ViewContextMenuShowOnlyFunction" action="show-only-log-function"/>
<menuitem name="ViewContextMenuHideFilename" action="hide-filename"/> <menuitem name="ViewContextMenuHideFilename" action="hide-filename"/>
<menuitem name="ViewContextMenuShowOnlyFilename" action="show-only-filename"/> <menuitem name="ViewContextMenuShowOnlyFilename" action="show-only-filename"/>
<menuitem name="ViewContextMenuHideBefore" action="hide-before-line"/> <menuitem name="ViewContextMenuHideBefore" action="hide-before-line"/>
@ -57,6 +59,8 @@
<menuitem name="ViewContextMenuShowOnlyCategory" action="show-only-log-category"/> <menuitem name="ViewContextMenuShowOnlyCategory" action="show-only-log-category"/>
<menuitem name="ViewContextMenuHideObject" action="hide-log-object"/> <menuitem name="ViewContextMenuHideObject" action="hide-log-object"/>
<menuitem name="ViewContextMenuShowOnlyObject" action="show-only-log-object"/> <menuitem name="ViewContextMenuShowOnlyObject" action="show-only-log-object"/>
<menuitem name="ViewContextMenuHideFunction" action="hide-log-function"/>
<menuitem name="ViewContextMenuShowOnlyFunction" action="show-only-log-function"/>
<menuitem name="ViewContextMenuHideFilename" action="hide-filename"/> <menuitem name="ViewContextMenuHideFilename" action="hide-filename"/>
<menuitem name="ViewContextMenuShowOnlyFilename" action="show-only-filename"/> <menuitem name="ViewContextMenuShowOnlyFilename" action="show-only-filename"/>
<menuitem name="ViewContextMenuHideBefore" action="hide-before-line"/> <menuitem name="ViewContextMenuHideBefore" action="hide-before-line"/>