[accerciser: 1/2] interface_view: Drop manual click handler that runs into exception
- From: Samuel Thibault <sthibaul src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [accerciser: 1/2] interface_view: Drop manual click handler that runs into exception
- Date: Wed, 10 Aug 2022 21:44:33 +0000 (UTC)
commit dc0c62994129bcddc7cbea6c6ab066b3e42614eb
Author: Michael Weghorn <m weghorn posteo de>
Date: Tue Aug 9 08:09:57 2022 +0200
interface_view: Drop manual click handler that runs into exception
Clicking into the `GtkTextView` that is used to display
and edit the text via the text interface resulted in
this exception being printed on stderr:
Traceback (most recent call last):
File ".../accerciser/share/accerciser/plugins/interface_view.py", line 1453, in _onTextViewPressed
self.offset_spin.set_value(iter.get_offset())
AttributeError: '_ResultTuple' object has no attribute 'get_offset'
Retrieving the offset from the `_ResultTuple` in
`_onTextViewPressed` could be fixed as follows:
- self.offset_spin.set_value(iter.get_offset())
+ self.offset_spin.set_value(iter[1].get_offset())
However, `_onTextCursorMove` is already registered
as a handler for cursor move events, and also gets
called when the cursor gets moved by clicking into
the GtkTextView using the mouse. Since
`_onTextCursorMove` already takes care of updating
the offset in the spinbox, there seems to be no
need for `_onTextViewPressed`, which was meant
to do exactly that, so just drop it.
Take over a helpful comment from its doc
to `_onTextCursorMove`.
plugins/interface_view.py | 26 +++-----------------------
plugins/interface_view.ui | 1 -
2 files changed, 3 insertions(+), 24 deletions(-)
---
diff --git a/plugins/interface_view.py b/plugins/interface_view.py
index 3d12cfe..eed404b 100644
--- a/plugins/interface_view.py
+++ b/plugins/interface_view.py
@@ -1430,32 +1430,12 @@ class _SectionText(_InterfaceSection):
# bold formatting is 4.
self.label_end.set_markup(_('End: %d') % end)
- def _onTextViewPressed(self, widget, event):
- '''
- Update spin button in the case that the textview was clicked.
- Once the spin button's value changes, it's own callback fires which
- re-populates the attribute view.
-
- @param widget: The widget that recived the click event,
- typically the text view.
- @type widget: gtk.Widget
- @param event: The click event.
- @type event: gtk.gdk.Event
- '''
- if event.button != 1:
- return
-
- x, y = event.get_coords()
- x, y = self.text_view.window_to_buffer_coords(gtk.TextWindowType.WIDGET,
- int(x), int(y))
- iter = self.text_view.get_iter_at_location(x, y)
-
- self.offset_spin.set_value(iter.get_offset())
-
def _onTextCursorMove(self, text_buffer, param_spec):
'''
Update spinner when input cursor moves.
-
+ Once the spin button's value changes, it's own callback fires
+ which re-populates the attribute view.
+
@param text_buffer: The section's main text buffer.
@type text_buffer: gtk.TextBuffer
@param param_spec: Some gobject crud
diff --git a/plugins/interface_view.ui b/plugins/interface_view.ui
index ee5722a..8a6599c 100644
--- a/plugins/interface_view.ui
+++ b/plugins/interface_view.ui
@@ -2517,7 +2517,6 @@
<property name="can_focus">True</property>
<property name="editable">False</property>
<property name="accepts_tab">False</property>
- <signal name="button-press-event" handler="_onTextViewPressed"
swapped="no"/>
<signal name="focus-in-event" handler="_onTextFocusChanged"
swapped="no"/>
<signal name="focus-out-event" handler="_onTextFocusChanged"
swapped="no"/>
</object>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]