mirror of
https://gitlab.gnome.org/GNOME/gimp.git
synced 2025-07-03 17:33:25 +00:00
tools: in performance-log-viewer.py, defer UI updates util needed
In the performance-log viewer, defer updates to the various UI elements when the selection changes until they're actually shown. This improves responsiveness when changing the selection.
This commit is contained in:
parent
0245775346
commit
a7afbe13ec
1 changed files with 70 additions and 28 deletions
|
@ -1369,7 +1369,7 @@ class InformationViewer (Gtk.ScrolledWindow):
|
|||
for element in info:
|
||||
add_element (element)
|
||||
|
||||
class VariablesViewer (Gtk.Box):
|
||||
class VariablesViewer (Gtk.ScrolledWindow):
|
||||
class Store (Gtk.ListStore):
|
||||
NAME = 0
|
||||
COLOR = 1
|
||||
|
@ -1397,21 +1397,17 @@ class VariablesViewer (Gtk.Box):
|
|||
def __init__ (self, *args, **kwargs):
|
||||
Gtk.Box.__init__ (self,
|
||||
*args,
|
||||
orientation = Gtk.Orientation.VERTICAL,
|
||||
hscrollbar_policy = Gtk.PolicyType.AUTOMATIC,
|
||||
vscrollbar_policy = Gtk.PolicyType.AUTOMATIC,
|
||||
**kwargs)
|
||||
|
||||
scroll = Gtk.ScrolledWindow (
|
||||
hscrollbar_policy = Gtk.PolicyType.AUTOMATIC,
|
||||
vscrollbar_policy = Gtk.PolicyType.AUTOMATIC
|
||||
)
|
||||
self.pack_start (scroll, True, True, 0)
|
||||
scroll.show ()
|
||||
self.needs_update = True
|
||||
|
||||
store = self.Store ()
|
||||
self.store = store
|
||||
|
||||
tree = Gtk.TreeView (model = store)
|
||||
scroll.add (tree)
|
||||
self.add (tree)
|
||||
tree.show ()
|
||||
|
||||
self.single_sample_cols = []
|
||||
|
@ -1457,9 +1453,12 @@ class VariablesViewer (Gtk.Box):
|
|||
|
||||
selection.connect ("change-complete", self.selection_change_complete)
|
||||
|
||||
self.selection_change_complete (selection)
|
||||
def update (self):
|
||||
if not self.needs_update:
|
||||
return
|
||||
|
||||
self.needs_update = False
|
||||
|
||||
def selection_change_complete (self, selection):
|
||||
sel = selection.get_effective_selection ()
|
||||
n_sel = len (sel)
|
||||
|
||||
|
@ -1506,6 +1505,17 @@ class VariablesViewer (Gtk.Box):
|
|||
for col in self.single_sample_cols: col.set_visible (n_sel == 1)
|
||||
for col in self.multi_sample_cols: col.set_visible (n_sel > 1)
|
||||
|
||||
def do_map (self):
|
||||
self.update ()
|
||||
|
||||
Gtk.ScrolledWindow.do_map (self)
|
||||
|
||||
def selection_change_complete (self, selection):
|
||||
self.needs_update = True
|
||||
|
||||
if self.get_mapped ():
|
||||
self.update ()
|
||||
|
||||
class BacktraceViewer (Gtk.Box):
|
||||
class ThreadStore (Gtk.ListStore):
|
||||
INDEX = 0
|
||||
|
@ -1534,6 +1544,8 @@ class BacktraceViewer (Gtk.Box):
|
|||
orientation = Gtk.Orientation.HORIZONTAL,
|
||||
**kwargs)
|
||||
|
||||
self.needs_update = True
|
||||
|
||||
vbox = Gtk.Box (orientation = Gtk.Orientation.VERTICAL)
|
||||
self.pack_start (vbox, False, False, 0)
|
||||
vbox.show ()
|
||||
|
@ -1687,8 +1699,6 @@ class BacktraceViewer (Gtk.Box):
|
|||
|
||||
selection.connect ("change-complete", self.selection_change_complete)
|
||||
|
||||
self.selection_change_complete (selection)
|
||||
|
||||
@GObject.Property (type = bool, default = False)
|
||||
def available (self):
|
||||
sel = selection.get_effective_selection ()
|
||||
|
@ -1700,7 +1710,12 @@ class BacktraceViewer (Gtk.Box):
|
|||
|
||||
return False
|
||||
|
||||
def selection_change_complete (self, selection):
|
||||
def update (self):
|
||||
if not self.needs_update or not self.available:
|
||||
return
|
||||
|
||||
self.needs_update = False
|
||||
|
||||
tid = None
|
||||
|
||||
sel_rows = self.thread_tree.get_selection ().get_selected_rows ()[1]
|
||||
|
@ -1708,7 +1723,6 @@ class BacktraceViewer (Gtk.Box):
|
|||
if sel_rows:
|
||||
tid = self.thread_store[sel_rows[0]][self.ThreadStore.ID]
|
||||
|
||||
if self.available:
|
||||
i, = selection.get_effective_selection ()
|
||||
|
||||
self.thread_store.clear ()
|
||||
|
@ -1723,6 +1737,17 @@ class BacktraceViewer (Gtk.Box):
|
|||
if thread.id == tid:
|
||||
self.thread_tree.get_selection ().select_iter (iter)
|
||||
|
||||
def do_map (self):
|
||||
self.update ()
|
||||
|
||||
Gtk.Box.do_map (self)
|
||||
|
||||
def selection_change_complete (self, selection):
|
||||
self.needs_update = True
|
||||
|
||||
if self.get_mapped ():
|
||||
self.update ()
|
||||
|
||||
self.notify ("available")
|
||||
|
||||
def threads_row_activated (self, tree, path, col):
|
||||
|
@ -1968,6 +1993,7 @@ class ProfileViewer (Gtk.ScrolledWindow):
|
|||
col.set_cell_data_func (cell,
|
||||
format_percentage_col, store.INCLUSIVE)
|
||||
|
||||
if id:
|
||||
self.update ()
|
||||
|
||||
def update (self):
|
||||
|
@ -2217,13 +2243,14 @@ class ProfileViewer (Gtk.ScrolledWindow):
|
|||
)
|
||||
|
||||
self.adjustment_changed_handler = None
|
||||
self.needs_update = True
|
||||
|
||||
profile = self.Profile ()
|
||||
self.root_profile = profile
|
||||
self.add (profile)
|
||||
profile.show ()
|
||||
|
||||
selection.connect ("change-complete", lambda *args: self.update ())
|
||||
selection.connect ("change-complete", self.selection_change_complete)
|
||||
|
||||
profile.connect ("subprofile-added", self.subprofile_added)
|
||||
|
||||
|
@ -2237,9 +2264,24 @@ class ProfileViewer (Gtk.ScrolledWindow):
|
|||
return False
|
||||
|
||||
def update (self):
|
||||
if self.available:
|
||||
if not self.needs_update or not self.available:
|
||||
return
|
||||
|
||||
self.needs_update = False
|
||||
|
||||
self.root_profile.update ()
|
||||
|
||||
def do_map (self):
|
||||
self.update ()
|
||||
|
||||
Gtk.ScrolledWindow.do_map (self)
|
||||
|
||||
def selection_change_complete (self, selection):
|
||||
self.needs_update = True
|
||||
|
||||
if self.get_mapped ():
|
||||
self.update ()
|
||||
|
||||
self.notify ("available")
|
||||
|
||||
def subprofile_added (self, profile, subprofile):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue