{"action":"opened","number":1244,"pull_request":{"url":"https://api.github.com/repos/geany/geany/pulls/1244","id":86272144,"html_url":"https://github.com/geany/geany/pull/1244","diff_url":"https://github.com/geany/geany/pull/1244.diff","patch_url":"https://github.com/geany/geany/pull/1244.patch","issue_url":"https://api.github.com/repos/geany/geany/issues/1244","number":1244,"state":"open","locked":false,"title":"Improvements to plugin mechanism for OO-style plugins","user":{"login":"codebrainz","id":181177,"avatar_url":"https://avatars.githubusercontent.com/u/181177?v=3","gravatar_id":"","url":"https://api.github.com/users/codebrainz","html_url":"https://github.com/codebrainz","followers_url":"https://api.github.com/users/codebrainz/followers","following_url":"https://api.github.com/users/codebrainz/following{/other_user}","gists_url":"https://api.github.com/users/codebrainz/gists{/gist_id}","starred_url":"https://api.github.com/users/codebrainz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codebrainz/subscriptions","organizations_url":"https://api.github.com/users/codebrainz/orgs","repos_url":"https://api.github.com/users/codebrainz/repos","events_url":"https://api.github.com/users/codebrainz/events{/privacy}","received_events_url":"https://api.github.com/users/codebrainz/received_events","type":"User","site_admin":false},"body":"Usually when writing a plugin I like to have keep the the loading/hooks code in a single file (ex. `plugin.c`) and then having some kind of \"context\" object code in a separate file, often implemented in OO-style (ex. constructor, destructor, functions taking instance as first param, etc). The new plugin API has been designed specifically to make this possible.\r\n\r\nTo further improve the new plugin API, this PR adds changes that reduce the boilerplate needed to write an OO-style plugin (often GObject-based, but not necessarily) properly.\r\n\r\nThe [first change](https://github.com/codebrainz/geany/commit/cafa5a6513979523090e9b16fbe4cc59e0312590) is to add a macro to make it simpler to register a GObject type of which an instance is bound to the module loading/unloading lifetime.\r\n\r\nThe [second change](https://github.com/codebrainz/geany/commit/16c487aa0db51e41c39026636cec13f0a959c431) (which is leading to the 3rd change), simply adds typedefs and better documentation for the existing callback functions.\r\n\r\nThe [third change](https://github.com/codebrainz/geany/commit/ac66af8e2ff450dfa2e02b2f42fe623813f83b1c) is to add a second set of callback functions which get passed the instance data as the first parameter, in usual OO fashion. Typedefs are added to those from the 2nd change to allow casting functions to the right type. I'm not super fond of the `_swapped` prefix, but some kind of different name is required to avoid breaking backwards compatibility.\r\n\r\nOverall the changes are pretty trivial. I tested them using the code [in this repo](https://github.com/codebrainz/geany-test-object-friendly). To see how this improves the plugin code a little, see https://github.com/codebrainz/geany-test-object-friendly/commit/87454f0c2908b423491053ef9d1f5bbb2174facf where I modified a normal plugin to use the changes in this PR.\r\n\r\nThe changes are completely backwards compatible.\r\n\r\nNote: these changes are a result of my [brain dump in these comments](https://github.com/geany/geany/commit/437837d3a54367393c41d6c1e1f4d1af4481627e#commitcomment-19107275).","created_at":"2016-09-22T02:44:00Z","updated_at":"2016-09-22T02:44:00Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/geany/geany/pulls/1244/commits","review_comments_url":"https://api.github.com/repos/geany/geany/pulls/1244/comments","review_comment_url":"https://api.github.com/repos/geany/geany/pulls/comments{/number}","comments_url":"https://api.github.com/repos/geany/geany/issues/1244/comments","statuses_url":"https://api.github.com/repos/geany/geany/statuses/ac66af8e2ff450dfa2e02b2f42fe623813f83b1c","head":{"label":"codebrainz:object-friendly","ref":"object-friendly","sha":"ac66af8e2ff450dfa2e02b2f42fe623813f83b1c","user":{"login":"codebrainz","id":181177,"avatar_url":"https://avatars.githubusercontent.com/u/181177?v=3","gravatar_id":"","url":"https://api.github.com/users/codebrainz","html_url":"https://github.com/codebrainz","followers_url":"https://api.github.com/users/codebrainz/followers","following_url":"https://api.github.com/users/codebrainz/following{/other_user}","gists_url":"https://api.github.com/users/codebrainz/gists{/gist_id}","starred_url":"https://api.github.com/users/codebrainz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codebrainz/subscriptions","organizations_url":"https://api.github.com/users/codebrainz/orgs","repos_url":"https://api.github.com/users/codebrainz/repos","events_url":"https://api.github.com/users/codebrainz/events{/privacy}","received_events_url":"https://api.github.com/users/codebrainz/received_events","type":"User","site_admin":false},"repo":{"id":2543691,"name":"geany","full_name":"codebrainz/geany","owner":{"login":"codebrainz","id":181177,"avatar_url":"https://avatars.githubusercontent.com/u/181177?v=3","gravatar_id":"","url":"https://api.github.com/users/codebrainz","html_url":"https://github.com/codebrainz","followers_url":"https://api.github.com/users/codebrainz/followers","following_url":"https://api.github.com/users/codebrainz/following{/other_user}","gists_url":"https://api.github.com/users/codebrainz/gists{/gist_id}","starred_url":"https://api.github.com/users/codebrainz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/codebrainz/subscriptions","organizations_url":"https://api.github.com/users/codebrainz/orgs","repos_url":"https://api.github.com/users/codebrainz/repos","events_url":"https://api.github.com/users/codebrainz/events{/privacy}","received_events_url":"https://api.github.com/users/codebrainz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/codebrainz/geany","description":"A fast and lightweight IDE","fork":true,"url":"https://api.github.com/repos/codebrainz/geany","forks_url":"https://api.github.com/repos/codebrainz/geany/forks","keys_url":"https://api.github.com/repos/codebrainz/geany/keys{/key_id}","collaborators_url":"https://api.github.com/repos/codebrainz/geany/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/codebrainz/geany/teams","hooks_url":"https://api.github.com/repos/codebrainz/geany/hooks","issue_events_url":"https://api.github.com/repos/codebrainz/geany/issues/events{/number}","events_url":"https://api.github.com/repos/codebrainz/geany/events","assignees_url":"https://api.github.com/repos/codebrainz/geany/assignees{/user}","branches_url":"https://api.github.com/repos/codebrainz/geany/branches{/branch}","tags_url":"https://api.github.com/repos/codebrainz/geany/tags","blobs_url":"https://api.github.com/repos/codebrainz/geany/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/codebrainz/geany/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/codebrainz/geany/git/refs{/sha}","trees_url":"https://api.github.com/repos/codebrainz/geany/git/trees{/sha}","statuses_url":"https://api.github.com/repos/codebrainz/geany/statuses/{sha}","languages_url":"https://api.github.com/repos/codebrainz/geany/languages","stargazers_url":"https://api.github.com/repos/codebrainz/geany/stargazers","contributors_url":"https://api.github.com/repos/codebrainz/geany/contributors","subscribers_url":"https://api.github.com/repos/codebrainz/geany/subscribers","subscription_url":"https://api.github.com/repos/codebrainz/geany/subscription","commits_url":"https://api.github.com/repos/codebrainz/geany/commits{/sha}","git_commits_url":"https://api.github.com/repos/codebrainz/geany/git/commits{/sha}","comments_url":"https://api.github.com/repos/codebrainz/geany/comments{/number}","issue_comment_url":"https://api.github.com/repos/codebrainz/geany/issues/comments{/number}","contents_url":"https://api.github.com/repos/codebrainz/geany/contents/{+path}","compare_url":"https://api.github.com/repos/codebrainz/geany/compare/{base}...{head}","merges_url":"https://api.github.com/repos/codebrainz/geany/merges","archive_url":"https://api.github.com/repos/codebrainz/geany/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/codebrainz/geany/downloads","issues_url":"https://api.github.com/repos/codebrainz/geany/issues{/number}","pulls_url":"https://api.github.com/repos/codebrainz/geany/pulls{/number}","milestones_url":"https://api.github.com/repos/codebrainz/geany/milestones{/number}","notifications_url":"https://api.github.com/repos/codebrainz/geany/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/codebrainz/geany/labels{/name}","releases_url":"https://api.github.com/repos/codebrainz/geany/releases{/id}","deployments_url":"https://api.github.com/repos/codebrainz/geany/deployments","created_at":"2011-10-09T17:58:38Z","updated_at":"2016-09-02T02:54:08Z","pushed_at":"2016-09-22T02:23:34Z","git_url":"git://github.com/codebrainz/geany.git","ssh_url":"git@github.com:codebrainz/geany.git","clone_url":"https://github.com/codebrainz/geany.git","svn_url":"https://github.com/codebrainz/geany","homepage":"http://www.geany.org","size":51643,"stargazers_count":4,"watchers_count":4,"language":"C","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":4,"default_branch":"master"}},"base":{"label":"geany:master","ref":"master","sha":"d8ee2ccf8e4a477dd663c7966ed28c137cb00aa1","user":{"login":"geany","id":1108795,"avatar_url":"https://avatars.githubusercontent.com/u/1108795?v=3","gravatar_id":"","url":"https://api.github.com/users/geany","html_url":"https://github.com/geany","followers_url":"https://api.github.com/users/geany/followers","following_url":"https://api.github.com/users/geany/following{/other_user}","gists_url":"https://api.github.com/users/geany/gists{/gist_id}","starred_url":"https://api.github.com/users/geany/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geany/subscriptions","organizations_url":"https://api.github.com/users/geany/orgs","repos_url":"https://api.github.com/users/geany/repos","events_url":"https://api.github.com/users/geany/events{/privacy}","received_events_url":"https://api.github.com/users/geany/received_events","type":"Organization","site_admin":false},"repo":{"id":2532922,"name":"geany","full_name":"geany/geany","owner":{"login":"geany","id":1108795,"avatar_url":"https://avatars.githubusercontent.com/u/1108795?v=3","gravatar_id":"","url":"https://api.github.com/users/geany","html_url":"https://github.com/geany","followers_url":"https://api.github.com/users/geany/followers","following_url":"https://api.github.com/users/geany/following{/other_user}","gists_url":"https://api.github.com/users/geany/gists{/gist_id}","starred_url":"https://api.github.com/users/geany/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/geany/subscriptions","organizations_url":"https://api.github.com/users/geany/orgs","repos_url":"https://api.github.com/users/geany/repos","events_url":"https://api.github.com/users/geany/events{/privacy}","received_events_url":"https://api.github.com/users/geany/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/geany/geany","description":"A fast and lightweight IDE","fork":false,"url":"https://api.github.com/repos/geany/geany","forks_url":"https://api.github.com/repos/geany/geany/forks","keys_url":"https://api.github.com/repos/geany/geany/keys{/key_id}","collaborators_url":"https://api.github.com/repos/geany/geany/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/geany/geany/teams","hooks_url":"https://api.github.com/repos/geany/geany/hooks","issue_events_url":"https://api.github.com/repos/geany/geany/issues/events{/number}","events_url":"https://api.github.com/repos/geany/geany/events","assignees_url":"https://api.github.com/repos/geany/geany/assignees{/user}","branches_url":"https://api.github.com/repos/geany/geany/branches{/branch}","tags_url":"https://api.github.com/repos/geany/geany/tags","blobs_url":"https://api.github.com/repos/geany/geany/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/geany/geany/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/geany/geany/git/refs{/sha}","trees_url":"https://api.github.com/repos/geany/geany/git/trees{/sha}","statuses_url":"https://api.github.com/repos/geany/geany/statuses/{sha}","languages_url":"https://api.github.com/repos/geany/geany/languages","stargazers_url":"https://api.github.com/repos/geany/geany/stargazers","contributors_url":"https://api.github.com/repos/geany/geany/contributors","subscribers_url":"https://api.github.com/repos/geany/geany/subscribers","subscription_url":"https://api.github.com/repos/geany/geany/subscription","commits_url":"https://api.github.com/repos/geany/geany/commits{/sha}","git_commits_url":"https://api.github.com/repos/geany/geany/git/commits{/sha}","comments_url":"https://api.github.com/repos/geany/geany/comments{/number}","issue_comment_url":"https://api.github.com/repos/geany/geany/issues/comments{/number}","contents_url":"https://api.github.com/repos/geany/geany/contents/{+path}","compare_url":"https://api.github.com/repos/geany/geany/compare/{base}...{head}","merges_url":"https://api.github.com/repos/geany/geany/merges","archive_url":"https://api.github.com/repos/geany/geany/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/geany/geany/downloads","issues_url":"https://api.github.com/repos/geany/geany/issues{/number}","pulls_url":"https://api.github.com/repos/geany/geany/pulls{/number}","milestones_url":"https://api.github.com/repos/geany/geany/milestones{/number}","notifications_url":"https://api.github.com/repos/geany/geany/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/geany/geany/labels{/name}","releases_url":"https://api.github.com/repos/geany/geany/releases{/id}","deployments_url":"https://api.github.com/repos/geany/geany/deployments","created_at":"2011-10-07T14:25:32Z","updated_at":"2016-09-20T02:36:52Z","pushed_at":"2016-09-22T02:44:00Z","git_url":"git://github.com/geany/geany.git","ssh_url":"git@github.com:geany/geany.git","clone_url":"https://github.com/geany/geany.git","svn_url":"https://github.com/geany/geany","homepage":"http://www.geany.org","size":58794,"stargazers_count":813,"watchers_count":813,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":282,"mirror_url":null,"open_issues_count":419,"forks":282,"open_issues":419,"watchers":813,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/geany/geany/pulls/1244"},"html":{"href":"https://github.com/geany/geany/pull/1244"},"issue":{"href":"https://api.github.com/repos/geany/geany/issues/1244"},"comments":{"href":"https://api.github.com/repos/geany/geany/issues/1244/comments"},"review_comments":{"href":"https://api.github.com/repos/geany/geany/pulls/1244/comments"},"review_comment":{"href":"https://api.github.com/repos/geany/geany/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/geany/geany/pulls/1244/commits"},"statuses":{"href":"https://api.github.com/repos/geany/geany/statuses/ac66af8e2ff450dfa2e02b2f42fe623813f83b1c"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":3,"additions":216,"deletions":19,"changed_files":3}}
{"actor":{"display_login":"codebrainz"}}