Skip to content

Option to completly reload a plugin #19

Open

Description

@frlan

On developing a plugin it would be quiet useful to complete unload and load a given plugin instead of restarting Geany complete.

Activity

  1. changed the title [-]Option to complete reload a plugin[/-] [+]Option to completly reload a plugin[/+] on Feb 20, 2015
  2. elextr commented on Feb 21, 2015

    @elextr
    Collaborator

    Assuming you mean python plugins, then you can already load and unload them, its just that if they crash they might leave the system in an unknown state (like a Geany plugin can crash geany).

  3. frlan commented on Feb 21, 2015

    @frlan
    Author

    Am 21.02.2015 um 02:14 schrieb elextr:

    Assuming you mean python plugins, then you can already load and unload
    them, its just that if they crash they might leave the system in an
    unknown state (like a Geany plugin can crash geany).

    Maybe my observations are wrong, but I've got the feeling that it's not
    reloaded from disc. So doing a change on geanypy-plugin is not applied
    after deactivating and reactivating plguin.

  4. elextr commented on Feb 21, 2015

    @elextr
    Collaborator

    Ahh, yes, you are right, the module is never unloaded, like Geany itself which opens the dll to get the info for the plugin dialog, geanypy loads the plugin module to get the info for its plugin manager. But this seems to only happen at startup, then the dialog is populated and doesn't seem to be reloaded.

    By the way Geanypy continues Geany's confusing terminology where "load" really means activate, since the plugin was already actually loaded to get its info. So in fact load and unload only mean activate and deactivate.

  5. codebrainz commented on Feb 21, 2015

    @codebrainz
    Owner

    I think doing something like reload()/imp.reload() isn't going to work, but I'd be happy to be proven wrong :)

  6. elextr commented on Feb 22, 2015

    @elextr
    Collaborator

    Well, imp.load_source() sort of sounds like it will reload the module if its run again.

    You can't actually unload the module because then it won't appear in the plugin manager because its info isn't available. And how do you unload a module anyway? Is it safe to just delete the global module object? So as @codebrainz says maybe just reload it and pray?

  7. codebrainz commented on Feb 22, 2015

    @codebrainz
    Owner

    On 15-02-21 04:53 PM, elextr wrote:

    And how do you unload a module anyway? Is it safe to just delete the global module object?

    Probably, but if it uses any C extensions, I don't think they'll be
    unloaded or re-initialized next time they're imported. Also they
    probably won't actually be unloaded/collected until nothing refers to
    them again, which might not be when the del some_module occurs.

  8. frlan commented on Jul 10, 2015

    @frlan
    Author

    Will it be possible to do it with keystroke?

  9. elextr commented on Jul 10, 2015

    @elextr
    Collaborator

    At the moment plugins can only set keybindings when they start.

    That means that "master" plugins like Geanypy cannot set keybindings for its child Python plugins since it doesn't know them when it starts.

    And as the Geanypy plugin manager is itself a plugin therefore I don't think it can have keybindings at the moment.

    A new plugin loading method that will support "native" Python plugins is planned to be added during the 1.26 development period, and so the Python plugins will be part of the normal PM I believe.

  10. frlan commented on Jul 10, 2015

    @frlan
    Author

    For geanypy I was thinking about a global reload feature; As of the new plugin interface: Yes.

  11. elextr commented on Jul 10, 2015

    @elextr
    Collaborator

    @frlan I read:

    I've added a feature on my fork to add a 'refresh' button to the python plugin manager, it saves the activated plugins, unloads all, re-searches for plugins, then restores the plugins that were loaded.

    to say the "Geanypy" reload is part of the plugin manager plugin, so that is what needs the keybinding, but I may be wrong since the OP hasn't left a link to the code ;-)

  12. elextr commented on Jul 10, 2015

    @elextr
    Collaborator

    I don't think (IIRC) that the Geany plugin API exports the required functions for adding keybinding actions, even for plugins in C, it only supports adding keybinding actions at plugin startup. This is because the keybinding preference GUI does not allow the number of actions in a section to be changed after creation and so no such API exists.

    You could look at changing this, as several other parts of Geany could benefit from "dynamic" actions, eg the build menu. But its not intuitively obvious how to do it without breaking lots of stuff which is why its not been done.

    Also plugins should not define actual keys for actions since they can clash with ones a user has defined for Geany actions or ones defined for other plugins. Plugins should only add actions and let the user define the key to use.

  13. elextr commented on Jul 10, 2015

    @elextr
    Collaborator

    On 10 July 2015 at 20:00, rob notifications@github.com wrote:

    Yeah, I'm pretty new to the project so thank you for your experience.

    I'm wondering could it be done in pygtk like in thsi example:
    https://developer.gnome.org/pygtk/stable/class-gtkaccellabel.html#id3253816

    ​It will probably work for adding an action, but where would you allow the
    user to define the keybinding? It won't add the action into the Geany
    keybinding preferences dialog. Having multiple different places to define
    keybindings is not a good user interface.​

    Also beware that Geany does its own key handling before GTK. It lets
    keys it doesn't know about go through to Scintilla and GTK, but if it has
    the key defined it will override your accelerator, like if the user or
    another plugin defines it.

    I'm in work at the minute or I'd give it a go

    —
    Reply to this email directly or view it on GitHub
    #19 (comment).

  14. elextr commented on Jul 11, 2015

    @elextr
    Collaborator

    Well a true Python/C hacker might manage it with ctypes ;-P

    But the question is where would you get the group pointer, and if you said by running plugin_set_key_group() I'll ask where you get the plugin pointer from?

    I think its better to wait for a bit until the new plugin system is added and then help moving Geanypy to work with that.

  15. codebrainz commented on Jul 11, 2015

    @codebrainz
    Owner

    I'll ask where you get the plugin pointer from

    You already answered it :)

    from ctypes import *
    mod = CDLL(handle=None)
    geany_plugin_ptr = c_void_p.in_dll(mod, "geany_plugin")

    (untested pseudo-code)

  16. elextr commented on Jul 11, 2015

    @elextr
    Collaborator

    Thats the Geanypy pointer not the non-existent pointer for the Python plugin :)

  17. codebrainz commented on Jul 11, 2015

    @codebrainz
    Owner

    I thought that was the one you meant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions