Allow plugins to register command line options

Bug #1544386 reported by Timothy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Diodon
Fix Released
Wishlist
Unassigned

Bug Description

Now that Diodon no longer manages keybinding plugins need a new way to implement user activatable features. Allowing plugins to register command line options would stay with the design Diodon itself implemented.

One use of this feature would be a Pop & Paste plugin. The user would bind say 'diodon pop' to a keybinding. So when the said keybinding is pressed the plugin would paste and then remove the selected item.

Related branches

Revision history for this message
Oliver Sauder (sao) wrote :

I like the idea. The implementation might be a bit more tricky. Will have to think about it a bit more when I get around to it - patches are always welcome....

Changed in diodon:
status: New → Confirmed
importance: Undecided → Wishlist
Revision history for this message
Timothy (redhatter271-deactivatedaccount) wrote :

After some tinkering I got something working. Doesn't allow plugins to set descriptions to be printed in the help though.

Revision history for this message
Timothy (redhatter271-deactivatedaccount) wrote :

This one allows descriptions, but will only display them if a diodon instance is already running. As this may be confusing I don't know if it would be better to not display them at all.

Revision history for this message
Oliver Sauder (sao) wrote :

Thanks for the patch.

This looks good. Actually only having the description when Diodon is already running is not a bad thing - because those actions are only available when Diodon is already running.

There is one problem though with the patch. It uses the function g_option_context_parse_strv. This is only available since glib version 2.40.

Diodon will also need to be be built with Ubuntu 14.04 . 14.04 ships with glib version 2.40 so this would work in general but the vapi file of valac 0.22 doesn't include this method so there is an compile error. It only got added in a later vala version as per https://mail.gnome.org/archives/commits-list/2014-April/msg03393.html.

Do not really know how vapi files can be extended within a project - you have any ideas?

Changed in diodon:
status: Confirmed → In Progress
Revision history for this message
Timothy (redhatter271-deactivatedaccount) wrote :

There isn't a way to simply 'extend' a vapi file, you have to include the entire file. What is normal done in these situations is to copy the whole glib-2.0.vapi file (the one with the parse_strv definition) to your project vapidir. That way valac will use your project's local copy instead of the users incomplete copy.

Revision history for this message
Oliver Sauder (sao) wrote :

I thought so too (or was rather afraid that this is the case... ;)).

I am not really in favor of overwriting very basic vapi files as this way fixes of glib binding when Diodon is compiled with newer vala versions are completely ignored. This could even be memory leak fixes or similar (seen many such fixes in the past)

Currently I see two ways forward:

1 Adjusting the patch that the parse_strv is not being used
2 Increasing of minimum requirements to build Diodon (as the latest LTS should always be supported I think earliest possible would be with the first Diodon release, after Ubuntu 16.04 has been released)

I do not really see that option 1 can be accomplished or would you see a way?

If not I guess it is best to postpone applying of this patch.

Revision history for this message
Timothy (redhatter271-deactivatedaccount) wrote :

After some more mucking around I was able come up with a solution. The following patch, while a bit hackish, should work with valac 0.22.

Revision history for this message
Timothy (redhatter271-deactivatedaccount) wrote :

One more small revision to make the help a little less confusing.

Revision history for this message
Oliver Sauder (sao) wrote :

I have made some small adjustment (mainly naming changes) and it actually looked good and I committed it to trunk lp:diodon - this way the daily ppa recipe built it on all supported Ubuntu version - which went all smoothly.

When I am now testing it it doesn't seem to work though - command line arguments are pretty much ignored and when calling --help the default help of a GApplication is shown.

I do not have the time to debug this more so if you could have a look that would be great. Otherwise will I revert the patch to have a clean trunk again and would need to look into this later.

Thanks.

Revision history for this message
Timothy (redhatter271-deactivatedaccount) wrote :

I pulled the latest changes and as far as I can tell it's working on my system.

> diodon --help (C:2 diodon:509+) ~/Projects/build/diodon 10.11.59
Usage:
  diodon [OPTION...] <action> | [CHECKSUM] - GTK+ Clipboard Manager

Actions:
  Actions are only available while diodon is running.

Application Options:
  -h, --help Show help options
  -v, --version Print version information
  --display=DISPLAY X display to use

> diodon & (C:2 diodon:509+) ~/Projects/build/diodon 10.12.07
> diodon --help (C:2 diodon:509+) ~/Projects/build/diodon 10.12.19
Usage:
  diodon [OPTION...] <action> | [CHECKSUM] - GTK+ Clipboard Manager

Actions:
  alternative Open the alternative interface.

Application Options:
  -h, --help Show help options
  -v, --version Print version information
  --display=DISPLAY X display to use

> (C:2 diodon:509+) ~/Projects/build/diodon 10.12.34

Could it be something particular to your system? What Linux distribution and versions of Gtk/GLib are you using?

Revision history for this message
Oliver Sauder (sao) wrote :

I have tested it on Ubuntu 14.04 with glib version 2.40.2 and libgtk-3.0 version 3.10.8.

My output is the following:

Usage:
  diodon [OPTION...]

Help Options:
  -h, --help Show help options
  --help-all Show all help options
  --help-gapplication Show GApplication options

It compiles without any errors though but it could very well be that there is an issue in the used deps. It would be good to know what version works I guess.

Revision history for this message
Oliver Sauder (sao) wrote :

As it causes issues with Ubuntu 14.04 (command lines needed e.g. for Unity Scope Lens do not work after applying this patch) - I have reverted this change for now from trunk to be able to release a new Diodon version.

As I think it is a issue in one of the libraries it is best to postpone this change till deps can be changed. For testing I have now pushed the changes into the branch plugins-cmdline.

Oliver Sauder (sao)
Changed in diodon:
milestone: none → 1.6.0
Revision history for this message
Oliver Sauder (sao) wrote :

I have finally got around to integrate your patch.

There were some issues which caused paste action not to work properly. I fixed those and integrated into trunk. It will be soon available in diodon daily ppa for testing.

Thanks a lot for your work.

Changed in diodon:
status: In Progress → Fix Committed
Oliver Sauder (sao)
Changed in diodon:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.