getting-things-gnome / gtg

Getting Things GNOME! trunk
https://wiki.gnome.org/Apps/GTG
GNU General Public License v3.0
552 stars 166 forks source link

AttributeError: 'NoneType' object has no attribute 'grab_focus' #1137

Open SqAtx opened 1 week ago

SqAtx commented 1 week ago

Repro:

Context: Global generic exception

Traceback (most recent call last):
  File "/home/kevin/src/gtg/.local_build/install/lib/python3/dist-packages/GTG/gtk/browser/main_window.py", line 833, in focus_sidebar
    self.tagtreeview.grab_focus()
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'grab_focus'

GTG: 0.7-dev-bd58425d Flatpak: False Snap: False Display Name: wayland-0 Desktop: ubuntu:GNOME

lxml: True caldav: True liblarch: False Cheetah3: False dbus-python: False pdflatex: False pypdftk: False

OS: Ubuntu 24.04 LTS Python: CPython 3.12.3 GLib: 2.80.0 PyGLib: 3.48.2 PyGObject: 3.48.2 GTK: 4.2.14

SqAtx commented 4 days ago

It looks like https://github.com/getting-things-gnome/gtg/commit/e96a8f8f15477dcc7e1ba64c33e0fc174abc0c0a handled a similar case, with the justification that "tagtreeview is None if it's hidden". But the left side bar isn't hidden when I do CTRL-B.

Given

~/src/gtg$ ag focus_sidebar
GTG/gtk/browser/main_window.py
208:            ('focus_sidebar', self.focus_sidebar, ('win.focus_sidebar', ['<ctrl>B'])),
830:    def focus_sidebar(self, action, param):

I'm wondering if this shortcut and associated action shouldn't just have been removed but have been forgotten?

I haven't been able to see where self.tagtreeview is supposed to be set, and I'm starting to wonder if I'm not actually staring at a pile of dead code :) I don't have time to investigate right now but it looks a lot like the code related to the tag pane now lives at https://github.com/getting-things-gnome/gtg/blob/master/GTG/gtk/browser/sidebar.py? Like https://github.com/getting-things-gnome/gtg/blob/bd58425d0b03e6e71792152b42dad88e17a48104/GTG/gtk/browser/main_window.py#L1538 has been replaced with https://github.com/getting-things-gnome/gtg/blob/bd58425d0b03e6e71792152b42dad88e17a48104/GTG/gtk/browser/sidebar.py#L466, for example?

SqAtx commented 3 days ago

I'm wondering if this shortcut and associated action shouldn't just have been removed but have been forgotten?

I tried Ctrl-B in 0.6 and it does focus the tag side panel. Probably to allow navigation by keyboard. So my statement was incorrect, and this is indeed a regression - it's just that self.tagtreeview.grab_focus() is no longer the way to focus the panel.

There is probably still a lot of cleanup to do around tagtreeview, but that can be done separately. We'll also need to verify all the other shortcuts in 0.7 - Ctrl-B might not be the only one that got broken.