Skip to content

Commit f5f425d

Browse files
committed
fix: the syntax menu wasn't working anymore
1 parent d42b0b9 commit f5f425d

File tree

3 files changed

+10
-15
lines changed

3 files changed

+10
-15
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1818
### Fixed
1919

2020
- Some signals weren't properly renamed from the previous GTK3 migration (@MightyCreak)
21+
- The syntax menu wasn't working anymore (@MightyCreak)
2122

2223
## 0.8.1 - 2023-04-07
2324

src/diffuse/widgets.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ def __init__(self, n, prefs):
215215
self.undoblock = None
216216

217217
# cached data
218-
self.syntax = None
218+
self.syntax = ''
219219
self.diffmap_cache = None
220220

221221
# editing mode
@@ -545,13 +545,13 @@ def setCharMode(self) -> None:
545545
self.emit('mode-changed')
546546

547547
# sets the syntax highlighting rules
548-
def setSyntax(self, s):
549-
if self.syntax is not s:
550-
self.syntax = s
548+
def setSyntax(self, new_syntax: str) -> None:
549+
if self.syntax is not new_syntax:
550+
self.syntax = new_syntax
551551
# invalidate the syntax caches
552552
for pane in self.panes:
553553
pane.syntax_cache = []
554-
self.emit('syntax-changed', s)
554+
self.emit('syntax-changed', new_syntax)
555555
# force all panes to redraw
556556
for darea in self.dareas:
557557
darea.queue_draw()

src/diffuse/window.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -906,9 +906,6 @@ def __init__(self, rc_dir, **kwargs):
906906
]
907907
]])
908908

909-
# used to disable menu events when switching tabs
910-
self.menu_update_depth = 0
911-
912909
menubar = Gio.Menu()
913910
for label, sections in menu_specs:
914911
menubar.append_submenu(label, self._create_menu(sections))
@@ -1257,9 +1254,9 @@ def setStatus(self, s: Optional[str]) -> None:
12571254
sb.push(context, s)
12581255

12591256
# update the label in the status bar
1260-
def setSyntax(self, s):
1257+
def setSyntax(self, s: str) -> None:
12611258
# update menu
1262-
self.syntax_action.set_state(GLib.Variant.new_string(s or ''))
1259+
self.syntax_action.set_state(GLib.Variant.new_string(s))
12631260

12641261
# callback used when switching notebook pages
12651262
def switch_page_cb(self, widget, ptr, page_num):
@@ -1691,11 +1688,8 @@ def preferences_cb(self, widget, data):
16911688
self.preferences_updated()
16921689

16931690
# callback for all of the syntax highlighting menu items
1694-
def syntax_cb(self, widget, data):
1695-
# ignore events while we update the menu when switching tabs
1696-
# also ignore notification of the newly disabled item
1697-
if self.menu_update_depth == 0 and widget.get_active():
1698-
self.getCurrentViewer().setSyntax(data)
1691+
def syntax_cb(self, widget: Gtk.Widget, data: GLib.Variant) -> None:
1692+
self.getCurrentViewer().setSyntax(data.get_string())
16991693

17001694
# callback for the first tab menu item
17011695
def first_tab_cb(self, widget, data):

0 commit comments

Comments
 (0)