Refactor and fix zoom handling

ColumnManager has to apply the zoom factor to newly added columns. Otherwise,
showing a previously hidden column appears with scale 1.0.

This also drops the value-changed signal emission for the vadjustment, as it is
apparently not needed.
This commit is contained in:
René Stadler 2011-11-05 23:52:40 +01:00 committed by Stefan Sauer
parent 4e334e0e00
commit b866669ae1
2 changed files with 32 additions and 10 deletions

View file

@ -377,6 +377,7 @@ class ColumnManager (Common.GUI.Manager):
self.view = None self.view = None
self.actions = None self.actions = None
self.zoom = 1.0
self.__columns_changed_id = None self.__columns_changed_id = None
self.columns = [] self.columns = []
self.column_order = list (self.column_classes) self.column_order = list (self.column_classes)
@ -450,6 +451,15 @@ class ColumnManager (Common.GUI.Manager):
sort_model.set_sort_column_id (TREE_SORTABLE_UNSORTED_COLUMN_ID, sort_model.set_sort_column_id (TREE_SORTABLE_UNSORTED_COLUMN_ID,
gtk.SORT_ASCENDING) gtk.SORT_ASCENDING)
def set_zoom (self, scale):
for column in self.columns:
cell = column.view_column.get_cell_renderers ()[0]
cell.props.scale = scale
column.view_column.queue_resize ()
self.zoom = scale
def get_toggle_action (self, column_class): def get_toggle_action (self, column_class):
action_name = "show-%s-column" % (column_class.name,) action_name = "show-%s-column" % (column_class.name,)
@ -463,8 +473,13 @@ class ColumnManager (Common.GUI.Manager):
name = column.name name = column.name
pos = self.__get_column_insert_position (column) pos = self.__get_column_insert_position (column)
if self.view.props.fixed_height_mode: if self.view.props.fixed_height_mode:
column.view_column.props.sizing = gtk.TREE_VIEW_COLUMN_FIXED column.view_column.props.sizing = gtk.TREE_VIEW_COLUMN_FIXED
cell = column.view_column.get_cell_renderers ()[0]
cell.props.scale = self.zoom
self.columns.insert (pos, column) self.columns.insert (pos, column)
self.view.insert_column (column.view_column, pos) self.view.insert_column (column.view_column, pos)

View file

@ -19,6 +19,8 @@
"""GStreamer Debug Viewer GUI module.""" """GStreamer Debug Viewer GUI module."""
ZOOM_FACTOR = 1.15
def _ (s): def _ (s):
return s return s
@ -286,6 +288,7 @@ class Window (object):
def attach (self): def attach (self):
self.zoom_level = 0
self.window_state.attach (window = self.gtk_window, self.window_state.attach (window = self.gtk_window,
state = self.app.state_section) state = self.app.state_section)
@ -577,18 +580,22 @@ class Window (object):
self.clipboard.set_text (self.get_active_line ()[col_id]) self.clipboard.set_text (self.get_active_line ()[col_id])
def handle_enlarge_text_action_activate (self, action): def handle_enlarge_text_action_activate (self, action):
for col in self.column_manager.columns:
cell = col.view_column.get_cell_renderers ()[0] self.update_zoom_level (1)
cell.props.scale *= 1.15
col.view_column.queue_resize ()
self.widgets.log_view_scrolled_window.props.vadjustment.emit ("value-changed")
def handle_shrink_text_action_activate (self, action): def handle_shrink_text_action_activate (self, action):
for col in self.column_manager.columns:
cell = col.view_column.get_cell_renderers ()[0] self.update_zoom_level (-1)
cell.props.scale /= 1.15
col.view_column.queue_resize () def update_zoom_level (self, delta_step):
self.widgets.log_view_scrolled_window.props.vadjustment.emit ("value-changed")
if not delta_step:
return
self.zoom_level += delta_step
scale = ZOOM_FACTOR ** self.zoom_level
self.column_manager.set_zoom (scale)
def add_model_filter (self, filter): def add_model_filter (self, filter):