Display timestamp and full message of selected line

This commit is contained in:
René Stadler 2007-11-28 15:32:06 +02:00 committed by Stefan Sauer
parent 635659a6b9
commit 47dc733bc6
2 changed files with 186 additions and 16 deletions

View file

@ -493,6 +493,8 @@ class TextColumn (SizedColumn):
cell = gtk.CellRendererText ()
column.pack_start (cell)
cell.props.yalign = 0.
if self.font_family:
cell.props.family = self.font_family
cell.props.family_set = True
@ -996,6 +998,131 @@ class ViewColumnManager (ColumnManager):
for column in self.iter_items ():
self.size_column (column, view, model)
class LineViewLogModel (FilteredLogModel):
def __init__ (self, lazy_log_model):
FilteredLogModel.__init__ (self, lazy_log_model)
self.line_offsets = []
self.line_levels = []
def insert_line (self, position, parent_line_index):
if position == -1:
position = len (self.line_offsets)
li = parent_line_index
self.line_offsets.insert (position, self.parent_model.line_offsets[li])
self.line_levels.insert (position, self.parent_model.line_levels[li])
path = (position,)
tree_iter = self.get_iter (path)
self.row_inserted (path, tree_iter)
def replace_line (self, line_index, parent_line_index):
li = line_index
self.line_offsets[li] = self.parent_model.line_offsets[parent_line_index]
self.line_levels[li] = self.parent_model.line_levels[parent_line_index]
path = (line_index,)
tree_iter = self.get_iter (path)
self.row_changed (path, tree_iter)
class WrappingMessageColumn (MessageColumn):
def wrap_to_width (self, width):
col = self.view_column
col.props.max_width = width
col.get_cells ()[0].props.wrap_width = width
col.queue_resize ()
class LineViewColumnManager (ColumnManager):
column_classes = (TimeColumn, WrappingMessageColumn,)
def __init__ (self):
ColumnManager.__init__ (self)
def attach (self, window):
self.__size_update = None
self.view = window.widgets.line_view
self.view.set_size_request (0, 0)
self.view.connect_after ("size-allocate", self.__handle_size_allocate)
ColumnManager.attach (self)
def __update_sizes (self):
view_width = self.view.get_allocation ().width
if view_width == self.__size_update:
# Prevent endless recursion.
return
self.__size_update = view_width
col = self.find_item (name = "time")
other_width = col.view_column.props.width
try:
col = self.find_item (name = "message")
except KeyError:
return
width = view_width - other_width
col.wrap_to_width (width)
def __handle_size_allocate (self, self_, allocation):
self.__update_sizes ()
class LineView (object):
def __init__ (self):
self.column_manager = LineViewColumnManager ()
def attach (self, window):
self.line_view = window.widgets.line_view
log_view = window.log_view
log_view.connect ("notify::model", self.handle_log_view_notify_model)
sel = log_view.get_selection ()
sel.connect ("changed", self.handle_log_view_selection_changed)
self.column_manager.attach (window)
def handle_log_view_notify_model (self, view, gparam):
log_model = view.props.model
if log_model is None:
return
line_model = LineViewLogModel (log_model)
self.line_view.props.model = line_model
def handle_log_view_selection_changed (self, selection):
model, tree_iter = selection.get_selected ()
if tree_iter is None:
return
path = model.get_path (tree_iter)
line_index = model.parent_line_index (path[0])
line_model = self.line_view.props.model
if len (line_model) == 0:
line_model.insert_line (0, line_index)
else:
line_model.replace_line (0, line_index)
class Window (object):
def __init__ (self, app):
@ -1069,6 +1196,8 @@ class Window (object):
self.log_view.connect ("button-press-event", self.handle_log_view_button_press_event)
self.line_view = LineView ()
self.attach ()
self.column_manager.attach (self.log_view)
@ -1115,6 +1244,8 @@ class Window (object):
sel = self.log_view.get_selection ()
sel.set_mode (gtk.SELECTION_BROWSE)
self.line_view.attach (self)
def detach (self):
self.set_log_file (None)
@ -1397,8 +1528,7 @@ class Window (object):
self.progress_bar = None
self.log_model.set_log (self.log_file)
self.log_filter.reset ()
self.log_filter = FilteredLogModel (self.log_model)
self.actions.reload_file.props.sensitive = True
self.actions.groups["RowActions"].props.sensitive = True

View file

@ -30,13 +30,18 @@
<property name="spacing">0</property>
<child>
<widget class="GtkHBox" id="hbox_view">
<widget class="GtkVBox" id="vbox_view">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
<child>
<widget class="GtkVBox" id="vbox_view">
<widget class="GtkVPaned" id="vpaned_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
<child>
<widget class="GtkHBox" id="hbox_view">
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
@ -57,8 +62,8 @@
<property name="headers_visible">True</property>
<property name="rules_hint">True</property>
<property name="reorderable">True</property>
<property name="enable_search">True</property>
<property name="fixed_height_mode">False</property>
<property name="enable_search">False</property>
<property name="fixed_height_mode">True</property>
<property name="hover_selection">False</property>
<property name="hover_expand">False</property>
</widget>
@ -68,6 +73,42 @@
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
</widget>
<packing>
<property name="shrink">True</property>
<property name="resize">True</property>
</packing>
</child>
<child>
<widget class="GtkScrolledWindow" id="line_view_scrolled_window">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_NEVER</property>
<property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property>
<property name="shadow_type">GTK_SHADOW_IN</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTreeView" id="line_view">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">False</property>
<property name="rules_hint">True</property>
<property name="reorderable">False</property>
<property name="enable_search">False</property>
<property name="fixed_height_mode">False</property>
<property name="hover_selection">False</property>
<property name="hover_expand">False</property>
</widget>
</child>
</widget>
<packing>
<property name="shrink">True</property>
<property name="resize">False</property>
</packing>
</child>
</widget>
@ -75,7 +116,6 @@
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="pack_type">GTK_PACK_END</property>
</packing>
</child>
</widget>