{"action":"created","comment":{"url":"https://api.github.com/repos/awesomeWM/awesome/pulls/comments/66703040","id":66703040,"diff_hunk":"@@ -0,0 +1,160 @@\n+# Using Cairo and LGI\n+\n+These days, Awesome interface is mostly based on a library called LGI. It allows\n+to access C libraries such as GTK, GLib, Cairo, Pango, PangoCairo and RSVG using\n+Lua code without having to write actual \"glue\" C code.\n+\n+This is done using the GObject-introspection framework. The main advantage is\n+the time saved and large number of features exposed for free. The downside is\n+the lack of proper Lua contric documentation and examples. Some examples can be\n+found in [LGI own documentation](https://github.com/pavouk/lgi/tree/master/docs)\n+, but this doesn't even cover 1% of the actual API. Using other APIs require\n+some trial and errors. It can also prove impossible if the introspection data\n+is missing in inacurate. Using those low level APIs directly is also crash\n+prone. It is the programmer responsability to properly check return and errors\n+values.\n+\n+## Using LGI in Awesome\n+\n+GObject and Gnome centric libraries tend to use the common C practive of\n+emulating namespaces using underscores in funciton name. LGI expose a proper\n+namespace based API. For example, if the C function is:\n+\n+    cairo_image_surface_create()\n+\n+Then LGI equivalent is:\n+\n+    lgi.cairo.ImageSurface.create()\n+\n+The same goes for enums:\n+\n+    CAIRO_FORMAT_ARGB32\n+\n+become:\n+\n+    lgi.cairo.Format.ARGB32\n+\n+LGI is also object oriented while the C API is function based. When those\n+function take the \"class\" \"object\", then this:\n+\n+    cairo_line_to(cr, x, y)\n+\n+can be expressed as:\n+\n+    cr:line_to(x, y)\n+\n+It is however important to note some inconsistencies. For example, Cairo is\n+called `lgi.cairo` while GLib is called `lgi.GLib`. Figuring this out will\n+require some tried and errors. The best way to do this without actually\n+reloading Awesome is to open the `lua` command in a terminal and using `print`:\n+\n+    print(\"This will print a table address:\", require(\"lgi\").cairo)\n+    print(\"This will print an error:\", require(\"lgi\").Cairo)\n+\n+It is recommanded to avoid using `require` everytime you use a function and\n+instead include the libraries at the top of your `rc.lua` or lua module\n+\n+    local cairo = require(\"lgi\").cairo\n+\n+## The Cairo API\n+\n+Cairo is a 2D graphic library used by Awesome, Gnome and XFCE. It allows to\n+paint paths on a `surface`. Awesome use it internally and being able to call\n+is directly should be considered a power user feature.\n+\n+Understanding these few important concepts is necessary to be able to use Cairo:\n+\n+**Surface**:\n+\n+A surface is the area where the painting will be done. There is multiple types\n+of surfaces including:\n+\n+ * Color pixmap with transparency (`ARGB32`) or without (`RGB24`)\n+ * Monochrome pixmap surfaces with transparency (`A8`) or without (`A1`)\n+ * SVG vectorial surfaces\n+ * Native (XCB) surfaces\n+ * Framebuffers and other less interesting ones from an AwesomeWM point of view.\n+\n+For more details, read:\n+\n+* [Surfaces](https://cairographics.org/manual/cairo-Image-Surfaces.html).\n+\n+**Sources**:\n+\n+Sources are elements like colors, patterns or gradient. See `gears.color` for\n+common sources.\n+\n+For more details, read:\n+\n+* [Pattern](http://cairographics.org/manual/cairo-cairo-pattern-t.html)\n+\n+**Context and paths**:\n+\n+A context is the proxy between the program and the surface. The context hold a\n+set of paths. Paths are something like a line, circle or rectangle. They may or","path":"docs/06-using-cairo.md","position":94,"original_position":94,"commit_id":"4395640776a4ad86e2a9c3a5528912c33ac57f49","original_commit_id":"4395640776a4ad86e2a9c3a5528912c33ac57f49","user":{"login":"psychon","id":89482,"avatar_url":"https://avatars.githubusercontent.com/u/89482?v=3","gravatar_id":"","url":"https://api.github.com/users/psychon","html_url":"https://github.com/psychon","followers_url":"https://api.github.com/users/psychon/followers","following_url":"https://api.github.com/users/psychon/following{/other_user}","gists_url":"https://api.github.com/users/psychon/gists{/gist_id}","starred_url":"https://api.github.com/users/psychon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/psychon/subscriptions","organizations_url":"https://api.github.com/users/psychon/orgs","repos_url":"https://api.github.com/users/psychon/repos","events_url":"https://api.github.com/users/psychon/events{/privacy}","received_events_url":"https://api.github.com/users/psychon/received_events","type":"User","site_admin":false},"body":"Technically (in cairo's term), it's a single path and not a set of paths...","created_at":"2016-06-11T08:34:01Z","updated_at":"2016-06-11T08:34:01Z","html_url":"https://github.com/awesomeWM/awesome/pull/959#discussion_r66703040","pull_request_url":"https://api.github.com/repos/awesomeWM/awesome/pulls/959","_links":{"self":{"href":"https://api.github.com/repos/awesomeWM/awesome/pulls/comments/66703040"},"html":{"href":"https://github.com/awesomeWM/awesome/pull/959#discussion_r66703040"},"pull_request":{"href":"https://api.github.com/repos/awesomeWM/awesome/pulls/959"}}},"pull_request":{"url":"https://api.github.com/repos/awesomeWM/awesome/pulls/959","id":73457685,"html_url":"https://github.com/awesomeWM/awesome/pull/959","diff_url":"https://github.com/awesomeWM/awesome/pull/959.diff","patch_url":"https://github.com/awesomeWM/awesome/pull/959.patch","issue_url":"https://api.github.com/repos/awesomeWM/awesome/issues/959","number":959,"state":"open","locked":false,"title":"doc: Add a Cairo/LGI introduction page","user":{"login":"Elv13","id":340384,"avatar_url":"https://avatars.githubusercontent.com/u/340384?v=3","gravatar_id":"","url":"https://api.github.com/users/Elv13","html_url":"https://github.com/Elv13","followers_url":"https://api.github.com/users/Elv13/followers","following_url":"https://api.github.com/users/Elv13/following{/other_user}","gists_url":"https://api.github.com/users/Elv13/gists{/gist_id}","starred_url":"https://api.github.com/users/Elv13/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Elv13/subscriptions","organizations_url":"https://api.github.com/users/Elv13/orgs","repos_url":"https://api.github.com/users/Elv13/repos","events_url":"https://api.github.com/users/Elv13/events{/privacy}","received_events_url":"https://api.github.com/users/Elv13/received_events","type":"User","site_admin":false},"body":"Try to make @funeralismatic a happy user ","created_at":"2016-06-11T03:53:20Z","updated_at":"2016-06-11T08:34:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"2f65dac88c0e4ae316c7aa51d5a10eba6daecc89","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/awesomeWM/awesome/pulls/959/commits","review_comments_url":"https://api.github.com/repos/awesomeWM/awesome/pulls/959/comments","review_comment_url":"https://api.github.com/repos/awesomeWM/awesome/pulls/comments{/number}","comments_url":"https://api.github.com/repos/awesomeWM/awesome/issues/959/comments","statuses_url":"https://api.github.com/repos/awesomeWM/awesome/statuses/4395640776a4ad86e2a9c3a5528912c33ac57f49","head":{"label":"Elv13:cairo_lgi_doc","ref":"cairo_lgi_doc","sha":"4395640776a4ad86e2a9c3a5528912c33ac57f49","user":{"login":"Elv13","id":340384,"avatar_url":"https://avatars.githubusercontent.com/u/340384?v=3","gravatar_id":"","url":"https://api.github.com/users/Elv13","html_url":"https://github.com/Elv13","followers_url":"https://api.github.com/users/Elv13/followers","following_url":"https://api.github.com/users/Elv13/following{/other_user}","gists_url":"https://api.github.com/users/Elv13/gists{/gist_id}","starred_url":"https://api.github.com/users/Elv13/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Elv13/subscriptions","organizations_url":"https://api.github.com/users/Elv13/orgs","repos_url":"https://api.github.com/users/Elv13/repos","events_url":"https://api.github.com/users/Elv13/events{/privacy}","received_events_url":"https://api.github.com/users/Elv13/received_events","type":"User","site_admin":false},"repo":{"id":17379398,"name":"awesome-1","full_name":"Elv13/awesome-1","owner":{"login":"Elv13","id":340384,"avatar_url":"https://avatars.githubusercontent.com/u/340384?v=3","gravatar_id":"","url":"https://api.github.com/users/Elv13","html_url":"https://github.com/Elv13","followers_url":"https://api.github.com/users/Elv13/followers","following_url":"https://api.github.com/users/Elv13/following{/other_user}","gists_url":"https://api.github.com/users/Elv13/gists{/gist_id}","starred_url":"https://api.github.com/users/Elv13/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Elv13/subscriptions","organizations_url":"https://api.github.com/users/Elv13/orgs","repos_url":"https://api.github.com/users/Elv13/repos","events_url":"https://api.github.com/users/Elv13/events{/privacy}","received_events_url":"https://api.github.com/users/Elv13/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Elv13/awesome-1","description":"Semi-official mirror of the awesome window manager from git://git.naquadah.org/awesome.git, updated hourly.","fork":true,"url":"https://api.github.com/repos/Elv13/awesome-1","forks_url":"https://api.github.com/repos/Elv13/awesome-1/forks","keys_url":"https://api.github.com/repos/Elv13/awesome-1/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Elv13/awesome-1/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Elv13/awesome-1/teams","hooks_url":"https://api.github.com/repos/Elv13/awesome-1/hooks","issue_events_url":"https://api.github.com/repos/Elv13/awesome-1/issues/events{/number}","events_url":"https://api.github.com/repos/Elv13/awesome-1/events","assignees_url":"https://api.github.com/repos/Elv13/awesome-1/assignees{/user}","branches_url":"https://api.github.com/repos/Elv13/awesome-1/branches{/branch}","tags_url":"https://api.github.com/repos/Elv13/awesome-1/tags","blobs_url":"https://api.github.com/repos/Elv13/awesome-1/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Elv13/awesome-1/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Elv13/awesome-1/git/refs{/sha}","trees_url":"https://api.github.com/repos/Elv13/awesome-1/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Elv13/awesome-1/statuses/{sha}","languages_url":"https://api.github.com/repos/Elv13/awesome-1/languages","stargazers_url":"https://api.github.com/repos/Elv13/awesome-1/stargazers","contributors_url":"https://api.github.com/repos/Elv13/awesome-1/contributors","subscribers_url":"https://api.github.com/repos/Elv13/awesome-1/subscribers","subscription_url":"https://api.github.com/repos/Elv13/awesome-1/subscription","commits_url":"https://api.github.com/repos/Elv13/awesome-1/commits{/sha}","git_commits_url":"https://api.github.com/repos/Elv13/awesome-1/git/commits{/sha}","comments_url":"https://api.github.com/repos/Elv13/awesome-1/comments{/number}","issue_comment_url":"https://api.github.com/repos/Elv13/awesome-1/issues/comments{/number}","contents_url":"https://api.github.com/repos/Elv13/awesome-1/contents/{+path}","compare_url":"https://api.github.com/repos/Elv13/awesome-1/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Elv13/awesome-1/merges","archive_url":"https://api.github.com/repos/Elv13/awesome-1/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Elv13/awesome-1/downloads","issues_url":"https://api.github.com/repos/Elv13/awesome-1/issues{/number}","pulls_url":"https://api.github.com/repos/Elv13/awesome-1/pulls{/number}","milestones_url":"https://api.github.com/repos/Elv13/awesome-1/milestones{/number}","notifications_url":"https://api.github.com/repos/Elv13/awesome-1/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Elv13/awesome-1/labels{/name}","releases_url":"https://api.github.com/repos/Elv13/awesome-1/releases{/id}","deployments_url":"https://api.github.com/repos/Elv13/awesome-1/deployments","created_at":"2014-03-03T20:41:58Z","updated_at":"2014-11-01T22:48:43Z","pushed_at":"2016-06-11T04:32:26Z","git_url":"git://github.com/Elv13/awesome-1.git","ssh_url":"git@github.com:Elv13/awesome-1.git","clone_url":"https://github.com/Elv13/awesome-1.git","svn_url":"https://github.com/Elv13/awesome-1","homepage":"https://awesome.naquadah.org/","size":11687,"stargazers_count":0,"watchers_count":0,"language":"C","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":9,"forks":0,"open_issues":9,"watchers":0,"default_branch":"master"}},"base":{"label":"awesomeWM:master","ref":"master","sha":"d4dc579105d1a9321aefe481444b6673865c278b","user":{"login":"awesomeWM","id":6843364,"avatar_url":"https://avatars.githubusercontent.com/u/6843364?v=3","gravatar_id":"","url":"https://api.github.com/users/awesomeWM","html_url":"https://github.com/awesomeWM","followers_url":"https://api.github.com/users/awesomeWM/followers","following_url":"https://api.github.com/users/awesomeWM/following{/other_user}","gists_url":"https://api.github.com/users/awesomeWM/gists{/gist_id}","starred_url":"https://api.github.com/users/awesomeWM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awesomeWM/subscriptions","organizations_url":"https://api.github.com/users/awesomeWM/orgs","repos_url":"https://api.github.com/users/awesomeWM/repos","events_url":"https://api.github.com/users/awesomeWM/events{/privacy}","received_events_url":"https://api.github.com/users/awesomeWM/received_events","type":"Organization","site_admin":false},"repo":{"id":17378009,"name":"awesome","full_name":"awesomeWM/awesome","owner":{"login":"awesomeWM","id":6843364,"avatar_url":"https://avatars.githubusercontent.com/u/6843364?v=3","gravatar_id":"","url":"https://api.github.com/users/awesomeWM","html_url":"https://github.com/awesomeWM","followers_url":"https://api.github.com/users/awesomeWM/followers","following_url":"https://api.github.com/users/awesomeWM/following{/other_user}","gists_url":"https://api.github.com/users/awesomeWM/gists{/gist_id}","starred_url":"https://api.github.com/users/awesomeWM/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/awesomeWM/subscriptions","organizations_url":"https://api.github.com/users/awesomeWM/orgs","repos_url":"https://api.github.com/users/awesomeWM/repos","events_url":"https://api.github.com/users/awesomeWM/events{/privacy}","received_events_url":"https://api.github.com/users/awesomeWM/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/awesomeWM/awesome","description":"awesome window manager","fork":false,"url":"https://api.github.com/repos/awesomeWM/awesome","forks_url":"https://api.github.com/repos/awesomeWM/awesome/forks","keys_url":"https://api.github.com/repos/awesomeWM/awesome/keys{/key_id}","collaborators_url":"https://api.github.com/repos/awesomeWM/awesome/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/awesomeWM/awesome/teams","hooks_url":"https://api.github.com/repos/awesomeWM/awesome/hooks","issue_events_url":"https://api.github.com/repos/awesomeWM/awesome/issues/events{/number}","events_url":"https://api.github.com/repos/awesomeWM/awesome/events","assignees_url":"https://api.github.com/repos/awesomeWM/awesome/assignees{/user}","branches_url":"https://api.github.com/repos/awesomeWM/awesome/branches{/branch}","tags_url":"https://api.github.com/repos/awesomeWM/awesome/tags","blobs_url":"https://api.github.com/repos/awesomeWM/awesome/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/awesomeWM/awesome/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/awesomeWM/awesome/git/refs{/sha}","trees_url":"https://api.github.com/repos/awesomeWM/awesome/git/trees{/sha}","statuses_url":"https://api.github.com/repos/awesomeWM/awesome/statuses/{sha}","languages_url":"https://api.github.com/repos/awesomeWM/awesome/languages","stargazers_url":"https://api.github.com/repos/awesomeWM/awesome/stargazers","contributors_url":"https://api.github.com/repos/awesomeWM/awesome/contributors","subscribers_url":"https://api.github.com/repos/awesomeWM/awesome/subscribers","subscription_url":"https://api.github.com/repos/awesomeWM/awesome/subscription","commits_url":"https://api.github.com/repos/awesomeWM/awesome/commits{/sha}","git_commits_url":"https://api.github.com/repos/awesomeWM/awesome/git/commits{/sha}","comments_url":"https://api.github.com/repos/awesomeWM/awesome/comments{/number}","issue_comment_url":"https://api.github.com/repos/awesomeWM/awesome/issues/comments{/number}","contents_url":"https://api.github.com/repos/awesomeWM/awesome/contents/{+path}","compare_url":"https://api.github.com/repos/awesomeWM/awesome/compare/{base}...{head}","merges_url":"https://api.github.com/repos/awesomeWM/awesome/merges","archive_url":"https://api.github.com/repos/awesomeWM/awesome/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/awesomeWM/awesome/downloads","issues_url":"https://api.github.com/repos/awesomeWM/awesome/issues{/number}","pulls_url":"https://api.github.com/repos/awesomeWM/awesome/pulls{/number}","milestones_url":"https://api.github.com/repos/awesomeWM/awesome/milestones{/number}","notifications_url":"https://api.github.com/repos/awesomeWM/awesome/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/awesomeWM/awesome/labels{/name}","releases_url":"https://api.github.com/repos/awesomeWM/awesome/releases{/id}","deployments_url":"https://api.github.com/repos/awesomeWM/awesome/deployments","created_at":"2014-03-03T19:56:16Z","updated_at":"2016-06-10T20:37:44Z","pushed_at":"2016-06-11T04:32:27Z","git_url":"git://github.com/awesomeWM/awesome.git","ssh_url":"git@github.com:awesomeWM/awesome.git","clone_url":"https://github.com/awesomeWM/awesome.git","svn_url":"https://github.com/awesomeWM/awesome","homepage":"https://awesomewm.org/","size":16103,"stargazers_count":772,"watchers_count":772,"language":"Lua","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":118,"mirror_url":null,"open_issues_count":119,"forks":118,"open_issues":119,"watchers":772,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/awesomeWM/awesome/pulls/959"},"html":{"href":"https://github.com/awesomeWM/awesome/pull/959"},"issue":{"href":"https://api.github.com/repos/awesomeWM/awesome/issues/959"},"comments":{"href":"https://api.github.com/repos/awesomeWM/awesome/issues/959/comments"},"review_comments":{"href":"https://api.github.com/repos/awesomeWM/awesome/pulls/959/comments"},"review_comment":{"href":"https://api.github.com/repos/awesomeWM/awesome/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/awesomeWM/awesome/pulls/959/commits"},"statuses":{"href":"https://api.github.com/repos/awesomeWM/awesome/statuses/4395640776a4ad86e2a9c3a5528912c33ac57f49"}}}}
{"actor":{"display_login":"psychon"}}