gedit-markdownpreview
gedit-markdownpreview copied to clipboard
not running in 3.36.1
After upgrading to Ubuntu 20.04 and attempting to run the plugin with Gedit launched from terminal, the following error occurs:
File "/home/joshp/.local/share/gedit/plugins/markdownpreview/markdownpreview.py", line 76, in menu_button_handler
self.attach_to_view()
File "/home/joshp/.local/share/gedit/plugins/markdownpreview/markdownpreview.py", line 89, in attach_to_view
self.toggle_preview(None, None, view)
File "/home/joshp/.local/share/gedit/plugins/markdownpreview/markdownpreview.py", line 100, in toggle_preview
self.enable_preview(view)
File "/home/joshp/.local/share/gedit/plugins/markdownpreview/markdownpreview.py", line 118, in enable_preview
box.pack_end(webview, True, True, 0)
AttributeError: 'GeditViewFrame' object has no attribute 'pack_end'
so the plugin tries to get scroll window (the widget which contains the code)
before 3.36 parent of this scrolledwindow
was a GtkBox
which I could simply add web-view to it in a hacky way.
the whole process was something like this:
scrolledwindow = self.get_scrolledwindow(view)
box = scrolledwindow.get_parent()
box.pack_end(webview, True, True, 0)
but now the box doesn't exist anymore and instead of the box there is a GeditViewFrame
which is based on GtkOverlay
(useless to us)
As the result the current hacky way to patch webview doesn't work anymore and we have to find a new hacky way to bring it back, which won't be easy
Would replicating and mirroring the left side pane code work?
Or, is it even possible to hook into gedit appropriately for that to be an option?
Sadly it's out of my GTK knowledge to work further on it.
Hi @swilmet sorry to grab you into this conversation but do you have any suggestion for us?
There is GeditTab (subclass of GtkBox, vertical) which contains a GeditViewFrame (subclass of GtkOverlay, and GtkOverlay is a subclass of GtkBin so it can contain only one child widget). The GeditViewFrame contains the GtkScrolledWindow which contains the GeditView. Note that the GeditTab can contain also a GtkInfoBar above the GeditViewFrame.
It's possible to re-parent a widget by increasing the ref count on it, call gtk_container_remove()
, add for example a GtkGrid, add the widget to the GtkGrid and then add the GtkGrid to the parent container.
I know that there is a plugin that restores the overview/minimap on the right side of the scrolled window, maybe the same code can be used to pack something on the right side: https://github.com/johnfactotum/gedit-restore-minimap
But I see that there is an issue with that plugin when an infobar is shown.