aliva / gedit-markdownpreview

GNU General Public License v2.0
22 stars 3 forks source link

not running in 3.36.1 #13

Open joshp23 opened 4 years ago

joshp23 commented 4 years ago

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'
aliva commented 4 years ago

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

joshp23 commented 4 years ago

Would replicating and mirroring the left side pane code work?

joshp23 commented 4 years ago

Or, is it even possible to hook into gedit appropriately for that to be an option?

aliva commented 4 years ago

Sadly it's out of my GTK knowledge to work further on it.

aliva commented 4 years ago

Hi @swilmet sorry to grab you into this conversation but do you have any suggestion for us?

ghost commented 4 years ago

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.