├── patches ├── gobject.d.ts └── gio.d.ts ├── changes.md ├── .gitignore ├── .npmignore ├── example ├── imports.ts ├── example.coffee ├── example.ts ├── browser.ts ├── client.ts ├── browser.js ├── record-collection.coffee ├── record-collection.ts ├── liststore.coffee └── record-collection.js ├── .vscode ├── launch.json └── tasks.json ├── license.md ├── tsconfig.json ├── package.json ├── src ├── common.js ├── gjs.d.ts ├── gjs.js ├── atk-1.0.d.ts ├── pango-1.0.d.ts ├── gtksource-3.0.d.ts ├── gobject-2.0.d.ts └── soup-2.4.d.ts ├── exceptions ├── readme.md ├── index.js ├── gir2dts.json ├── gir2dts └── bin └── gir2dts /patches/gobject.d.ts: -------------------------------------------------------------------------------- 1 | export const TYPE_STRING: number 2 | -------------------------------------------------------------------------------- /changes.md: -------------------------------------------------------------------------------- 1 | ### changes 2 | 3 | 03-24-2017 0.1.3 - add ./bin command file -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .tscache 2 | dist 3 | build 4 | node_modules 5 | bower_components 6 | packages 7 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .tscache 2 | dist 3 | build 4 | node_modules 5 | bower_components 6 | packages 7 | gir 8 | -------------------------------------------------------------------------------- /example/imports.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Import ambient modules 3 | */ 4 | define.imports({ 5 | Gda: imports.gi.Gda, 6 | Soup: imports.gi.Soup, 7 | WebKit: imports.gi.WebKit 8 | }) 9 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | "name": "Debug", 6 | "type": "lldb", 7 | "request": "launch", 8 | "cwd": "${workspaceRoot}", 9 | "program": "/usr/bin/gjs", 10 | "args": ["./index.js"] 11 | } 12 | ] 13 | } -------------------------------------------------------------------------------- /patches/gio.d.ts: -------------------------------------------------------------------------------- 1 | export class File extends GObject.Object { 2 | query_exists(obj:any): boolean 3 | load_contents(obj:any): any 4 | make_directory(obj:any): boolean 5 | delete(obj:any): boolean 6 | create(flags:any, obj: any): any 7 | get_basename(): string 8 | get_path(): string 9 | get_parent():File 10 | static new_for_path(path: string): File 11 | } 12 | 13 | -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.1.0", 3 | "command": "/bin/sh", 4 | "cwd": "${workspaceRoot}", 5 | "isShellCommand": true, 6 | "args": ["-c"], 7 | "showOutput": "always", 8 | "echoCommand": true, 9 | "suppressTaskName": true, 10 | "tasks": [ 11 | { 12 | "isBuildCommand": true, 13 | "taskName": "build", 14 | "args": ["/usr/bin/time tsc"] 15 | } 16 | ] 17 | } -------------------------------------------------------------------------------- /license.md: -------------------------------------------------------------------------------- 1 | # Apache 2.0 License 2 | 3 | Copyright (c) 2017 Bruce Davidson <darkoverlordofdata@gmail.com> 4 | 5 | Licensed under the Apache License, Version 2.0 (the "License"); 6 | you may not use this file except in compliance with the License. 7 | You may obtain a copy of the License at 8 | 9 | http://www.apache.org/licenses/LICENSE-2.0 10 | 11 | Unless required by applicable law or agreed to in writing, software 12 | distributed under the License is distributed on an "AS IS" BASIS, 13 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | See the License for the specific language governing permissions and 15 | limitations under the License. 16 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "target": "es5", 4 | "module": "amd", 5 | "rootDir": "src", 6 | "allowJs": true, 7 | "allowUnreachableCode": true, 8 | "allowUnusedLabels": true, 9 | "outFile": "index.js" 10 | }, 11 | "files": [ 12 | "src/webkit-3.0.d.ts", 13 | "src/soup-2.4.d.ts", 14 | "src/pango-1.0.d.ts", 15 | "src/gdk-3.0.d.ts", 16 | "src/gtk-3.0.d.ts", 17 | "src/gtksource-3.0.d.ts", 18 | "src/gobject-2.0.d.ts", 19 | "src/glib-2.0.d.ts", 20 | "src/gio-2.0.d.ts", 21 | "src/gda-5.0.d.ts", 22 | "src/atk-1.0.d.ts", 23 | "src/gjs.d.ts", 24 | "src/gjs.js", 25 | "example/imports.ts", 26 | "example/example.ts" 27 | ] 28 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gir2dts", 3 | "version": "0.1.3", 4 | "description": "Convert gir metadata to *.d.ts format", 5 | "main": "index.js", 6 | "bin": { 7 | "gir2dts": "./bin/gir2dts" 8 | }, 9 | "scripts": { 10 | "test": "echo \"Error: no test specified\" && exit 1", 11 | "start": "node ./index" 12 | }, 13 | "repository": { 14 | "type": "git", 15 | "url": "https://github.com/darkoverlordofdata/gir2dts.git" 16 | }, 17 | "keywords": [ 18 | "typescript", 19 | "gtk" 20 | ], 21 | "author": "darkoverlordofdata", 22 | "license": "Apache-2.0", 23 | "bugs": { 24 | "url": "https://github.com/darkoverlordofdata/gir2dts/issues" 25 | }, 26 | "homepage": "https://github.com/darkoverlordofdata/gir2dts#readme", 27 | "dependencies": { 28 | }, 29 | "devDependencies": { 30 | "xml2js": "^0.4.17" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/common.js: -------------------------------------------------------------------------------- 1 | (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.bundle = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o any'. 6 | Types of parameters 'flags' and 'first_property_name' are incompatible. 7 | Type 'string' is not assignable to type 'DBusObjectManagerClientFlags'. 8 | 9 | gir/gio-2.0.d.ts(1094,18): error TS2417: Class static side 'typeof DBusProxy' incorrectly extends base class static side 'typeof Object'. 10 | Types of property 'new' are incompatible. 11 | Type '(connection: DBusConnection, flags: DBusProxyFlags, info: any, name: string, object_path: string,...' is not assignable to type '(object_type: any, first_property_name: string, ...args: any[]) => any'. 12 | Types of parameters 'flags' and 'first_property_name' are incompatible. 13 | Type 'string' is not assignable to type 'DBusProxyFlags'. 14 | -------------------------------------------------------------------------------- /src/gjs.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * gjs.d.ts 3 | * 4 | * Gjs basic declarations for typescript 5 | */ 6 | 7 | /** 8 | * Command line args 9 | */ 10 | declare const ARGV: string[] 11 | /** 12 | * print to console 13 | */ 14 | declare function print(...args: any[]) 15 | declare function printerr(...args: any[]) 16 | declare function log(message: any) 17 | declare function logError(message: any) 18 | /** 19 | * get module as value 20 | */ 21 | declare function require(name: string): any 22 | /** 23 | * localization - imports.gettext.gettext 24 | */ 25 | declare function _(str:string): string 26 | 27 | /** 28 | * native imports 29 | */ 30 | declare namespace imports { 31 | var cairo: any 32 | var dbus: any 33 | var format: any 34 | var gettext: any 35 | var gi: any 36 | var jsUnit: any 37 | var lang: any 38 | var promise: any 39 | var misc: any 40 | var signals: any 41 | var ui: any 42 | } 43 | 44 | /** 45 | * define module 46 | * 47 | * @param name of module 48 | * @param deps list of dependencies 49 | * @param callback definition 50 | * 51 | */ 52 | declare namespace define { 53 | export var version: string 54 | export function path(path: string) 55 | export function imports(libraries: any) 56 | } 57 | 58 | /** 59 | * extend String with imports.format.format 60 | */ 61 | declare interface String { 62 | printf(...args: any[]): string 63 | } 64 | 65 | /** 66 | * Gnome class polyfills 67 | */ 68 | declare module "Lang" { 69 | export function Class(properties: any): void 70 | } 71 | -------------------------------------------------------------------------------- /src/gjs.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2017 darkoverlordofdata 3 | * 4 | * Simple module loader/gjs helper 5 | * normalized access to amd, commonjs and gjs imports 6 | * 7 | */ 8 | Object.defineProperties(window, { 9 | define: { value: (function (modules) { 10 | return (name, deps, callback) => { 11 | if (typeof name !== 'string') { /* browserify bundle */ 12 | const bundle = deps() 13 | for (name in bundle) 14 | modules[name] = { id: name, exports: bundle[name] } 15 | 16 | } else { /* amd module */ 17 | modules[name] = { id: name, exports: {} } 18 | const args = [(name) => modules[name] ? modules[name].exports : imports[name], 19 | modules[name].exports] 20 | for (let i = 2; i < deps.length; i++) 21 | args.push(modules[deps[i]].exports) 22 | callback.apply(modules[name].exports, args) 23 | } 24 | } 25 | }({ /* builtin modules */ 26 | Lang: { id: 'Lang', exports: imports.lang }, 27 | Gio: { id: 'Gio', exports: imports.gi.Gio }, 28 | Atk: { id: 'Atk', exports: imports.gi.Atk }, 29 | Gdk: { id: 'Gdk', exports: imports.gi.Gdk }, 30 | Gtk: { id: 'Gtk', exports: imports.gi.Gtk }, 31 | GLib: { id: 'GLib', exports: imports.gi.GLib }, 32 | Pango: { id: 'Pango', exports: imports.gi.Pango }, 33 | GObject: { id: 'GObject', exports: imports.gi.GObject } 34 | }))}, 35 | console: {value: { 36 | log() { print.apply(null, arguments) }, 37 | warn() { print.apply(null, arguments) }, 38 | error() { print.apply(null, arguments) }, 39 | info() { print.apply(null, arguments) } 40 | }}, 41 | _: {value: imports.gettext.gettext } 42 | }) 43 | Object.defineProperties(define, { 44 | amd: { value: true }, 45 | version: { value: '0.1.0' }, 46 | path: { value: (path) => imports.searchPath.unshift(path) }, 47 | imports: { value: (libs) => define([], ()=> libs)} 48 | }) 49 | Object.defineProperties(String.prototype, { 50 | printf: { value: imports.format.format } 51 | }) 52 | -------------------------------------------------------------------------------- /example/example.coffee: -------------------------------------------------------------------------------- 1 | #!/usr/bin/gjs 2 | ### 3 | # from https://media.readthedocs.org/pdf/gjs-tutorial/latest/gjs-tutorial.pdf 4 | # lesson 4.3 ListBox page 14 5 | ### 6 | Gtk = imports.gi.Gtk 7 | Lang = imports.lang 8 | 9 | class ListBoxRowWithData 10 | constructor: (data) -> 11 | @gob = new Gtk.ListBoxRow() 12 | @gob.data = data 13 | @gob.add new Gtk.Label(label: data) 14 | 15 | class ListBoxWindow 16 | constructor: () -> 17 | @gob = new Gtk.Window(title: "ListBox Demo") 18 | @border_width = 10 19 | 20 | box_outer = new Gtk.Box(orientation: Gtk.Orientation.VERTICAL, spacing: 6) 21 | @gob.add box_outer 22 | 23 | listbox = new Gtk.ListBox() 24 | listbox.selection_mode = Gtk.SelectionMode.NONE 25 | box_outer.pack_start listbox, true, true, 0 26 | 27 | row = new Gtk.ListBoxRow() 28 | hbox = new Gtk.Box(orientation: Gtk.Orientation.HORIZONTAL, spacing: 50) 29 | row.add hbox 30 | vbox = new Gtk.Box(orientation: Gtk.Orientation.VERTICAL) 31 | hbox.pack_start vbox, true, true, 0 32 | 33 | label1 = new Gtk.Label(label: "Automatic Date & Time", xalign: 0) 34 | label2 = new Gtk.Label(label: "Requires internet access", xalign: 0) 35 | vbox.pack_start label1, true, true, 0 36 | vbox.pack_start label2, true, true, 0 37 | 38 | swtch = new Gtk.Switch() 39 | swtch.valign = Gtk.Align.CENTER 40 | hbox.pack_start swtch, false, true, 0 41 | 42 | listbox.add row 43 | 44 | row = new Gtk.ListBoxRow() 45 | hbox = new Gtk.Box(orientation: Gtk.Orientation.HORIZONTAL, spacing: 50) 46 | row.add hbox 47 | label = new Gtk.Label(label: "Enable Automatic Update", xalign: 0) 48 | check = new Gtk.CheckButton() 49 | hbox.pack_start label, true, true, 0 50 | hbox.pack_start check, false, true, 0 51 | 52 | listbox.add row 53 | 54 | row = new Gtk.ListBoxRow() 55 | hbox = new Gtk.Box(orientation: Gtk.Orientation.HORIZONTAL, spacing: 50) 56 | row.add hbox 57 | label = new Gtk.Label(label: "Date Format", xalign: 0) 58 | combo = new Gtk.ComboBoxText() 59 | combo.insert 0, "0", "24-hour" 60 | combo.insert 1, "1", "AM/PM" 61 | hbox.pack_start label, true, true, 0 62 | hbox.pack_start combo, false, true, 0 63 | 64 | listbox.add row 65 | listbox2 = new Gtk.ListBox() 66 | items = "This is a sorted ListBox Fail".split(' ') 67 | 68 | items.forEach (item) => 69 | listbox2.add(new ListBoxRowWithData(item).gob) 70 | 71 | sortFunc = (row1, row2, data, notifyDestroy) => 72 | row1.data.toLowerCase() > row2.data.toLowerCase() 73 | 74 | filterFunc = (row, data, notifyDestroy) => 75 | (row.data != 'Fail') 76 | 77 | listbox2.connect "row-activated", (widget, row) => 78 | print(row.data) 79 | 80 | listbox2.set_sort_func sortFunc, null, false 81 | listbox2.set_filter_func filterFunc, null, false 82 | 83 | box_outer.pack_start listbox2, true, true, 0 84 | listbox2.show_all() 85 | 86 | Gtk.init null 87 | win = new ListBoxWindow() 88 | win.gob.connect "delete-event", Gtk.main_quit 89 | win.gob.show_all() 90 | Gtk.main() 91 | -------------------------------------------------------------------------------- /example/example.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * from https://media.readthedocs.org/pdf/gjs-tutorial/latest/gjs-tutorial.pdf 3 | * lesson 4.3 ListBox page 14 4 | */ 5 | import * as Gtk from 'Gtk' 6 | 7 | class ListBoxRowWithData { 8 | object: Gtk.ListBoxRow 9 | constructor(data) { 10 | this.object = new Gtk.ListBoxRow() 11 | /* create a custom 'data' field for sorting */ 12 | this.object['data'] = data 13 | this.object.add(new Gtk.Label({label: data})) 14 | } 15 | } 16 | 17 | class ListBoxWindow { 18 | object: Gtk.Window 19 | constructor() { 20 | this.object = new Gtk.Window({ 21 | window_position: Gtk.WindowPosition.CENTER, 22 | title: "ListBox Demo" 23 | }) 24 | 25 | let box_outer = new Gtk.Box({orientation: Gtk.Orientation.VERTICAL, spacing: 6}) 26 | this.object.add(box_outer) 27 | 28 | let listbox = new Gtk.ListBox() 29 | // property not defined error: 30 | // listbox.selection_mode = Gtk.SelectionMode.NONE 31 | // use the api instead: 32 | listbox.set_selection_mode(Gtk.SelectionMode.NONE) 33 | box_outer.pack_start(listbox, true, true, 0) 34 | 35 | let row = new Gtk.ListBoxRow() 36 | let hbox = new Gtk.Box({orientation: Gtk.Orientation.HORIZONTAL, spacing: 50}) 37 | row.add(hbox) 38 | let vbox = new Gtk.Box({orientation: Gtk.Orientation.VERTICAL}) 39 | hbox.pack_start(vbox, true, true, 0) 40 | 41 | let label1 = new Gtk.Label({label: "Automatic Date & Time", xalign: 0}) 42 | let label2 = new Gtk.Label({label: "Requires internet access", xalign: 0}) 43 | vbox.pack_start(label1, true, true, 0) 44 | vbox.pack_start(label2, true, true, 0) 45 | 46 | let swtch = new Gtk.Switch() 47 | // property not defined error: 48 | // swtch.valign = Gtk.Align.CENTER 49 | // use the api instead: 50 | swtch.set_valign(Gtk.Align.CENTER) 51 | hbox.pack_start(swtch, false, true, 0) 52 | 53 | listbox.add(row) 54 | 55 | row = new Gtk.ListBoxRow() 56 | hbox = new Gtk.Box({orientation: Gtk.Orientation.HORIZONTAL, spacing: 50}) 57 | row.add(hbox) 58 | let label = new Gtk.Label({label: "Enable Automatic Update", xalign: 0}) 59 | let check = new Gtk.CheckButton() 60 | hbox.pack_start(label, true, true, 0) 61 | hbox.pack_start(check, false, true, 0) 62 | 63 | listbox.add(row) 64 | 65 | row = new Gtk.ListBoxRow() 66 | hbox = new Gtk.Box({orientation: Gtk.Orientation.HORIZONTAL, spacing: 50}) 67 | row.add(hbox) 68 | label = new Gtk.Label({label: "Date Format", xalign: 0}) 69 | let combo = new Gtk.ComboBoxText() 70 | combo.insert(0, "0", "24-hour") 71 | combo.insert(1, "1", "AM/PM") 72 | hbox.pack_start(label, true, true, 0) 73 | hbox.pack_start(combo, false, true, 0) 74 | 75 | listbox.add(row) 76 | let listbox2 = new Gtk.ListBox() 77 | let items = "This is a sorted ListBox Fail".split(' ') 78 | 79 | items.forEach((item) => listbox2.add(new ListBoxRowWithData(item).object)) 80 | 81 | let sortFunc = ((row1, row2, data, notifyDestroy) => row1.data.toLowerCase() > row2.data.toLowerCase()) 82 | 83 | let filterFunc = ((row, data, notifyDestroy) => (row.data != 'Fail')) 84 | 85 | listbox2.connect("row-activated", (widget, row) => print(row.data)) 86 | 87 | listbox2.set_sort_func(sortFunc, null, false) 88 | listbox2.set_filter_func(filterFunc, null, false) 89 | 90 | box_outer.pack_start(listbox2, true, true, 0) 91 | listbox2.show_all() 92 | } 93 | } 94 | Gtk.init(null) 95 | let win = new ListBoxWindow() 96 | win.object.connect("delete-event", Gtk.main_quit) 97 | win.object.show_all() 98 | Gtk.main() 99 | -------------------------------------------------------------------------------- /example/browser.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as Gtk from 'Gtk' 3 | import * as WebKit from 'WebKit' 4 | 5 | let argv = ARGV 6 | 7 | Gtk.init(null) 8 | let window = new Gtk.Window({ 9 | title: 'jsGtk+ browser', 10 | type : Gtk.WindowType.TOPLEVEL, 11 | window_position: Gtk.WindowPosition.CENTER 12 | }) 13 | let webView = new WebKit.WebView() 14 | 15 | let toolbar = new Gtk.Toolbar() 16 | // buttons to go back, go forward, or refresh 17 | let button = { 18 | back: Gtk.ToolButton.new_from_stock(Gtk.STOCK_GO_BACK), 19 | forward: Gtk.ToolButton.new_from_stock(Gtk.STOCK_GO_FORWARD), 20 | refresh: Gtk.ToolButton.new_from_stock(Gtk.STOCK_REFRESH) 21 | } 22 | // where the URL is written and shown 23 | let urlBar = new Gtk.Entry() 24 | // the browser container, so that's scrollable 25 | let scrollWindow = new Gtk.ScrolledWindow({}) 26 | // horizontal and vertical boxes 27 | let hbox = new Gtk.Box({orientation: Gtk.Orientation.HORIZONTAL}) 28 | let vbox = new Gtk.Box({orientation: Gtk.Orientation.VERTICAL}) 29 | 30 | let gtkSettings = Gtk.Settings.get_default() 31 | gtkSettings.gtk_application_prefer_dark_theme = true 32 | //gtkSettings.gtk_theme_name = 'Adwaita' 33 | 34 | //Setting up optional Dark theme (gotta love it!) 35 | //./browser.js google.com --dark 36 | if (argv.some(info => info === '--dark')) { 37 | let gtkSettings = Gtk.Settings.get_default() 38 | gtkSettings.gtk_application_prefer_dark_theme = true 39 | gtkSettings.gtk_theme_name = 'Adwaita' 40 | } else if(argv.some(info => info === '--light')) { 41 | let gtkSettings = Gtk.Settings.get_default() 42 | gtkSettings.gtk_application_prefer_dark_theme = false 43 | 44 | gtkSettings.gtk_theme_name = 'Adwaita' 45 | } 46 | 47 | // open first argument or shameless plug 48 | 49 | webView.load_uri(url(argv.filter(url => '-' !== url[0])[0] || 'https://darkoverlordofdata.com')) 50 | 51 | // can't change to new page until this gets fixed 52 | //whenever a new page is loaded ... 53 | webView.connect('document-load-finished', (widget, loadEvent, data) => { 54 | switch (loadEvent) { 55 | case 2: // XXX: where is WEBKIT_LOAD_COMMITTED ? 56 | // ... update the URL bar with the current adress 57 | urlBar.set_text(widget.get_uri()) 58 | button.back.set_sensitive(webView.can_go_back()) 59 | button.forward.set_sensitive(webView.can_go_forward()) 60 | break 61 | } 62 | }) 63 | 64 | // configure buttons actions 65 | button.back.connect('clicked', () => webView.go_back()) 66 | button.forward.connect('clicked', () => webView.go_forward()) 67 | button.refresh.connect('clicked', () => webView.reload()) 68 | 69 | // enrich the toolbar 70 | toolbar.add(button.back) 71 | toolbar.add(button.forward) 72 | toolbar.add(button.refresh) 73 | 74 | // define "enter" / call-to-action event 75 | // whenever the url changes on the bar 76 | urlBar.connect('activate', () => { 77 | let href = url(urlBar.get_text()) 78 | urlBar.set_text(href) 79 | webView.load_uri(href) 80 | }) 81 | 82 | // make the container scrollable 83 | scrollWindow.add(webView) 84 | 85 | // pack horizontally toolbar and url bar 86 | hbox.pack_start(toolbar, false, false, 0) 87 | hbox.pack_start(urlBar, true, true, 8) 88 | 89 | // pack vertically top bar (hbox) and scrollable window 90 | vbox.pack_start(hbox, false, true, 0) 91 | vbox.pack_start(scrollWindow, true, true, 0) 92 | 93 | // configure main window 94 | window.set_default_size(1024, 720) 95 | window.set_resizable(true) 96 | window.connect('show', () => { 97 | // bring it on top in OSX 98 | window.set_keep_above(true) 99 | Gtk.main() 100 | }) 101 | window.connect('destroy', () => Gtk.main_quit()) 102 | window.connect('delete_event', () => false) 103 | 104 | // add vertical ui and show them all 105 | window.add(vbox) 106 | window.show_all() 107 | 108 | // little helper 109 | // if link doesn't have a protocol, prefixes it via http:// 110 | function url(href) { 111 | return /^([a-z]{2,}):/.test(href) ? href : ('https://' + href) 112 | } 113 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # gir2dts # 2 | 3 | Generated *.d.ts files for using Gir with Typescript 4 | 5 | ## install 6 | ``` 7 | cd myproject 8 | npm install --save-dev gir2dts 9 | ``` 10 | then include in tsconfig.json 11 | 12 | ## example 13 | 14 | example tsconfig: (from https://github.com/darkoverlordofdata/bosco-player) 15 | ```json 16 | { 17 | "compilerOptions": { 18 | "target": "es5", // es5 compatability for gjs 19 | "module": "amd", // pack using amd module format 20 | "rootDir": "src", // module names based from src 21 | "outFile": "bin/bosco-player", // the target executable 22 | "allowJs": true 23 | }, 24 | "files": [ 25 | "node_modules/gir2dts/src/gjs.d.ts", // Gjs 26 | "node_modules/gir2dts/src/gobject-2.0.d.ts", // GObject 27 | "node_modules/gir2dts/src/atk-1.0.d.ts", // Atk 28 | "node_modules/gir2dts/src/glib-2.0.d.ts", // GLib 29 | "node_modules/gir2dts/src/gio-2.0.d.ts", // Gio 30 | "node_modules/gir2dts/src/gdk-3.0.d.ts", // Gdk 31 | "node_modules/gir2dts/src/gtk-3.0.d.ts", // Gtk 32 | "node_modules/gir2dts/src/pango-1.0.d.ts", // Pango 33 | "node_modules/gir2dts/src/gjs.js", // module loader/helper 34 | 35 | "src/common.d.ts", // nodejs: xml2js 36 | "src/common.js", // browserify bundle 37 | "src/main.ts" // main program entry point 38 | 39 | ] 40 | } 41 | ``` 42 | 43 | also, see https://github.com/darkoverlordofdata/ouroboros, uses WebKit and Soup 44 | 45 | ## Usage for compatible Libraries 46 | 47 | This assumes you already have a single top level file `src/main.ts` that (re-)exports all public declarations. 48 | Then, create a JavaScript file `exports.js` that exports the desired components by declaring them as top level constants (the name is arbitrary). 49 | Example: 50 | 51 | ```typescript 52 | // src/main.ts 53 | 54 | export const foo = 42; 55 | ``` 56 | 57 | ```javascript 58 | // exports.js 59 | 60 | const __LIBRARY__ = {} 61 | define("__LIBRARY__", ["require", "exports", "src/main"], function (require, exports, main_1) { 62 | "use strict"; 63 | function __export(m) { 64 | for (var p in m) if (!__LIBRARY__.hasOwnProperty(p)) __LIBRARY__[p] = m[p]; 65 | } 66 | Object.defineProperty(exports, "__esModule", { value: true }); 67 | __export(main_1); 68 | }); 69 | 70 | const foo = __LIBRARY__.foo; 71 | // potentially mode gnome js "exports" 72 | ``` 73 | 74 | Finally, add this javascript file as last (!) entry to your tsconfig: 75 | 76 | ```json 77 | { 78 | // ... 79 | "files": [ 80 | // ... 81 | "src/main.ts", // main library entry point 82 | "exports.js" // exports for compatibility with non-typescript gjs apps 83 | ] 84 | } 85 | ``` 86 | 87 | The compilated file can then be used for example in a gnome shell plugin by using 88 | 89 | ```javascript 90 | const Me = imports.misc.extensionUtils.getCurrentExtension(); 91 | const foo = Me.imports.myExportedLibraryFile.foo; // => 42 92 | ``` 93 | 94 | ## rules 95 | Conversion is iterative 96 | 97 | * numeric typedefs are replaced with 'number' 98 | * constructors are replaced with default having one optional hash table parameter 99 | * only constants, functions, enums, and classes 100 | * anything else, not defined in this group of modules, gets replaced with 'any' 101 | * as dicovered: 102 | * fix with add/patch entries in gir2dts.json 103 | 104 | 105 | 106 | ## differences 107 | 108 | The original javascript uses 109 | ```javascript 110 | this.text.buffer.text = text 111 | ``` 112 | 113 | In typescript, you may either: 114 | ```typescript 115 | this.text.get_buffer().set_text(text, text.length) 116 | this.text['buffer'] = text 117 | ``` 118 | 119 | 120 | ## why? 121 | 122 | Why? I couldn't have said it better: 123 | 124 | https://www.webreflection.co.uk/blog/2015/11/30/how-to-export-javascript-modules#the-curious-case-of-gjs-modules 125 | 126 | -------------------------------------------------------------------------------- /example/client.ts: -------------------------------------------------------------------------------- 1 | 2 | import * as Gtk from 'Gtk' 3 | import * as WebKit from 'WebKit' 4 | import {Serve} from 'server' 5 | 6 | let argv = ARGV 7 | 8 | Gtk.init(null) 9 | 10 | let s = new Serve("/home/bruce/Git/spaceship-warrior-ts/web") 11 | 12 | s.app.run(ARGV) 13 | // Gtk.main() 14 | 15 | 16 | // Gtk.init(null) 17 | let window = new Gtk.Window({ 18 | title: 'jsGtk+ browser', 19 | type : Gtk.WindowType.TOPLEVEL, 20 | window_position: Gtk.WindowPosition.CENTER 21 | }) 22 | let webView = new WebKit.WebView() 23 | // webView.load_uri(url(argv.filter(url => '-' !== url[0])[0] || 'darkoverlordofdata.com')) 24 | webView.load_uri(url(argv.filter(url => '-' !== url[0])[0] || 'http:0.0.0.0:8088/index.html')) 25 | 26 | // can't change to new page until this gets fixed 27 | //whenever a new page is loaded ... 28 | webView.connect('document-load-finished', (widget, loadEvent, data) => { 29 | switch (loadEvent) { 30 | case 2: // XXX: where is WEBKIT_LOAD_COMMITTED ? 31 | // ... update the URL bar with the current adress 32 | urlBar.set_text(widget.get_uri()) 33 | button.back.set_sensitive(webView.can_go_back()) 34 | button.forward.set_sensitive(webView.can_go_forward()) 35 | break 36 | } 37 | }) 38 | 39 | 40 | let toolbar = new Gtk.Toolbar() 41 | // buttons to go back, go forward, or refresh 42 | let button = { 43 | back: Gtk.ToolButton.new_from_stock(Gtk.STOCK_GO_BACK), 44 | forward: Gtk.ToolButton.new_from_stock(Gtk.STOCK_GO_FORWARD), 45 | refresh: Gtk.ToolButton.new_from_stock(Gtk.STOCK_REFRESH) 46 | } 47 | // where the URL is written and shown 48 | let urlBar = new Gtk.Entry() 49 | // the browser container, so that's scrollable 50 | let scrollWindow = new Gtk.ScrolledWindow({}) 51 | // horizontal and vertical boxes 52 | let hbox = new Gtk.Box({orientation: Gtk.Orientation.HORIZONTAL}) 53 | let vbox = new Gtk.Box({orientation: Gtk.Orientation.VERTICAL}) 54 | 55 | let gtkSettings = Gtk.Settings.get_default() 56 | gtkSettings.gtk_application_prefer_dark_theme = true 57 | //gtkSettings.gtk_theme_name = 'Adwaita' 58 | 59 | //Setting up optional Dark theme (gotta love it!) 60 | //./browser.js google.com --dark 61 | if (argv.some(info => info === '--dark')) { 62 | let gtkSettings = Gtk.Settings.get_default() 63 | gtkSettings.gtk_application_prefer_dark_theme = true 64 | gtkSettings.gtk_theme_name = 'Adwaita' 65 | } else if(argv.some(info => info === '--light')) { 66 | let gtkSettings = Gtk.Settings.get_default() 67 | gtkSettings.gtk_application_prefer_dark_theme = false 68 | 69 | gtkSettings.gtk_theme_name = 'Adwaita' 70 | } 71 | 72 | // configure buttons actions 73 | button.back.connect('clicked', () => webView.go_back()) 74 | button.forward.connect('clicked', () => webView.go_forward()) 75 | button.refresh.connect('clicked', () => webView.reload()) 76 | 77 | // enrich the toolbar 78 | toolbar.add(button.back) 79 | toolbar.add(button.forward) 80 | toolbar.add(button.refresh) 81 | 82 | // define "enter" / call-to-action event 83 | // whenever the url changes on the bar 84 | urlBar.connect('activate', () => { 85 | let href = url(urlBar.get_text()) 86 | urlBar.set_text(href) 87 | webView.load_uri(href) 88 | }) 89 | 90 | // make the container scrollable 91 | scrollWindow.add(webView) 92 | 93 | // pack horizontally toolbar and url bar 94 | // hbox.pack_start(toolbar, false, false, 0) 95 | // hbox.pack_start(urlBar, true, true, 8) 96 | 97 | // pack vertically top bar (hbox) and scrollable window 98 | vbox.pack_start(hbox, false, true, 0) 99 | vbox.pack_start(scrollWindow, true, true, 0) 100 | 101 | // configure main window 102 | window.set_default_size(1024, 720) 103 | window.set_resizable(true) 104 | window.connect('show', () => { 105 | // bring it on top in OSX 106 | window.set_keep_above(true) 107 | Gtk.main() 108 | }) 109 | window.connect('destroy', () => Gtk.main_quit()) 110 | window.connect('delete_event', () => false) 111 | 112 | // add vertical ui and show them all 113 | window.add(vbox) 114 | window.show_all() 115 | 116 | // little helper 117 | // if link doesn't have a protocol, prefixes it via http:// 118 | function url(href) { 119 | return /^([a-z]{2,}):/.test(href) ? href : ('https://' + href) 120 | } 121 | -------------------------------------------------------------------------------- /example/browser.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env gjs 2 | 3 | // A basic GJS Webkit based browser example. 4 | // Similar logic and basic interface found in this PyGTK example: 5 | // http://www.eurion.net/python-snippets/snippet/Webkit%20Browser.html 6 | 7 | ;(function (Gtk, WebKit2) {'use strict'; 8 | 9 | 10 | // necessary to initialize the graphic environment 11 | // if this fails it means the host cannot show GTK3 12 | Gtk.init(null); 13 | 14 | const 15 | 16 | argv = ARGV, 17 | 18 | // main program window 19 | window = new Gtk.Window({ 20 | title: 'jsGtk+ browser', 21 | type : Gtk.WindowType.TOPLEVEL, 22 | window_position: Gtk.WindowPosition.CENTER 23 | }), 24 | // the WebKit2 browser wrapper 25 | webView = new WebKit2.WebView(), 26 | // toolbar with buttons 27 | toolbar = new Gtk.Toolbar(), 28 | // buttons to go back, go forward, or refresh 29 | button = { 30 | back: Gtk.ToolButton.new_from_stock(Gtk.STOCK_GO_BACK), 31 | forward: Gtk.ToolButton.new_from_stock(Gtk.STOCK_GO_FORWARD), 32 | refresh: Gtk.ToolButton.new_from_stock(Gtk.STOCK_REFRESH) 33 | }, 34 | // where the URL is written and shown 35 | urlBar = new Gtk.Entry(), 36 | // the browser container, so that's scrollable 37 | scrollWindow = new Gtk.ScrolledWindow({}), 38 | // horizontal and vertical boxes 39 | hbox = new Gtk.Box({orientation: Gtk.Orientation.HORIZONTAL}), 40 | vbox = new Gtk.Box({orientation: Gtk.Orientation.VERTICAL}) 41 | ; 42 | 43 | // Setting up optional Dark theme (gotta love it!) 44 | // ./browser.js google.com --dark 45 | if (argv.some(info => info === '--dark')) { 46 | let gtkSettings = Gtk.Settings.get_default(); 47 | gtkSettings.gtk_application_prefer_dark_theme = true; 48 | gtkSettings.gtk_theme_name = 'Adwaita'; 49 | } else if(argv.some(info => info === '--light')) { 50 | let gtkSettings = Gtk.Settings.get_default(); 51 | gtkSettings.gtk_application_prefer_dark_theme = false; 52 | gtkSettings.gtk_theme_name = 'Adwaita'; 53 | } 54 | 55 | // open first argument or Google 56 | webView.load_uri(url(argv.filter(url => '-' !== url[0])[0] || 'google.com')); 57 | 58 | // whenever a new page is loaded ... 59 | webView.connect('load-changed', (widget, loadEvent, data) => { 60 | switch (loadEvent) { 61 | case 2: // XXX: where is WEBKIT_LOAD_COMMITTED ? 62 | // ... update the URL bar with the current adress 63 | urlBar.set_text(widget.get_uri()); 64 | button.back.set_sensitive(webView.can_go_back()); 65 | button.forward.set_sensitive(webView.can_go_forward()); 66 | break; 67 | } 68 | }); 69 | 70 | // configure buttons actions 71 | button.back.connect('clicked', () => webView.go_back()); 72 | button.forward.connect('clicked', () => webView.go_forward()); 73 | button.refresh.connect('clicked', () => webView.reload()); 74 | 75 | // enrich the toolbar 76 | toolbar.add(button.back); 77 | toolbar.add(button.forward); 78 | toolbar.add(button.refresh); 79 | 80 | // define "enter" / call-to-action event 81 | // whenever the url changes on the bar 82 | urlBar.connect('activate', () => { 83 | let href = url(urlBar.get_text()); 84 | urlBar.set_text(href); 85 | webView.load_uri(href); 86 | }); 87 | 88 | // make the container scrollable 89 | scrollWindow.add(webView); 90 | 91 | // pack horizontally toolbar and url bar 92 | hbox.pack_start(toolbar, false, false, 0); 93 | hbox.pack_start(urlBar, true, true, 8); 94 | 95 | // pack vertically top bar (hbox) and scrollable window 96 | vbox.pack_start(hbox, false, true, 0); 97 | vbox.pack_start(scrollWindow, true, true, 0); 98 | 99 | // configure main window 100 | window.set_default_size(1024, 720); 101 | window.set_resizable(true); 102 | window.connect('show', () => { 103 | // bring it on top in OSX 104 | window.set_keep_above(true); 105 | Gtk.main() 106 | }); 107 | window.connect('destroy', () => Gtk.main_quit()); 108 | window.connect('delete_event', () => false); 109 | 110 | // add vertical ui and show them all 111 | window.add(vbox); 112 | window.show_all(); 113 | 114 | // little helper 115 | // if link doesn't have a protocol, prefixes it via http:// 116 | function url(href) { 117 | return /^([a-z]{2,}):/.test(href) ? href : ('http://' + href); 118 | } 119 | 120 | }( 121 | imports.gi.Gtk, 122 | imports.gi.WebKit2 123 | )); -------------------------------------------------------------------------------- /example/record-collection.coffee: -------------------------------------------------------------------------------- 1 | GLib = imports.gi.GLib 2 | Gtk = imports.gi.Gtk 3 | Gda = imports.gi.Gda 4 | 5 | class Demo 6 | 7 | constructor: () -> 8 | @setupWindow() 9 | @setupDatabase() 10 | @selectData() 11 | 12 | 13 | setupWindow: () -> 14 | @window = new Gtk.Window( 15 | title: "Bosco" 16 | height_request: 350 17 | window_position: Gtk.WindowPosition.CENTER 18 | ) 19 | 20 | @window.set_border_width(12) 21 | @window.set_icon_from_file("/home/bruce/gjs/bosco/Char_Monkey_Free_Images/Animations/monkey_armsup_happy.png") 22 | 23 | @window.connect "delete-event", () => 24 | Gtk.main_quit() 25 | return true 26 | 27 | 28 | # main box 29 | mainBox = new Gtk.Box(orientation: Gtk.Orientation.VERTICAL, spacing: 5) 30 | @window.add(mainBox) 31 | 32 | # first label 33 | info1 = new Gtk.Label(label: "Insert a record", xalign: 0, use_markup: true) 34 | mainBox.pack_start(info1, false, false, 5) 35 | 36 | # "insert a record" horizontal box 37 | insertBox = new Gtk.Box(orientation: Gtk.Orientation.HORIZONTAL, spacing: 5) 38 | mainBox.pack_start(insertBox, false, false, 5) 39 | 40 | # ID field 41 | insertBox.pack_start(new Gtk.Label(label: "ID:"), false, false, 5) 42 | @idEntry = new Gtk.Entry() 43 | insertBox.pack_start(@idEntry, false, false, 5) 44 | 45 | # Name field 46 | insertBox.pack_start(new Gtk.Label(label: "Name:"), false, false, 5) 47 | @name_entry = new Gtk.Entry(activates_default: true) 48 | insertBox.pack_start(@name_entry, true, true, 5) 49 | 50 | # Insert button 51 | insertButton = new Gtk.Button(label: "Insert", can_default: true) 52 | insertButton.connect("clicked", => @insertClicked()) 53 | insertBox.pack_start(insertButton, false, false, 5) 54 | insertButton.grab_default() 55 | 56 | # Browse textview 57 | info2 = new Gtk.Label(label: "Browse the table", xalign: 0, use_markup: true) 58 | mainBox.pack_start(info2, false, false, 5) 59 | @text = new Gtk.TextView(editable: false) 60 | sw = new Gtk.ScrolledWindow(shadow_type:Gtk.ShadowType.IN) 61 | sw.add(@text) 62 | mainBox.pack_start(sw, true, true, 5) 63 | 64 | @countLabel = new Gtk.Label(label: "", xalign: 0, use_markup: true) 65 | mainBox.pack_start(@countLabel, false, false, 0) 66 | 67 | @window.set_default_size(820, 640) 68 | @window.show_all() 69 | @window.present() 70 | 71 | 72 | setupDatabase: () -> 73 | @connection = new Gda.Connection( 74 | provider: Gda.Config.get_provider("SQLite"), 75 | cnc_string:"DB_DIR=#{GLib.get_home_dir()};DB_NAME=gnome_demo" 76 | ) 77 | @connection.open() 78 | 79 | try 80 | dm = @connection.execute_select_command("select * from demo") 81 | catch e 82 | @connection.execute_non_select_command("create table demo(id integer, name varchar(100))") 83 | 84 | selectData: () -> 85 | dm = @connection.execute_select_command("select * from demo order by 1, 2") 86 | iter = dm.create_iter() 87 | 88 | text = "" 89 | 90 | while iter.move_next() 91 | idField = Gda.value_stringify(iter.get_value_at(0)) 92 | nameField = Gda.value_stringify(iter.get_value_at(1)) 93 | 94 | text += "#{idField}\t=>\t#{nameField}\n" 95 | 96 | 97 | @text.buffer.text = text 98 | @countLabel.label = "#{dm.get_n_rows()} record(s)" 99 | 100 | 101 | showError: (msg) -> 102 | dialog = new Gtk.MessageDialog( 103 | message_type: Gtk.MessageType.ERROR 104 | buttons: Gtk.ButtonsType.CLOSE 105 | text: msg 106 | transient_for: @window 107 | modal: true 108 | destroy_with_parent: true 109 | ) 110 | dialog.run() 111 | dialog.destroy() 112 | 113 | 114 | insertClicked: () -> 115 | if !@validateFields() 116 | return 117 | 118 | # Gda.execute_non_select_command(@connection, "insert into demo values('" + @idEntry.text + "', '" + @name_entry.text + "')") 119 | 120 | b = new Gda.SqlBuilder(stmt_type:Gda.SqlStatementType.INSERT) 121 | b.set_table("demo") 122 | b.add_field_value_as_gvalue("id", @idEntry.text) 123 | b.add_field_value_as_gvalue("name", @name_entry.text) 124 | stmt = b.get_statement() 125 | @connection.statement_execute_non_select(stmt, null) 126 | 127 | @clearFields() 128 | @selectData() 129 | 130 | 131 | validateFields: () -> 132 | if @idEntry.text == "" || @name_entry.text == "" 133 | @showError("All fields are mandatory") 134 | return false 135 | 136 | if isNaN(parseInt(@idEntry.text)) 137 | @showError("Enter a number") 138 | @idEntry.grab_focus() 139 | return false 140 | 141 | return true 142 | 143 | 144 | clearFields: () -> 145 | @idEntry.text = "" 146 | @name_entry.text = "" 147 | @idEntry.grab_focus() 148 | 149 | Gtk.init(null, null) 150 | 151 | demo = new Demo() 152 | 153 | Gtk.main() -------------------------------------------------------------------------------- /example/record-collection.ts: -------------------------------------------------------------------------------- 1 | import * as Gtk from 'Gtk' 2 | import * as Gda from 'Gda' 3 | import * as GLib from 'GLib' 4 | 5 | class Demo { 6 | 7 | window: Gtk.Window 8 | connection: Gda.Connection 9 | id_entry: Gtk.Entry 10 | name_entry: Gtk.Entry 11 | text: Gtk.TextView 12 | count_label: Gtk.Label 13 | 14 | constructor() { 15 | this.setupWindow() 16 | this.setupDatabase() 17 | this.selectData() 18 | 19 | } 20 | 21 | setupWindow() { 22 | this.window = new Gtk.Window({title: "Data Access Demo", height_request: 350}) 23 | this.window.connect("delete-event", () => Gtk.main_quit()) 24 | 25 | // main box 26 | var main_box = new Gtk.Box({orientation: Gtk.Orientation.VERTICAL, spacing: 5}) 27 | this.window.add(main_box) 28 | 29 | // first label 30 | var info1 = new Gtk.Label({label: "Insert a record", xalign: 0, use_markup: true}) 31 | main_box.pack_start(info1, false, false, 5) 32 | 33 | // "insert a record" horizontal box 34 | var insert_box = new Gtk.Box({orientation: Gtk.Orientation.HORIZONTAL, spacing: 5}) 35 | main_box.pack_start(insert_box, false, false, 5) 36 | 37 | // ID field 38 | insert_box.pack_start(new Gtk.Label({label: "ID:"}), false, false, 5) 39 | this.id_entry = new Gtk.Entry() 40 | insert_box.pack_start(this.id_entry, false, false, 5) 41 | 42 | // Name field 43 | insert_box.pack_start(new Gtk.Label({label: "Name:"}), false, false, 5) 44 | this.name_entry = new Gtk.Entry({activates_default: true}) 45 | insert_box.pack_start(this.name_entry, true, true, 5) 46 | 47 | // Insert button 48 | var insert_button = new Gtk.Button({label: "Insert", can_default: true}) 49 | insert_button.connect("clicked", this.insertClicked) 50 | insert_box.pack_start(insert_button, false, false, 5) 51 | insert_button.grab_default() 52 | 53 | // Browse textview 54 | var info2 = new Gtk.Label({label: "Browse the table", xalign: 0, use_markup: true}) 55 | main_box.pack_start(info2, false, false, 5) 56 | this.text = new Gtk.TextView({editable: false}) 57 | var sw = new Gtk.ScrolledWindow({shadow_type:Gtk.ShadowType.IN}) 58 | sw.add(this.text) 59 | main_box.pack_start(sw, true, true, 5) 60 | 61 | this.count_label = new Gtk.Label({label: "", xalign: 0, use_markup: true}) 62 | main_box.pack_start(this.count_label, false, false, 0) 63 | 64 | this.window.show_all() 65 | } 66 | 67 | setupDatabase() { 68 | this.connection = new Gda.Connection({ 69 | provider: Gda.Config.get_provider("SQLite"), 70 | cnc_string:"DB_DIR=" + GLib.get_home_dir() + ";DB_NAME=gnome_demo" 71 | }) 72 | this.connection.open() 73 | 74 | try { 75 | var dm = this.connection.execute_select_command("select * from demo") 76 | } catch(e) { 77 | this.connection.execute_non_select_command("create table demo(id integer, name varchar(100))") 78 | } 79 | } 80 | 81 | selectData() { 82 | var dm = this.connection.execute_select_command ("select * from demo order by 1, 2") 83 | var iter = dm.create_iter() 84 | 85 | var text = "" 86 | 87 | while(iter.move_next()) { 88 | var id_field = Gda.value_stringify(iter.get_value_at(0)) 89 | var name_field = Gda.value_stringify(iter.get_value_at(1)) 90 | 91 | text += id_field + "\t=>\t" + name_field + '\n' 92 | } 93 | 94 | // this.text.buffer.text = text 95 | this.text.get_buffer().set_text(text, text.length) 96 | 97 | this.count_label.set_label("" + dm.get_n_rows() + " record(s)") 98 | } 99 | 100 | showError(msg) { 101 | var dialog = new Gtk.MessageDialog({ 102 | message_type: Gtk.MessageType.ERROR, 103 | buttons: Gtk.ButtonsType.CLOSE, 104 | text: msg, 105 | transient_for: this.window, 106 | modal: true, 107 | destroy_with_parent: true 108 | }) 109 | dialog.run() 110 | dialog.destroy() 111 | } 112 | 113 | insertClicked() { 114 | if(!this.validateFields()) 115 | return 116 | 117 | // Gda.execute_non_select_command(this.connection, "insert into demo values('" + this.id_entry.text + "', '" + this.name_entry.text + "')") 118 | 119 | var b = new Gda.SqlBuilder({stmt_type:Gda.SqlStatementType.INSERT}) 120 | b.set_table("demo") 121 | b.add_field_value_as_gvalue("id", this.id_entry.get_text()) 122 | b.add_field_value_as_gvalue("name", this.name_entry.get_text()) 123 | var stmt = b.get_statement() 124 | this.connection.statement_execute_non_select(stmt, null) 125 | 126 | this.clearFields() 127 | this.selectData() 128 | } 129 | 130 | validateFields() { 131 | if(this.id_entry.get_text() == "" || this.name_entry.get_text() == "") { 132 | this.showError("All fields are mandatory") 133 | return false 134 | } 135 | if(isNaN(parseInt(this.id_entry.get_text()))) { 136 | this.showError("Enter a number") 137 | this.id_entry.grab_focus() 138 | return false 139 | } 140 | return true 141 | } 142 | 143 | clearFields() { 144 | this.id_entry.set_text("") 145 | this.name_entry.set_text("") 146 | this.id_entry.grab_focus() 147 | } 148 | } 149 | 150 | Gtk.init(null) 151 | 152 | var demo = new Demo() 153 | 154 | Gtk.main() -------------------------------------------------------------------------------- /example/liststore.coffee: -------------------------------------------------------------------------------- 1 | #!/usr/bin/gjs 2 | 3 | GObject = imports.gi.GObject 4 | Gtk = imports.gi.Gtk 5 | Pango = imports.gi.Pango 6 | 7 | class TreeViewExample 8 | Name: 'TreeView Example with Simple ListStore' 9 | 10 | # Create the application itself 11 | constructor:() -> 12 | @application = new Gtk.Application( 13 | application_id: 'org.example.jstreeviewsimpleliststore' 14 | ) 15 | 16 | # Connect 'activate' and 'startup' signals to the callback s 17 | @application.connect('activate', => @_onActivate()) 18 | @application.connect('startup', => @_onStartup()) 19 | 20 | 21 | # Callback for 'activate' signal presents window when active 22 | _onActivate:() -> 23 | @_window.present() 24 | 25 | # Callback for 'startup' signal builds the UI 26 | _onStartup:() -> 27 | @_buildUI() 28 | 29 | # Build the application's UI 30 | _buildUI:() -> 31 | # Create the application window 32 | @_window = new Gtk.ApplicationWindow( 33 | application: @application, 34 | window_position: Gtk.WindowPosition.CENTER, 35 | default_height: 250, 36 | default_width: 100, 37 | border_width: 20, 38 | title: "My Phone Book") 39 | 40 | # Create the underlying liststore for the phonebook 41 | @_listStore = new Gtk.ListStore() 42 | @_listStore.set_column_types([ 43 | GObject.TYPE_STRING, 44 | GObject.TYPE_STRING, 45 | GObject.TYPE_STRING, 46 | GObject.TYPE_STRING]) 47 | 48 | # Data to go in the phonebook 49 | phonebook = [ 50 | { name: "Jurg", surname: "Billeter", phone: "555-0123", description: "A friendly person." }, 51 | { name: "Johannes", surname: "Schmid", phone: "555-1234", description: "Easy phone number to remember." }, 52 | { name: "Julita", surname: "Inca", phone: "555-2345", description: "Another friendly person." }, 53 | { name: "Javier", surname: "Jardon", phone: "555-3456", description: "Bring fish for his penguins." }, 54 | { name: "Jason", surname: "Clinton", phone: "555-4567", description: "His cake's not a lie." }, 55 | { name: "Random J.", surname: "Hacker", phone: "555-5678", description: "Very random!" } 56 | ] 57 | 58 | # Put the data in the phonebook 59 | for contact in phonebook 60 | @_listStore.set(@_listStore.append(), [0, 1, 2, 3], 61 | [contact.name, contact.surname, contact.phone, contact.description]) 62 | 63 | 64 | # Create the treeview 65 | @_treeView = new Gtk.TreeView( 66 | expand: true, 67 | model: @_listStore) 68 | 69 | # Create the columns for the address book 70 | firstName = new Gtk.TreeViewColumn(title: "First Name") 71 | lastName = new Gtk.TreeViewColumn(title: "Last Name") 72 | phone = new Gtk.TreeViewColumn(title: "Phone Number") 73 | 74 | # Create a cell renderer for when bold text is needed 75 | bold = new Gtk.CellRendererText(weight: Pango.Weight.BOLD) 76 | 77 | # Create a cell renderer for normal text 78 | normal = new Gtk.CellRendererText() 79 | 80 | # Pack the cell renderers into the columns 81 | firstName.pack_start(bold, true) 82 | lastName.pack_start(normal, true) 83 | phone.pack_start(normal, true) 84 | 85 | # Set each column to pull text from the TreeView's model 86 | firstName.add_attribute(bold, "text", 0) 87 | lastName.add_attribute(normal, "text", 1) 88 | phone.add_attribute(normal, "text", 2) 89 | 90 | # Insert the columns into the treeview 91 | @_treeView.insert_column(firstName, 0) 92 | @_treeView.insert_column(lastName, 1) 93 | @_treeView.insert_column(phone, 2) 94 | 95 | # Create the label that shows details for the name you select 96 | @_label = new Gtk.Label(label: "") 97 | 98 | # Get which item is selected 99 | @selection = @_treeView.get_selection() 100 | 101 | # When something new is selected, call _on_changed 102 | @selection.connect('changed', => @_onSelectionChanged()) 103 | 104 | # Create a grid to organize everything in 105 | @_grid = new Gtk.Grid 106 | 107 | # Attach the treeview and label to the grid 108 | @_grid.attach(@_treeView, 0, 0, 1, 1) 109 | @_grid.attach(@_label, 0, 1, 1, 1) 110 | 111 | # Add the grid to the window 112 | @_window.add(@_grid) 113 | 114 | # Show the window and all child widgets 115 | @_window.show_all() 116 | 117 | _onSelectionChanged: () -> 118 | 119 | # Grab a treeiter pointing to the current selection 120 | [ isSelected, model, iter ] = @selection.get_selected() 121 | 122 | # Set the label to read off the values stored in the current selection 123 | @_label.set_label("\n" + 124 | @_listStore.get_value(iter, 0) + " " + 125 | @_listStore.get_value(iter, 1) + " " + 126 | @_listStore.get_value(iter, 2) + "\n" + 127 | @_listStore.get_value(iter, 3)) 128 | 129 | 130 | # Run the application 131 | app = new TreeViewExample() 132 | app.application.run(ARGV) 133 | -------------------------------------------------------------------------------- /example/record-collection.js: -------------------------------------------------------------------------------- 1 | const GLib = imports.gi.GLib; 2 | const Gtk = imports.gi.Gtk; 3 | const Gda = imports.gi.Gda; 4 | const Lang = imports.lang; 5 | 6 | function Demo () { 7 | this._init (); 8 | } 9 | 10 | Demo.prototype = { 11 | 12 | _init: function () { 13 | this.setupWindow (); 14 | this.setupDatabase (); 15 | this.selectData (); 16 | }, 17 | 18 | setupWindow: function () { 19 | this.window = new Gtk.Window ({title: "Data Access Demo", height_request: 350}); 20 | this.window.connect ("delete-event", function () { 21 | Gtk.main_quit(); 22 | return true; 23 | }); 24 | 25 | // main box 26 | var main_box = new Gtk.Box ({orientation: Gtk.Orientation.VERTICAL, spacing: 5}); 27 | this.window.add (main_box); 28 | 29 | // first label 30 | var info1 = new Gtk.Label ({label: "Insert a record", xalign: 0, use_markup: true}); 31 | main_box.pack_start (info1, false, false, 5); 32 | 33 | // "insert a record" horizontal box 34 | var insert_box = new Gtk.Box ({orientation: Gtk.Orientation.HORIZONTAL, spacing: 5}); 35 | main_box.pack_start (insert_box, false, false, 5); 36 | 37 | // ID field 38 | insert_box.pack_start (new Gtk.Label ({label: "ID:"}), false, false, 5); 39 | this.id_entry = new Gtk.Entry (); 40 | insert_box.pack_start (this.id_entry, false, false, 5); 41 | 42 | // Name field 43 | insert_box.pack_start (new Gtk.Label ({label: "Name:"}), false, false, 5); 44 | this.name_entry = new Gtk.Entry ({activates_default: true}); 45 | insert_box.pack_start (this.name_entry, true, true, 5); 46 | 47 | // Insert button 48 | var insert_button = new Gtk.Button ({label: "Insert", can_default: true}); 49 | insert_button.connect ("clicked", Lang.bind (this, this._insertClicked)); 50 | insert_box.pack_start (insert_button, false, false, 5); 51 | insert_button.grab_default (); 52 | 53 | // Browse textview 54 | var info2 = new Gtk.Label ({label: "Browse the table", xalign: 0, use_markup: true}); 55 | main_box.pack_start (info2, false, false, 5); 56 | this.text = new Gtk.TextView ({editable: false}); 57 | var sw = new Gtk.ScrolledWindow ({shadow_type:Gtk.ShadowType.IN}); 58 | sw.add (this.text); 59 | main_box.pack_start (sw, true, true, 5); 60 | 61 | this.count_label = new Gtk.Label ({label: "", xalign: 0, use_markup: true}); 62 | main_box.pack_start (this.count_label, false, false, 0); 63 | 64 | this.window.show_all (); 65 | }, 66 | 67 | setupDatabase: function () { 68 | this.connection = new Gda.Connection ({provider: Gda.Config.get_provider("SQLite"), 69 | cnc_string:"DB_DIR=" + GLib.get_home_dir () + ";DB_NAME=gnome_demo"}); 70 | this.connection.open (); 71 | 72 | try { 73 | var dm = this.connection.execute_select_command ("select * from demo"); 74 | } catch (e) { 75 | this.connection.execute_non_select_command ("create table demo (id integer, name varchar(100))"); 76 | } 77 | }, 78 | 79 | selectData: function () { 80 | var dm = this.connection.execute_select_command ("select * from demo order by 1, 2"); 81 | var iter = dm.create_iter (); 82 | 83 | var text = ""; 84 | 85 | while (iter.move_next ()) { 86 | var id_field = Gda.value_stringify (iter.get_value_at (0)); 87 | var name_field = Gda.value_stringify (iter.get_value_at (1)); 88 | 89 | text += id_field + "\t=>\t" + name_field + '\n'; 90 | } 91 | 92 | this.text.buffer.text = text; 93 | this.count_label.label = "" + dm.get_n_rows () + " record(s)"; 94 | }, 95 | 96 | _showError: function (msg) { 97 | var dialog = new Gtk.MessageDialog ({message_type: Gtk.MessageType.ERROR, 98 | buttons: Gtk.ButtonsType.CLOSE, 99 | text: msg, 100 | transient_for: this.window, 101 | modal: true, 102 | destroy_with_parent: true}); 103 | dialog.run (); 104 | dialog.destroy (); 105 | }, 106 | 107 | _insertClicked: function () { 108 | if (!this._validateFields ()) 109 | return; 110 | 111 | // Gda.execute_non_select_command (this.connection, "insert into demo values ('" + this.id_entry.text + "', '" + this.name_entry.text + "')"); 112 | 113 | var b = new Gda.SqlBuilder ({stmt_type:Gda.SqlStatementType.INSERT}); 114 | b.set_table ("demo"); 115 | b.add_field_value_as_gvalue ("id", this.id_entry.text); 116 | b.add_field_value_as_gvalue ("name", this.name_entry.text); 117 | var stmt = b.get_statement (); 118 | this.connection.statement_execute_non_select (stmt, null); 119 | 120 | this._clearFields (); 121 | this.selectData (); 122 | }, 123 | 124 | _validateFields: function () { 125 | if (this.id_entry.text == "" || this.name_entry.text == "") { 126 | this._showError ("All fields are mandatory"); 127 | return false; 128 | } 129 | if (isNaN (parseInt (this.id_entry.text))) { 130 | this._showError ("Enter a number"); 131 | this.id_entry.grab_focus (); 132 | return false; 133 | } 134 | return true; 135 | }, 136 | 137 | _clearFields: function () { 138 | this.id_entry.text = ""; 139 | this.name_entry.text = ""; 140 | this.id_entry.grab_focus (); 141 | } 142 | } 143 | 144 | Gtk.init (null, null); 145 | 146 | var demo = new Demo (); 147 | 148 | Gtk.main (); -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright 2017 darkoverlordofdata 3 | * 4 | * Module loader/gjs helper 5 | * normalized access to amd, commonjs and gjs imports 6 | * 7 | */ 8 | Object.defineProperties(window, { 9 | define: { value: (function (modules) { 10 | return function (name, deps, callback) { 11 | if (typeof name !== 'string') { 12 | var bundle = deps(); 13 | for (name in bundle) 14 | modules[name] = { id: name, exports: bundle[name] }; 15 | } 16 | else { 17 | modules[name] = { id: name, exports: {} }; 18 | var args = [function (name) { return modules[name] ? modules[name].exports : imports[name]; }, 19 | modules[name].exports]; 20 | for (var i = 2; i < deps.length; i++) 21 | args.push(modules[deps[i]].exports); 22 | callback.apply(modules[name].exports, args); 23 | } 24 | }; 25 | }({ 26 | Lang: { id: 'Lang', exports: imports.lang }, 27 | Gio: { id: 'Gio', exports: imports.gi.Gio }, 28 | Atk: { id: 'Atk', exports: imports.gi.Atk }, 29 | Gdk: { id: 'Gdk', exports: imports.gi.Gdk }, 30 | Gtk: { id: 'Gtk', exports: imports.gi.Gtk }, 31 | GLib: { id: 'GLib', exports: imports.gi.GLib }, 32 | Pango: { id: 'Pango', exports: imports.gi.Pango }, 33 | GObject: { id: 'GObject', exports: imports.gi.GObject } 34 | })) }, 35 | console: { value: { 36 | log: function () { print.apply(null, arguments); }, 37 | warn: function () { print.apply(null, arguments); }, 38 | error: function () { print.apply(null, arguments); }, 39 | info: function () { print.apply(null, arguments); } 40 | } }, 41 | _: { value: imports.gettext.gettext } 42 | }); 43 | Object.defineProperties(define, { 44 | amd: { value: true }, 45 | version: { value: '0.1.0' }, 46 | path: { value: function (path) { return imports.searchPath.unshift(path); } }, 47 | imports: { value: function (libs) { return define([], function () { return libs; }); } } 48 | }); 49 | Object.defineProperties(String.prototype, { 50 | printf: { value: imports.format.format } 51 | }); 52 | /** 53 | * Import ambient modules 54 | */ 55 | define.imports({ 56 | Gda: imports.gi.Gda, 57 | Soup: imports.gi.Soup, 58 | WebKit: imports.gi.WebKit 59 | }); 60 | define("example/example", ["require", "exports", "Gtk"], function (require, exports, Gtk) { 61 | "use strict"; 62 | var ListBoxRowWithData = (function () { 63 | function ListBoxRowWithData(data) { 64 | this.object = new Gtk.ListBoxRow(); 65 | /* create a custom 'data' field for sorting */ 66 | this.object['data'] = data; 67 | this.object.add(new Gtk.Label({ label: data })); 68 | } 69 | return ListBoxRowWithData; 70 | }()); 71 | var ListBoxWindow = (function () { 72 | function ListBoxWindow() { 73 | this.object = new Gtk.Window({ 74 | window_position: Gtk.WindowPosition.CENTER, 75 | title: "ListBox Demo" 76 | }); 77 | var box_outer = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL, spacing: 6 }); 78 | this.object.add(box_outer); 79 | var listbox = new Gtk.ListBox(); 80 | // property not defined error: 81 | // listbox.selection_mode = Gtk.SelectionMode.NONE 82 | // use the api instead: 83 | listbox.set_selection_mode(Gtk.SelectionMode.NONE); 84 | box_outer.pack_start(listbox, true, true, 0); 85 | var row = new Gtk.ListBoxRow(); 86 | var hbox = new Gtk.Box({ orientation: Gtk.Orientation.HORIZONTAL, spacing: 50 }); 87 | row.add(hbox); 88 | var vbox = new Gtk.Box({ orientation: Gtk.Orientation.VERTICAL }); 89 | hbox.pack_start(vbox, true, true, 0); 90 | var label1 = new Gtk.Label({ label: "Automatic Date & Time", xalign: 0 }); 91 | var label2 = new Gtk.Label({ label: "Requires internet access", xalign: 0 }); 92 | vbox.pack_start(label1, true, true, 0); 93 | vbox.pack_start(label2, true, true, 0); 94 | var swtch = new Gtk.Switch(); 95 | // property not defined error: 96 | // swtch.valign = Gtk.Align.CENTER 97 | // use the api instead: 98 | swtch.set_valign(Gtk.Align.CENTER); 99 | hbox.pack_start(swtch, false, true, 0); 100 | listbox.add(row); 101 | row = new Gtk.ListBoxRow(); 102 | hbox = new Gtk.Box({ orientation: Gtk.Orientation.HORIZONTAL, spacing: 50 }); 103 | row.add(hbox); 104 | var label = new Gtk.Label({ label: "Enable Automatic Update", xalign: 0 }); 105 | var check = new Gtk.CheckButton(); 106 | hbox.pack_start(label, true, true, 0); 107 | hbox.pack_start(check, false, true, 0); 108 | listbox.add(row); 109 | row = new Gtk.ListBoxRow(); 110 | hbox = new Gtk.Box({ orientation: Gtk.Orientation.HORIZONTAL, spacing: 50 }); 111 | row.add(hbox); 112 | label = new Gtk.Label({ label: "Date Format", xalign: 0 }); 113 | var combo = new Gtk.ComboBoxText(); 114 | combo.insert(0, "0", "24-hour"); 115 | combo.insert(1, "1", "AM/PM"); 116 | hbox.pack_start(label, true, true, 0); 117 | hbox.pack_start(combo, false, true, 0); 118 | listbox.add(row); 119 | var listbox2 = new Gtk.ListBox(); 120 | var items = "This is a sorted ListBox Fail".split(' '); 121 | items.forEach(function (item) { return listbox2.add(new ListBoxRowWithData(item).object); }); 122 | var sortFunc = (function (row1, row2, data, notifyDestroy) { return row1.data.toLowerCase() > row2.data.toLowerCase(); }); 123 | var filterFunc = (function (row, data, notifyDestroy) { return (row.data != 'Fail'); }); 124 | listbox2.connect("row-activated", function (widget, row) { return print(row.data); }); 125 | listbox2.set_sort_func(sortFunc, null, false); 126 | listbox2.set_filter_func(filterFunc, null, false); 127 | box_outer.pack_start(listbox2, true, true, 0); 128 | listbox2.show_all(); 129 | } 130 | return ListBoxWindow; 131 | }()); 132 | Gtk.init(null); 133 | var win = new ListBoxWindow(); 134 | win.object.connect("delete-event", Gtk.main_quit); 135 | win.object.show_all(); 136 | Gtk.main(); 137 | }); 138 | -------------------------------------------------------------------------------- /gir2dts.json: -------------------------------------------------------------------------------- 1 | { 2 | "module": { 3 | "Atk": { 4 | "source": "/usr/share/gir-1.0/Atk-1.0.gir", 5 | "output": "src/atk-1.0.d.ts", 6 | "import": ["GObject"] 7 | }, 8 | "Gda": { 9 | "source": "/usr/share/gir-1.0/Gda-5.0.gir", 10 | "output": "src/gda-5.0.d.ts", 11 | "import": ["GObject", "GLib"], 12 | "patch": { 13 | "Connection": { 14 | "statement_execute_non_select": "statement_execute_non_select(stmt: Statement, params: Set, last_insert_row?: Set):number" 15 | } 16 | } 17 | 18 | }, 19 | "Gio": { 20 | "source": "/usr/share/gir-1.0/Gio-2.0.gir", 21 | "output": "src/gio-2.0.d.ts", 22 | "patch": "patches/gio.d.ts", 23 | "import": ["GObject", "GLib"] 24 | }, 25 | "GLib": { 26 | "source": "/usr/share/gir-1.0/GLib-2.0.gir", 27 | "output": "src/glib-2.0.d.ts", 28 | "add": { 29 | "Application": { 30 | "run": "run(argv: any)" 31 | } 32 | } 33 | }, 34 | "GObject": { 35 | "source": "/usr/share/gir-1.0/GObject-2.0.gir", 36 | "output": "src/gobject-2.0.d.ts", 37 | "patch": "patches/gobject.d.ts", 38 | "add": { 39 | "Object": { 40 | "connect": "connect(...args: any[]):any", 41 | "get_valist": "get_valist(...args: any[]):void", 42 | "get_property": "get_property(...args: any[]):any", 43 | "newv": "static newv(...args: any[]):Object", 44 | "replace_data": "replace_data(...args: any[]):any", 45 | "set_property": "set_property(...args: any[]):void", 46 | "set_valist": "set_valist(...args: any[]):void" 47 | } 48 | } 49 | }, 50 | 51 | "GtkSource": { 52 | "source": "/usr/share/gir-1.0/GtkSource-3.0.gir", 53 | "output": "src/gtksource-3.0.d.ts", 54 | "import": ["GObject", "Gio", "Gdk", "Gtk"] 55 | }, 56 | "Gtk": { 57 | "source": "/usr/share/gir-1.0/Gtk-3.0.gir", 58 | "output": "src/gtk-3.0.d.ts", 59 | "import": ["GObject", "GLib", "Gio", "Gdk", "Atk","Pango"], 60 | "add": { 61 | "Application": { 62 | "add_action": "add_action(action: any)" 63 | }, 64 | "FileChooserDialog": { 65 | "set_select_multiple": "set_select_multiple(select: boolean)" 66 | }, 67 | "ListStore": { 68 | "get_value": "get_value(iter: any, index: number): any" 69 | }, 70 | "Settings": { 71 | "gtk_application_prefer_dark_theme": "gtk_application_prefer_dark_theme: boolean", 72 | "gtk_theme_name": "gtk_theme_name: string" 73 | 74 | } 75 | }, 76 | "patch" : { 77 | "Bin": { 78 | "mnemonic_activate": "mnemonic_activate(...args: any[]):boolean" 79 | }, 80 | "Container": { 81 | "remove" : "remove(...args: any[]):void", 82 | "child_notify": "child_notify(...args: any[]):void" 83 | }, 84 | "CheckButton": { 85 | "new_with_label": "static new_with_label(...args: any[]):CheckButton" 86 | }, 87 | "CheckMenuItem": { 88 | "new_with_label": "static new_with_label(...args: any[]):CheckMenuItem" 89 | }, 90 | "ComboBoxText": { 91 | "remove" : "remove(...args: any[]):void" 92 | }, 93 | "CssProvider": { 94 | "load_from_data": "load_from_data(...args:any[]):boolean" 95 | }, 96 | "LinkButton": { 97 | "new_with_label": "static new_with_label(...args: any[]):LinkButton" 98 | }, 99 | "ListStore": { 100 | "append": "append():any", 101 | "newv": "static newv(...args: any[]):ListStore", 102 | "set_column_types": "set_column_types(types: number[]):void" 103 | }, 104 | "MenuButton": { 105 | "get_direction": "get_direction(): number", 106 | "set_direction": "set_direction(dir: number):void" 107 | }, 108 | "MenuItem": { 109 | "activate": "activate():any" 110 | }, 111 | "RadioButton": { 112 | "new_with_label": "static new_with_label(...args: any[]):RadioButton", 113 | "new_with_mnemonic": "static new_with_mnemonic(...args: any[]):RadioButton" 114 | }, 115 | "RadioMenuItem": { 116 | "new_with_label": "static new_with_label(...args: any[]):RadioMenuItem", 117 | "new_with_mnemonic": "static new_with_mnemonic(...args: any[]):RadioMenuItem" 118 | }, 119 | "RadioToolButton": { 120 | "new_with_label": "static new_with_label(...args: any[]):RadioToolButton", 121 | "new_from_stock": "static new_from_stock(...args: any[]):RadioToolButton" 122 | }, 123 | "Statusbar": { 124 | "remove" : "remove(...args: any[]):void" 125 | }, 126 | "Style": { 127 | "get_valist": "get_valist(...args: any[]):void" 128 | }, 129 | "StyleContext": { 130 | "get_property": "get_property(...args: any[]):any", 131 | "get_valist": "get_valist(...args: any[]):void" 132 | }, 133 | "StyleProperties": { 134 | "get_property": "get_property(...args: any[]):any", 135 | "get_valist": "get_valist(...args: any[]):void", 136 | "set_property": "set_property(...args: any[]):void", 137 | "set_valist": "set_valist(...args: any[]):void" 138 | }, 139 | "Switch": { 140 | "get_state": "get_state():number", 141 | "set_state": "set_state(state: number)" 142 | }, 143 | "TextView": { 144 | "get_window": "get_window(win?: number):Gdk.Window" 145 | }, 146 | "TreeSelection": { 147 | "get_selected": "get_selected():any" 148 | }, 149 | "TreeStore": { 150 | "newv": "static newv(...args: any[]):TreeStore" 151 | }, 152 | "ThemingEngine": { 153 | "get_property": "get_property(...args: any[]):any", 154 | "get_valist": "get_valist(...args: any[]):void" 155 | }, 156 | "ToggleButton": { 157 | "get_direction": "get_direction(): number", 158 | "set_direction": "set_direction(dir: number):void" 159 | }, 160 | "ToggleToolButton": { 161 | "new_from_stock": "static new_from_stock(...args: any[]):ToggleToolButton" 162 | }, 163 | "Toolbar": { 164 | "get_style": "get_style():number", 165 | "set_style": "set_style(style: number)" 166 | }, 167 | "ToolPalette": { 168 | "get_style": "get_style():number", 169 | "set_style": "set_style(style: number)" 170 | }, 171 | "Widget": { 172 | "activate": "activate():any", 173 | "child_notify": "child_notify(...args: any[]):void", 174 | "get_state": "get_state():number", 175 | "get_settings": "get_settings():any", 176 | "get_style": "get_style():number", 177 | "get_window": "get_window(win?: number):Gdk.Window", 178 | "get_direction": "get_direction(): number", 179 | "set_direction": "set_direction(dir: number):void", 180 | "set_state": "set_state(state: number)", 181 | "set_style": "set_style(style: number)" 182 | }, 183 | "Window": { 184 | "mnemonic_activate": "mnemonic_activate(...args: any[]):boolean" 185 | } 186 | } 187 | }, 188 | "Gdk": { 189 | "source": "/usr/share/gir-1.0/Gdk-3.0.gir", 190 | "output": "src/gdk-3.0.d.ts", 191 | "import": ["GObject", "Gio", "Pango"] 192 | }, 193 | "Pango": { 194 | "source": "/usr/share/gir-1.0/Pango-1.0.gir", 195 | "output": "src/pango-1.0.d.ts", 196 | "import": ["GObject"] 197 | }, 198 | "Soup": { 199 | "source": "/usr/share/gir-1.0/Soup-2.4.gir", 200 | "output": "src/soup-2.4.d.ts", 201 | "import": ["GObject", "Gio", "GLib"], 202 | "patch": { 203 | "Message": { 204 | "set_response": "set_response(content_type: string, resp_use: MemoryUse, resp_body: string, resp_length: number):void" 205 | } 206 | } 207 | }, 208 | "WebKit": { 209 | "source": "/usr/share/gir-1.0/WebKit-3.0.gir", 210 | "output": "src/webkit-3.0.d.ts", 211 | "import": ["GObject", "Gio", "Gtk", "Soup"], 212 | "patch": { 213 | "DOMCharacterData": { 214 | "replace_data": "replace_data(...args: any[]):any" 215 | }, 216 | "DOMCSSStyleDeclaration": { 217 | "set_property": "set_property(...args: any[]):void" 218 | }, 219 | "DOMElement": { 220 | "remove": "remove(index?: number):void" 221 | }, 222 | "DOMHTMLSelectElement": { 223 | "remove": "remove(index?: number):void" 224 | }, 225 | "DOMObject": { 226 | "set_property": "set_property(...args: any[]):void" 227 | }, 228 | "WebView": { 229 | "get_settings": "get_settings():any" 230 | } 231 | 232 | } 233 | } 234 | } 235 | } 236 | -------------------------------------------------------------------------------- /src/atk-1.0.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Atk.d.ts 3 | * 4 | */ 5 | declare module 'Atk' { 6 | import * as GObject from "GObject" 7 | export const BINARY_AGE:number 8 | export const INTERFACE_AGE:number 9 | export const MAJOR_VERSION:number 10 | export const MICRO_VERSION:number 11 | export const MINOR_VERSION:number 12 | export const VERSION_MIN_REQUIRED:number 13 | export function add_focus_tracker(focus_tracker: any):number 14 | export function add_global_event_listener(listener: any, event_type: string):number 15 | export function add_key_event_listener(listener: any, data: any):number 16 | export function attribute_set_free(attrib_set: any):void 17 | export function focus_tracker_init(init: any):void 18 | export function focus_tracker_notify(object: Object):void 19 | export function get_binary_age():number 20 | export function get_default_registry():Registry 21 | export function get_focus_object():Object 22 | export function get_interface_age():number 23 | export function get_major_version():number 24 | export function get_micro_version():number 25 | export function get_minor_version():number 26 | export function get_root():Object 27 | export function get_toolkit_name():string 28 | export function get_toolkit_version():string 29 | export function get_version():string 30 | export function relation_type_for_name(name: string):RelationType 31 | export function relation_type_get_name(type: RelationType):string 32 | export function relation_type_register(name: string):RelationType 33 | export function remove_focus_tracker(tracker_id: number):void 34 | export function remove_global_event_listener(listener_id: number):void 35 | export function remove_key_event_listener(listener_id: number):void 36 | export function role_for_name(name: string):Role 37 | export function role_get_localized_name(role: Role):string 38 | export function role_get_name(role: Role):string 39 | export function role_register(name: string):Role 40 | export function state_type_for_name(name: string):StateType 41 | export function state_type_get_name(type: StateType):string 42 | export function state_type_register(name: string):StateType 43 | export function text_attribute_for_name(name: string):TextAttribute 44 | export function text_attribute_get_name(attr: TextAttribute):string 45 | export function text_attribute_get_value(attr: TextAttribute, index_: number):string 46 | export function text_attribute_register(name: string):TextAttribute 47 | export function text_free_ranges(ranges: any[]):void 48 | export function value_type_get_localized_name(value_type: ValueType):string 49 | export function value_type_get_name(value_type: ValueType):string 50 | export enum CoordType { 51 | SCREEN, 52 | WINDOW, 53 | } 54 | export enum KeyEventType { 55 | PRESS, 56 | RELEASE, 57 | LAST_DEFINED, 58 | } 59 | export enum Layer { 60 | INVALID, 61 | BACKGROUND, 62 | CANVAS, 63 | WIDGET, 64 | MDI, 65 | POPUP, 66 | OVERLAY, 67 | WINDOW, 68 | } 69 | export enum RelationType { 70 | NULL, 71 | CONTROLLED_BY, 72 | CONTROLLER_FOR, 73 | LABEL_FOR, 74 | LABELLED_BY, 75 | MEMBER_OF, 76 | NODE_CHILD_OF, 77 | FLOWS_TO, 78 | FLOWS_FROM, 79 | SUBWINDOW_OF, 80 | EMBEDS, 81 | EMBEDDED_BY, 82 | POPUP_FOR, 83 | PARENT_WINDOW_OF, 84 | DESCRIBED_BY, 85 | DESCRIPTION_FOR, 86 | NODE_PARENT_OF, 87 | LAST_DEFINED, 88 | } 89 | export enum Role { 90 | INVALID, 91 | ACCELERATOR_LABEL, 92 | ALERT, 93 | ANIMATION, 94 | ARROW, 95 | CALENDAR, 96 | CANVAS, 97 | CHECK_BOX, 98 | CHECK_MENU_ITEM, 99 | COLOR_CHOOSER, 100 | COLUMN_HEADER, 101 | COMBO_BOX, 102 | DATE_EDITOR, 103 | DESKTOP_ICON, 104 | DESKTOP_FRAME, 105 | DIAL, 106 | DIALOG, 107 | DIRECTORY_PANE, 108 | DRAWING_AREA, 109 | FILE_CHOOSER, 110 | FILLER, 111 | FONT_CHOOSER, 112 | FRAME, 113 | GLASS_PANE, 114 | HTML_CONTAINER, 115 | ICON, 116 | IMAGE, 117 | INTERNAL_FRAME, 118 | LABEL, 119 | LAYERED_PANE, 120 | LIST, 121 | LIST_ITEM, 122 | MENU, 123 | MENU_BAR, 124 | MENU_ITEM, 125 | OPTION_PANE, 126 | PAGE_TAB, 127 | PAGE_TAB_LIST, 128 | PANEL, 129 | PASSWORD_TEXT, 130 | POPUP_MENU, 131 | PROGRESS_BAR, 132 | PUSH_BUTTON, 133 | RADIO_BUTTON, 134 | RADIO_MENU_ITEM, 135 | ROOT_PANE, 136 | ROW_HEADER, 137 | SCROLL_BAR, 138 | SCROLL_PANE, 139 | SEPARATOR, 140 | SLIDER, 141 | SPLIT_PANE, 142 | SPIN_BUTTON, 143 | STATUSBAR, 144 | TABLE, 145 | TABLE_CELL, 146 | TABLE_COLUMN_HEADER, 147 | TABLE_ROW_HEADER, 148 | TEAR_OFF_MENU_ITEM, 149 | TERMINAL, 150 | TEXT, 151 | TOGGLE_BUTTON, 152 | TOOL_BAR, 153 | TOOL_TIP, 154 | TREE, 155 | TREE_TABLE, 156 | UNKNOWN, 157 | VIEWPORT, 158 | WINDOW, 159 | HEADER, 160 | FOOTER, 161 | PARAGRAPH, 162 | RULER, 163 | APPLICATION, 164 | AUTOCOMPLETE, 165 | EDIT_BAR, 166 | EMBEDDED, 167 | ENTRY, 168 | CHART, 169 | CAPTION, 170 | DOCUMENT_FRAME, 171 | HEADING, 172 | PAGE, 173 | SECTION, 174 | REDUNDANT_OBJECT, 175 | FORM, 176 | LINK, 177 | INPUT_METHOD_WINDOW, 178 | TABLE_ROW, 179 | TREE_ITEM, 180 | DOCUMENT_SPREADSHEET, 181 | DOCUMENT_PRESENTATION, 182 | DOCUMENT_TEXT, 183 | DOCUMENT_WEB, 184 | DOCUMENT_EMAIL, 185 | COMMENT, 186 | LIST_BOX, 187 | GROUPING, 188 | IMAGE_MAP, 189 | NOTIFICATION, 190 | INFO_BAR, 191 | LEVEL_BAR, 192 | TITLE_BAR, 193 | BLOCK_QUOTE, 194 | AUDIO, 195 | VIDEO, 196 | DEFINITION, 197 | ARTICLE, 198 | LANDMARK, 199 | LOG, 200 | MARQUEE, 201 | MATH, 202 | RATING, 203 | TIMER, 204 | DESCRIPTION_LIST, 205 | DESCRIPTION_TERM, 206 | DESCRIPTION_VALUE, 207 | STATIC, 208 | MATH_FRACTION, 209 | MATH_ROOT, 210 | SUBSCRIPT, 211 | SUPERSCRIPT, 212 | LAST_DEFINED, 213 | } 214 | export enum StateType { 215 | INVALID, 216 | ACTIVE, 217 | ARMED, 218 | BUSY, 219 | CHECKED, 220 | DEFUNCT, 221 | EDITABLE, 222 | ENABLED, 223 | EXPANDABLE, 224 | EXPANDED, 225 | FOCUSABLE, 226 | FOCUSED, 227 | HORIZONTAL, 228 | ICONIFIED, 229 | MODAL, 230 | MULTI_LINE, 231 | MULTISELECTABLE, 232 | OPAQUE, 233 | PRESSED, 234 | RESIZABLE, 235 | SELECTABLE, 236 | SELECTED, 237 | SENSITIVE, 238 | SHOWING, 239 | SINGLE_LINE, 240 | STALE, 241 | TRANSIENT, 242 | VERTICAL, 243 | VISIBLE, 244 | MANAGES_DESCENDANTS, 245 | INDETERMINATE, 246 | TRUNCATED, 247 | REQUIRED, 248 | INVALID_ENTRY, 249 | SUPPORTS_AUTOCOMPLETION, 250 | SELECTABLE_TEXT, 251 | DEFAULT, 252 | ANIMATED, 253 | VISITED, 254 | CHECKABLE, 255 | HAS_POPUP, 256 | HAS_TOOLTIP, 257 | READ_ONLY, 258 | LAST_DEFINED, 259 | } 260 | export enum TextAttribute { 261 | INVALID, 262 | LEFT_MARGIN, 263 | RIGHT_MARGIN, 264 | INDENT, 265 | INVISIBLE, 266 | EDITABLE, 267 | PIXELS_ABOVE_LINES, 268 | PIXELS_BELOW_LINES, 269 | PIXELS_INSIDE_WRAP, 270 | BG_FULL_HEIGHT, 271 | RISE, 272 | UNDERLINE, 273 | STRIKETHROUGH, 274 | SIZE, 275 | SCALE, 276 | WEIGHT, 277 | LANGUAGE, 278 | FAMILY_NAME, 279 | BG_COLOR, 280 | FG_COLOR, 281 | BG_STIPPLE, 282 | FG_STIPPLE, 283 | WRAP_MODE, 284 | DIRECTION, 285 | JUSTIFICATION, 286 | STRETCH, 287 | VARIANT, 288 | STYLE, 289 | LAST_DEFINED, 290 | } 291 | export enum TextBoundary { 292 | CHAR, 293 | WORD_START, 294 | WORD_END, 295 | SENTENCE_START, 296 | SENTENCE_END, 297 | LINE_START, 298 | LINE_END, 299 | } 300 | export enum TextClipType { 301 | NONE, 302 | MIN, 303 | MAX, 304 | BOTH, 305 | } 306 | export enum TextGranularity { 307 | CHAR, 308 | WORD, 309 | SENTENCE, 310 | LINE, 311 | PARAGRAPH, 312 | } 313 | export enum ValueType { 314 | VERY_WEAK, 315 | WEAK, 316 | ACCEPTABLE, 317 | STRONG, 318 | VERY_STRONG, 319 | VERY_LOW, 320 | LOW, 321 | MEDIUM, 322 | HIGH, 323 | VERY_HIGH, 324 | VERY_BAD, 325 | BAD, 326 | GOOD, 327 | VERY_GOOD, 328 | BEST, 329 | LAST_DEFINED, 330 | } 331 | export enum HyperlinkStateFlags{ 332 | INLINE, 333 | } 334 | export class GObjectAccessible extends Object { 335 | static for_object(obj: GObject.Object):Object 336 | get_object():GObject.Object 337 | } 338 | export class Hyperlink extends GObject.Object { 339 | get_end_index():number 340 | get_n_anchors():number 341 | get_object(i: number):Object 342 | get_start_index():number 343 | get_uri(i: number):string 344 | is_inline():boolean 345 | is_selected_link():boolean 346 | is_valid():boolean 347 | } 348 | export class Misc extends GObject.Object { 349 | static get_instance():Misc 350 | threads_enter():void 351 | threads_leave():void 352 | } 353 | export class NoOpObject extends Object { 354 | constructor(config?: any) 355 | } 356 | export class NoOpObjectFactory extends ObjectFactory { 357 | constructor(config?: any) 358 | } 359 | export class Object extends GObject.Object { 360 | add_relationship(relationship: RelationType, target: Object):boolean 361 | connect_property_change_handler(handler: any):number 362 | get_attributes():any 363 | get_description():string 364 | get_index_in_parent():number 365 | get_layer():Layer 366 | get_mdi_zorder():number 367 | get_n_accessible_children():number 368 | get_name():string 369 | get_object_locale():string 370 | get_parent():Object 371 | get_role():Role 372 | initialize(data: any):void 373 | notify_state_change(state: any, value: boolean):void 374 | peek_parent():Object 375 | ref_accessible_child(i: number):Object 376 | ref_relation_set():RelationSet 377 | ref_state_set():StateSet 378 | remove_property_change_handler(handler_id: number):void 379 | remove_relationship(relationship: RelationType, target: Object):boolean 380 | set_description(description: string):void 381 | set_name(name: string):void 382 | set_parent(parent: Object):void 383 | set_role(role: Role):void 384 | } 385 | export class ObjectFactory extends GObject.Object { 386 | create_accessible(obj: GObject.Object):Object 387 | get_accessible_type():any 388 | invalidate():void 389 | } 390 | export class Plug extends Object { 391 | constructor(config?: any) 392 | get_id():string 393 | } 394 | export class Registry extends GObject.Object { 395 | get_factory(type: any):ObjectFactory 396 | get_factory_type(type: any):any 397 | set_factory_type(type: any, factory_type: any):void 398 | } 399 | export class Relation extends GObject.Object { 400 | constructor(config?: any) 401 | add_target(target: Object):void 402 | get_relation_type():RelationType 403 | get_target():Object[] 404 | remove_target(target: Object):boolean 405 | } 406 | export class RelationSet extends GObject.Object { 407 | constructor(config?: any) 408 | add(relation: Relation):void 409 | add_relation_by_type(relationship: RelationType, target: Object):void 410 | contains(relationship: RelationType):boolean 411 | contains_target(relationship: RelationType, target: Object):boolean 412 | get_n_relations():number 413 | get_relation(i: number):Relation 414 | get_relation_by_type(relationship: RelationType):Relation 415 | remove(relation: Relation):void 416 | } 417 | export class Socket extends Object { 418 | constructor(config?: any) 419 | embed(plug_id: string):void 420 | is_occupied():boolean 421 | } 422 | export class StateSet extends GObject.Object { 423 | constructor(config?: any) 424 | add_state(type: StateType):boolean 425 | add_states(types: StateType[], n_types: number):void 426 | and_sets(compare_set: StateSet):StateSet 427 | clear_states():void 428 | contains_state(type: StateType):boolean 429 | contains_states(types: StateType[], n_types: number):boolean 430 | is_empty():boolean 431 | or_sets(compare_set: StateSet):StateSet 432 | remove_state(type: StateType):boolean 433 | xor_sets(compare_set: StateSet):StateSet 434 | } 435 | export class Util extends GObject.Object { 436 | } 437 | } -------------------------------------------------------------------------------- /gir2dts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | /** 3 | * gir2dts 4 | * 5 | * Convert Gnome Gir bindings file to typescript declarations 6 | * 7 | */ 8 | const fs = require('fs') 9 | const os = require('os') 10 | const util = require('util') 11 | const {execSync} = require('child_process') 12 | const {parseString} = require('xml2js') 13 | 14 | const cfg = require('./gir2dts.json') 15 | const sym = {} 16 | const gir = {} 17 | let count = Object.keys(cfg.module).length 18 | 19 | for (let name in cfg.module) { 20 | let src = fs.readFileSync(cfg.module[name].source, {encoding: 'utf8'}) 21 | // provide a closure so we know which request completed 22 | ;(function(name, src){ 23 | parseString(src, (err, res) => { 24 | gir[name] = res 25 | count-- 26 | console.log(`${count} ${name}`) 27 | if (count <= 0) build(cfg, gir) 28 | }) 29 | })(name, src) 30 | } 31 | 32 | function build(cfg, gir) { 33 | const ts = { 34 | "compilerOptions": { 35 | "target": "es5", // es5 compatability for gjs 36 | "module": "amd", // pack using amd module format 37 | "rootDir": "src", // maodule names based from src 38 | "allowJs": true, // amd loader & nodejs modules are js 39 | "outFile": "index.js" // the target executable 40 | }, 41 | "files": [ 42 | "src/gjs.d.ts", 43 | "src/gjs.js", 44 | "example/imports.ts", 45 | "example/record-collection.ts" 46 | ] 47 | } 48 | for (let name in gir) { 49 | getSymbols(name, gir[name]) 50 | } 51 | for (let name in cfg.module) { 52 | let out = [] 53 | out.push(generateModule(name, gir[name], cfg.module[name])) 54 | fs.writeFileSync(cfg.module[name].output, out.join('\n')) 55 | ts.files.unshift(cfg.module[name].output) 56 | } 57 | fs.writeFileSync("./tsconfig.json", JSON.stringify(ts, null, 2)) 58 | } 59 | 60 | //////////////////////////////////////////////////////////////////////////////////////////// 61 | // pass 1 - generate a symbol table of all known identifiers 62 | //////////////////////////////////////////////////////////////////////////////////////////// 63 | function getSymbols(module, gir) { 64 | 65 | let ns = gir.repository.namespace[0] 66 | if (ns.function) 67 | for (let func of ns.function) { 68 | let name = getName(func.$['name']) 69 | sym[`${module}.${name}`] = `${module}.${name}` 70 | } 71 | if (ns.enumeration) 72 | for (let enumeration of ns.enumeration) { 73 | let name = enumeration.$['name'] 74 | sym[`${module}.${name}`] = `${module}.${name}` 75 | } 76 | if (ns.bitfield) 77 | for (let bitfield of ns.bitfield) { 78 | let name = bitfield.$['name'] 79 | sym[`${module}.${name}`] = `${module}.${name}` 80 | } 81 | if (ns.class) 82 | for (let klass of ns.class) { 83 | let name = klass.$['name'] 84 | sym[`${module}.${name}`] = `${module}.${name}` 85 | } 86 | } 87 | //////////////////////////////////////////////////////////////////////////////////////////// 88 | // pass 2 - process each file 89 | //////////////////////////////////////////////////////////////////////////////////////////// 90 | function generateModule(name, gir, module) { 91 | out = ['/**'] 92 | out.push(` * ${name}.d.ts`) 93 | out.push(' *') 94 | out.push(' */') 95 | out.push(`declare module '${name}' {`) 96 | if (module.import) 97 | for (let im of module.import) 98 | out.push(` import * as ${im} from "${im}"`) 99 | switch (typeof module.patch) { 100 | case 'string': 101 | out.push(fs.readFileSync(module.patch, {encoding: 'utf8'})) 102 | addGirInfo(name, gir, {}, module.add, out) 103 | break 104 | case 'object': 105 | addGirInfo(name, gir, module.patch, module.add, out) 106 | break 107 | default: 108 | addGirInfo(name, gir, module.patch, module.add, out) 109 | } 110 | out.push('}') 111 | return out.join('\n') // fixups: 112 | .replace(/\: object/g, ": any") 113 | .replace(/\:object/g, ":any") 114 | .replace(/\.\.\.args\: any\)/g, "...args: any[])") 115 | .replace(/argc\: number, argv\: string\[\]/g, "argv:string[]") 116 | } 117 | 118 | 119 | function addGirInfo(modName, gir, patch, add, out) { 120 | 121 | let ns = gir.repository.namespace[0] 122 | 123 | // Constants 124 | if (ns.constant) 125 | for (let constant of ns.constant) { 126 | let name = constant.$['name'] 127 | out.push(` export const ${name}:${getType(modName, constant)}`) 128 | } 129 | 130 | // Get the requested functions 131 | if (ns.function) 132 | for (let func of ns.function) { 133 | let name = getName(func.$['name']) 134 | 135 | try { 136 | let def = [] 137 | def.push(` export function ${name}(`) 138 | if (func.parameters) { 139 | if (func.parameters[0].parameter) 140 | for (let parameter of func.parameters[0].parameter) { 141 | let name = getName(parameter.$['name']) 142 | if (name === '...') name = '...args' 143 | def.push(`${name}: ${getType(modName, parameter)}`) 144 | def.push(', ') 145 | } 146 | } 147 | if (def[def.length-1] === ', ') 148 | def[def.length-1] = ")" 149 | else 150 | def.push(')') 151 | def.push(getReturnType(modName, func)) 152 | out.push(def.join('')) 153 | } catch (e) { 154 | console.log(e.message) 155 | } 156 | } 157 | 158 | 159 | // Get the requested enums 160 | if (ns.enumeration) 161 | for (let enumeration of ns.enumeration) { 162 | let name = enumeration.$['name'] 163 | try { 164 | out.push(` export enum ${name} {`) 165 | for (let member of enumeration.member) { 166 | let name = member.$['name'].toUpperCase() 167 | if (name[0] >= '0' && name[0] <= '9') name = "_"+name 168 | out.push(` ${name},`) 169 | } 170 | out.push(' }') 171 | } catch (e) { 172 | console.log(e.message) 173 | } 174 | } 175 | 176 | // Bitfield is a type of enum 177 | if (ns.bitfield) 178 | for (let bitfield of ns.bitfield) { 179 | let name = bitfield.$['name'] 180 | try { 181 | out.push(` export enum ${name}{`) 182 | for (let member of bitfield.member) { 183 | let name = member.$['name'].toUpperCase() 184 | if (name[0] >= '0' && name[0] <= '9') name = "_"+name 185 | out.push(` ${name},`) 186 | } 187 | out.push(' }') 188 | } catch (e) { 189 | console.log(e.message) 190 | } 191 | } 192 | 193 | // Get the requested classes 194 | if (ns.class) 195 | for (let klass of ns.class) { 196 | let name = klass.$['name'] 197 | let pt = patch ? patch[name] : null 198 | let ad = add ? add[name] : null 199 | try { 200 | let def = [] 201 | def.push(` export class ${name}`) 202 | if (klass.$['parent']) 203 | def.push(` extends ${klass.$['parent']}`) 204 | def.push(' {') 205 | out.push(def.join('')) 206 | 207 | /** 208 | * Static methods (functions) 209 | */ 210 | if (klass.function) { 211 | for (let func of klass.function) { 212 | if (func.$['name'] === "new") continue // Use standard constructor 213 | if (func.$['name'] === "newv") continue // FIXME! 214 | let line = [] 215 | // if (pt && pt[method.$['name']]) { 216 | // out.push(' '+pt[method.$['name']]) 217 | // } else { 218 | line.push(` static ${func.$['name']}(`) 219 | if (func.parameters) { 220 | if (func.parameters[0].parameter) 221 | for (let parameter of func.parameters[0].parameter) { 222 | let name = getName(parameter.$['name']) 223 | if (name === '...') name = '...args' 224 | line.push(`${name}: ${getType(modName, parameter)}`) 225 | line.push(', ') 226 | } 227 | } 228 | if (line[line.length-1] === ', ') 229 | line[line.length-1] = ")" 230 | else 231 | line.push(')') 232 | line.push(getReturnType(modName, func)) 233 | // } 234 | out.push(line.join('')) 235 | } 236 | 237 | } 238 | /** 239 | * Constructors 240 | */ 241 | if (klass.constructor[0]) { 242 | out.push(" constructor(config?: any)") 243 | for (let ctor in klass.constructor) { 244 | let constructor = klass.constructor[ctor] 245 | if (typeof constructor === 'object') { 246 | if (constructor.$['name'] === 'new') continue 247 | let line = [] 248 | if (pt && pt[constructor.$['name']]) { 249 | out.push(' '+pt[constructor.$['name']]) 250 | } else { 251 | line.push(` static ${constructor.$['name']}(`) 252 | if (constructor.parameters) { 253 | for (let parameter of constructor.parameters[0].parameter) { 254 | let name = getName(parameter.$['name']) 255 | if (name === '...') name = '...args' 256 | line.push(`${name}: ${getType(modName, parameter)}`) 257 | line.push(', ') 258 | } 259 | } 260 | if (line[line.length-1] === ', ') 261 | line[line.length-1] = `):${name}` 262 | else 263 | line.push(`):${name}`) 264 | } 265 | out.push(line.join('')) 266 | } 267 | } 268 | 269 | } 270 | 271 | // if (name === "Object") { 272 | // console.log(name + " "+ JSON.stringify(ad, null, 2)) 273 | // } 274 | // if (name === "Settings") { 275 | // console.log(name + " "+ JSON.stringify(ad, null, 2)) 276 | // } 277 | if (ad) { 278 | for (let mn in ad) { 279 | out.push(' '+ad[mn]) 280 | } 281 | 282 | } 283 | 284 | /** 285 | * Methods 286 | */ 287 | if (klass.method) { 288 | for (let method of klass.method) { 289 | let line = [] 290 | if (pt && pt[method.$['name']]) { 291 | out.push(' '+pt[method.$['name']]) 292 | } else { 293 | line.push(` ${method.$['name']}(`) 294 | if (method.parameters) { 295 | if (method.parameters[0].parameter) 296 | for (let parameter of method.parameters[0].parameter) { 297 | let name = getName(parameter.$['name']) 298 | if (name === '...') name = '...args' 299 | line.push(`${name}: ${getType(modName, parameter)}`) 300 | line.push(', ') 301 | } 302 | } 303 | if (line[line.length-1] === ', ') 304 | line[line.length-1] = ")" 305 | else 306 | line.push(')') 307 | line.push(getReturnType(modName, method)) 308 | } 309 | out.push(line.join('')) 310 | } 311 | } 312 | 313 | out.push(' }') 314 | } catch (e) { 315 | console.log(e.message) 316 | } 317 | } 318 | 319 | return out.join("\n") 320 | } 321 | 322 | /* Fixup: reserved keyword is identifier name */ 323 | function getName(name) { 324 | switch(name) { 325 | case 'in': return 'in_' 326 | case 'function': return 'function_' 327 | case 'true': return 'true_' 328 | case 'false': return 'false_' 329 | case 'break': return 'break_' 330 | } 331 | return name 332 | } 333 | 334 | /* Decode the type */ 335 | function getType(modName, parameter) { 336 | let [name, isArray] = ['', ''] 337 | 338 | if (parameter.array) { 339 | isArray = '[]' 340 | if (parameter.array[0].type) { 341 | name = parameter.array[0].type[0].$['name'] 342 | } 343 | } else if (parameter.type) { 344 | name = parameter.type[0].$['name'] 345 | } 346 | 347 | let x = name.split(' ') 348 | if (x.length === 1) 349 | name = x[0] 350 | else 351 | name = x[1] 352 | 353 | switch(name) { 354 | case '': return 'any'+isArray 355 | case 'utf8': return 'string'+isArray 356 | case 'none': return 'void'+isArray 357 | case 'double': return 'number'+isArray 358 | case 'guint32': return 'number'+isArray 359 | case 'guint16': return 'number'+isArray 360 | case 'gint16': return 'number'+isArray 361 | case 'gunichar': return 'number'+isArray 362 | case 'gint8': return 'number'+isArray 363 | case 'gint32': return 'number'+isArray 364 | case 'gushort': return 'number'+isArray 365 | case 'gfloat': return 'number'+isArray 366 | case 'gboolean': return 'boolean'+isArray 367 | case 'gpointer': return 'object'+isArray 368 | case 'gchar': return 'number'+isArray 369 | case 'guint': return 'number'+isArray 370 | case 'glong': return 'number'+isArray 371 | case 'gulong': return 'number'+isArray 372 | case 'gint': return 'number'+isArray 373 | case 'guint8': return 'number'+isArray 374 | case 'guint64': return 'number'+isArray 375 | case 'gint64': return 'number'+isArray 376 | case 'gdouble': return 'number'+isArray 377 | case 'gssize': return 'number'+isArray 378 | case 'gsize': return 'number'+isArray 379 | case 'long': return 'number'+isArray 380 | case 'object': return 'any'+isArray 381 | case 'va_list': return 'any'+isArray 382 | default: 383 | if (sym[name] || sym[`${modName}.${name}`]) 384 | return name+isArray 385 | else 386 | return 'any'+isArray 387 | } 388 | return '_unknown'+isArray 389 | } 390 | 391 | /* Process the return type */ 392 | function getReturnType(modName, method) { 393 | if (method['return-value']) { 394 | return ':'+getType(modName, method['return-value'][0]) 395 | } else return '' 396 | 397 | } 398 | -------------------------------------------------------------------------------- /bin/gir2dts: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | /** 3 | * gir2dts 4 | * 5 | * Convert Gnome Gir bindings file to typescript declarations 6 | * 7 | */ 8 | const fs = require('fs') 9 | const os = require('os') 10 | const util = require('util') 11 | const {execSync} = require('child_process') 12 | const {parseString} = require('xml2js') 13 | 14 | const cfg = require('../../../gir2dts.json') 15 | const sym = {} 16 | const gir = {} 17 | let count = Object.keys(cfg.module).length 18 | 19 | for (let name in cfg.module) { 20 | let src = fs.readFileSync(cfg.module[name].source, {encoding: 'utf8'}) 21 | // provide a closure so we know which request completed 22 | ;(function(name, src){ 23 | parseString(src, (err, res) => { 24 | gir[name] = res 25 | count-- 26 | console.log(`${count} ${name}`) 27 | if (count <= 0) build(cfg, gir) 28 | }) 29 | })(name, src) 30 | } 31 | 32 | function build(cfg, gir) { 33 | const ts = { 34 | "compilerOptions": { 35 | "target": "es5", // es5 compatability for gjs 36 | "module": "amd", // pack using amd module format 37 | "rootDir": "src", // maodule names based from src 38 | "allowJs": true, // amd loader & nodejs modules are js 39 | "outFile": "index.js" // the target executable 40 | }, 41 | "files": [ 42 | "src/gjs.d.ts", 43 | "src/gjs.js", 44 | "example/imports.ts", 45 | "example/record-collection.ts" 46 | ] 47 | } 48 | for (let name in gir) { 49 | getSymbols(name, gir[name]) 50 | } 51 | for (let name in cfg.module) { 52 | let out = [] 53 | out.push(generateModule(name, gir[name], cfg.module[name])) 54 | fs.writeFileSync(cfg.module[name].output, out.join('\n')) 55 | ts.files.unshift(cfg.module[name].output) 56 | } 57 | fs.writeFileSync("./tsconfig.json", JSON.stringify(ts, null, 2)) 58 | } 59 | 60 | //////////////////////////////////////////////////////////////////////////////////////////// 61 | // pass 1 - generate a symbol table of all known identifiers 62 | //////////////////////////////////////////////////////////////////////////////////////////// 63 | function getSymbols(module, gir) { 64 | 65 | let ns = gir.repository.namespace[0] 66 | if (ns.function) 67 | for (let func of ns.function) { 68 | let name = getName(func.$['name']) 69 | sym[`${module}.${name}`] = `${module}.${name}` 70 | } 71 | if (ns.enumeration) 72 | for (let enumeration of ns.enumeration) { 73 | let name = enumeration.$['name'] 74 | sym[`${module}.${name}`] = `${module}.${name}` 75 | } 76 | if (ns.bitfield) 77 | for (let bitfield of ns.bitfield) { 78 | let name = bitfield.$['name'] 79 | sym[`${module}.${name}`] = `${module}.${name}` 80 | } 81 | if (ns.class) 82 | for (let klass of ns.class) { 83 | let name = klass.$['name'] 84 | sym[`${module}.${name}`] = `${module}.${name}` 85 | } 86 | } 87 | //////////////////////////////////////////////////////////////////////////////////////////// 88 | // pass 2 - process each file 89 | //////////////////////////////////////////////////////////////////////////////////////////// 90 | function generateModule(name, gir, module) { 91 | out = ['/**'] 92 | out.push(` * ${name}.d.ts`) 93 | out.push(' *') 94 | out.push(' */') 95 | out.push(`declare module '${name}' {`) 96 | if (module.import) 97 | for (let im of module.import) 98 | out.push(` import * as ${im} from "${im}"`) 99 | switch (typeof module.patch) { 100 | case 'string': 101 | out.push(fs.readFileSync(module.patch, {encoding: 'utf8'})) 102 | addGirInfo(name, gir, {}, module.add, out) 103 | break 104 | case 'object': 105 | addGirInfo(name, gir, module.patch, module.add, out) 106 | break 107 | default: 108 | addGirInfo(name, gir, module.patch, module.add, out) 109 | } 110 | out.push('}') 111 | return out.join('\n') // fixups: 112 | .replace(/\: object/g, ": any") 113 | .replace(/\:object/g, ":any") 114 | .replace(/\.\.\.args\: any\)/g, "...args: any[])") 115 | .replace(/argc\: number, argv\: string\[\]/g, "argv:string[]") 116 | } 117 | 118 | 119 | function addGirInfo(modName, gir, patch, add, out) { 120 | 121 | let ns = gir.repository.namespace[0] 122 | 123 | // Constants 124 | if (ns.constant) 125 | for (let constant of ns.constant) { 126 | let name = constant.$['name'] 127 | out.push(` export const ${name}:${getType(modName, constant)}`) 128 | } 129 | 130 | // Get the requested functions 131 | if (ns.function) 132 | for (let func of ns.function) { 133 | let name = getName(func.$['name']) 134 | 135 | try { 136 | let def = [] 137 | def.push(` export function ${name}(`) 138 | if (func.parameters) { 139 | if (func.parameters[0].parameter) 140 | for (let parameter of func.parameters[0].parameter) { 141 | let name = getName(parameter.$['name']) 142 | if (name === '...') name = '...args' 143 | def.push(`${name}: ${getType(modName, parameter)}`) 144 | def.push(', ') 145 | } 146 | } 147 | if (def[def.length-1] === ', ') 148 | def[def.length-1] = ")" 149 | else 150 | def.push(')') 151 | def.push(getReturnType(modName, func)) 152 | out.push(def.join('')) 153 | } catch (e) { 154 | console.log(e.message) 155 | } 156 | } 157 | 158 | 159 | // Get the requested enums 160 | if (ns.enumeration) 161 | for (let enumeration of ns.enumeration) { 162 | let name = enumeration.$['name'] 163 | try { 164 | out.push(` export enum ${name} {`) 165 | for (let member of enumeration.member) { 166 | let name = member.$['name'].toUpperCase() 167 | if (name[0] >= '0' && name[0] <= '9') name = "_"+name 168 | out.push(` ${name},`) 169 | } 170 | out.push(' }') 171 | } catch (e) { 172 | console.log(e.message) 173 | } 174 | } 175 | 176 | // Bitfield is a type of enum 177 | if (ns.bitfield) 178 | for (let bitfield of ns.bitfield) { 179 | let name = bitfield.$['name'] 180 | try { 181 | out.push(` export enum ${name}{`) 182 | for (let member of bitfield.member) { 183 | let name = member.$['name'].toUpperCase() 184 | if (name[0] >= '0' && name[0] <= '9') name = "_"+name 185 | out.push(` ${name},`) 186 | } 187 | out.push(' }') 188 | } catch (e) { 189 | console.log(e.message) 190 | } 191 | } 192 | 193 | // Get the requested classes 194 | if (ns.class) 195 | for (let klass of ns.class) { 196 | let name = klass.$['name'] 197 | let pt = patch ? patch[name] : null 198 | let ad = add ? add[name] : null 199 | try { 200 | let def = [] 201 | def.push(` export class ${name}`) 202 | if (klass.$['parent']) 203 | def.push(` extends ${klass.$['parent']}`) 204 | def.push(' {') 205 | out.push(def.join('')) 206 | 207 | /** 208 | * Static methods (functions) 209 | */ 210 | if (klass.function) { 211 | for (let func of klass.function) { 212 | if (func.$['name'] === "new") continue // Use standard constructor 213 | if (func.$['name'] === "newv") continue // FIXME! 214 | let line = [] 215 | // if (pt && pt[method.$['name']]) { 216 | // out.push(' '+pt[method.$['name']]) 217 | // } else { 218 | line.push(` static ${func.$['name']}(`) 219 | if (func.parameters) { 220 | if (func.parameters[0].parameter) 221 | for (let parameter of func.parameters[0].parameter) { 222 | let name = getName(parameter.$['name']) 223 | if (name === '...') name = '...args' 224 | line.push(`${name}: ${getType(modName, parameter)}`) 225 | line.push(', ') 226 | } 227 | } 228 | if (line[line.length-1] === ', ') 229 | line[line.length-1] = ")" 230 | else 231 | line.push(')') 232 | line.push(getReturnType(modName, func)) 233 | // } 234 | out.push(line.join('')) 235 | } 236 | 237 | } 238 | /** 239 | * Constructors 240 | */ 241 | if (klass.constructor[0]) { 242 | out.push(" constructor(config?: any)") 243 | for (let ctor in klass.constructor) { 244 | let constructor = klass.constructor[ctor] 245 | if (typeof constructor === 'object') { 246 | if (constructor.$['name'] === 'new') continue 247 | let line = [] 248 | if (pt && pt[constructor.$['name']]) { 249 | out.push(' '+pt[constructor.$['name']]) 250 | } else { 251 | line.push(` static ${constructor.$['name']}(`) 252 | if (constructor.parameters) { 253 | for (let parameter of constructor.parameters[0].parameter) { 254 | let name = getName(parameter.$['name']) 255 | if (name === '...') name = '...args' 256 | line.push(`${name}: ${getType(modName, parameter)}`) 257 | line.push(', ') 258 | } 259 | } 260 | if (line[line.length-1] === ', ') 261 | line[line.length-1] = `):${name}` 262 | else 263 | line.push(`):${name}`) 264 | } 265 | out.push(line.join('')) 266 | } 267 | } 268 | 269 | } 270 | 271 | // if (name === "Object") { 272 | // console.log(name + " "+ JSON.stringify(ad, null, 2)) 273 | // } 274 | // if (name === "Settings") { 275 | // console.log(name + " "+ JSON.stringify(ad, null, 2)) 276 | // } 277 | if (ad) { 278 | for (let mn in ad) { 279 | out.push(' '+ad[mn]) 280 | } 281 | 282 | } 283 | 284 | /** 285 | * Methods 286 | */ 287 | if (klass.method) { 288 | for (let method of klass.method) { 289 | let line = [] 290 | if (pt && pt[method.$['name']]) { 291 | out.push(' '+pt[method.$['name']]) 292 | } else { 293 | line.push(` ${method.$['name']}(`) 294 | if (method.parameters) { 295 | if (method.parameters[0].parameter) 296 | for (let parameter of method.parameters[0].parameter) { 297 | let name = getName(parameter.$['name']) 298 | if (name === '...') name = '...args' 299 | line.push(`${name}: ${getType(modName, parameter)}`) 300 | line.push(', ') 301 | } 302 | } 303 | if (line[line.length-1] === ', ') 304 | line[line.length-1] = ")" 305 | else 306 | line.push(')') 307 | line.push(getReturnType(modName, method)) 308 | } 309 | out.push(line.join('')) 310 | } 311 | } 312 | 313 | out.push(' }') 314 | } catch (e) { 315 | console.log(e.message) 316 | } 317 | } 318 | 319 | return out.join("\n") 320 | } 321 | 322 | /* Fixup: reserved keyword is identifier name */ 323 | function getName(name) { 324 | switch(name) { 325 | case 'in': return 'in_' 326 | case 'function': return 'function_' 327 | case 'true': return 'true_' 328 | case 'false': return 'false_' 329 | case 'break': return 'break_' 330 | } 331 | return name 332 | } 333 | 334 | /* Decode the type */ 335 | function getType(modName, parameter) { 336 | let [name, isArray] = ['', ''] 337 | 338 | if (parameter.array) { 339 | isArray = '[]' 340 | if (parameter.array[0].type) { 341 | name = parameter.array[0].type[0].$['name'] 342 | } 343 | } else if (parameter.type) { 344 | name = parameter.type[0].$['name'] 345 | } 346 | 347 | let x = name.split(' ') 348 | if (x.length === 1) 349 | name = x[0] 350 | else 351 | name = x[1] 352 | 353 | switch(name) { 354 | case '': return 'any'+isArray 355 | case 'utf8': return 'string'+isArray 356 | case 'none': return 'void'+isArray 357 | case 'double': return 'number'+isArray 358 | case 'guint32': return 'number'+isArray 359 | case 'guint16': return 'number'+isArray 360 | case 'gint16': return 'number'+isArray 361 | case 'gunichar': return 'number'+isArray 362 | case 'gint8': return 'number'+isArray 363 | case 'gint32': return 'number'+isArray 364 | case 'gushort': return 'number'+isArray 365 | case 'gfloat': return 'number'+isArray 366 | case 'gboolean': return 'boolean'+isArray 367 | case 'gpointer': return 'object'+isArray 368 | case 'gchar': return 'number'+isArray 369 | case 'guint': return 'number'+isArray 370 | case 'glong': return 'number'+isArray 371 | case 'gulong': return 'number'+isArray 372 | case 'gint': return 'number'+isArray 373 | case 'guint8': return 'number'+isArray 374 | case 'guint64': return 'number'+isArray 375 | case 'gint64': return 'number'+isArray 376 | case 'gdouble': return 'number'+isArray 377 | case 'gssize': return 'number'+isArray 378 | case 'gsize': return 'number'+isArray 379 | case 'long': return 'number'+isArray 380 | case 'object': return 'any'+isArray 381 | case 'va_list': return 'any'+isArray 382 | default: 383 | if (sym[name] || sym[`${modName}.${name}`]) 384 | return name+isArray 385 | else 386 | return 'any'+isArray 387 | } 388 | return '_unknown'+isArray 389 | } 390 | 391 | /* Process the return type */ 392 | function getReturnType(modName, method) { 393 | if (method['return-value']) { 394 | return ':'+getType(modName, method['return-value'][0]) 395 | } else return '' 396 | 397 | } 398 | -------------------------------------------------------------------------------- /src/pango-1.0.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Pango.d.ts 3 | * 4 | */ 5 | declare module 'Pango' { 6 | import * as GObject from "GObject" 7 | export const ANALYSIS_FLAG_CENTERED_BASELINE:number 8 | export const ANALYSIS_FLAG_IS_ELLIPSIS:number 9 | export const ATTR_INDEX_FROM_TEXT_BEGINNING:number 10 | export const ENGINE_TYPE_LANG:string 11 | export const ENGINE_TYPE_SHAPE:string 12 | export const GLYPH_EMPTY:any 13 | export const GLYPH_INVALID_INPUT:any 14 | export const GLYPH_UNKNOWN_FLAG:any 15 | export const RENDER_TYPE_NONE:string 16 | export const SCALE:number 17 | export const UNKNOWN_GLYPH_HEIGHT:number 18 | export const UNKNOWN_GLYPH_WIDTH:number 19 | export function attr_background_alpha_new(alpha: number):any 20 | export function attr_background_new(red: number, green: number, blue: number):any 21 | export function attr_fallback_new(enable_fallback: boolean):any 22 | export function attr_family_new(family: string):any 23 | export function attr_foreground_alpha_new(alpha: number):any 24 | export function attr_foreground_new(red: number, green: number, blue: number):any 25 | export function attr_gravity_hint_new(hint: GravityHint):any 26 | export function attr_gravity_new(gravity: Gravity):any 27 | export function attr_letter_spacing_new(letter_spacing: number):any 28 | export function attr_rise_new(rise: number):any 29 | export function attr_scale_new(scale_factor: number):any 30 | export function attr_stretch_new(stretch: Stretch):any 31 | export function attr_strikethrough_color_new(red: number, green: number, blue: number):any 32 | export function attr_strikethrough_new(strikethrough: boolean):any 33 | export function attr_style_new(style: Style):any 34 | export function attr_type_get_name(type: AttrType):string 35 | export function attr_type_register(name: string):AttrType 36 | export function attr_underline_color_new(red: number, green: number, blue: number):any 37 | export function attr_underline_new(underline: Underline):any 38 | export function attr_variant_new(variant: Variant):any 39 | export function attr_weight_new(weight: Weight):any 40 | export function bidi_type_for_unichar(ch: number):BidiType 41 | export function break_(text: string, length: number, analysis: any, attrs: any[], attrs_len: number):void 42 | export function config_key_get(key: string):string 43 | export function config_key_get_system(key: string):string 44 | export function default_break(text: string, length: number, analysis: any, attrs: any, attrs_len: number):void 45 | export function extents_to_pixels(inclusive: any, nearest: any):void 46 | export function find_base_dir(text: string, length: number):Direction 47 | export function find_map(language: any, engine_type_id: number, render_type_id: number):any 48 | export function find_paragraph_boundary(text: string, length: number, paragraph_delimiter_index: number, next_paragraph_start: number):void 49 | export function font_description_from_string(str: string):any 50 | export function get_lib_subdirectory():string 51 | export function get_log_attrs(text: string, length: number, level: number, language: any, log_attrs: any[], attrs_len: number):void 52 | export function get_mirror_char(ch: number, mirrored_ch: number):boolean 53 | export function get_sysconf_subdirectory():string 54 | export function gravity_get_for_matrix(matrix: any):Gravity 55 | export function gravity_get_for_script(script: Script, base_gravity: Gravity, hint: GravityHint):Gravity 56 | export function gravity_get_for_script_and_width(script: Script, wide: boolean, base_gravity: Gravity, hint: GravityHint):Gravity 57 | export function gravity_to_rotation(gravity: Gravity):number 58 | export function is_zero_width(ch: number):boolean 59 | export function itemize(context: Context, text: string, start_index: number, length: number, attrs: any, cached_iter: any):any 60 | export function itemize_with_base_dir(context: Context, base_dir: Direction, text: string, start_index: number, length: number, attrs: any, cached_iter: any):any 61 | export function language_from_string(language: string):any 62 | export function language_get_default():any 63 | export function log2vis_get_embedding_levels(text: string, length: number, pbase_dir: Direction):number 64 | export function lookup_aliases(fontname: string, families: string[], n_families: number):void 65 | export function markup_parser_finish(context: any, attr_list: any, text: string, accel_char: number):boolean 66 | export function markup_parser_new(accel_marker: number):any 67 | export function module_register(module: any):void 68 | export function parse_enum(type: any, str: string, value: number, warn: boolean, possible_values: string):boolean 69 | export function parse_markup(markup_text: string, length: number, accel_marker: number, attr_list: any, text: string, accel_char: number):boolean 70 | export function parse_stretch(str: string, stretch: Stretch, warn: boolean):boolean 71 | export function parse_style(str: string, style: Style, warn: boolean):boolean 72 | export function parse_variant(str: string, variant: Variant, warn: boolean):boolean 73 | export function parse_weight(str: string, weight: Weight, warn: boolean):boolean 74 | export function quantize_line_geometry(thickness: number, position: number):void 75 | export function read_line(stream: any, str: any):number 76 | export function reorder_items(logical_items: any):any 77 | export function scan_int(pos: string, out: number):boolean 78 | export function scan_string(pos: string, out: any):boolean 79 | export function scan_word(pos: string, out: any):boolean 80 | export function script_for_unichar(ch: number):Script 81 | export function script_get_sample_language(script: Script):any 82 | export function shape(text: string, length: number, analysis: any, glyphs: any):void 83 | export function shape_full(item_text: string, item_length: number, paragraph_text: string, paragraph_length: number, analysis: any, glyphs: any):void 84 | export function skip_space(pos: string):boolean 85 | export function split_file_list(str: string):string[] 86 | export function trim_string(str: string):string 87 | export function unichar_direction(ch: number):Direction 88 | export function units_from_double(d: number):number 89 | export function units_to_double(i: number):number 90 | export function version():number 91 | export function version_check(required_major: number, required_minor: number, required_micro: number):string 92 | export function version_string():string 93 | export enum Alignment { 94 | LEFT, 95 | CENTER, 96 | RIGHT, 97 | } 98 | export enum AttrType { 99 | INVALID, 100 | LANGUAGE, 101 | FAMILY, 102 | STYLE, 103 | WEIGHT, 104 | VARIANT, 105 | STRETCH, 106 | SIZE, 107 | FONT_DESC, 108 | FOREGROUND, 109 | BACKGROUND, 110 | UNDERLINE, 111 | STRIKETHROUGH, 112 | RISE, 113 | SHAPE, 114 | SCALE, 115 | FALLBACK, 116 | LETTER_SPACING, 117 | UNDERLINE_COLOR, 118 | STRIKETHROUGH_COLOR, 119 | ABSOLUTE_SIZE, 120 | GRAVITY, 121 | GRAVITY_HINT, 122 | FONT_FEATURES, 123 | FOREGROUND_ALPHA, 124 | BACKGROUND_ALPHA, 125 | } 126 | export enum BidiType { 127 | L, 128 | LRE, 129 | LRO, 130 | R, 131 | AL, 132 | RLE, 133 | RLO, 134 | PDF, 135 | EN, 136 | ES, 137 | ET, 138 | AN, 139 | CS, 140 | NSM, 141 | BN, 142 | B, 143 | S, 144 | WS, 145 | ON, 146 | } 147 | export enum CoverageLevel { 148 | NONE, 149 | FALLBACK, 150 | APPROXIMATE, 151 | EXACT, 152 | } 153 | export enum Direction { 154 | LTR, 155 | RTL, 156 | TTB_LTR, 157 | TTB_RTL, 158 | WEAK_LTR, 159 | WEAK_RTL, 160 | NEUTRAL, 161 | } 162 | export enum EllipsizeMode { 163 | NONE, 164 | START, 165 | MIDDLE, 166 | END, 167 | } 168 | export enum Gravity { 169 | SOUTH, 170 | EAST, 171 | NORTH, 172 | WEST, 173 | AUTO, 174 | } 175 | export enum GravityHint { 176 | NATURAL, 177 | STRONG, 178 | LINE, 179 | } 180 | export enum RenderPart { 181 | FOREGROUND, 182 | BACKGROUND, 183 | UNDERLINE, 184 | STRIKETHROUGH, 185 | } 186 | export enum Script { 187 | INVALID_CODE, 188 | COMMON, 189 | INHERITED, 190 | ARABIC, 191 | ARMENIAN, 192 | BENGALI, 193 | BOPOMOFO, 194 | CHEROKEE, 195 | COPTIC, 196 | CYRILLIC, 197 | DESERET, 198 | DEVANAGARI, 199 | ETHIOPIC, 200 | GEORGIAN, 201 | GOTHIC, 202 | GREEK, 203 | GUJARATI, 204 | GURMUKHI, 205 | HAN, 206 | HANGUL, 207 | HEBREW, 208 | HIRAGANA, 209 | KANNADA, 210 | KATAKANA, 211 | KHMER, 212 | LAO, 213 | LATIN, 214 | MALAYALAM, 215 | MONGOLIAN, 216 | MYANMAR, 217 | OGHAM, 218 | OLD_ITALIC, 219 | ORIYA, 220 | RUNIC, 221 | SINHALA, 222 | SYRIAC, 223 | TAMIL, 224 | TELUGU, 225 | THAANA, 226 | THAI, 227 | TIBETAN, 228 | CANADIAN_ABORIGINAL, 229 | YI, 230 | TAGALOG, 231 | HANUNOO, 232 | BUHID, 233 | TAGBANWA, 234 | BRAILLE, 235 | CYPRIOT, 236 | LIMBU, 237 | OSMANYA, 238 | SHAVIAN, 239 | LINEAR_B, 240 | TAI_LE, 241 | UGARITIC, 242 | NEW_TAI_LUE, 243 | BUGINESE, 244 | GLAGOLITIC, 245 | TIFINAGH, 246 | SYLOTI_NAGRI, 247 | OLD_PERSIAN, 248 | KHAROSHTHI, 249 | UNKNOWN, 250 | BALINESE, 251 | CUNEIFORM, 252 | PHOENICIAN, 253 | PHAGS_PA, 254 | NKO, 255 | KAYAH_LI, 256 | LEPCHA, 257 | REJANG, 258 | SUNDANESE, 259 | SAURASHTRA, 260 | CHAM, 261 | OL_CHIKI, 262 | VAI, 263 | CARIAN, 264 | LYCIAN, 265 | LYDIAN, 266 | BATAK, 267 | BRAHMI, 268 | MANDAIC, 269 | CHAKMA, 270 | MEROITIC_CURSIVE, 271 | MEROITIC_HIEROGLYPHS, 272 | MIAO, 273 | SHARADA, 274 | SORA_SOMPENG, 275 | TAKRI, 276 | } 277 | export enum Stretch { 278 | ULTRA_CONDENSED, 279 | EXTRA_CONDENSED, 280 | CONDENSED, 281 | SEMI_CONDENSED, 282 | NORMAL, 283 | SEMI_EXPANDED, 284 | EXPANDED, 285 | EXTRA_EXPANDED, 286 | ULTRA_EXPANDED, 287 | } 288 | export enum Style { 289 | NORMAL, 290 | OBLIQUE, 291 | ITALIC, 292 | } 293 | export enum TabAlign { 294 | LEFT, 295 | } 296 | export enum Underline { 297 | NONE, 298 | SINGLE, 299 | DOUBLE, 300 | LOW, 301 | ERROR, 302 | } 303 | export enum Variant { 304 | NORMAL, 305 | SMALL_CAPS, 306 | } 307 | export enum Weight { 308 | THIN, 309 | ULTRALIGHT, 310 | LIGHT, 311 | SEMILIGHT, 312 | BOOK, 313 | NORMAL, 314 | MEDIUM, 315 | SEMIBOLD, 316 | BOLD, 317 | ULTRABOLD, 318 | HEAVY, 319 | ULTRAHEAVY, 320 | } 321 | export enum WrapMode { 322 | WORD, 323 | CHAR, 324 | WORD_CHAR, 325 | } 326 | export enum FontMask{ 327 | FAMILY, 328 | STYLE, 329 | VARIANT, 330 | WEIGHT, 331 | STRETCH, 332 | SIZE, 333 | GRAVITY, 334 | } 335 | export class Context extends GObject.Object { 336 | constructor(config?: any) 337 | changed():void 338 | get_base_dir():Direction 339 | get_base_gravity():Gravity 340 | get_font_description():any 341 | get_font_map():FontMap 342 | get_gravity():Gravity 343 | get_gravity_hint():GravityHint 344 | get_language():any 345 | get_matrix():any 346 | get_metrics(desc: any, language: any):any 347 | get_serial():number 348 | list_families(families: FontFamily[], n_families: number):void 349 | load_font(desc: any):Font 350 | load_fontset(desc: any, language: any):Fontset 351 | set_base_dir(direction: Direction):void 352 | set_base_gravity(gravity: Gravity):void 353 | set_font_description(desc: any):void 354 | set_font_map(font_map: FontMap):void 355 | set_gravity_hint(hint: GravityHint):void 356 | set_language(language: any):void 357 | set_matrix(matrix: any):void 358 | } 359 | export class Engine extends GObject.Object { 360 | } 361 | export class EngineLang extends Engine { 362 | } 363 | export class EngineShape extends Engine { 364 | } 365 | export class Font extends GObject.Object { 366 | static descriptions_free(descs: any[], n_descs: number):void 367 | describe():any 368 | describe_with_absolute_size():any 369 | find_shaper(language: any, ch: number):EngineShape 370 | get_coverage(language: any):any 371 | get_font_map():FontMap 372 | get_glyph_extents(glyph: any, ink_rect: any, logical_rect: any):void 373 | get_metrics(language: any):any 374 | } 375 | export class FontFace extends GObject.Object { 376 | describe():any 377 | get_face_name():string 378 | is_synthesized():boolean 379 | list_sizes(sizes: number[], n_sizes: number):void 380 | } 381 | export class FontFamily extends GObject.Object { 382 | get_name():string 383 | is_monospace():boolean 384 | list_faces(faces: FontFace[], n_faces: number):void 385 | } 386 | export class FontMap extends GObject.Object { 387 | changed():void 388 | create_context():Context 389 | get_serial():number 390 | get_shape_engine_type():string 391 | list_families(families: FontFamily[], n_families: number):void 392 | load_font(context: Context, desc: any):Font 393 | load_fontset(context: Context, desc: any, language: any):Fontset 394 | } 395 | export class Fontset extends GObject.Object { 396 | foreach(func: any, data: any):void 397 | get_font(wc: number):Font 398 | get_metrics():any 399 | } 400 | export class FontsetSimple extends Fontset { 401 | constructor(config?: any) 402 | append(font: Font):void 403 | size():number 404 | } 405 | export class Layout extends GObject.Object { 406 | constructor(config?: any) 407 | context_changed():void 408 | copy():Layout 409 | get_alignment():Alignment 410 | get_attributes():any 411 | get_auto_dir():boolean 412 | get_baseline():number 413 | get_character_count():number 414 | get_context():Context 415 | get_cursor_pos(index_: number, strong_pos: any, weak_pos: any):void 416 | get_ellipsize():EllipsizeMode 417 | get_extents(ink_rect: any, logical_rect: any):void 418 | get_font_description():any 419 | get_height():number 420 | get_indent():number 421 | get_iter():any 422 | get_justify():boolean 423 | get_line(line: number):any 424 | get_line_count():number 425 | get_line_readonly(line: number):any 426 | get_lines():any 427 | get_lines_readonly():any 428 | get_log_attrs(attrs: any[], n_attrs: number):void 429 | get_log_attrs_readonly(n_attrs: number):any[] 430 | get_pixel_extents(ink_rect: any, logical_rect: any):void 431 | get_pixel_size(width: number, height: number):void 432 | get_serial():number 433 | get_single_paragraph_mode():boolean 434 | get_size(width: number, height: number):void 435 | get_spacing():number 436 | get_tabs():any 437 | get_text():string 438 | get_unknown_glyphs_count():number 439 | get_width():number 440 | get_wrap():WrapMode 441 | index_to_line_x(index_: number, trailing: boolean, line: number, x_pos: number):void 442 | index_to_pos(index_: number, pos: any):void 443 | is_ellipsized():boolean 444 | is_wrapped():boolean 445 | move_cursor_visually(strong: boolean, old_index: number, old_trailing: number, direction: number, new_index: number, new_trailing: number):void 446 | set_alignment(alignment: Alignment):void 447 | set_attributes(attrs: any):void 448 | set_auto_dir(auto_dir: boolean):void 449 | set_ellipsize(ellipsize: EllipsizeMode):void 450 | set_font_description(desc: any):void 451 | set_height(height: number):void 452 | set_indent(indent: number):void 453 | set_justify(justify: boolean):void 454 | set_markup(markup: string, length: number):void 455 | set_markup_with_accel(markup: string, length: number, accel_marker: number, accel_char: number):void 456 | set_single_paragraph_mode(setting: boolean):void 457 | set_spacing(spacing: number):void 458 | set_tabs(tabs: any):void 459 | set_text(text: string, length: number):void 460 | set_width(width: number):void 461 | set_wrap(wrap: WrapMode):void 462 | xy_to_index(x: number, y: number, index_: number, trailing: number):boolean 463 | } 464 | export class Renderer extends GObject.Object { 465 | activate():void 466 | deactivate():void 467 | draw_error_underline(x: number, y: number, width: number, height: number):void 468 | draw_glyph(font: Font, glyph: any, x: number, y: number):void 469 | draw_glyph_item(text: string, glyph_item: any, x: number, y: number):void 470 | draw_glyphs(font: Font, glyphs: any, x: number, y: number):void 471 | draw_layout(layout: Layout, x: number, y: number):void 472 | draw_layout_line(line: any, x: number, y: number):void 473 | draw_rectangle(part: RenderPart, x: number, y: number, width: number, height: number):void 474 | draw_trapezoid(part: RenderPart, y1_: number, x11: number, x21: number, y2: number, x12: number, x22: number):void 475 | get_alpha(part: RenderPart):number 476 | get_color(part: RenderPart):any 477 | get_layout():Layout 478 | get_layout_line():any 479 | get_matrix():any 480 | part_changed(part: RenderPart):void 481 | set_alpha(part: RenderPart, alpha: number):void 482 | set_color(part: RenderPart, color: any):void 483 | set_matrix(matrix: any):void 484 | } 485 | } -------------------------------------------------------------------------------- /src/gtksource-3.0.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GtkSource.d.ts 3 | * 4 | */ 5 | declare module 'GtkSource' { 6 | import * as GObject from "GObject" 7 | import * as Gio from "Gio" 8 | import * as Gdk from "Gdk" 9 | import * as Gtk from "Gtk" 10 | export function completion_error_quark():any 11 | export function encoding_get_all():any 12 | export function encoding_get_current():any 13 | export function encoding_get_default_candidates():any 14 | export function encoding_get_from_charset(charset: string):any 15 | export function encoding_get_utf8():any 16 | export function file_loader_error_quark():any 17 | export function file_saver_error_quark():any 18 | export function utils_escape_search_text(text: string):string 19 | export function utils_unescape_search_text(text: string):string 20 | export enum BackgroundPatternType { 21 | NONE, 22 | GRID, 23 | } 24 | export enum BracketMatchType { 25 | NONE, 26 | OUT_OF_RANGE, 27 | NOT_FOUND, 28 | FOUND, 29 | } 30 | export enum ChangeCaseType { 31 | LOWER, 32 | UPPER, 33 | TOGGLE, 34 | TITLE, 35 | } 36 | export enum CompletionError { 37 | ALREADY_BOUND, 38 | NOT_BOUND, 39 | } 40 | export enum CompressionType { 41 | NONE, 42 | GZIP, 43 | } 44 | export enum FileLoaderError { 45 | TOO_BIG, 46 | ENCODING_AUTO_DETECTION_FAILED, 47 | CONVERSION_FALLBACK, 48 | } 49 | export enum FileSaverError { 50 | INVALID_CHARS, 51 | EXTERNALLY_MODIFIED, 52 | } 53 | export enum GutterRendererAlignmentMode { 54 | CELL, 55 | FIRST, 56 | LAST, 57 | } 58 | export enum NewlineType { 59 | LF, 60 | CR, 61 | CR_LF, 62 | } 63 | export enum SmartHomeEndType { 64 | DISABLED, 65 | BEFORE, 66 | AFTER, 67 | ALWAYS, 68 | } 69 | export enum ViewGutterPosition { 70 | LINES, 71 | MARKS, 72 | } 73 | export enum CompletionActivation{ 74 | NONE, 75 | INTERACTIVE, 76 | USER_REQUESTED, 77 | } 78 | export enum DrawSpacesFlags{ 79 | SPACE, 80 | TAB, 81 | NEWLINE, 82 | NBSP, 83 | LEADING, 84 | TEXT, 85 | TRAILING, 86 | ALL, 87 | } 88 | export enum FileSaverFlags{ 89 | NONE, 90 | IGNORE_INVALID_CHARS, 91 | IGNORE_MODIFICATION_TIME, 92 | CREATE_BACKUP, 93 | } 94 | export enum GutterRendererState{ 95 | NORMAL, 96 | CURSOR, 97 | PRELIT, 98 | SELECTED, 99 | } 100 | export enum SortFlags{ 101 | NONE, 102 | CASE_SENSITIVE, 103 | REVERSE_ORDER, 104 | REMOVE_DUPLICATES, 105 | } 106 | export class Buffer extends Gtk.TextBuffer { 107 | constructor(config?: any) 108 | static new_with_language(language: Language):Buffer 109 | backward_iter_to_source_mark(iter: any, category: string):boolean 110 | begin_not_undoable_action():void 111 | can_redo():boolean 112 | can_undo():boolean 113 | change_case(case_type: ChangeCaseType, start: any, end: any):void 114 | create_source_mark(name: string, category: string, where: any):Mark 115 | end_not_undoable_action():void 116 | ensure_highlight(start: any, end: any):void 117 | forward_iter_to_source_mark(iter: any, category: string):boolean 118 | get_context_classes_at_iter(iter: any):string[] 119 | get_highlight_matching_brackets():boolean 120 | get_highlight_syntax():boolean 121 | get_implicit_trailing_newline():boolean 122 | get_language():Language 123 | get_max_undo_levels():number 124 | get_source_marks_at_iter(iter: any, category: string):any 125 | get_source_marks_at_line(line: number, category: string):any 126 | get_style_scheme():StyleScheme 127 | get_undo_manager():any 128 | iter_backward_to_context_class_toggle(iter: any, context_class: string):boolean 129 | iter_forward_to_context_class_toggle(iter: any, context_class: string):boolean 130 | iter_has_context_class(iter: any, context_class: string):boolean 131 | join_lines(start: any, end: any):void 132 | redo():void 133 | remove_source_marks(start: any, end: any, category: string):void 134 | set_highlight_matching_brackets(highlight: boolean):void 135 | set_highlight_syntax(highlight: boolean):void 136 | set_implicit_trailing_newline(implicit_trailing_newline: boolean):void 137 | set_language(language: Language):void 138 | set_max_undo_levels(max_undo_levels: number):void 139 | set_style_scheme(scheme: StyleScheme):void 140 | set_undo_manager(manager: any):void 141 | sort_lines(start: any, end: any, flags: SortFlags, column: number):void 142 | undo():void 143 | } 144 | export class Completion extends GObject.Object { 145 | add_provider(provider: any):boolean 146 | block_interactive():void 147 | create_context(position: any):CompletionContext 148 | get_info_window():CompletionInfo 149 | get_providers():any 150 | get_view():View 151 | hide():void 152 | move_window(iter: any):void 153 | remove_provider(provider: any):boolean 154 | show(providers: any, context: CompletionContext):boolean 155 | unblock_interactive():void 156 | } 157 | export class CompletionContext extends GObject.InitiallyUnowned { 158 | add_proposals(provider: any, proposals: any, finished: boolean):void 159 | get_activation():CompletionActivation 160 | get_iter(iter: any):boolean 161 | } 162 | export class CompletionInfo extends Gtk.Window { 163 | constructor(config?: any) 164 | get_widget():Gtk.Widget 165 | move_to_iter(view: Gtk.TextView, iter: any):void 166 | set_widget(widget: Gtk.Widget):void 167 | } 168 | export class CompletionItem extends GObject.Object { 169 | constructor(config?: any) 170 | static new_from_stock(label: string, text: string, stock: string, info: string):CompletionItem 171 | static new_with_markup(markup: string, text: string, icon: any, info: string):CompletionItem 172 | } 173 | export class CompletionWords extends GObject.Object { 174 | constructor(config?: any) 175 | register(buffer: Gtk.TextBuffer):void 176 | unregister(buffer: Gtk.TextBuffer):void 177 | } 178 | export class File extends GObject.Object { 179 | constructor(config?: any) 180 | check_file_on_disk():void 181 | get_compression_type():CompressionType 182 | get_encoding():any 183 | get_location():any 184 | get_newline_type():NewlineType 185 | is_deleted():boolean 186 | is_externally_modified():boolean 187 | is_local():boolean 188 | is_readonly():boolean 189 | set_location(location: any):void 190 | set_mount_operation_factory(callback: any, user_data: any, notify: any):void 191 | } 192 | export class FileLoader extends GObject.Object { 193 | constructor(config?: any) 194 | static new_from_stream(buffer: Buffer, file: File, stream: Gio.InputStream):FileLoader 195 | get_buffer():Buffer 196 | get_compression_type():CompressionType 197 | get_encoding():any 198 | get_file():File 199 | get_input_stream():Gio.InputStream 200 | get_location():any 201 | get_newline_type():NewlineType 202 | load_async(io_priority: number, cancellable: Gio.Cancellable, progress_callback: any, progress_callback_data: any, progress_callback_notify: any, callback: any, user_data: any):void 203 | load_finish(result: any):boolean 204 | set_candidate_encodings(candidate_encodings: any):void 205 | } 206 | export class FileSaver extends GObject.Object { 207 | constructor(config?: any) 208 | static new_with_target(buffer: Buffer, file: File, target_location: any):FileSaver 209 | get_buffer():Buffer 210 | get_compression_type():CompressionType 211 | get_encoding():any 212 | get_file():File 213 | get_flags():FileSaverFlags 214 | get_location():any 215 | get_newline_type():NewlineType 216 | save_async(io_priority: number, cancellable: Gio.Cancellable, progress_callback: any, progress_callback_data: any, progress_callback_notify: any, callback: any, user_data: any):void 217 | save_finish(result: any):boolean 218 | set_compression_type(compression_type: CompressionType):void 219 | set_encoding(encoding: any):void 220 | set_flags(flags: FileSaverFlags):void 221 | set_newline_type(newline_type: NewlineType):void 222 | } 223 | export class Gutter extends GObject.Object { 224 | get_padding(xpad: number, ypad: number):void 225 | get_renderer_at_pos(x: number, y: number):GutterRenderer 226 | get_window():Gdk.Window 227 | insert(renderer: GutterRenderer, position: number):boolean 228 | queue_draw():void 229 | remove(renderer: GutterRenderer):void 230 | reorder(renderer: GutterRenderer, position: number):void 231 | set_padding(xpad: number, ypad: number):void 232 | } 233 | export class GutterRenderer extends GObject.InitiallyUnowned { 234 | activate(iter: any, area: any, event: any):void 235 | begin(cr: any, background_area: any, cell_area: any, start: any, end: any):void 236 | draw(cr: any, background_area: any, cell_area: any, start: any, end: any, state: GutterRendererState):void 237 | end():void 238 | get_alignment(xalign: number, yalign: number):void 239 | get_alignment_mode():GutterRendererAlignmentMode 240 | get_background(color: any):boolean 241 | get_padding(xpad: number, ypad: number):void 242 | get_size():number 243 | get_view():Gtk.TextView 244 | get_visible():boolean 245 | get_window_type():Gtk.TextWindowType 246 | query_activatable(iter: any, area: any, event: any):boolean 247 | query_data(start: any, end: any, state: GutterRendererState):void 248 | query_tooltip(iter: any, area: any, x: number, y: number, tooltip: Gtk.Tooltip):boolean 249 | queue_draw():void 250 | set_alignment(xalign: number, yalign: number):void 251 | set_alignment_mode(mode: GutterRendererAlignmentMode):void 252 | set_background(color: any):void 253 | set_padding(xpad: number, ypad: number):void 254 | set_size(size: number):void 255 | set_visible(visible: boolean):void 256 | } 257 | export class GutterRendererPixbuf extends GutterRenderer { 258 | constructor(config?: any) 259 | get_gicon():any 260 | get_icon_name():string 261 | get_pixbuf():any 262 | get_stock_id():string 263 | set_gicon(icon: any):void 264 | set_icon_name(icon_name: string):void 265 | set_pixbuf(pixbuf: any):void 266 | set_stock_id(stock_id: string):void 267 | } 268 | export class GutterRendererText extends GutterRenderer { 269 | constructor(config?: any) 270 | measure(text: string, width: number, height: number):void 271 | measure_markup(markup: string, width: number, height: number):void 272 | set_markup(markup: string, length: number):void 273 | set_text(text: string, length: number):void 274 | } 275 | export class Language extends GObject.Object { 276 | get_globs():string[] 277 | get_hidden():boolean 278 | get_id():string 279 | get_metadata(name: string):string 280 | get_mime_types():string[] 281 | get_name():string 282 | get_section():string 283 | get_style_fallback(style_id: string):string 284 | get_style_ids():string[] 285 | get_style_name(style_id: string):string 286 | } 287 | export class LanguageManager extends GObject.Object { 288 | static get_default():LanguageManager 289 | constructor(config?: any) 290 | get_language(id: string):Language 291 | get_language_ids():string[] 292 | get_search_path():string[] 293 | guess_language(filename: string, content_type: string):Language 294 | set_search_path(dirs: string[]):void 295 | } 296 | export class Map extends View { 297 | constructor(config?: any) 298 | get_view():View 299 | set_view(view: View):void 300 | } 301 | export class Mark extends Gtk.TextMark { 302 | constructor(config?: any) 303 | get_category():string 304 | next(category: string):Mark 305 | prev(category: string):Mark 306 | } 307 | export class MarkAttributes extends GObject.Object { 308 | constructor(config?: any) 309 | get_background(background: any):boolean 310 | get_gicon():any 311 | get_icon_name():string 312 | get_pixbuf():any 313 | get_stock_id():string 314 | get_tooltip_markup(mark: Mark):string 315 | get_tooltip_text(mark: Mark):string 316 | render_icon(widget: Gtk.Widget, size: number):any 317 | set_background(background: any):void 318 | set_gicon(gicon: any):void 319 | set_icon_name(icon_name: string):void 320 | set_pixbuf(pixbuf: any):void 321 | set_stock_id(stock_id: string):void 322 | } 323 | export class PrintCompositor extends GObject.Object { 324 | constructor(config?: any) 325 | static new_from_view(view: View):PrintCompositor 326 | draw_page(context: Gtk.PrintContext, page_nr: number):void 327 | get_body_font_name():string 328 | get_bottom_margin(unit: Gtk.Unit):number 329 | get_buffer():Buffer 330 | get_footer_font_name():string 331 | get_header_font_name():string 332 | get_highlight_syntax():boolean 333 | get_left_margin(unit: Gtk.Unit):number 334 | get_line_numbers_font_name():string 335 | get_n_pages():number 336 | get_pagination_progress():number 337 | get_print_footer():boolean 338 | get_print_header():boolean 339 | get_print_line_numbers():number 340 | get_right_margin(unit: Gtk.Unit):number 341 | get_tab_width():number 342 | get_top_margin(unit: Gtk.Unit):number 343 | get_wrap_mode():Gtk.WrapMode 344 | paginate(context: Gtk.PrintContext):boolean 345 | set_body_font_name(font_name: string):void 346 | set_bottom_margin(margin: number, unit: Gtk.Unit):void 347 | set_footer_font_name(font_name: string):void 348 | set_footer_format(separator: boolean, left: string, center: string, right: string):void 349 | set_header_font_name(font_name: string):void 350 | set_header_format(separator: boolean, left: string, center: string, right: string):void 351 | set_highlight_syntax(highlight: boolean):void 352 | set_left_margin(margin: number, unit: Gtk.Unit):void 353 | set_line_numbers_font_name(font_name: string):void 354 | set_print_footer(print: boolean):void 355 | set_print_header(print: boolean):void 356 | set_print_line_numbers(interval: number):void 357 | set_right_margin(margin: number, unit: Gtk.Unit):void 358 | set_tab_width(width: number):void 359 | set_top_margin(margin: number, unit: Gtk.Unit):void 360 | set_wrap_mode(wrap_mode: Gtk.WrapMode):void 361 | } 362 | export class SearchContext extends GObject.Object { 363 | constructor(config?: any) 364 | backward(iter: any, match_start: any, match_end: any):boolean 365 | backward_async(iter: any, cancellable: Gio.Cancellable, callback: any, user_data: any):void 366 | backward_finish(result: any, match_start: any, match_end: any):boolean 367 | forward(iter: any, match_start: any, match_end: any):boolean 368 | forward_async(iter: any, cancellable: Gio.Cancellable, callback: any, user_data: any):void 369 | forward_finish(result: any, match_start: any, match_end: any):boolean 370 | get_buffer():Buffer 371 | get_highlight():boolean 372 | get_match_style():Style 373 | get_occurrence_position(match_start: any, match_end: any):number 374 | get_occurrences_count():number 375 | get_regex_error():any 376 | get_settings():SearchSettings 377 | replace(match_start: any, match_end: any, replace: string, replace_length: number):boolean 378 | replace_all(replace: string, replace_length: number):number 379 | set_highlight(highlight: boolean):void 380 | set_match_style(match_style: Style):void 381 | set_settings(settings: SearchSettings):void 382 | } 383 | export class SearchSettings extends GObject.Object { 384 | constructor(config?: any) 385 | get_at_word_boundaries():boolean 386 | get_case_sensitive():boolean 387 | get_regex_enabled():boolean 388 | get_search_text():string 389 | get_wrap_around():boolean 390 | set_at_word_boundaries(at_word_boundaries: boolean):void 391 | set_case_sensitive(case_sensitive: boolean):void 392 | set_regex_enabled(regex_enabled: boolean):void 393 | set_search_text(search_text: string):void 394 | set_wrap_around(wrap_around: boolean):void 395 | } 396 | export class Style extends GObject.Object { 397 | copy():Style 398 | } 399 | export class StyleScheme extends GObject.Object { 400 | get_authors():string[] 401 | get_description():string 402 | get_filename():string 403 | get_id():string 404 | get_name():string 405 | get_style(style_id: string):Style 406 | } 407 | export class StyleSchemeChooserButton extends Gtk.Button { 408 | constructor(config?: any) 409 | } 410 | export class StyleSchemeChooserWidget extends Gtk.Bin { 411 | constructor(config?: any) 412 | } 413 | export class StyleSchemeManager extends GObject.Object { 414 | static get_default():StyleSchemeManager 415 | constructor(config?: any) 416 | append_search_path(path: string):void 417 | force_rescan():void 418 | get_scheme(scheme_id: string):StyleScheme 419 | get_scheme_ids():string[] 420 | get_search_path():string[] 421 | prepend_search_path(path: string):void 422 | set_search_path(path: string[]):void 423 | } 424 | export class View extends Gtk.TextView { 425 | constructor(config?: any) 426 | static new_with_buffer(buffer: Buffer):View 427 | get_auto_indent():boolean 428 | get_background_pattern():BackgroundPatternType 429 | get_completion():Completion 430 | get_draw_spaces():DrawSpacesFlags 431 | get_gutter(window_type: Gtk.TextWindowType):Gutter 432 | get_highlight_current_line():boolean 433 | get_indent_on_tab():boolean 434 | get_indent_width():number 435 | get_insert_spaces_instead_of_tabs():boolean 436 | get_mark_attributes(category: string, priority: number):MarkAttributes 437 | get_right_margin_position():number 438 | get_show_line_marks():boolean 439 | get_show_line_numbers():boolean 440 | get_show_right_margin():boolean 441 | get_smart_backspace():boolean 442 | get_smart_home_end():SmartHomeEndType 443 | get_tab_width():number 444 | get_visual_column(iter: any):number 445 | indent_lines(start: any, end: any):void 446 | set_auto_indent(enable: boolean):void 447 | set_background_pattern(background_pattern: BackgroundPatternType):void 448 | set_draw_spaces(flags: DrawSpacesFlags):void 449 | set_highlight_current_line(highlight: boolean):void 450 | set_indent_on_tab(enable: boolean):void 451 | set_indent_width(width: number):void 452 | set_insert_spaces_instead_of_tabs(enable: boolean):void 453 | set_mark_attributes(category: string, attributes: MarkAttributes, priority: number):void 454 | set_right_margin_position(pos: number):void 455 | set_show_line_marks(show: boolean):void 456 | set_show_line_numbers(show: boolean):void 457 | set_show_right_margin(show: boolean):void 458 | set_smart_backspace(smart_backspace: boolean):void 459 | set_smart_home_end(smart_home_end: SmartHomeEndType):void 460 | set_tab_width(width: number):void 461 | unindent_lines(start: any, end: any):void 462 | } 463 | } -------------------------------------------------------------------------------- /src/gobject-2.0.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * GObject.d.ts 3 | * 4 | */ 5 | declare module 'GObject' { 6 | export const TYPE_STRING: number 7 | 8 | export const PARAM_MASK:number 9 | export const PARAM_STATIC_STRINGS:number 10 | export const PARAM_USER_SHIFT:number 11 | export const SIGNAL_FLAGS_MASK:number 12 | export const SIGNAL_MATCH_MASK:number 13 | export const TYPE_FLAG_RESERVED_ID_BIT:any 14 | export const TYPE_FUNDAMENTAL_MAX:number 15 | export const TYPE_FUNDAMENTAL_SHIFT:number 16 | export const TYPE_RESERVED_BSE_FIRST:number 17 | export const TYPE_RESERVED_BSE_LAST:number 18 | export const TYPE_RESERVED_GLIB_FIRST:number 19 | export const TYPE_RESERVED_GLIB_LAST:number 20 | export const TYPE_RESERVED_USER_FIRST:number 21 | export const VALUE_COLLECT_FORMAT_MAX_LENGTH:number 22 | export const VALUE_NOCOPY_CONTENTS:number 23 | export function boxed_copy(boxed_type: any, src_boxed: any):any 24 | export function boxed_free(boxed_type: any, boxed: any):void 25 | export function boxed_type_register_static(name: string, boxed_copy: any, boxed_free: any):any 26 | export function cclosure_marshal_BOOLEAN__BOXED_BOXED(closure: any, return_value: any, n_param_values: number, param_values: any, invocation_hint: any, marshal_data: any):void 27 | export function cclosure_marshal_BOOLEAN__FLAGS(closure: any, return_value: any, n_param_values: number, param_values: any, invocation_hint: any, marshal_data: any):void 28 | export function cclosure_marshal_STRING__OBJECT_POINTER(closure: any, return_value: any, n_param_values: number, param_values: any, invocation_hint: any, marshal_data: any):void 29 | export function cclosure_marshal_VOID__BOOLEAN(closure: any, return_value: any, n_param_values: number, param_values: any, invocation_hint: any, marshal_data: any):void 30 | export function cclosure_marshal_VOID__BOXED(closure: any, return_value: any, n_param_values: number, param_values: any, invocation_hint: any, marshal_data: any):void 31 | export function cclosure_marshal_VOID__CHAR(closure: any, return_value: any, n_param_values: number, param_values: any, invocation_hint: any, marshal_data: any):void 32 | export function cclosure_marshal_VOID__DOUBLE(closure: any, return_value: any, n_param_values: number, param_values: any, invocation_hint: any, marshal_data: any):void 33 | export function cclosure_marshal_VOID__ENUM(closure: any, return_value: any, n_param_values: number, param_values: any, invocation_hint: any, marshal_data: any):void 34 | export function cclosure_marshal_VOID__FLAGS(closure: any, return_value: any, n_param_values: number, param_values: any, invocation_hint: any, marshal_data: any):void 35 | export function cclosure_marshal_VOID__FLOAT(closure: any, return_value: any, n_param_values: number, param_values: any, invocation_hint: any, marshal_data: any):void 36 | export function cclosure_marshal_VOID__INT(closure: any, return_value: any, n_param_values: number, param_values: any, invocation_hint: any, marshal_data: any):void 37 | export function cclosure_marshal_VOID__LONG(closure: any, return_value: any, n_param_values: number, param_values: any, invocation_hint: any, marshal_data: any):void 38 | export function cclosure_marshal_VOID__OBJECT(closure: any, return_value: any, n_param_values: number, param_values: any, invocation_hint: any, marshal_data: any):void 39 | export function cclosure_marshal_VOID__PARAM(closure: any, return_value: any, n_param_values: number, param_values: any, invocation_hint: any, marshal_data: any):void 40 | export function cclosure_marshal_VOID__POINTER(closure: any, return_value: any, n_param_values: number, param_values: any, invocation_hint: any, marshal_data: any):void 41 | export function cclosure_marshal_VOID__STRING(closure: any, return_value: any, n_param_values: number, param_values: any, invocation_hint: any, marshal_data: any):void 42 | export function cclosure_marshal_VOID__UCHAR(closure: any, return_value: any, n_param_values: number, param_values: any, invocation_hint: any, marshal_data: any):void 43 | export function cclosure_marshal_VOID__UINT(closure: any, return_value: any, n_param_values: number, param_values: any, invocation_hint: any, marshal_data: any):void 44 | export function cclosure_marshal_VOID__UINT_POINTER(closure: any, return_value: any, n_param_values: number, param_values: any, invocation_hint: any, marshal_data: any):void 45 | export function cclosure_marshal_VOID__ULONG(closure: any, return_value: any, n_param_values: number, param_values: any, invocation_hint: any, marshal_data: any):void 46 | export function cclosure_marshal_VOID__VARIANT(closure: any, return_value: any, n_param_values: number, param_values: any, invocation_hint: any, marshal_data: any):void 47 | export function cclosure_marshal_VOID__VOID(closure: any, return_value: any, n_param_values: number, param_values: any, invocation_hint: any, marshal_data: any):void 48 | export function cclosure_marshal_generic(closure: any, return_gvalue: any, n_param_values: number, param_values: any, invocation_hint: any, marshal_data: any):void 49 | export function cclosure_new(callback_func: any, user_data: any, destroy_data: any):any 50 | export function cclosure_new_object(callback_func: any, object: Object):any 51 | export function cclosure_new_object_swap(callback_func: any, object: Object):any 52 | export function cclosure_new_swap(callback_func: any, user_data: any, destroy_data: any):any 53 | export function clear_object(object_ptr: Object):void 54 | export function enum_complete_type_info(g_enum_type: any, info: any, const_values: any):void 55 | export function enum_get_value(enum_class: any, value: number):any 56 | export function enum_get_value_by_name(enum_class: any, name: string):any 57 | export function enum_get_value_by_nick(enum_class: any, nick: string):any 58 | export function enum_register_static(name: string, const_static_values: any):any 59 | export function flags_complete_type_info(g_flags_type: any, info: any, const_values: any):void 60 | export function flags_get_first_value(flags_class: any, value: number):any 61 | export function flags_get_value_by_name(flags_class: any, name: string):any 62 | export function flags_get_value_by_nick(flags_class: any, nick: string):any 63 | export function flags_register_static(name: string, const_static_values: any):any 64 | export function gtype_get_type():any 65 | export function param_spec_boolean(name: string, nick: string, blurb: string, default_value: boolean, flags: ParamFlags):ParamSpec 66 | export function param_spec_boxed(name: string, nick: string, blurb: string, boxed_type: any, flags: ParamFlags):ParamSpec 67 | export function param_spec_char(name: string, nick: string, blurb: string, minimum: number, maximum: number, default_value: number, flags: ParamFlags):ParamSpec 68 | export function param_spec_double(name: string, nick: string, blurb: string, minimum: number, maximum: number, default_value: number, flags: ParamFlags):ParamSpec 69 | export function param_spec_enum(name: string, nick: string, blurb: string, enum_type: any, default_value: number, flags: ParamFlags):ParamSpec 70 | export function param_spec_flags(name: string, nick: string, blurb: string, flags_type: any, default_value: number, flags: ParamFlags):ParamSpec 71 | export function param_spec_float(name: string, nick: string, blurb: string, minimum: number, maximum: number, default_value: number, flags: ParamFlags):ParamSpec 72 | export function param_spec_gtype(name: string, nick: string, blurb: string, is_a_type: any, flags: ParamFlags):ParamSpec 73 | export function param_spec_int(name: string, nick: string, blurb: string, minimum: number, maximum: number, default_value: number, flags: ParamFlags):ParamSpec 74 | export function param_spec_int64(name: string, nick: string, blurb: string, minimum: number, maximum: number, default_value: number, flags: ParamFlags):ParamSpec 75 | export function param_spec_long(name: string, nick: string, blurb: string, minimum: number, maximum: number, default_value: number, flags: ParamFlags):ParamSpec 76 | export function param_spec_object(name: string, nick: string, blurb: string, object_type: any, flags: ParamFlags):ParamSpec 77 | export function param_spec_override(name: string, overridden: ParamSpec):ParamSpec 78 | export function param_spec_param(name: string, nick: string, blurb: string, param_type: any, flags: ParamFlags):ParamSpec 79 | export function param_spec_pointer(name: string, nick: string, blurb: string, flags: ParamFlags):ParamSpec 80 | export function param_spec_pool_new(type_prefixing: boolean):any 81 | export function param_spec_string(name: string, nick: string, blurb: string, default_value: string, flags: ParamFlags):ParamSpec 82 | export function param_spec_uchar(name: string, nick: string, blurb: string, minimum: number, maximum: number, default_value: number, flags: ParamFlags):ParamSpec 83 | export function param_spec_uint(name: string, nick: string, blurb: string, minimum: number, maximum: number, default_value: number, flags: ParamFlags):ParamSpec 84 | export function param_spec_uint64(name: string, nick: string, blurb: string, minimum: number, maximum: number, default_value: number, flags: ParamFlags):ParamSpec 85 | export function param_spec_ulong(name: string, nick: string, blurb: string, minimum: number, maximum: number, default_value: number, flags: ParamFlags):ParamSpec 86 | export function param_spec_unichar(name: string, nick: string, blurb: string, default_value: number, flags: ParamFlags):ParamSpec 87 | export function param_spec_value_array(name: string, nick: string, blurb: string, element_spec: ParamSpec, flags: ParamFlags):ParamSpec 88 | export function param_spec_variant(name: string, nick: string, blurb: string, type: any, default_value: any, flags: ParamFlags):ParamSpec 89 | export function param_type_register_static(name: string, pspec_info: any):any 90 | export function param_value_convert(pspec: ParamSpec, src_value: any, dest_value: any, strict_validation: boolean):boolean 91 | export function param_value_defaults(pspec: ParamSpec, value: any):boolean 92 | export function param_value_set_default(pspec: ParamSpec, value: any):void 93 | export function param_value_validate(pspec: ParamSpec, value: any):boolean 94 | export function param_values_cmp(pspec: ParamSpec, value1: any, value2: any):number 95 | export function pointer_type_register_static(name: string):any 96 | export function signal_accumulator_first_wins(ihint: any, return_accu: any, handler_return: any, dummy: any):boolean 97 | export function signal_accumulator_true_handled(ihint: any, return_accu: any, handler_return: any, dummy: any):boolean 98 | export function signal_add_emission_hook(signal_id: number, detail: any, hook_func: any, hook_data: any, data_destroy: any):number 99 | export function signal_chain_from_overridden(instance_and_params: any[], return_value: any):void 100 | export function signal_chain_from_overridden_handler(instance: any, ...args: any[]):void 101 | export function signal_connect_closure(instance: Object, detailed_signal: string, closure: any, after: boolean):number 102 | export function signal_connect_closure_by_id(instance: Object, signal_id: number, detail: any, closure: any, after: boolean):number 103 | export function signal_connect_data(instance: Object, detailed_signal: string, c_handler: any, data: any, destroy_data: any, connect_flags: ConnectFlags):number 104 | export function signal_connect_object(instance: any, detailed_signal: string, c_handler: any, gobject: any, connect_flags: ConnectFlags):number 105 | export function signal_emit(instance: Object, signal_id: number, detail: any, ...args: any[]):void 106 | export function signal_emit_by_name(instance: Object, detailed_signal: string, ...args: any[]):void 107 | export function signal_emit_valist(instance: any, signal_id: number, detail: any, var_args: any):void 108 | export function signal_emitv(instance_and_params: any[], signal_id: number, detail: any, return_value: any):void 109 | export function signal_get_invocation_hint(instance: Object):any 110 | export function signal_handler_block(instance: Object, handler_id: number):void 111 | export function signal_handler_disconnect(instance: Object, handler_id: number):void 112 | export function signal_handler_find(instance: Object, mask: SignalMatchType, signal_id: number, detail: any, closure: any, func: any, data: any):number 113 | export function signal_handler_is_connected(instance: Object, handler_id: number):boolean 114 | export function signal_handler_unblock(instance: Object, handler_id: number):void 115 | export function signal_handlers_block_matched(instance: Object, mask: SignalMatchType, signal_id: number, detail: any, closure: any, func: any, data: any):number 116 | export function signal_handlers_destroy(instance: Object):void 117 | export function signal_handlers_disconnect_matched(instance: Object, mask: SignalMatchType, signal_id: number, detail: any, closure: any, func: any, data: any):number 118 | export function signal_handlers_unblock_matched(instance: Object, mask: SignalMatchType, signal_id: number, detail: any, closure: any, func: any, data: any):number 119 | export function signal_has_handler_pending(instance: Object, signal_id: number, detail: any, may_be_blocked: boolean):boolean 120 | export function signal_list_ids(itype: any, n_ids: number):number[] 121 | export function signal_lookup(name: string, itype: any):number 122 | export function signal_name(signal_id: number):string 123 | export function signal_new(signal_name: string, itype: any, signal_flags: SignalFlags, class_offset: number, accumulator: any, accu_data: any, c_marshaller: any, return_type: any, n_params: number, ...args: any[]):number 124 | export function signal_new_class_handler(signal_name: string, itype: any, signal_flags: SignalFlags, class_handler: any, accumulator: any, accu_data: any, c_marshaller: any, return_type: any, n_params: number, ...args: any[]):number 125 | export function signal_new_valist(signal_name: string, itype: any, signal_flags: SignalFlags, class_closure: any, accumulator: any, accu_data: any, c_marshaller: any, return_type: any, n_params: number, args: any):number 126 | export function signal_newv(signal_name: string, itype: any, signal_flags: SignalFlags, class_closure: any, accumulator: any, accu_data: any, c_marshaller: any, return_type: any, n_params: number, param_types: any[]):number 127 | export function signal_override_class_closure(signal_id: number, instance_type: any, class_closure: any):void 128 | export function signal_override_class_handler(signal_name: string, instance_type: any, class_handler: any):void 129 | export function signal_parse_name(detailed_signal: string, itype: any, signal_id_p: number, detail_p: any, force_detail_quark: boolean):boolean 130 | export function signal_query(signal_id: number, query: any):void 131 | export function signal_remove_emission_hook(signal_id: number, hook_id: number):void 132 | export function signal_set_va_marshaller(signal_id: number, instance_type: any, va_marshaller: any):void 133 | export function signal_stop_emission(instance: Object, signal_id: number, detail: any):void 134 | export function signal_stop_emission_by_name(instance: Object, detailed_signal: string):void 135 | export function signal_type_cclosure_new(itype: any, struct_offset: number):any 136 | export function source_set_closure(source: any, closure: any):void 137 | export function source_set_dummy_callback(source: any):void 138 | export function strdup_value_contents(value: any):string 139 | export function type_add_class_cache_func(cache_data: any, cache_func: any):void 140 | export function type_add_class_private(class_type: any, private_size: number):void 141 | export function type_add_instance_private(class_type: any, private_size: number):number 142 | export function type_add_interface_check(check_data: any, check_func: any):void 143 | export function type_add_interface_dynamic(instance_type: any, interface_type: any, plugin: any):void 144 | export function type_add_interface_static(instance_type: any, interface_type: any, info: any):void 145 | export function type_check_class_cast(g_class: any, is_a_type: any):any 146 | export function type_check_class_is_a(g_class: any, is_a_type: any):boolean 147 | export function type_check_instance(instance: any):boolean 148 | export function type_check_instance_cast(instance: any, iface_type: any):any 149 | export function type_check_instance_is_a(instance: any, iface_type: any):boolean 150 | export function type_check_instance_is_fundamentally_a(instance: any, fundamental_type: any):boolean 151 | export function type_check_is_value_type(type: any):boolean 152 | export function type_check_value(value: any):boolean 153 | export function type_check_value_holds(value: any, type: any):boolean 154 | export function type_children(type: any, n_children: number):any[] 155 | export function type_class_add_private(g_class: any, private_size: number):void 156 | export function type_class_adjust_private_offset(g_class: any, private_size_or_offset: number):void 157 | export function type_class_get_instance_private_offset(g_class: any):number 158 | export function type_class_peek(type: any):any 159 | export function type_class_peek_static(type: any):any 160 | export function type_class_ref(type: any):any 161 | export function type_create_instance(type: any):any 162 | export function type_default_interface_peek(g_type: any):any 163 | export function type_default_interface_ref(g_type: any):any 164 | export function type_default_interface_unref(g_iface: any):void 165 | export function type_depth(type: any):number 166 | export function type_ensure(type: any):void 167 | export function type_free_instance(instance: any):void 168 | export function type_from_name(name: string):any 169 | export function type_fundamental(type_id: any):any 170 | export function type_fundamental_next():any 171 | export function type_get_instance_count(type: any):number 172 | export function type_get_plugin(type: any):any 173 | export function type_get_qdata(type: any, quark: any):any 174 | export function type_get_type_registration_serial():number 175 | export function type_init():void 176 | export function type_init_with_debug_flags(debug_flags: TypeDebugFlags):void 177 | export function type_interface_add_prerequisite(interface_type: any, prerequisite_type: any):void 178 | export function type_interface_get_plugin(instance_type: any, interface_type: any):any 179 | export function type_interface_peek(instance_class: any, iface_type: any):any 180 | export function type_interface_prerequisites(interface_type: any, n_prerequisites: number):any[] 181 | export function type_interfaces(type: any, n_interfaces: number):any[] 182 | export function type_is_a(type: any, is_a_type: any):boolean 183 | export function type_name(type: any):string 184 | export function type_name_from_class(g_class: any):string 185 | export function type_name_from_instance(instance: any):string 186 | export function type_next_base(leaf_type: any, root_type: any):any 187 | export function type_parent(type: any):any 188 | export function type_qname(type: any):any 189 | export function type_query(type: any, query: any):void 190 | export function type_register_dynamic(parent_type: any, type_name: string, plugin: any, flags: TypeFlags):any 191 | export function type_register_fundamental(type_id: any, type_name: string, info: any, finfo: any, flags: TypeFlags):any 192 | export function type_register_static(parent_type: any, type_name: string, info: any, flags: TypeFlags):any 193 | export function type_register_static_simple(parent_type: any, type_name: string, class_size: number, class_init: any, instance_size: number, instance_init: any, flags: TypeFlags):any 194 | export function type_remove_class_cache_func(cache_data: any, cache_func: any):void 195 | export function type_remove_interface_check(check_data: any, check_func: any):void 196 | export function type_set_qdata(type: any, quark: any, data: any):void 197 | export function type_test_flags(type: any, flags: number):boolean 198 | export function type_value_table_peek(type: any):any 199 | export function value_register_transform_func(src_type: any, dest_type: any, transform_func: any):void 200 | export function value_type_compatible(src_type: any, dest_type: any):boolean 201 | export function value_type_transformable(src_type: any, dest_type: any):boolean 202 | export enum BindingFlags{ 203 | DEFAULT, 204 | BIDIRECTIONAL, 205 | SYNC_CREATE, 206 | INVERT_BOOLEAN, 207 | } 208 | export enum ConnectFlags{ 209 | AFTER, 210 | SWAPPED, 211 | } 212 | export enum ParamFlags{ 213 | READABLE, 214 | WRITABLE, 215 | READWRITE, 216 | CONSTRUCT, 217 | CONSTRUCT_ONLY, 218 | LAX_VALIDATION, 219 | STATIC_NAME, 220 | PRIVATE, 221 | STATIC_NICK, 222 | STATIC_BLURB, 223 | EXPLICIT_NOTIFY, 224 | DEPRECATED, 225 | } 226 | export enum SignalFlags{ 227 | RUN_FIRST, 228 | RUN_LAST, 229 | RUN_CLEANUP, 230 | NO_RECURSE, 231 | DETAILED, 232 | ACTION, 233 | NO_HOOKS, 234 | MUST_COLLECT, 235 | DEPRECATED, 236 | } 237 | export enum SignalMatchType{ 238 | ID, 239 | DETAIL, 240 | CLOSURE, 241 | FUNC, 242 | DATA, 243 | UNBLOCKED, 244 | } 245 | export enum TypeDebugFlags{ 246 | NONE, 247 | OBJECTS, 248 | SIGNALS, 249 | INSTANCE_COUNT, 250 | MASK, 251 | } 252 | export enum TypeFlags{ 253 | ABSTRACT, 254 | VALUE_ABSTRACT, 255 | } 256 | export enum TypeFundamentalFlags{ 257 | CLASSED, 258 | INSTANTIATABLE, 259 | DERIVABLE, 260 | DEEP_DERIVABLE, 261 | } 262 | export class Binding extends Object { 263 | get_flags():BindingFlags 264 | get_source():Object 265 | get_source_property():string 266 | get_target():Object 267 | get_target_property():string 268 | unbind():void 269 | } 270 | export class InitiallyUnowned extends Object { 271 | } 272 | export class Object { 273 | static compat_control(what: number, data: any):number 274 | static connect(object: any, signal_spec: string, ...args: any[]):any 275 | static disconnect(object: any, signal_spec: string, ...args: any[]):void 276 | static get(object: any, first_property_name: string, ...args: any[]):void 277 | static interface_find_property(g_iface: any, property_name: string):ParamSpec 278 | static interface_install_property(g_iface: any, pspec: ParamSpec):void 279 | static interface_list_properties(g_iface: any, n_properties_p: number):ParamSpec[] 280 | static set(object: any, first_property_name: string, ...args: any[]):void 281 | constructor(config?: any) 282 | static new_valist(object_type: any, first_property_name: string, var_args: any):Object 283 | static newv(object_type: any, n_parameters: number, parameters: any[]):Object 284 | connect(...args: any[]):any 285 | get_valist(...args: any[]):void 286 | get_property(...args: any[]):any 287 | static newv(...args: any[]):Object 288 | replace_data(...args: any[]):any 289 | set_property(...args: any[]):void 290 | set_valist(...args: any[]):void 291 | add_toggle_ref(notify: any, data: any):void 292 | add_weak_pointer(weak_pointer_location: any):void 293 | bind_property(source_property: string, target: Object, target_property: string, flags: BindingFlags):Binding 294 | bind_property_full(source_property: string, target: Object, target_property: string, flags: BindingFlags, transform_to: any, transform_from: any, user_data: any, notify: any):Binding 295 | bind_property_with_closures(source_property: string, target: Object, target_property: string, flags: BindingFlags, transform_to: any, transform_from: any):Binding 296 | dup_data(key: string, dup_func: any, user_data: any):any 297 | dup_qdata(quark: any, dup_func: any, user_data: any):any 298 | force_floating():void 299 | freeze_notify():void 300 | get_data(key: string):any 301 | get_property(property_name: string, value: any):void 302 | get_qdata(quark: any):any 303 | get_valist(first_property_name: string, var_args: any):void 304 | is_floating():boolean 305 | notify(property_name: string):void 306 | notify_by_pspec(pspec: ParamSpec):void 307 | ref():Object 308 | ref_sink():Object 309 | remove_toggle_ref(notify: any, data: any):void 310 | remove_weak_pointer(weak_pointer_location: any):void 311 | replace_data(key: string, oldval: any, newval: any, destroy: any, old_destroy: any):boolean 312 | replace_qdata(quark: any, oldval: any, newval: any, destroy: any, old_destroy: any):boolean 313 | run_dispose():void 314 | set_data(key: string, data: any):void 315 | set_data_full(key: string, data: any, destroy: any):void 316 | set_property(property_name: string, value: any):void 317 | set_qdata(quark: any, data: any):void 318 | set_qdata_full(quark: any, data: any, destroy: any):void 319 | set_valist(first_property_name: string, var_args: any):void 320 | steal_data(key: string):any 321 | steal_qdata(quark: any):any 322 | thaw_notify():void 323 | unref():void 324 | watch_closure(closure: any):void 325 | weak_ref(notify: any, data: any):void 326 | weak_unref(notify: any, data: any):void 327 | } 328 | export class ParamSpec { 329 | static internal(param_type: any, name: string, nick: string, blurb: string, flags: ParamFlags):any 330 | get_blurb():string 331 | get_default_value():any 332 | get_name():string 333 | get_name_quark():any 334 | get_nick():string 335 | get_qdata(quark: any):any 336 | get_redirect_target():ParamSpec 337 | ref():ParamSpec 338 | ref_sink():ParamSpec 339 | set_qdata(quark: any, data: any):void 340 | set_qdata_full(quark: any, data: any, destroy: any):void 341 | sink():void 342 | steal_qdata(quark: any):any 343 | unref():void 344 | } 345 | export class ParamSpecBoolean extends ParamSpec { 346 | } 347 | export class ParamSpecBoxed extends ParamSpec { 348 | } 349 | export class ParamSpecChar extends ParamSpec { 350 | } 351 | export class ParamSpecDouble extends ParamSpec { 352 | } 353 | export class ParamSpecEnum extends ParamSpec { 354 | } 355 | export class ParamSpecFlags extends ParamSpec { 356 | } 357 | export class ParamSpecFloat extends ParamSpec { 358 | } 359 | export class ParamSpecGType extends ParamSpec { 360 | } 361 | export class ParamSpecInt extends ParamSpec { 362 | } 363 | export class ParamSpecInt64 extends ParamSpec { 364 | } 365 | export class ParamSpecLong extends ParamSpec { 366 | } 367 | export class ParamSpecObject extends ParamSpec { 368 | } 369 | export class ParamSpecOverride extends ParamSpec { 370 | } 371 | export class ParamSpecParam extends ParamSpec { 372 | } 373 | export class ParamSpecPointer extends ParamSpec { 374 | } 375 | export class ParamSpecString extends ParamSpec { 376 | } 377 | export class ParamSpecUChar extends ParamSpec { 378 | } 379 | export class ParamSpecUInt extends ParamSpec { 380 | } 381 | export class ParamSpecUInt64 extends ParamSpec { 382 | } 383 | export class ParamSpecULong extends ParamSpec { 384 | } 385 | export class ParamSpecUnichar extends ParamSpec { 386 | } 387 | export class ParamSpecValueArray extends ParamSpec { 388 | } 389 | export class ParamSpecVariant extends ParamSpec { 390 | } 391 | export class TypeModule extends Object { 392 | add_interface(instance_type: any, interface_type: any, interface_info: any):void 393 | register_enum(name: string, const_static_values: any):any 394 | register_flags(name: string, const_static_values: any):any 395 | register_type(parent_type: any, type_name: string, type_info: any, flags: TypeFlags):any 396 | set_name(name: string):void 397 | unuse():void 398 | use():boolean 399 | } 400 | } -------------------------------------------------------------------------------- /src/soup-2.4.d.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Soup.d.ts 3 | * 4 | */ 5 | declare module 'Soup' { 6 | import * as GObject from "GObject" 7 | import * as Gio from "Gio" 8 | import * as GLib from "GLib" 9 | export const ADDRESS_ANY_PORT:number 10 | export const ADDRESS_FAMILY:string 11 | export const ADDRESS_NAME:string 12 | export const ADDRESS_PHYSICAL:string 13 | export const ADDRESS_PORT:string 14 | export const ADDRESS_PROTOCOL:string 15 | export const ADDRESS_SOCKADDR:string 16 | export const AUTH_DOMAIN_ADD_PATH:string 17 | export const AUTH_DOMAIN_BASIC_AUTH_CALLBACK:string 18 | export const AUTH_DOMAIN_BASIC_AUTH_DATA:string 19 | export const AUTH_DOMAIN_BASIC_H:number 20 | export const AUTH_DOMAIN_DIGEST_AUTH_CALLBACK:string 21 | export const AUTH_DOMAIN_DIGEST_AUTH_DATA:string 22 | export const AUTH_DOMAIN_DIGEST_H:number 23 | export const AUTH_DOMAIN_FILTER:string 24 | export const AUTH_DOMAIN_FILTER_DATA:string 25 | export const AUTH_DOMAIN_GENERIC_AUTH_CALLBACK:string 26 | export const AUTH_DOMAIN_GENERIC_AUTH_DATA:string 27 | export const AUTH_DOMAIN_H:number 28 | export const AUTH_DOMAIN_PROXY:string 29 | export const AUTH_DOMAIN_REALM:string 30 | export const AUTH_DOMAIN_REMOVE_PATH:string 31 | export const AUTH_H:number 32 | export const AUTH_HOST:string 33 | export const AUTH_IS_AUTHENTICATED:string 34 | export const AUTH_IS_FOR_PROXY:string 35 | export const AUTH_MANAGER_H:number 36 | export const AUTH_REALM:string 37 | export const AUTH_SCHEME_NAME:string 38 | export const CACHE_H:number 39 | export const CHAR_HTTP_CTL:number 40 | export const CHAR_HTTP_SEPARATOR:number 41 | export const CHAR_URI_GEN_DELIMS:number 42 | export const CHAR_URI_PERCENT_ENCODED:number 43 | export const CHAR_URI_SUB_DELIMS:number 44 | export const CONTENT_DECODER_H:number 45 | export const CONTENT_SNIFFER_H:number 46 | export const COOKIE_H:number 47 | export const COOKIE_JAR_ACCEPT_POLICY:string 48 | export const COOKIE_JAR_DB_FILENAME:string 49 | export const COOKIE_JAR_DB_H:number 50 | export const COOKIE_JAR_H:number 51 | export const COOKIE_JAR_READ_ONLY:string 52 | export const COOKIE_JAR_TEXT_FILENAME:string 53 | export const COOKIE_JAR_TEXT_H:number 54 | export const COOKIE_MAX_AGE_ONE_DAY:number 55 | export const COOKIE_MAX_AGE_ONE_HOUR:number 56 | export const COOKIE_MAX_AGE_ONE_WEEK:number 57 | export const COOKIE_MAX_AGE_ONE_YEAR:number 58 | export const DATE_H:number 59 | export const FORM_H:number 60 | export const FORM_MIME_TYPE_MULTIPART:string 61 | export const FORM_MIME_TYPE_URLENCODED:string 62 | export const HEADERS_H:number 63 | export const LOGGER_H:number 64 | export const MESSAGE_BODY_H:number 65 | export const MESSAGE_FIRST_PARTY:string 66 | export const MESSAGE_FLAGS:string 67 | export const MESSAGE_H:number 68 | export const MESSAGE_HEADERS_H:number 69 | export const MESSAGE_HTTP_VERSION:string 70 | export const MESSAGE_METHOD:string 71 | export const MESSAGE_PRIORITY:string 72 | export const MESSAGE_REASON_PHRASE:string 73 | export const MESSAGE_REQUEST_BODY:string 74 | export const MESSAGE_REQUEST_BODY_DATA:string 75 | export const MESSAGE_REQUEST_HEADERS:string 76 | export const MESSAGE_RESPONSE_BODY:string 77 | export const MESSAGE_RESPONSE_BODY_DATA:string 78 | export const MESSAGE_RESPONSE_HEADERS:string 79 | export const MESSAGE_SERVER_SIDE:string 80 | export const MESSAGE_STATUS_CODE:string 81 | export const MESSAGE_TLS_CERTIFICATE:string 82 | export const MESSAGE_TLS_ERRORS:string 83 | export const MESSAGE_URI:string 84 | export const METHOD_H:number 85 | export const MISC_H:number 86 | export const MULTIPART_H:number 87 | export const MULTIPART_INPUT_STREAM_H:number 88 | export const PASSWORD_MANAGER_H:number 89 | export const PROXY_RESOLVER_DEFAULT_H:number 90 | export const PROXY_URI_RESOLVER_H:number 91 | export const REQUESTER_H:number 92 | export const REQUEST_DATA_H:number 93 | export const REQUEST_FILE_H:number 94 | export const REQUEST_H:number 95 | export const REQUEST_HTTP_H:number 96 | export const REQUEST_SESSION:string 97 | export const REQUEST_URI:string 98 | export const SERVER_ASYNC_CONTEXT:string 99 | export const SERVER_H:number 100 | export const SERVER_HTTPS_ALIASES:string 101 | export const SERVER_HTTP_ALIASES:string 102 | export const SERVER_INTERFACE:string 103 | export const SERVER_PORT:string 104 | export const SERVER_RAW_PATHS:string 105 | export const SERVER_SERVER_HEADER:string 106 | export const SERVER_SSL_CERT_FILE:string 107 | export const SERVER_SSL_KEY_FILE:string 108 | export const SERVER_TLS_CERTIFICATE:string 109 | export const SESSION_ACCEPT_LANGUAGE:string 110 | export const SESSION_ACCEPT_LANGUAGE_AUTO:string 111 | export const SESSION_ADD_FEATURE:string 112 | export const SESSION_ADD_FEATURE_BY_TYPE:string 113 | export const SESSION_ASYNC_CONTEXT:string 114 | export const SESSION_ASYNC_H:number 115 | export const SESSION_FEATURE_H:number 116 | export const SESSION_H:number 117 | export const SESSION_HTTPS_ALIASES:string 118 | export const SESSION_HTTP_ALIASES:string 119 | export const SESSION_IDLE_TIMEOUT:string 120 | export const SESSION_LOCAL_ADDRESS:string 121 | export const SESSION_MAX_CONNS:string 122 | export const SESSION_MAX_CONNS_PER_HOST:string 123 | export const SESSION_PROXY_RESOLVER:string 124 | export const SESSION_PROXY_URI:string 125 | export const SESSION_REMOVE_FEATURE_BY_TYPE:string 126 | export const SESSION_SSL_CA_FILE:string 127 | export const SESSION_SSL_STRICT:string 128 | export const SESSION_SSL_USE_SYSTEM_CA_FILE:string 129 | export const SESSION_SYNC_H:number 130 | export const SESSION_TIMEOUT:string 131 | export const SESSION_TLS_DATABASE:string 132 | export const SESSION_TLS_INTERACTION:string 133 | export const SESSION_USER_AGENT:string 134 | export const SESSION_USE_NTLM:string 135 | export const SESSION_USE_THREAD_CONTEXT:string 136 | export const SOCKET_ASYNC_CONTEXT:string 137 | export const SOCKET_FLAG_NONBLOCKING:string 138 | export const SOCKET_H:number 139 | export const SOCKET_IS_SERVER:string 140 | export const SOCKET_LOCAL_ADDRESS:string 141 | export const SOCKET_REMOTE_ADDRESS:string 142 | export const SOCKET_SSL_CREDENTIALS:string 143 | export const SOCKET_SSL_FALLBACK:string 144 | export const SOCKET_SSL_STRICT:string 145 | export const SOCKET_TIMEOUT:string 146 | export const SOCKET_TLS_CERTIFICATE:string 147 | export const SOCKET_TLS_ERRORS:string 148 | export const SOCKET_TRUSTED_CERTIFICATE:string 149 | export const SOCKET_USE_THREAD_CONTEXT:string 150 | export const STATUS_H:number 151 | export const TYPES_H:number 152 | export const URI_H:number 153 | export const VALUE_UTILS_H:number 154 | export const XMLRPC_H:number 155 | export const XMLRPC_OLD_H:number 156 | export function add_completion(async_context: any, function_: any, data: any):any 157 | export function add_idle(async_context: any, function_: any, data: any):any 158 | export function add_io_watch(async_context: any, chan: any, condition: GLib.IOCondition, function_: any, data: any):any 159 | export function add_timeout(async_context: any, interval: number, function_: any, data: any):any 160 | export function cookie_parse(header: string, origin: any):any 161 | export function cookies_free(cookies: any):void 162 | export function cookies_from_request(msg: Message):any 163 | export function cookies_from_response(msg: Message):any 164 | export function cookies_to_cookie_header(cookies: any):string 165 | export function cookies_to_request(cookies: any, msg: Message):void 166 | export function cookies_to_response(cookies: any, msg: Message):void 167 | export function form_decode(encoded_form: string):any 168 | export function form_decode_multipart(msg: Message, file_control_name: string, filename: string, content_type: string, file: any):any 169 | export function form_encode(first_field: string, ...args: any[]):string 170 | export function form_encode_datalist(form_data_set: any):string 171 | export function form_encode_hash(form_data_set: any):string 172 | export function form_encode_valist(first_field: string, args: any):string 173 | export function form_request_new(method: string, uri: string, first_field: string, ...args: any[]):Message 174 | export function form_request_new_from_datalist(method: string, uri: string, form_data_set: any):Message 175 | export function form_request_new_from_hash(method: string, uri: string, form_data_set: any):Message 176 | export function form_request_new_from_multipart(uri: string, multipart: any):Message 177 | export function header_contains(header: string, token: string):boolean 178 | export function header_free_list(list: any):void 179 | export function header_free_param_list(param_list: any):void 180 | export function header_g_string_append_param(string: any, name: string, value: string):void 181 | export function header_g_string_append_param_quoted(string: any, name: string, value: string):void 182 | export function header_parse_list(header: string):any 183 | export function header_parse_param_list(header: string):any 184 | export function header_parse_quality_list(header: string, unacceptable: any):any 185 | export function header_parse_semi_param_list(header: string):any 186 | export function headers_parse(str: string, len: number, dest: any):boolean 187 | export function headers_parse_request(str: string, len: number, req_headers: any, req_method: string, req_path: string, ver: HTTPVersion):number 188 | export function headers_parse_response(str: string, len: number, headers: any, ver: HTTPVersion, status_code: number, reason_phrase: string):boolean 189 | export function headers_parse_status_line(status_line: string, ver: HTTPVersion, status_code: number, reason_phrase: string):boolean 190 | export function http_error_quark():any 191 | export function message_headers_iter_init(iter: any, hdrs: any):void 192 | export function request_error_quark():any 193 | export function requester_error_quark():any 194 | export function status_get_phrase(status_code: number):string 195 | export function status_proxify(status_code: number):number 196 | export function str_case_equal(v1: any, v2: any):boolean 197 | export function str_case_hash(key: any):number 198 | export function tld_domain_is_public_suffix(domain: string):boolean 199 | export function tld_error_quark():any 200 | export function tld_get_base_domain(hostname: string):string 201 | export function uri_decode(part: string):string 202 | export function uri_encode(part: string, escape_extra: string):string 203 | export function uri_normalize(part: string, unescape_extra: string):string 204 | export function value_array_append(array: any, type: any, ...args: any[]):void 205 | export function value_array_append_vals(array: any, first_type: any, ...args: any[]):void 206 | export function value_array_from_args(args: any):any 207 | export function value_array_get_nth(array: any, index_: number, type: any, ...args: any[]):boolean 208 | export function value_array_insert(array: any, index_: number, type: any, ...args: any[]):void 209 | export function value_array_new():any 210 | export function value_array_new_with_vals(first_type: any, ...args: any[]):any 211 | export function value_array_to_args(array: any, args: any):boolean 212 | export function value_hash_insert(hash: any, key: string, type: any, ...args: any[]):void 213 | export function value_hash_insert_vals(hash: any, first_key: string, ...args: any[]):void 214 | export function value_hash_insert_value(hash: any, key: string, value: any):void 215 | export function value_hash_lookup(hash: any, key: string, type: any, ...args: any[]):boolean 216 | export function value_hash_lookup_vals(hash: any, first_key: string, ...args: any[]):boolean 217 | export function value_hash_new():any 218 | export function value_hash_new_with_vals(first_key: string, ...args: any[]):any 219 | export function websocket_client_prepare_handshake(msg: Message, origin: string, protocols: string[]):void 220 | export function websocket_client_verify_handshake(msg: Message):boolean 221 | export function websocket_error_get_quark():any 222 | export function websocket_server_check_handshake(msg: Message, origin: string, protocols: string[]):boolean 223 | export function websocket_server_process_handshake(msg: Message, expected_origin: string, protocols: string[]):boolean 224 | export function xmlrpc_build_fault(fault_code: number, fault_format: string, ...args: any[]):string 225 | export function xmlrpc_build_method_call(method_name: string, params: any[], n_params: number):string 226 | export function xmlrpc_build_method_response(value: any):string 227 | export function xmlrpc_build_request(method_name: string, params: any):string 228 | export function xmlrpc_build_response(value: any):string 229 | export function xmlrpc_error_quark():any 230 | export function xmlrpc_extract_method_call(method_call: string, length: number, method_name: string, ...args: any[]):boolean 231 | export function xmlrpc_extract_method_response(method_response: string, length: number, error: any, type: any, ...args: any[]):boolean 232 | export function xmlrpc_fault_quark():any 233 | export function xmlrpc_message_new(uri: string, method_name: string, params: any):Message 234 | export function xmlrpc_message_set_fault(msg: Message, fault_code: number, fault_format: string, ...args: any[]):void 235 | export function xmlrpc_message_set_response(msg: Message, value: any):boolean 236 | export function xmlrpc_parse_method_call(method_call: string, length: number, method_name: string, params: any):boolean 237 | export function xmlrpc_parse_method_response(method_response: string, length: number, value: any):boolean 238 | export function xmlrpc_parse_request(method_call: string, length: number, params: any):string 239 | export function xmlrpc_parse_response(method_response: string, length: number, signature: string):any 240 | export function xmlrpc_request_new(uri: string, method_name: string, ...args: any[]):Message 241 | export function xmlrpc_set_fault(msg: Message, fault_code: number, fault_format: string, ...args: any[]):void 242 | export function xmlrpc_set_response(msg: Message, type: any, ...args: any[]):void 243 | export function xmlrpc_variant_get_datetime(variant: any):any 244 | export function xmlrpc_variant_new_datetime(date: any):any 245 | export enum AddressFamily { 246 | INVALID, 247 | IPV4, 248 | IPV6, 249 | } 250 | export enum CacheResponse { 251 | FRESH, 252 | NEEDS_VALIDATION, 253 | STALE, 254 | } 255 | export enum CacheType { 256 | SINGLE_USER, 257 | SHARED, 258 | } 259 | export enum ConnectionState { 260 | NEW, 261 | CONNECTING, 262 | IDLE, 263 | IN_USE, 264 | REMOTE_DISCONNECTED, 265 | DISCONNECTED, 266 | } 267 | export enum CookieJarAcceptPolicy { 268 | ALWAYS, 269 | NEVER, 270 | NO_THIRD_PARTY, 271 | } 272 | export enum DateFormat { 273 | HTTP, 274 | COOKIE, 275 | RFC2822, 276 | ISO8601_COMPACT, 277 | ISO8601_FULL, 278 | ISO8601, 279 | ISO8601_XMLRPC, 280 | } 281 | export enum Encoding { 282 | UNRECOGNIZED, 283 | NONE, 284 | CONTENT_LENGTH, 285 | EOF, 286 | CHUNKED, 287 | BYTERANGES, 288 | } 289 | export enum HTTPVersion { 290 | HTTP_1_0, 291 | HTTP_1_1, 292 | } 293 | export enum KnownStatusCode { 294 | NONE, 295 | CANCELLED, 296 | CANT_RESOLVE, 297 | CANT_RESOLVE_PROXY, 298 | CANT_CONNECT, 299 | CANT_CONNECT_PROXY, 300 | SSL_FAILED, 301 | IO_ERROR, 302 | MALFORMED, 303 | TRY_AGAIN, 304 | TOO_MANY_REDIRECTS, 305 | TLS_FAILED, 306 | CONTINUE, 307 | SWITCHING_PROTOCOLS, 308 | PROCESSING, 309 | OK, 310 | CREATED, 311 | ACCEPTED, 312 | NON_AUTHORITATIVE, 313 | NO_CONTENT, 314 | RESET_CONTENT, 315 | PARTIAL_CONTENT, 316 | MULTI_STATUS, 317 | MULTIPLE_CHOICES, 318 | MOVED_PERMANENTLY, 319 | FOUND, 320 | MOVED_TEMPORARILY, 321 | SEE_OTHER, 322 | NOT_MODIFIED, 323 | USE_PROXY, 324 | NOT_APPEARING_IN_THIS_PROTOCOL, 325 | TEMPORARY_REDIRECT, 326 | BAD_REQUEST, 327 | UNAUTHORIZED, 328 | PAYMENT_REQUIRED, 329 | FORBIDDEN, 330 | NOT_FOUND, 331 | METHOD_NOT_ALLOWED, 332 | NOT_ACCEPTABLE, 333 | PROXY_AUTHENTICATION_REQUIRED, 334 | PROXY_UNAUTHORIZED, 335 | REQUEST_TIMEOUT, 336 | CONFLICT, 337 | GONE, 338 | LENGTH_REQUIRED, 339 | PRECONDITION_FAILED, 340 | REQUEST_ENTITY_TOO_LARGE, 341 | REQUEST_URI_TOO_LONG, 342 | UNSUPPORTED_MEDIA_TYPE, 343 | REQUESTED_RANGE_NOT_SATISFIABLE, 344 | INVALID_RANGE, 345 | EXPECTATION_FAILED, 346 | UNPROCESSABLE_ENTITY, 347 | LOCKED, 348 | FAILED_DEPENDENCY, 349 | INTERNAL_SERVER_ERROR, 350 | NOT_IMPLEMENTED, 351 | BAD_GATEWAY, 352 | SERVICE_UNAVAILABLE, 353 | GATEWAY_TIMEOUT, 354 | HTTP_VERSION_NOT_SUPPORTED, 355 | INSUFFICIENT_STORAGE, 356 | NOT_EXTENDED, 357 | } 358 | export enum LoggerLogLevel { 359 | NONE, 360 | MINIMAL, 361 | HEADERS, 362 | BODY, 363 | } 364 | export enum MemoryUse { 365 | STATIC, 366 | TAKE, 367 | COPY, 368 | TEMPORARY, 369 | } 370 | export enum MessageHeadersType { 371 | REQUEST, 372 | RESPONSE, 373 | MULTIPART, 374 | } 375 | export enum MessagePriority { 376 | VERY_LOW, 377 | LOW, 378 | NORMAL, 379 | HIGH, 380 | VERY_HIGH, 381 | } 382 | export enum RequestError { 383 | BAD_URI, 384 | UNSUPPORTED_URI_SCHEME, 385 | PARSING, 386 | ENCODING, 387 | } 388 | export enum RequesterError { 389 | BAD_URI, 390 | UNSUPPORTED_URI_SCHEME, 391 | } 392 | export enum SocketIOStatus { 393 | OK, 394 | WOULD_BLOCK, 395 | EOF, 396 | ERROR, 397 | } 398 | export enum Status { 399 | NONE, 400 | CANCELLED, 401 | CANT_RESOLVE, 402 | CANT_RESOLVE_PROXY, 403 | CANT_CONNECT, 404 | CANT_CONNECT_PROXY, 405 | SSL_FAILED, 406 | IO_ERROR, 407 | MALFORMED, 408 | TRY_AGAIN, 409 | TOO_MANY_REDIRECTS, 410 | TLS_FAILED, 411 | CONTINUE, 412 | SWITCHING_PROTOCOLS, 413 | PROCESSING, 414 | OK, 415 | CREATED, 416 | ACCEPTED, 417 | NON_AUTHORITATIVE, 418 | NO_CONTENT, 419 | RESET_CONTENT, 420 | PARTIAL_CONTENT, 421 | MULTI_STATUS, 422 | MULTIPLE_CHOICES, 423 | MOVED_PERMANENTLY, 424 | FOUND, 425 | MOVED_TEMPORARILY, 426 | SEE_OTHER, 427 | NOT_MODIFIED, 428 | USE_PROXY, 429 | NOT_APPEARING_IN_THIS_PROTOCOL, 430 | TEMPORARY_REDIRECT, 431 | BAD_REQUEST, 432 | UNAUTHORIZED, 433 | PAYMENT_REQUIRED, 434 | FORBIDDEN, 435 | NOT_FOUND, 436 | METHOD_NOT_ALLOWED, 437 | NOT_ACCEPTABLE, 438 | PROXY_AUTHENTICATION_REQUIRED, 439 | PROXY_UNAUTHORIZED, 440 | REQUEST_TIMEOUT, 441 | CONFLICT, 442 | GONE, 443 | LENGTH_REQUIRED, 444 | PRECONDITION_FAILED, 445 | REQUEST_ENTITY_TOO_LARGE, 446 | REQUEST_URI_TOO_LONG, 447 | UNSUPPORTED_MEDIA_TYPE, 448 | REQUESTED_RANGE_NOT_SATISFIABLE, 449 | INVALID_RANGE, 450 | EXPECTATION_FAILED, 451 | UNPROCESSABLE_ENTITY, 452 | LOCKED, 453 | FAILED_DEPENDENCY, 454 | INTERNAL_SERVER_ERROR, 455 | NOT_IMPLEMENTED, 456 | BAD_GATEWAY, 457 | SERVICE_UNAVAILABLE, 458 | GATEWAY_TIMEOUT, 459 | HTTP_VERSION_NOT_SUPPORTED, 460 | INSUFFICIENT_STORAGE, 461 | NOT_EXTENDED, 462 | } 463 | export enum TLDError { 464 | INVALID_HOSTNAME, 465 | IS_IP_ADDRESS, 466 | NOT_ENOUGH_DOMAINS, 467 | NO_BASE_DOMAIN, 468 | } 469 | export enum WebsocketCloseCode { 470 | NORMAL, 471 | GOING_AWAY, 472 | PROTOCOL_ERROR, 473 | UNSUPPORTED_DATA, 474 | NO_STATUS, 475 | ABNORMAL, 476 | BAD_DATA, 477 | POLICY_VIOLATION, 478 | TOO_BIG, 479 | NO_EXTENSION, 480 | SERVER_ERROR, 481 | TLS_HANDSHAKE, 482 | } 483 | export enum WebsocketConnectionType { 484 | UNKNOWN, 485 | CLIENT, 486 | SERVER, 487 | } 488 | export enum WebsocketDataType { 489 | TEXT, 490 | BINARY, 491 | } 492 | export enum WebsocketError { 493 | FAILED, 494 | NOT_WEBSOCKET, 495 | BAD_HANDSHAKE, 496 | BAD_ORIGIN, 497 | } 498 | export enum WebsocketState { 499 | OPEN, 500 | CLOSING, 501 | CLOSED, 502 | } 503 | export enum XMLRPCError { 504 | ARGUMENTS, 505 | RETVAL, 506 | } 507 | export enum XMLRPCFault { 508 | PARSE_ERROR_NOT_WELL_FORMED, 509 | PARSE_ERROR_UNSUPPORTED_ENCODING, 510 | PARSE_ERROR_INVALID_CHARACTER_FOR_ENCODING, 511 | SERVER_ERROR_INVALID_XML_RPC, 512 | SERVER_ERROR_REQUESTED_METHOD_NOT_FOUND, 513 | SERVER_ERROR_INVALID_METHOD_PARAMETERS, 514 | SERVER_ERROR_INTERNAL_XML_RPC_ERROR, 515 | APPLICATION_ERROR, 516 | SYSTEM_ERROR, 517 | TRANSPORT_ERROR, 518 | } 519 | export enum Cacheability{ 520 | CACHEABLE, 521 | UNCACHEABLE, 522 | INVALIDATES, 523 | VALIDATES, 524 | } 525 | export enum Expectation{ 526 | UNRECOGNIZED, 527 | CONTINUE, 528 | } 529 | export enum MessageFlags{ 530 | NO_REDIRECT, 531 | CAN_REBUILD, 532 | OVERWRITE_CHUNKS, 533 | CONTENT_DECODED, 534 | CERTIFICATE_TRUSTED, 535 | NEW_CONNECTION, 536 | IDEMPOTENT, 537 | IGNORE_CONNECTION_LIMITS, 538 | } 539 | export enum ServerListenOptions{ 540 | HTTPS, 541 | IPV4_ONLY, 542 | IPV6_ONLY, 543 | } 544 | export class Address extends GObject.Object { 545 | constructor(config?: any) 546 | static new_any(family: AddressFamily, port: number):Address 547 | static new_from_sockaddr(sa: any, len: number):Address 548 | equal_by_ip(addr2: Address):boolean 549 | equal_by_name(addr2: Address):boolean 550 | get_gsockaddr():Gio.SocketAddress 551 | get_name():string 552 | get_physical():string 553 | get_port():number 554 | get_sockaddr(len: number):any 555 | hash_by_ip():number 556 | hash_by_name():number 557 | is_resolved():boolean 558 | resolve_async(async_context: any, cancellable: Gio.Cancellable, callback: any, user_data: any):void 559 | resolve_sync(cancellable: Gio.Cancellable):number 560 | } 561 | export class Auth extends GObject.Object { 562 | constructor(config?: any) 563 | authenticate(username: string, password: string):void 564 | free_protection_space(space: any):void 565 | get_authorization(msg: Message):string 566 | get_host():string 567 | get_info():string 568 | get_protection_space(source_uri: any):any 569 | get_realm():string 570 | get_saved_password(user: string):string 571 | get_saved_users():any 572 | get_scheme_name():string 573 | has_saved_password(username: string, password: string):void 574 | is_authenticated():boolean 575 | is_for_proxy():boolean 576 | is_ready(msg: Message):boolean 577 | save_password(username: string, password: string):void 578 | update(msg: Message, auth_header: string):boolean 579 | } 580 | export class AuthBasic extends Auth { 581 | } 582 | export class AuthDigest extends Auth { 583 | } 584 | export class AuthDomain extends GObject.Object { 585 | accepts(msg: Message):string 586 | add_path(path: string):void 587 | basic_set_auth_callback(callback: any, user_data: any, dnotify: any):void 588 | challenge(msg: Message):void 589 | check_password(msg: Message, username: string, password: string):boolean 590 | covers(msg: Message):boolean 591 | digest_set_auth_callback(callback: any, user_data: any, dnotify: any):void 592 | get_realm():string 593 | remove_path(path: string):void 594 | set_filter(filter: any, filter_data: any, dnotify: any):void 595 | set_generic_auth_callback(auth_callback: any, auth_data: any, dnotify: any):void 596 | try_generic_auth_callback(msg: Message, username: string):boolean 597 | } 598 | export class AuthDomainBasic extends AuthDomain { 599 | constructor(config?: any) 600 | } 601 | export class AuthDomainDigest extends AuthDomain { 602 | static encode_password(username: string, realm: string, password: string):string 603 | constructor(config?: any) 604 | } 605 | export class AuthManager extends GObject.Object { 606 | use_auth(uri: any, auth: Auth):void 607 | } 608 | export class AuthNTLM extends Auth { 609 | } 610 | export class Cache extends GObject.Object { 611 | constructor(config?: any) 612 | clear():void 613 | dump():void 614 | flush():void 615 | get_max_size():number 616 | load():void 617 | set_max_size(max_size: number):void 618 | } 619 | export class ContentDecoder extends GObject.Object { 620 | } 621 | export class ContentSniffer extends GObject.Object { 622 | constructor(config?: any) 623 | get_buffer_size():number 624 | sniff(msg: Message, buffer: any, params: any):string 625 | } 626 | export class CookieJar extends GObject.Object { 627 | constructor(config?: any) 628 | add_cookie(cookie: any):void 629 | add_cookie_with_first_party(first_party: any, cookie: any):void 630 | all_cookies():any 631 | delete_cookie(cookie: any):void 632 | get_accept_policy():CookieJarAcceptPolicy 633 | get_cookie_list(uri: any, for_http: boolean):any 634 | get_cookies(uri: any, for_http: boolean):string 635 | is_persistent():boolean 636 | save():void 637 | set_accept_policy(policy: CookieJarAcceptPolicy):void 638 | set_cookie(uri: any, cookie: string):void 639 | set_cookie_with_first_party(uri: any, first_party: any, cookie: string):void 640 | } 641 | export class CookieJarDB extends CookieJar { 642 | constructor(config?: any) 643 | } 644 | export class CookieJarText extends CookieJar { 645 | constructor(config?: any) 646 | } 647 | export class Logger extends GObject.Object { 648 | constructor(config?: any) 649 | attach(session: Session):void 650 | detach(session: Session):void 651 | set_printer(printer: any, printer_data: any, destroy: any):void 652 | set_request_filter(request_filter: any, filter_data: any, destroy: any):void 653 | set_response_filter(response_filter: any, filter_data: any, destroy: any):void 654 | } 655 | export class Message extends GObject.Object { 656 | constructor(config?: any) 657 | static new_from_uri(method: string, uri: any):Message 658 | add_header_handler(signal: string, header: string, callback: any, user_data: any):number 659 | add_status_code_handler(signal: string, status_code: number, callback: any, user_data: any):number 660 | content_sniffed(content_type: string, params: any):void 661 | disable_feature(feature_type: any):void 662 | finished():void 663 | get_address():Address 664 | get_first_party():any 665 | get_flags():MessageFlags 666 | get_http_version():HTTPVersion 667 | get_https_status(certificate: Gio.TlsCertificate, errors: Gio.TlsCertificateFlags):boolean 668 | get_priority():MessagePriority 669 | get_soup_request():Request 670 | get_uri():any 671 | got_body():void 672 | got_chunk(chunk: any):void 673 | got_headers():void 674 | got_informational():void 675 | is_keepalive():boolean 676 | restarted():void 677 | set_chunk_allocator(allocator: any, user_data: any, destroy_notify: any):void 678 | set_first_party(first_party: any):void 679 | set_flags(flags: MessageFlags):void 680 | set_http_version(version: HTTPVersion):void 681 | set_priority(priority: MessagePriority):void 682 | set_redirect(status_code: number, redirect_uri: string):void 683 | set_request(content_type: string, req_use: MemoryUse, req_body: number[], req_length: number):void 684 | set_response(content_type: string, resp_use: MemoryUse, resp_body: string, resp_length: number):void 685 | 686 | set_status(status_code: number):void 687 | set_status_full(status_code: number, reason_phrase: string):void 688 | set_uri(uri: any):void 689 | starting():void 690 | wrote_body():void 691 | wrote_body_data(chunk: any):void 692 | wrote_chunk():void 693 | wrote_headers():void 694 | wrote_informational():void 695 | } 696 | export class MultipartInputStream extends Gio.FilterInputStream { 697 | constructor(config?: any) 698 | get_headers():any 699 | next_part(cancellable: Gio.Cancellable):Gio.InputStream 700 | next_part_async(io_priority: number, cancellable: Gio.Cancellable, callback: any, data: any):void 701 | next_part_finish(result: any):Gio.InputStream 702 | } 703 | export class ProxyResolverDefault extends GObject.Object { 704 | } 705 | export class Request extends GObject.Object { 706 | get_content_length():number 707 | get_content_type():string 708 | get_session():Session 709 | get_uri():any 710 | send(cancellable: Gio.Cancellable):Gio.InputStream 711 | send_async(cancellable: Gio.Cancellable, callback: any, user_data: any):void 712 | send_finish(result: any):Gio.InputStream 713 | } 714 | export class RequestData extends Request { 715 | } 716 | export class RequestFile extends Request { 717 | get_file():any 718 | } 719 | export class RequestHTTP extends Request { 720 | get_message():Message 721 | } 722 | export class Requester extends GObject.Object { 723 | constructor(config?: any) 724 | request(uri_string: string):Request 725 | request_uri(uri: any):Request 726 | } 727 | export class Server extends GObject.Object { 728 | constructor(config?: any) 729 | accept_iostream(stream: Gio.IOStream, local_addr: Gio.SocketAddress, remote_addr: Gio.SocketAddress):boolean 730 | add_auth_domain(auth_domain: AuthDomain):void 731 | add_early_handler(path: string, callback: any, user_data: any, destroy: any):void 732 | add_handler(path: string, callback: any, user_data: any, destroy: any):void 733 | add_websocket_handler(path: string, origin: string, protocols: string[], callback: any, user_data: any, destroy: any):void 734 | disconnect():void 735 | get_async_context():any 736 | get_listener():Socket 737 | get_listeners():any 738 | get_port():number 739 | get_uris():any 740 | is_https():boolean 741 | listen(address: Gio.SocketAddress, options: ServerListenOptions):boolean 742 | listen_all(port: number, options: ServerListenOptions):boolean 743 | listen_fd(fd: number, options: ServerListenOptions):boolean 744 | listen_local(port: number, options: ServerListenOptions):boolean 745 | listen_socket(socket: Gio.Socket, options: ServerListenOptions):boolean 746 | pause_message(msg: Message):void 747 | quit():void 748 | remove_auth_domain(auth_domain: AuthDomain):void 749 | remove_handler(path: string):void 750 | run():void 751 | run_async():void 752 | set_ssl_cert_file(ssl_cert_file: string, ssl_key_file: string):boolean 753 | unpause_message(msg: Message):void 754 | } 755 | export class Session extends GObject.Object { 756 | constructor(config?: any) 757 | static new_with_options(optname1: string, ...args: any[]):Session 758 | abort():void 759 | add_feature(feature: any):void 760 | add_feature_by_type(feature_type: any):void 761 | cancel_message(msg: Message, status_code: number):void 762 | get_async_context():any 763 | get_feature(feature_type: any):any 764 | get_feature_for_message(feature_type: any, msg: Message):any 765 | get_features(feature_type: any):any 766 | has_feature(feature_type: any):boolean 767 | pause_message(msg: Message):void 768 | prefetch_dns(hostname: string, cancellable: Gio.Cancellable, callback: any, user_data: any):void 769 | prepare_for_uri(uri: any):void 770 | queue_message(msg: Message, callback: any, user_data: any):void 771 | redirect_message(msg: Message):boolean 772 | remove_feature(feature: any):void 773 | remove_feature_by_type(feature_type: any):void 774 | request(uri_string: string):Request 775 | request_http(method: string, uri_string: string):RequestHTTP 776 | request_http_uri(method: string, uri: any):RequestHTTP 777 | request_uri(uri: any):Request 778 | requeue_message(msg: Message):void 779 | send(msg: Message, cancellable: Gio.Cancellable):Gio.InputStream 780 | send_async(msg: Message, cancellable: Gio.Cancellable, callback: any, user_data: any):void 781 | send_finish(result: any):Gio.InputStream 782 | send_message(msg: Message):number 783 | steal_connection(msg: Message):Gio.IOStream 784 | unpause_message(msg: Message):void 785 | websocket_connect_async(msg: Message, origin: string, protocols: string[], cancellable: Gio.Cancellable, callback: any, user_data: any):void 786 | websocket_connect_finish(result: any):WebsocketConnection 787 | would_redirect(msg: Message):boolean 788 | } 789 | export class SessionAsync extends Session { 790 | constructor(config?: any) 791 | static new_with_options(optname1: string, ...args: any[]):SessionAsync 792 | } 793 | export class SessionSync extends Session { 794 | constructor(config?: any) 795 | static new_with_options(optname1: string, ...args: any[]):SessionSync 796 | } 797 | export class Socket extends GObject.Object { 798 | constructor(config?: any) 799 | connect_async(cancellable: Gio.Cancellable, callback: any, user_data: any):void 800 | connect_sync(cancellable: Gio.Cancellable):number 801 | disconnect():void 802 | get_fd():number 803 | get_local_address():Address 804 | get_remote_address():Address 805 | is_connected():boolean 806 | is_ssl():boolean 807 | listen():boolean 808 | read(buffer: number[], len: number, nread: number, cancellable: Gio.Cancellable):SocketIOStatus 809 | read_until(buffer: number[], len: number, boundary: any, boundary_len: number, nread: number, got_boundary: boolean, cancellable: Gio.Cancellable):SocketIOStatus 810 | start_proxy_ssl(ssl_host: string, cancellable: Gio.Cancellable):boolean 811 | start_ssl(cancellable: Gio.Cancellable):boolean 812 | write(buffer: number[], len: number, nwrote: number, cancellable: Gio.Cancellable):SocketIOStatus 813 | } 814 | export class WebsocketConnection extends GObject.Object { 815 | constructor(config?: any) 816 | close(code: number, data: string):void 817 | get_close_code():number 818 | get_close_data():string 819 | get_connection_type():WebsocketConnectionType 820 | get_io_stream():Gio.IOStream 821 | get_origin():string 822 | get_protocol():string 823 | get_state():WebsocketState 824 | get_uri():any 825 | send_binary(data: number[], length: number):void 826 | send_text(text: string):void 827 | } 828 | } --------------------------------------------------------------------------------