diff --git a/CHANGELOG.md b/CHANGELOG.md index e468c94..63e5922 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Some signals weren't properly renamed from the previous GTK3 migration (@MightyCreak) +- The syntax menu wasn't working anymore (@MightyCreak) ## 0.8.1 - 2023-04-07 diff --git a/src/diffuse/widgets.py b/src/diffuse/widgets.py index b704501..f9379cb 100644 --- a/src/diffuse/widgets.py +++ b/src/diffuse/widgets.py @@ -215,7 +215,7 @@ class FileDiffViewerBase(Gtk.Grid): self.undoblock = None # cached data - self.syntax = None + self.syntax = '' self.diffmap_cache = None # editing mode @@ -545,13 +545,13 @@ class FileDiffViewerBase(Gtk.Grid): self.emit('mode-changed') # sets the syntax highlighting rules - def setSyntax(self, s): - if self.syntax is not s: - self.syntax = s + def setSyntax(self, new_syntax: str) -> None: + if self.syntax is not new_syntax: + self.syntax = new_syntax # invalidate the syntax caches for pane in self.panes: pane.syntax_cache = [] - self.emit('syntax-changed', s) + self.emit('syntax-changed', new_syntax) # force all panes to redraw for darea in self.dareas: darea.queue_draw() diff --git a/src/diffuse/window.py b/src/diffuse/window.py index 3b336ec..8385e5a 100644 --- a/src/diffuse/window.py +++ b/src/diffuse/window.py @@ -906,9 +906,6 @@ class DiffuseWindow(Gtk.ApplicationWindow): ] ]]) - # used to disable menu events when switching tabs - self.menu_update_depth = 0 - menubar = Gio.Menu() for label, sections in menu_specs: menubar.append_submenu(label, self._create_menu(sections)) @@ -1257,9 +1254,9 @@ class DiffuseWindow(Gtk.ApplicationWindow): sb.push(context, s) # update the label in the status bar - def setSyntax(self, s): + def setSyntax(self, s: str) -> None: # update menu - self.syntax_action.set_state(GLib.Variant.new_string(s or '')) + self.syntax_action.set_state(GLib.Variant.new_string(s)) # callback used when switching notebook pages def switch_page_cb(self, widget, ptr, page_num): @@ -1691,11 +1688,8 @@ class DiffuseWindow(Gtk.ApplicationWindow): self.preferences_updated() # callback for all of the syntax highlighting menu items - def syntax_cb(self, widget, data): - # ignore events while we update the menu when switching tabs - # also ignore notification of the newly disabled item - if self.menu_update_depth == 0 and widget.get_active(): - self.getCurrentViewer().setSyntax(data) + def syntax_cb(self, widget: Gtk.Widget, data: GLib.Variant) -> None: + self.getCurrentViewer().setSyntax(data.get_string()) # callback for the first tab menu item def first_tab_cb(self, widget, data):