├── .gitattributes ├── .github └── workflows │ └── ci.yml ├── .gitignore ├── .vscode └── c_cpp_properties.json ├── LICENSE ├── Makefile ├── README.md ├── examples ├── basic.v ├── box.v ├── button.v ├── dialog.v ├── entry.v ├── grid.v ├── label.v └── message_dialog.v ├── fmt.vsh ├── gdk ├── _cdefs.v ├── device.v ├── events.v ├── gdk.v ├── pixbuf.v └── window.v ├── gio ├── _cdefs.v ├── action_group.v ├── gapplication.v └── gio.v ├── glib ├── _cdefs.v ├── array.v ├── datasets.v ├── glib.v ├── glib_nix.v ├── list.v ├── node.v ├── slist.v └── string.v ├── gtk ├── _cdefs.v ├── about_dialog.v ├── accel_map.v ├── actionable.v ├── allocation.v ├── application.v ├── application_window.v ├── bin.v ├── box.v ├── buildable.v ├── builder.v ├── button.v ├── buttonbox.v ├── check_button.v ├── color_chooser.v ├── consts.v ├── container.v ├── dialog.v ├── entry.v ├── enums.v ├── grid.v ├── gtk3.v ├── gtk3_nix.v ├── image.v ├── interfaces.v ├── label.v ├── menu.v ├── message_dialog.v ├── paned.v ├── radio_button.v ├── requested_size.v ├── requisition.v ├── scrolled_window.v ├── style_context.v ├── text_view.v ├── toggle_button.v ├── utils.v ├── widget.v ├── widget_path.v └── window.v ├── pango ├── _cdefs.v ├── attributes.v ├── font_description.v ├── fonts.v ├── language.v ├── pango.v ├── stretch.v ├── underline.v ├── variant.v └── weight.v ├── tests ├── glib_lists_test.v ├── glib_string_test.v ├── importing_gdb_glib_and_gtk_works_test.v └── window_test.v ├── v.mod └── vpkg.json /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | on: [push, pull_request] 3 | jobs: 4 | ubuntu-latest: 5 | runs-on: ubuntu-latest 6 | steps: 7 | - name: Installing Dependencies 8 | run: sudo rm -f /etc/apt/sources.list.d/dotnetdev.list /etc/apt/sources.list.d/microsoft-prod.list; sudo apt-get update; sudo apt-get install xvfb; sudo apt-get install libgtk-3-dev; sudo apt-get install libgdk-pixbuf2.0-dev 9 | - name: Linking gdk-pixbuf 10 | run: sudo ln -s /usr/include/gdk-pixbuf-2.0/gdk-pixbuf /usr/include/gdk-pixbuf 11 | - name: Installing V 12 | run: cd ~; git clone https://github.com/vlang/v.git; cd v; make; sudo ./v symlink 13 | - uses: actions/checkout@v2 14 | 15 | - name: Running Test (TCC) 16 | env: 17 | VFLAGS: -cc tcc -cg -showcc 18 | run: xvfb-run make test 19 | continue-on-error: true 20 | 21 | - name: Running Test (CLANG) 22 | env: 23 | VFLAGS: -cc clang -cg -showcc 24 | run: xvfb-run make test 25 | continue-on-error: true 26 | 27 | - name: Running Test (GCC) 28 | env: 29 | VFLAGS: -cc gcc -cg -showcc 30 | run: xvfb-run make test 31 | continue-on-error: true 32 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | examples/* 2 | -------------------------------------------------------------------------------- /.vscode/c_cpp_properties.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "name": "Linux", 5 | "includePath": [ 6 | "${workspaceFolder}/**", 7 | "/usr/include/gtk-3.0", 8 | "/usr/include/glib-2.0", 9 | "/usr/lib/x86_64-linux-gnu/glib-2.0/include", 10 | "/usr/include/pango-1.0", 11 | "/usr/include/cairo", 12 | "/usr/include/gdk-pixbuf-2.0", 13 | "/usr/include/atk-1.0", 14 | "/usr/include/harfbuzz" 15 | ], 16 | "defines": [], 17 | "compilerPath": "/usr/bin/gcc", 18 | "cStandard": "gnu17", 19 | "cppStandard": "gnu++14", 20 | "intelliSenseMode": "gcc-x64" 21 | } 22 | ], 23 | "version": 4 24 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019-2020 The VGTK Project Developers. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | V ?= v 2 | 3 | %.o : %.mod 4 | 5 | all: fmt test examples 6 | 7 | .PHONY: fmt test examples 8 | 9 | fmt: 10 | $(V) run ./fmt.vsh 11 | 12 | test: 13 | $(V) test . 14 | 15 | examples: 16 | $(V) ./examples/box.v 17 | $(V) ./examples/button.v 18 | $(V) ./examples/basic.v 19 | $(V) ./examples/dialog.v 20 | $(V) ./examples/entry.v 21 | $(V) ./examples/grid.v 22 | $(V) ./examples/label.v 23 | 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # VGTK3 ![GitHub Workflow Status (branch)][workflow-badge] ![GitHub release (latest by date)][release-badge] 2 | 3 | [workflow-badge]: https://img.shields.io/github/workflow/status/vgtk/vgtk3/CI/master?style=flat-square 4 | [release-badge]: https://img.shields.io/github/v/release/vgtk/vgtk3?style=flat-square 5 | 6 | ## What is this? 7 | 8 | This is a manual wrapper for `gtk3` for V. 9 | The advantage compared to using `C.` directly is that `vgtk3` uses V structs and does it best to have a good V style when "translating" `gtk3` to V. 10 | This is mostly why the functions aren't auto-generated, as this doesn't create any helpful structures nor does it splits the files, because it doesn't know what a container is, this wrapper knows it and offers a `Container` interface ready for use. 11 | 12 | > Notes: We are still combining everything together here, will be separated after everything is finished 13 | 14 | ## Dependencies 15 | 16 | - gtk3 development package 17 | - pkgconfig 18 | 19 | ## Get Started 20 | 21 | ```v 22 | module main 23 | 24 | import gtk 25 | 26 | fn main() { 27 | window := gtk.new_window() 28 | window.set_title('Window Title') 29 | window.set_default_size(500, 600) 30 | window.set_position(.center) 31 | window.show() 32 | gtk.main() 33 | } 34 | ``` 35 | 36 | ## Examples 37 | 38 | Please checkout the [examples](./examples) folder. To compile all examples, simply run `make examples` command. 39 | 40 | ## Progress 41 | 42 | - GTK 43 | - [ ] AccelMap 44 | - [ ] ActionBar 45 | - [ ] Application 46 | - [ ] Box 47 | - [x] Button 48 | - [x] ComboBox 49 | - [ ] Container 50 | - [ ] Dialog 51 | - [ ] Entry 52 | - [x] Grid 53 | - [ ] Image 54 | - [x] Label 55 | - [ ] Menu 56 | - [ ] MenuItem 57 | - [ ] WidgetPath 58 | - [ ] Widget 59 | - [ ] Window 60 | - GDK 61 | - [ ] Device 62 | - [ ] Window 63 | - GIO 64 | - [ ] File 65 | - GLIB 66 | - [ ] Array 67 | - [ ] List 68 | - [ ] Node 69 | - [ ] SList 70 | - [ ] String 71 | 72 | ## Notes 73 | 74 | - You need the latest GTK+ installed. 75 | 76 | ## License 77 | 78 | Gtk is available under the MIT License, please refer to it. 79 | -------------------------------------------------------------------------------- /examples/basic.v: -------------------------------------------------------------------------------- 1 | module main 2 | 3 | import os 4 | import gtk 5 | 6 | fn btn_clicked(btn gtk.Button, data voidptr) { 7 | if btn.get_label() == 'VGTK3 is ..' { 8 | btn.set_label('VGTK3 is awesome!') 9 | } else { 10 | btn.set_label('VGTK3 is ..') 11 | } 12 | } 13 | 14 | fn run_quit(mi gtk.Button, data voidptr) { 15 | gtk.main_quit() 16 | } 17 | 18 | fn run_code(mi gtk.Button, data voidptr) { 19 | source := 'runme.v' 20 | app := &AppState(data) 21 | input := app.code.get_text() 22 | 23 | os.rm(source) or {} 24 | mut f := os.open_file(source, 'w+') or { panic(err) } 25 | f.writeln(input) or { panic(err) } 26 | f.close() 27 | 28 | mut cmd := os.Command{ 29 | path: 'v run runme.v' 30 | redirect_stdout: true 31 | } 32 | cmd.start() or { panic(err) } 33 | mut out := '' 34 | for !cmd.eof { 35 | out += cmd.read_line() 36 | } 37 | cmd.close() or { panic(err) } 38 | app.result.set_text(out) 39 | } 40 | 41 | fn menu_exit(mi gtk.MenuItem, data voidptr) { 42 | gtk.main_quit() 43 | } 44 | 45 | fn menu_about(mi gtk.MenuItem, data voidptr) { 46 | os.system("ls /") 47 | } 48 | 49 | fn alert_clicked(btn gtk.Button, data voidptr) { 50 | btn.set_label('All Fine!') 51 | } 52 | 53 | fn win_destroy(win gtk.Window, data voidptr) { 54 | gtk.main_quit() // necessary as gtk won't exit itself when window is destroyed. 55 | } 56 | 57 | struct AppState { 58 | mut: 59 | window gtk.Window 60 | menubar gtk.MenuBar 61 | have_menubar bool 62 | code gtk.TextView 63 | result gtk.TextView 64 | } 65 | 66 | fn new_appstate() AppState { 67 | return AppState{ 68 | window: gtk.new_window() 69 | } 70 | } 71 | 72 | fn (mut app AppState) ready() { 73 | w := app.window 74 | w.set_position(.center) 75 | w.set_title('Im made with V') 76 | w.on('destroy', win_destroy, voidptr(0)) 77 | w.show_all() 78 | } 79 | 80 | fn (mut app AppState)get_bbox() gtk.ButtonBox { 81 | bbox := gtk.new_hbutton_box() 82 | bbox.set_layout(.end) 83 | 84 | gtk.Box(bbox).set_spacing(10) 85 | app.window.set_border_width(10) 86 | // c := >k.Container(vbox.c) 87 | //c.set_border_width(10) 88 | 89 | a := gtk.new_button_with_label('Run') 90 | a.on('activate', run_code, app) 91 | a.on('clicked', run_code, app) 92 | r := gtk.new_button_with_label('Quit') 93 | r.on('activate', run_quit, app) 94 | r.on('clicked', run_quit, app) 95 | bbox.add(a) 96 | bbox.add(r) 97 | return bbox 98 | } 99 | 100 | fn (mut app AppState)get_paned() gtk.Paned { 101 | p := gtk.new_paned(.horizontal) 102 | p.set_position(200) 103 | p.set_wide_handle(true) 104 | code := gtk.new_text_view() 105 | code.set_text("fn main() { 106 | println('Hello World') 107 | } 108 | ") 109 | code0 := gtk.new_scrolled_window() 110 | code0.add(code) 111 | p.add1(code0) 112 | result := gtk.new_text_view() 113 | 114 | result.set_text('hello world') 115 | result.set_editable(false) 116 | result0 := gtk.new_scrolled_window() 117 | result0.add(result) 118 | p.add2(result0) 119 | 120 | app.code = code 121 | app.result = result 122 | return p 123 | } 124 | 125 | fn (mut app AppState)get_menubar() gtk.MenuBar { 126 | if app.have_menubar { 127 | return app.menubar 128 | } 129 | /* 130 | if mb := app.menubar { 131 | return mb 132 | } 133 | */ 134 | bar := gtk.new_menu_bar() 135 | app.menubar = bar 136 | 137 | menu := gtk.new_menu() 138 | file_me := gtk.new_menu_item_with_label("File") 139 | quit := gtk.new_menu_item_with_label("Quit") 140 | quit.set_accel_path('GTKTest/File/Quit') 141 | quit.set_use_underline(true) 142 | quit.on('activate', menu_exit, &app) 143 | file_me.set_submenu(menu) 144 | 145 | edit_me := gtk.new_menu_item_with_label('Edit') 146 | edit_me.set_submenu(menu) 147 | 148 | about := gtk.new_menu_item_with_label('About') 149 | about.on('activate', menu_about, voidptr(0)) 150 | menu.append(gtk.new_menu_item_with_label('Open')) 151 | menu.append(about) 152 | // menu.append(gtk.new_separator_menu_item()) 153 | menu.append(quit) 154 | bar.append(file_me) 155 | return bar 156 | } 157 | 158 | fn main() { 159 | mut app := new_appstate() 160 | 161 | menu := app.get_menubar() 162 | 163 | vbox := gtk.new_vbox(20) 164 | vbox.set_halign(.fill) 165 | btn := gtk.new_button_with_label('VGTK3 is ..') 166 | btn2 := gtk.new_button_with_label('Im useless!') 167 | alert := gtk.new_button_with_label('Alert!') 168 | 169 | hbox := gtk.new_hbox(20) 170 | hbox.set_halign(.end) 171 | entry := gtk.new_entry() 172 | 173 | btn.set_size(200, 100) 174 | btn2.set_size(100, 50) 175 | alert.set_size(80, 20) 176 | /* 177 | entry.set_text("Good Night!") 178 | btn.on("clicked", btn_clicked, &window) 179 | 180 | gtk.accel_map_add_entry('GTK-Test/File/Quit', 65, 0) 181 | quit.set_accel_path('GTKTest/File/Quit') 182 | quit.set_use_underline(true) 183 | quit.on('activate', menu_exit, &window) 184 | 185 | alert.on("clicked", alert_clicked, &window) 186 | */ 187 | entry.set_text('Good Night!') 188 | btn.on('clicked', btn_clicked, &app.window) 189 | 190 | gtk.accel_map_add_entry('GTK-Test/File/Quit', 65, 0) 191 | 192 | alert.on('clicked', alert_clicked, &app.window) 193 | 194 | hbox.add(entry) 195 | hbox.add(alert) 196 | 197 | vbox.pack_start(menu, false, false, 0) 198 | 199 | vbox.pack_start(btn, false, false, 0) 200 | vbox.pack_start(btn2, false, false, 0) 201 | vbox.pack_start(hbox, false, false, 0) 202 | 203 | paned := app.get_paned() 204 | 205 | vbox.pack_start(paned, true, true, 0) 206 | 207 | bbox := app.get_bbox() 208 | 209 | vbox.pack_end(bbox, false, false, 0) 210 | vbox.set_spacing(10) 211 | app.window.add(vbox) 212 | 213 | app.ready() 214 | gtk.main() 215 | } 216 | -------------------------------------------------------------------------------- /examples/box.v: -------------------------------------------------------------------------------- 1 | module main 2 | 3 | import gtk 4 | 5 | fn main() { 6 | window := gtk.new_window() 7 | window.set_title('Box Example') 8 | window.set_default_size(500, 50) 9 | 10 | box := gtk.new_box(.horizontal, 6) 11 | window.add(box) 12 | 13 | button1 := gtk.new_button_with_label('Hello') 14 | button1.on('clicked', on_button1_clicked, voidptr(0)) 15 | box.pack_start(button1, true, true, 0) 16 | 17 | button2 := gtk.new_button_with_label('Goodbye') 18 | button2.on('clicked', on_button2_clicked, voidptr(0)) 19 | box.pack_start(button2, false, false, 0) 20 | 21 | window.on('destroy', on_window_destroy, voidptr(0)) 22 | window.show_all() 23 | gtk.main() 24 | } 25 | 26 | fn on_button1_clicked(button1 gtk.Button, data voidptr) { 27 | println('Hello...') 28 | } 29 | 30 | fn on_button2_clicked(button2 gtk.Button, data voidptr) { 31 | println('Goodbye...') 32 | } 33 | 34 | fn on_window_destroy(window gtk.Window, data voidptr) { 35 | gtk.main_quit() 36 | } 37 | -------------------------------------------------------------------------------- /examples/button.v: -------------------------------------------------------------------------------- 1 | module main 2 | 3 | import gtk 4 | 5 | fn main() { 6 | window := gtk.new_window() 7 | window.set_title('Button Demo') 8 | window.set_border_width(10) 9 | 10 | hbox := gtk.new_hbox(6) 11 | window.add(hbox) 12 | 13 | mut button := gtk.new_button_with_label('Click me') 14 | button.on('clicked', on_clickme_clicked, window) 15 | hbox.pack_start(button, true, true, 0) 16 | 17 | button = gtk.new_button_with_mnemonic('_Open') 18 | button.on('clicked', on_open_clicked, window) 19 | hbox.pack_start(button, true, true, 0) 20 | 21 | button = gtk.new_button_with_mnemonic('_Close') 22 | button.on('clicked', on_close_clicked, window) 23 | hbox.pack_start(button, true, true, 0) 24 | 25 | window.on('destroy', on_destroy, window) 26 | window.show_all() 27 | 28 | gtk.main() 29 | } 30 | 31 | fn on_clickme_clicked(button gtk.Button, data voidptr) { 32 | println('Click me button was clicked') 33 | } 34 | 35 | fn on_open_clicked(button gtk.Button, data voidptr) { 36 | println('Open button was clicked') 37 | } 38 | 39 | fn on_close_clicked(button gtk.Button, data voidptr) { 40 | println('Close button was clicked') 41 | gtk.main_quit() 42 | } 43 | 44 | fn on_destroy(window gtk.Window, data voidptr) { 45 | gtk.main_quit() 46 | } 47 | -------------------------------------------------------------------------------- /examples/dialog.v: -------------------------------------------------------------------------------- 1 | module main 2 | 3 | import gtk 4 | 5 | fn main() { 6 | window := gtk.new_window() 7 | window.set_title('Main window') 8 | window.set_default_size(500, 250) 9 | window.on('destroy', on_window_destroy, voidptr(0)) 10 | 11 | dialog := gtk.new_dialog_from_parent('Dialog', window, .modal) 12 | dialog.set_default_size(150, 150) 13 | dialog.add_button('_CANCEL', .cancel) 14 | dialog.add_button('_OK', .yes) 15 | 16 | button := gtk.new_button_with_label('Show Dialog') 17 | button.on('clicked', on_btn_show_dialog_clicked, &dialog) 18 | 19 | window.add(button) 20 | 21 | window.show_all() 22 | gtk.main() 23 | } 24 | 25 | fn on_btn_show_dialog_clicked(button gtk.Button, data voidptr) { 26 | dialog := >k.Dialog(data) 27 | 28 | label := gtk.new_label('Are you sure want to quit?') 29 | box := dialog.get_content_area() 30 | box.add(label) 31 | 32 | label.show() 33 | res := dialog.run() 34 | 35 | if res == .yes { 36 | println('Yes') 37 | gtk.main_quit() 38 | } else { 39 | println('Cancel') 40 | dialog.hide() 41 | } 42 | } 43 | 44 | fn on_window_destroy(window gtk.Window, data voidptr) { 45 | gtk.main_quit() 46 | } 47 | -------------------------------------------------------------------------------- /examples/entry.v: -------------------------------------------------------------------------------- 1 | module main 2 | 3 | import gtk 4 | import glib 5 | 6 | struct EntryDemo { 7 | mut: 8 | window gtk.Window 9 | entry gtk.Entry 10 | btn_editable gtk.CheckButton 11 | btn_visible gtk.CheckButton 12 | btn_pulse gtk.CheckButton 13 | btn_icon gtk.CheckButton 14 | timeout_id u32 15 | } 16 | 17 | fn new_entry_demo() &EntryDemo { 18 | mut this := &EntryDemo{} 19 | 20 | window := gtk.new_window() 21 | this.window = window 22 | window.set_title('Entry Demo') 23 | 24 | vbox := gtk.new_box(.vertical, 6) 25 | window.add(vbox) 26 | 27 | entry := gtk.new_entry() 28 | this.entry = entry 29 | entry.set_text('Hello World') 30 | entry.set_editable(false) 31 | entry.on('changed', on_entry_text_changed, this) 32 | vbox.pack_start(entry, true, true, 0) 33 | 34 | hbox := gtk.new_box(.horizontal, 6) 35 | vbox.pack_start(hbox, true, true, 0) 36 | 37 | btn_editable := gtk.new_check_button_with_label('Editable') 38 | this.btn_editable = btn_editable 39 | btn_editable.on('toggled', on_btn_editable_toggled, this) 40 | hbox.pack_start(btn_editable, true, true, 0) 41 | 42 | btn_visible := gtk.new_check_button_with_label('Visible') 43 | this.btn_visible = btn_visible 44 | btn_visible.on('toggled', on_btn_visible_toggled, this) 45 | hbox.pack_start(btn_visible, true, true, 0) 46 | 47 | btn_pulse := gtk.new_check_button_with_label('Pulse') 48 | this.btn_pulse = btn_pulse 49 | btn_pulse.on('toggled', on_btn_pulse_clicked, this) 50 | hbox.pack_start(btn_pulse, true, true, 0) 51 | 52 | btn_icon := gtk.new_check_button_with_label('Icon') 53 | this.btn_icon = btn_icon 54 | btn_icon.on('toggled', on_btn_icon_clicked, this) 55 | hbox.pack_start(btn_icon, true, true, 0) 56 | 57 | return this 58 | } 59 | 60 | fn on_btn_editable_toggled(button gtk.CheckButton, data voidptr) { 61 | this := &EntryDemo(data) 62 | value := button.get_active() 63 | this.entry.set_editable(value) 64 | } 65 | 66 | fn on_btn_visible_toggled(button gtk.CheckButton, data voidptr) { 67 | this := &EntryDemo(data) 68 | value := button.get_active() 69 | this.entry.set_visibility(value) 70 | } 71 | 72 | fn do_pulse(data voidptr) bool { 73 | this := &EntryDemo(data) 74 | this.entry.progress_pulse() 75 | return true 76 | } 77 | 78 | fn on_btn_pulse_clicked(button gtk.CheckButton, data voidptr) { 79 | mut this := &EntryDemo(data) 80 | if button.get_active() { 81 | this.entry.set_progress_pulse_step(0.2) 82 | this.timeout_id = glib.timeout_add(u32(100), do_pulse, data) 83 | } else { 84 | glib.source_remove(this.timeout_id) 85 | this.timeout_id = u32(0) 86 | this.entry.set_progress_pulse_step(f32(0)) 87 | } 88 | } 89 | 90 | fn on_entry_text_changed(entry gtk.Entry, data voidptr) { 91 | text := entry.get_text().trim(' ') 92 | fraction := f32(text.len) / 10.0 93 | if fraction <= 1 { 94 | entry.set_progress_fraction(fraction) 95 | } 96 | } 97 | 98 | fn on_btn_icon_clicked(button gtk.CheckButton, data voidptr) { 99 | this := &EntryDemo(data) 100 | icon_name := if button.get_active() {'system-search-symbolic' } else { '' } 101 | this.entry.set_icon_from_icon_name(.primary, icon_name) 102 | } 103 | 104 | fn main() { 105 | entry_demo := new_entry_demo() 106 | window := &entry_demo.window 107 | window.on('destroy', on_window_destroy, voidptr(0)) 108 | window.show_all() 109 | gtk.main() 110 | } 111 | 112 | fn on_window_destroy(window gtk.Window, data voidptr) { 113 | gtk.main_quit() 114 | } 115 | -------------------------------------------------------------------------------- /examples/grid.v: -------------------------------------------------------------------------------- 1 | module main 2 | 3 | import gtk 4 | 5 | fn main() { 6 | window := gtk.new_window() 7 | window.set_title('Grid Example') 8 | 9 | grid := gtk.new_grid() 10 | window.add(grid) 11 | 12 | button1 := gtk.new_button_with_label('Button1') 13 | button2 := gtk.new_button_with_label('Button2') 14 | button3 := gtk.new_button_with_label('button3') 15 | button4 := gtk.new_button_with_label('button4') 16 | button5 := gtk.new_button_with_label('button5') 17 | button6 := gtk.new_button_with_label('button6') 18 | 19 | grid.add(button1) 20 | grid.attach(button2, 1, 0, 2, 1) 21 | grid.attach_next_to(button3, button1, .bottom, 1, 2) 22 | grid.attach_next_to(button4, button3, .right, 2, 1) 23 | grid.attach(button5, 1, 2, 1, 1) 24 | grid.attach_next_to(button6, button5, .right, 1, 1) 25 | 26 | window.on('destroy', on_destroy, voidptr(0)) 27 | window.show_all() 28 | gtk.main() 29 | } 30 | 31 | fn on_destroy(window gtk.Window, data voidptr) { 32 | gtk.main_quit() 33 | } 34 | -------------------------------------------------------------------------------- /examples/label.v: -------------------------------------------------------------------------------- 1 | module main 2 | 3 | import gtk 4 | 5 | fn main() { 6 | window := gtk.new_window() 7 | window.set_title('Label Example') 8 | window.set_default_size(500, 500) 9 | window.set_border_width(10) 10 | 11 | hbox := gtk.new_hbox(10) 12 | vbox_left := gtk.new_vbox(10) 13 | vbox_right := gtk.new_vbox(10) 14 | 15 | hbox.pack_start(vbox_left, true, true, 0) 16 | hbox.pack_start(vbox_right, true, true, 0) 17 | 18 | mut label := gtk.new_label('This is a normal label') 19 | vbox_left.pack_start(label, true, true, 0) 20 | 21 | label = gtk.new_label('This is a left-justified label.\nWith multiple lines.') 22 | label.set_justify(.left) 23 | vbox_left.pack_start(label, true, true, 0) 24 | 25 | label = gtk.new_empty_label() 26 | label.set_text('This is a right-justified label.\nWith multiple lines.') 27 | label.set_justify(.right) 28 | vbox_left.pack_start(label, true, true, 0) 29 | 30 | label = gtk.new_label("This is an example of a line-wrapped label. It " + 31 | "should not be taking up the entire " + 32 | "width allocated to it, but automatically " + 33 | "wraps the words to fit.\n" + 34 | " It supports multiple paragraphs correctly, " + 35 | "and correctly adds " + 36 | "many extra spaces. ") 37 | label.set_line_wrap(true) 38 | vbox_right.pack_start(label, true, true, 0) 39 | 40 | label = gtk.new_label("This is an example of a line-wrapped, filled label. " + 41 | "It should be taking " + 42 | "up the entire width allocated to it. " + 43 | "Here is a sentence to prove " + 44 | "my point. Here is another sentence. " + 45 | "Here comes the sun, do de do de do.\n" + 46 | " This is a new paragraph.\n" + 47 | " This is another newer, longer, better " + 48 | "paragraph. It is coming to an end, " + 49 | "unfortunately.") 50 | label.set_line_wrap(true) 51 | label.set_justify(.fill) 52 | vbox_right.pack_start(label, true, true, 0) 53 | 54 | label = gtk.new_empty_label() 55 | label.set_markup( "Text can be small, big, " + 56 | "bold, italic and even point to " + 57 | "somewhere in the internets.") 59 | label.set_line_wrap(true) 60 | vbox_left.pack_start(label, true, true, 0) 61 | 62 | label = gtk.new_label_with_mnemonic('_Press Alt + P to select button to the right') 63 | vbox_left.pack_start(label, true, true, 0) 64 | label.set_selectable(true) 65 | 66 | button := gtk.new_button_with_label('Click at your own risk') 67 | label.set_mnemonic_widget(button) 68 | vbox_right.pack_start(button, true, true, 0) 69 | 70 | window.add(hbox) 71 | window.on('destroy', on_destroy, window) 72 | window.show_all() 73 | 74 | gtk.main() 75 | } 76 | 77 | fn on_destroy(window gtk.Window, data voidptr) { 78 | gtk.main_quit() 79 | } 80 | -------------------------------------------------------------------------------- /examples/message_dialog.v: -------------------------------------------------------------------------------- 1 | module main 2 | 3 | import gtk 4 | 5 | fn main() { 6 | window := gtk.new_window() 7 | window.set_title('MessageDialog Demo') 8 | 9 | box := gtk.new_box(.horizontal, 6) 10 | window.add(box) 11 | 12 | button1 := gtk.new_button_with_label('Information') 13 | button1.on('clicked', on_info_clicked, &window) 14 | box.add(button1) 15 | 16 | button2 := gtk.new_button_with_label('Error') 17 | button2.on('clicked', on_err_clicked, &window) 18 | box.add(button2) 19 | 20 | button3 := gtk.new_button_with_label('Warning') 21 | button3.on('clicked', on_warn_clicked, &window) 22 | box.add(button3) 23 | 24 | button4 := gtk.new_button_with_label('Question') 25 | button4.on('clicked', on_question_clicked, &window) 26 | box.add(button4) 27 | 28 | window.on('destroy', on_window_destroy, &window) 29 | window.show_all() 30 | gtk.main() 31 | } 32 | 33 | fn on_info_clicked(button gtk.Button, data voidptr) { 34 | parent := >k.Window(data) 35 | dialog := gtk.new_message_dialog(parent, .modal, .info, .ok, 'This is an INFO MessageDialog') 36 | dialog.format_secondary_text('And this is the secondary text that explains things.') 37 | dialog.run() 38 | println('INFO dialog closed') 39 | dialog.destroy() 40 | } 41 | 42 | fn on_err_clicked(button gtk.Button, data voidptr) { 43 | parent := >k.Window(data) 44 | dialog := gtk.new_message_dialog(parent, .modal, .error, .cancel, 'This is an ERROR MessageDialog') 45 | dialog.format_secondary_text('And this is the secondary text that explains things.') 46 | dialog.run() 47 | println('ERROR dialog closed') 48 | dialog.destroy() 49 | } 50 | 51 | fn on_warn_clicked(button gtk.Button, data voidptr) { 52 | parent := >k.Window(data) 53 | dialog := gtk.new_message_dialog(parent, .modal, .warning, .ok_cancel, 'This is an WARNING MessageDialog') 54 | dialog.format_secondary_text('And this is the secondary text that explains things.') 55 | response := dialog.run() 56 | if response == .ok { 57 | println('WARN dialog closed by clicking OK button') 58 | } else if response == .cancel { 59 | println('WARN dialog closed by clicking CANCEL button') 60 | } 61 | dialog.destroy() 62 | } 63 | 64 | fn on_question_clicked(button gtk.Button, data voidptr) { 65 | parent := >k.Window(data) 66 | dialog := gtk.new_message_dialog(parent, .modal, .question, .yes_no, 'This is an QUESTION MessageDialog') 67 | dialog.format_secondary_text('And this is the secondary text that explains things.') 68 | response := dialog.run() 69 | if response == .yes { 70 | println('QUESTION dialog closed by clicking YES button') 71 | } else if response == .no { 72 | println('QUESTION dialog closed by clicking NO button') 73 | } 74 | dialog.destroy() 75 | } 76 | 77 | fn on_window_destroy(window gtk.Window, data voidptr) { 78 | gtk.main_quit() 79 | } 80 | -------------------------------------------------------------------------------- /fmt.vsh: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | const vexe = os.getenv('VEXE') 4 | 5 | v_files := os.walk_ext('./', '.v') 6 | 7 | for v_file in v_files { 8 | if v_file.contains('./examples/') { 9 | continue 10 | } 11 | if 0 != os.system('$vexe fmt $v_file -w') { 12 | panic('could not format $v_file') 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /gdk/_cdefs.v: -------------------------------------------------------------------------------- 1 | module gdk 2 | 3 | pub struct C.GdkWindow {} 4 | 5 | struct C.GdkWindowAttr {} 6 | 7 | struct C.GdkGravity {} 8 | 9 | struct C.GdkDisplay {} 10 | 11 | struct C.GdkScreen {} 12 | 13 | struct C.GdkVisual {} 14 | 15 | struct C.GdkRectangle {} 16 | 17 | pub struct C.GdkDevice {} 18 | 19 | struct C.GdkEvent {} 20 | 21 | struct C.GdkGeometry {} 22 | 23 | struct C.GdkGLContext {} 24 | 25 | struct C.GdkDrawingContext {} 26 | 27 | struct C.GdkWindowInvalidateHandlerFunc {} 28 | 29 | struct C.GdkFrameClock {} 30 | 31 | struct C.GdkFilterFunc {} 32 | 33 | struct C.GdkColor {} 34 | 35 | pub struct C.GdkRGBA {} 36 | 37 | struct C.GdkCursor {} 38 | 39 | pub struct C.GdkModifierType {} 40 | 41 | pub struct C.GdkPixbuf {} 42 | 43 | // GDK WINDOW 44 | fn C.gdk_window_new(&C.GdkWindow, &C.GdkWindowAttr, int) &C.GdkWindow 45 | 46 | fn C.gdk_window_destroy(&C.GdkWindow) 47 | 48 | fn C.gdk_window_get_window_type(&C.GdkWindow) int 49 | 50 | // C.GdkWindowType 51 | fn C.gdk_window_get_display(&C.GdkWindow) &C.GdkDisplay 52 | 53 | fn C.gdk_window_get_screen(&C.GdkWindow) &C.GdkScreen 54 | 55 | fn C.gdk_window_get_visual(&C.GdkWindow) &C.GdkVisual 56 | 57 | fn C.gdk_window_at_pointer(&int, &int) &C.GdkWindow 58 | 59 | fn C.gdk_window_show(&C.GdkWindow) 60 | 61 | fn C.gdk_window_show_unraised(&C.GdkWindow) 62 | 63 | fn C.gdk_window_hide(&C.GdkWindow) 64 | 65 | fn C.gdk_window_is_destroyed(&C.GdkWindow) bool 66 | 67 | fn C.gdk_window_is_visible(&C.GdkWindow) bool 68 | 69 | fn C.gdk_window_is_viewable(&C.GdkWindow) bool 70 | 71 | fn C.gdk_window_is_input_only(&C.GdkWindow) bool 72 | 73 | fn C.gdk_window_is_shaped(&C.GdkWindow) bool 74 | 75 | fn C.gdk_window_get_state(&C.GdkWindow) int 76 | 77 | // C.GdkWindowState 78 | fn C.gdk_window_withdraw(&C.GdkWindow) 79 | 80 | fn C.gdk_window_iconify(&C.GdkWindow) 81 | 82 | fn C.gdk_window_deiconify(&C.GdkWindow) 83 | 84 | fn C.gdk_window_stick(&C.GdkWindow) 85 | 86 | fn C.gdk_window_unstick(&C.GdkWindow) 87 | 88 | fn C.gdk_window_maximize(&C.GdkWindow) 89 | 90 | fn C.gdk_window_unmaximize(&C.GdkWindow) 91 | 92 | fn C.gdk_window_fullscreen(&C.GdkWindow) 93 | 94 | fn C.gdk_window_fullscreen_on_monitor(&C.GdkWindow, int) 95 | 96 | fn C.gdk_window_unfullscreen(&C.GdkWindow) 97 | 98 | fn C.gdk_window_get_fullscreen_mode(&C.GdkWindow) int 99 | 100 | // C.GdkFullscreenMode 101 | fn C.gdk_window_set_fullscreen_mode(&C.GdkWindow, int, C.GdkFullscreenMode) 102 | 103 | fn C.gdk_window_set_keep_above(&C.GdkWindow, bool) 104 | 105 | fn C.gdk_window_set_keep_below(&C.GdkWindow, bool) 106 | 107 | fn C.gdk_window_set_opacity(&C.GdkWindow, f64) 108 | 109 | fn C.gdk_window_set_composited(&C.GdkWindow, bool) 110 | 111 | fn C.gdk_window_get_composited(&C.GdkWindow) bool 112 | 113 | fn C.gdk_window_set_pass_through(&C.GdkWindow, bool) 114 | 115 | fn C.gdk_window_get_pass_through(&C.GdkWindow) bool 116 | 117 | fn C.gdk_window_move(&C.GdkWindow, int, int) 118 | 119 | fn C.gdk_window_resize(&C.GdkWindow, int, int) 120 | 121 | fn C.gdk_window_move_resize(&C.GdkWindow, int, int, int, int) 122 | 123 | fn C.gdk_window_scroll(&C.GdkWindow, int, int) 124 | 125 | fn C.gdk_window_move_to_rect(&C.GdkWindow, &C.GdkRectangle, int, C.GdkGravity, int, C.GdkGravity, int, C.GdkAnchorHints, int, int) 126 | 127 | // fn C.gdk_window_move_region(&C.GdkWindow, &cairo_region_t, int, int) 128 | fn C.gdk_window_flush(&C.GdkWindow) 129 | 130 | fn C.gdk_window_has_native(&C.GdkWindow) bool 131 | 132 | fn C.gdk_window_ensure_native(&C.GdkWindow) bool 133 | 134 | fn C.gdk_window_reparent(&C.GdkWindow, &C.GdkWindow, int, int) 135 | 136 | fn C.gdk_window_raise(&C.GdkWindow) 137 | 138 | fn C.gdk_window_lower(&C.GdkWindow) 139 | 140 | fn C.gdk_window_restack(&C.GdkWindow, &C.GdkWindow, bool) 141 | 142 | fn C.gdk_window_focus(&C.GdkWindow, u32) 143 | 144 | fn C.gdk_window_register_dnd(&C.GdkWindow) 145 | 146 | fn C.gdk_window_begin_resize_drag(&C.GdkWindow, int, C.GdkWindowEdge, int, int, int, u32) 147 | 148 | fn C.gdk_window_begin_resize_drag_for_device(&C.GdkWindow, int, C.GdkWindowEdge, &C.GdkDevice, int, int, int, u32) 149 | 150 | fn C.gdk_window_begin_move_drag(&C.GdkWindow, int, int, int, u32) 151 | 152 | fn C.gdk_window_begin_move_drag_for_device(&C.GdkWindow, &C.GdkDevice, int, int, int, u32) 153 | 154 | fn C.gdk_window_show_window_menu(&C.GdkWindow, &C.GdkEvent) bool 155 | 156 | fn C.gdk_window_rain_size(&C.GdkGeometry, int, C.GdkWindowHints, int, int, &int, &int) 157 | 158 | fn C.gdk_window_beep(&C.GdkWindow) 159 | 160 | fn C.gdk_window_get_scale_factor(&C.GdkWindow) int 161 | 162 | // fn C.gdk_window_set_opaque_region(&C.GdkWindow, &cairo_region_t) 163 | // fn C.gdk_window_create_gl_context(&C.GdkWindow, &GError) &C.GdkGLContext 164 | // fn C.gdk_window_mark_paint_from_clip(&C.GdkWindow, &cairo_t) 165 | // fn C.gdk_window_get_clip_region(&C.GdkWindow) &cairo_region_t 166 | fn C.gdk_window_begin_paint_rect(&C.GdkWindow, &C.GdkRectangle) 167 | 168 | // fn C.gdk_window_begin_paint_region(&C.GdkWindow, &cairo_region_t) 169 | fn C.gdk_window_end_paint(&C.GdkWindow) 170 | 171 | // fn C.gdk_window_begin_draw_frame(&C.GdkWindow, &cairo_region_t) &C.GdkDrawingContext 172 | fn C.gdk_window_end_draw_frame(&C.GdkWindow, &C.GdkDrawingContext) 173 | 174 | // fn C.gdk_window_get_visible_region(&C.GdkWindow) &cairo_region_t 175 | fn C.gdk_window_set_invalidate_handler(&C.GdkWindow, C.GdkWindowInvalidateHandlerFunc) 176 | 177 | fn C.gdk_window_invalidate_rect(&C.GdkWindow, &C.GdkRectangle, bool) 178 | 179 | // fn C.gdk_window_invalidate_region(&C.GdkWindow, &cairo_region_t, bool) 180 | // fn C.gdk_window_invalidate_maybe_recurse(&C.GdkWindow, &cairo_region_t, C.GdkWindowChildFunc, voidptr) 181 | // fn C.gdk_window_get_update_area(&C.GdkWindow) &cairo_region_t 182 | fn C.gdk_window_freeze_updates(&C.GdkWindow) 183 | 184 | fn C.gdk_window_thaw_updates(&C.GdkWindow) 185 | 186 | fn C.gdk_window_process_all_updates() 187 | 188 | fn C.gdk_window_process_updates(&C.GdkWindow, bool) 189 | 190 | fn C.gdk_window_set_debug_updates(bool) 191 | 192 | fn C.gdk_window_enable_synchronized_configure(&C.GdkWindow) 193 | 194 | fn C.gdk_window_configure_finished(&C.GdkWindow) 195 | 196 | fn C.gdk_window_get_frame_clock(&C.GdkWindow) &C.GdkFrameClock 197 | 198 | fn C.gdk_window_set_user_data(&C.GdkWindow, voidptr) 199 | 200 | fn C.gdk_window_set_override_redirect(&C.GdkWindow, bool) 201 | 202 | fn C.gdk_window_set_accept_focus(&C.GdkWindow, bool) 203 | 204 | fn C.gdk_window_get_accept_focus(&C.GdkWindow) bool 205 | 206 | fn C.gdk_window_set_focus_on_map(&C.GdkWindow, bool) 207 | 208 | fn C.gdk_window_get_focus_on_map(&C.GdkWindow) bool 209 | 210 | fn C.gdk_window_add_filter(&C.GdkWindow, C.GdkFilterFunc, voidptr) 211 | 212 | fn C.gdk_window_remove_filter(&C.GdkWindow, C.GdkFilterFunc, voidptr) 213 | 214 | // fn C.GdkXEvent(*xevent, *event) C.GdkFilterReturn 215 | // fn C.gdk_window_shape_combine_region(&C.GdkWindow, &cairo_region_t, int, int) 216 | fn C.gdk_window_set_child_shapes(&C.GdkWindow) 217 | 218 | fn C.gdk_window_merge_child_shapes(&C.GdkWindow) 219 | 220 | // fn C.gdk_window_input_shape_combine_region(&C.GdkWindow, &cairo_region_t, int, int) 221 | fn C.gdk_window_set_child_input_shapes(&C.GdkWindow) 222 | 223 | fn C.gdk_window_merge_child_input_shapes(&C.GdkWindow) 224 | 225 | fn C.gdk_window_set_static_gravities(&C.GdkWindow, bool) bool 226 | 227 | fn C.gdk_window_set_title(&C.GdkWindow, &charptr) 228 | 229 | fn C.gdk_window_set_background(&C.GdkWindow, &C.GdkColor) 230 | 231 | fn C.gdk_window_set_background_rgba(&C.GdkWindow, &C.GdkRGBA) 232 | 233 | // fn C.gdk_window_set_background_pattern(&C.GdkWindow, &cairo_pattern_t) 234 | // fn C.gdk_window_get_background_pattern(&C.GdkWindow) &cairo_pattern_t 235 | fn C.gdk_window_set_cursor(&C.GdkWindow, &C.GdkCursor) 236 | 237 | fn C.gdk_window_get_cursor(&C.GdkWindow) &C.GdkCursor 238 | 239 | fn C.gdk_window_get_user_data(&C.GdkWindow, &voidptr) 240 | 241 | fn C.gdk_window_get_geometry(&C.GdkWindow, &int, &int, &int, &int) 242 | 243 | fn C.gdk_window_set_geometry_hints(&C.GdkWindow, &C.GdkGeometry, int, C.GdkWindowHints) 244 | 245 | fn C.gdk_window_get_width(&C.GdkWindow) int 246 | 247 | fn C.gdk_window_get_height(&C.GdkWindow) int 248 | 249 | fn C.gdk_window_set_icon_list(&C.GdkWindow, &C.GList) 250 | 251 | fn C.gdk_window_set_modal_hint(&C.GdkWindow, bool) 252 | 253 | fn C.gdk_window_get_modal_hint(&C.GdkWindow) bool 254 | 255 | fn C.gdk_window_set_type_hint(&C.GdkWindow, int, C.GdkWindowTypeHint) 256 | 257 | fn C.gdk_window_get_type_hint(&C.GdkWindow) int 258 | 259 | // C.GdkWindowTypeHint 260 | fn C.gdk_window_set_shadow_width(&C.GdkWindow, int, int, int, int) 261 | 262 | fn C.gdk_window_set_skip_taskbar_hint(&C.GdkWindow, bool) 263 | 264 | fn C.gdk_window_set_skip_pager_hint(&C.GdkWindow, bool) 265 | 266 | fn C.gdk_window_set_urgency_hint(&C.GdkWindow, bool) 267 | 268 | fn C.gdk_window_get_position(&C.GdkWindow, &int, &int) 269 | 270 | fn C.gdk_window_get_root_origin(&C.GdkWindow, &int, &int) 271 | 272 | fn C.gdk_window_get_frame_extents(&C.GdkWindow, &C.GdkRectangle) 273 | 274 | fn C.gdk_window_get_origin(&C.GdkWindow, &int, &int) int 275 | 276 | fn C.gdk_window_get_root_coords(&C.GdkWindow, int, int, &int, &int) 277 | 278 | fn C.gdk_window_get_pointer(&C.GdkWindow, &int, &int, &C.GdkModifierType) &C.GdkWindow 279 | 280 | fn C.gdk_window_get_device_position(&C.GdkWindow, &C.GdkDevice, &int, &int, &C.GdkModifierType) &C.GdkWindow 281 | 282 | fn C.gdk_window_get_device_position_double(&C.GdkWindow, &C.GdkDevice, &f64, &f64, &C.GdkModifierType) &C.GdkWindow 283 | 284 | fn C.gdk_window_get_parent(&C.GdkWindow) &C.GdkWindow 285 | 286 | fn C.gdk_window_get_toplevel(&C.GdkWindow) &C.GdkWindow 287 | 288 | fn C.gdk_window_get_children(&C.GdkWindow) &C.GList 289 | 290 | fn C.gdk_window_get_children_with_user_data(&C.GdkWindow, voidptr) &C.GList 291 | 292 | fn C.gdk_window_peek_children(&C.GdkWindow) &C.GList 293 | 294 | fn C.gdk_window_get_events(&C.GdkWindow) int 295 | 296 | // C.GdkEventMask 297 | fn C.gdk_window_set_events(&C.GdkWindow, int, C.GdkEventMask) 298 | 299 | fn C.gdk_window_set_icon_name(&C.GdkWindow, &charptr) 300 | 301 | fn C.gdk_window_set_transient_for(&C.GdkWindow, &C.GdkWindow) 302 | 303 | fn C.gdk_window_set_role(&C.GdkWindow, &charptr) 304 | 305 | fn C.gdk_window_set_startup_id(&C.GdkWindow, &charptr) 306 | 307 | fn C.gdk_window_set_group(&C.GdkWindow, &C.GdkWindow) 308 | 309 | fn C.gdk_window_get_group(&C.GdkWindow) &C.GdkWindow 310 | 311 | fn C.gdk_window_set_decorations(&C.GdkWindow, int, C.GdkWMDecoration) 312 | 313 | fn C.gdk_window_get_decorations(&C.GdkWindow, &int, C.GdkWMDecoration) bool 314 | 315 | fn C.gdk_window_set_functions(&C.GdkWindow, int, C.GdkWMFunction) 316 | 317 | fn C.gdk_window_get_support_multidevice(&C.GdkWindow) bool 318 | 319 | fn C.gdk_window_set_support_multidevice(&C.GdkWindow, bool) 320 | 321 | fn C.gdk_window_get_device_cursor(&C.GdkWindow, &C.GdkDevice) &C.GdkCursor 322 | 323 | fn C.gdk_window_set_device_cursor(&C.GdkWindow, &C.GdkDevice, &C.GdkCursor) 324 | 325 | fn C.gdk_window_get_device_events(&C.GdkWindow, &C.GdkDevice) int 326 | 327 | // C.GdkEventMask 328 | fn C.gdk_window_set_device_events(&C.GdkWindow, &C.GdkDevice, int, C.GdkEventMask) 329 | 330 | fn C.gdk_window_get_source_events(&C.GdkWindow, int, C.GdkInputSource) int 331 | 332 | // C.GdkEventMask 333 | fn C.gdk_window_set_source_events(&C.GdkWindow, int, C.GdkInputSource, int, C.GdkEventMask) 334 | 335 | fn C.gdk_window_get_event_compression(&C.GdkWindow) bool 336 | 337 | fn C.gdk_window_set_event_compression(&C.GdkWindow, bool) 338 | 339 | fn C.gdk_window_geometry_changed(&C.GdkWindow) 340 | 341 | fn C.gdk_window_coords_from_parent(&C.GdkWindow, f64, f64, &f64, &f64) 342 | 343 | fn C.gdk_window_coords_to_parent(&C.GdkWindow, f64, f64, &f64, &f64) 344 | 345 | fn C.gdk_window_get_effective_parent(&C.GdkWindow) &C.GdkWindow 346 | 347 | fn C.gdk_window_get_effective_toplevel(&C.GdkWindow) &C.GdkWindow 348 | -------------------------------------------------------------------------------- /gdk/device.v: -------------------------------------------------------------------------------- 1 | module gdk 2 | 3 | pub enum InputSource { 4 | source_mouse = C.GDK_SOURCE_MOUSE 5 | source_pen = C.GDK_SOURCE_PEN 6 | source_eraser = C.GDK_SOURCE_ERASER 7 | source_cursor = C.GDK_SOURCE_CURSOR 8 | source_keyboard = C.GDK_SOURCE_KEYBOARD 9 | source_touchscreen = C.GDK_SOURCE_TOUCHSCREEN 10 | source_touchpad = C.GDK_SOURCE_TOUCHPAD 11 | source_trackpoint = C.GDK_SOURCE_TRACKPOINT 12 | source_tablet_pad = C.GDK_SOURCE_TABLET_PAD 13 | } 14 | 15 | pub struct Device { 16 | c &C.GdkDevice 17 | } 18 | 19 | pub fn (d &Device) get_cptr() &C.GdkDevice { 20 | return d.c 21 | } 22 | -------------------------------------------------------------------------------- /gdk/events.v: -------------------------------------------------------------------------------- 1 | module gdk 2 | 3 | pub enum EventMask { 4 | exposure_mask = C.GDK_EXPOSURE_MASK 5 | pointer_motion_mask = C.GDK_POINTER_MOTION_MASK 6 | pointer_motion_hint_mask = C.GDK_POINTER_MOTION_HINT_MASK 7 | button_motion_mask = C.GDK_BUTTON_MOTION_MASK 8 | button1_motion_mask = C.GDK_BUTTON1_MOTION_MASK 9 | button2_motion_mask = C.GDK_BUTTON2_MOTION_MASK 10 | button3_motion_mask = C.GDK_BUTTON3_MOTION_MASK 11 | button_press_mask = C.GDK_BUTTON_PRESS_MASK 12 | button_release_mask = C.GDK_BUTTON_RELEASE_MASK 13 | key_press_mask = C.GDK_KEY_PRESS_MASK 14 | key_release_mask = C.GDK_KEY_RELEASE_MASK 15 | enter_notify_mask = C.GDK_ENTER_NOTIFY_MASK 16 | leave_notify_mask = C.GDK_LEAVE_NOTIFY_MASK 17 | focus_change_mask = C.GDK_FOCUS_CHANGE_MASK 18 | structure_mask = C.GDK_STRUCTURE_MASK 19 | property_change_mask = C.GDK_PROPERTY_CHANGE_MASK 20 | visibility_notify_mask = C.GDK_VISIBILITY_NOTIFY_MASK 21 | proximity_in_mask = C.GDK_PROXIMITY_IN_MASK 22 | proximity_out_mask = C.GDK_PROXIMITY_OUT_MASK 23 | substructure_mask = C.GDK_SUBSTRUCTURE_MASK 24 | scroll_mask = C.GDK_SCROLL_MASK 25 | touch_mask = C.GDK_TOUCH_MASK 26 | smooth_scroll_mask = C.GDK_SMOOTH_SCROLL_MASK 27 | touchpad_gesture_mask = C.GDK_TOUCHPAD_GESTURE_MASK 28 | tablet_pad_mask = C.GDK_TABLET_PAD_MASK 29 | all_events_mask = C.GDK_ALL_EVENTS_MASK 30 | } 31 | 32 | pub enum WMDecoration { 33 | all = C.GDK_DECOR_ALL 34 | border = C.GDK_DECOR_BORDER 35 | resizeh = C.GDK_DECOR_RESIZEH 36 | title = C.GDK_DECOR_TITLE 37 | menu = C.GDK_DECOR_MENU 38 | minimize = C.GDK_DECOR_MINIMIZE 39 | maximize = C.GDK_DECOR_MAXIMIZE 40 | } 41 | 42 | pub enum WMFunction { 43 | all = C.GDK_FUNC_ALL 44 | resize = C.GDK_FUNC_RESIZE 45 | move = C.GDK_FUNC_MOVE 46 | minimize = C.GDK_FUNC_MINIMIZE 47 | maximize = C.GDK_FUNC_MAXIMIZE 48 | close = C.GDK_FUNC_CLOSE 49 | } 50 | -------------------------------------------------------------------------------- /gdk/gdk.v: -------------------------------------------------------------------------------- 1 | module gdk 2 | 3 | #pkgconfig gdk-3.0 4 | #include 5 | -------------------------------------------------------------------------------- /gdk/pixbuf.v: -------------------------------------------------------------------------------- 1 | module gdk 2 | 3 | pub struct Pixbuf { 4 | c &C.GdkPixbuf 5 | } 6 | 7 | pub fn (p Pixbuf) get_cptr() &C.GdkPixbuf { 8 | return p.c 9 | } 10 | -------------------------------------------------------------------------------- /gdk/window.v: -------------------------------------------------------------------------------- 1 | module gdk 2 | 3 | pub enum WindowType { 4 | root = C.GDK_WINDOW_ROOT 5 | toplevel = C.GDK_WINDOW_TOPLEVEL 6 | child = C.GDK_WINDOW_CHILD 7 | temp = C.GDK_WINDOW_TEMP 8 | foreign = C.GDK_WINDOW_FOREIGN 9 | offscreen = C.GDK_WINDOW_OFFSCREEN 10 | subsurface = C.GDK_WINDOW_SUBSURFACE 11 | } 12 | 13 | pub enum Gravity { 14 | north_west = C.GDK_GRAVITY_NORTH_WEST 15 | north = C.GDK_GRAVITY_NORTH 16 | north_east = C.GDK_GRAVITY_NORTH_EAST 17 | west = C.GDK_GRAVITY_WEST 18 | center = C.GDK_GRAVITY_CENTER 19 | east = C.GDK_GRAVITY_EAST 20 | south_west = C.GDK_GRAVITY_SOUTH_WEST 21 | south = C.GDK_GRAVITY_SOUTH 22 | south_east = C.GDK_GRAVITY_SOUTH_EAST 23 | static_ = C.GDK_GRAVITY_STATIC 24 | } 25 | 26 | pub enum WindowState { 27 | withdrawn = C.GDK_WINDOW_STATE_WITHDRAWN 28 | iconified = C.GDK_WINDOW_STATE_ICONIFIED 29 | maximized = C.GDK_WINDOW_STATE_MAXIMIZED 30 | sticky = C.GDK_WINDOW_STATE_STICKY 31 | fullscreen = C.GDK_WINDOW_STATE_FULLSCREEN 32 | above = C.GDK_WINDOW_STATE_ABOVE 33 | below = C.GDK_WINDOW_STATE_BELOW 34 | focused = C.GDK_WINDOW_STATE_FOCUSED 35 | tiled = C.GDK_WINDOW_STATE_TILED 36 | top_tiled = C.GDK_WINDOW_STATE_TOP_TILED 37 | top_resizable = C.GDK_WINDOW_STATE_TOP_RESIZABLE 38 | right_tiled = C.GDK_WINDOW_STATE_RIGHT_TILED 39 | right_resizable = C.GDK_WINDOW_STATE_RIGHT_RESIZABLE 40 | bottom_tiled = C.GDK_WINDOW_STATE_BOTTOM_TILED 41 | bottom_resizable = C.GDK_WINDOW_STATE_BOTTOM_RESIZABLE 42 | left_tiled = C.GDK_WINDOW_STATE_LEFT_TILED 43 | left_resizable = C.GDK_WINDOW_STATE_LEFT_RESIZABLE 44 | } 45 | 46 | pub enum FullScreenMode { 47 | current_monitor = C.GDK_FULLSCREEN_ON_CURRENT_MONITOR 48 | all_monitors = C.GDK_FULLSCREEN_ON_ALL_MONITORS 49 | } 50 | 51 | pub enum AnchorHints { 52 | flip_x = C.GDK_ANCHOR_FLIP_X 53 | flip_y = C.GDK_ANCHOR_FLIP_Y 54 | slide_x = C.GDK_ANCHOR_SLIDE_X 55 | slide_y = C.GDK_ANCHOR_SLIDE_Y 56 | resize_x = C.GDK_ANCHOR_RESIZE_X 57 | resize_y = C.GDK_ANCHOR_RESIZE_Y 58 | flip = C.GDK_ANCHOR_FLIP 59 | slide = C.GDK_ANCHOR_SLIDE 60 | resize = C.GDK_ANCHOR_RESIZE 61 | } 62 | 63 | pub enum WindowEdge { 64 | north_west = C.GDK_WINDOW_EDGE_NORTH_WEST 65 | north = C.GDK_WINDOW_EDGE_NORTH 66 | north_east = C.GDK_WINDOW_EDGE_NORTH_EAST 67 | west = C.GDK_WINDOW_EDGE_WEST 68 | east = C.GDK_WINDOW_EDGE_EAST 69 | south_west = C.GDK_WINDOW_EDGE_SOUTH_WEST 70 | south = C.GDK_WINDOW_EDGE_SOUTH 71 | south_east = C.GDK_WINDOW_EDGE_SOUTH_EAST 72 | } 73 | 74 | pub enum WindowHints { 75 | hint_pos = C.GDK_HINT_POS 76 | hint_min_size = C.GDK_HINT_MIN_SIZE 77 | hint_max_size = C.GDK_HINT_MAX_SIZE 78 | hint_base_size = C.GDK_HINT_BASE_SIZE 79 | hint_aspect = C.GDK_HINT_ASPECT 80 | hint_resize_inc = C.GDK_HINT_RESIZE_INC 81 | hint_win_gravity = C.GDK_HINT_WIN_GRAVITY 82 | hint_user_pos = C.GDK_HINT_USER_POS 83 | hint_user_size = C.GDK_HINT_USER_SIZE 84 | } 85 | 86 | pub enum ModifierType { 87 | shift_mask = C.GDK_SHIFT_MASK 88 | lock_mask = C.GDK_LOCK_MASK 89 | control_mask = C.GDK_CONTROL_MASK 90 | mod1_mask = C.GDK_MOD1_MASK 91 | mod2_mask = C.GDK_MOD2_MASK 92 | mod3_mask = C.GDK_MOD3_MASK 93 | mod4_mask = C.GDK_MOD4_MASK 94 | mod5_mask = C.GDK_MOD5_MASK 95 | button1_mask = C.GDK_BUTTON1_MASK 96 | button2_mask = C.GDK_BUTTON2_MASK 97 | button3_mask = C.GDK_BUTTON3_MASK 98 | button4_mask = C.GDK_BUTTON4_MASK 99 | button5_mask = C.GDK_BUTTON5_MASK 100 | modifier_reserved_13_mask = C.GDK_MODIFIER_RESERVED_13_MASK 101 | modifier_reserved_14_mask = C.GDK_MODIFIER_RESERVED_14_MASK 102 | modifier_reserved_15_mask = C.GDK_MODIFIER_RESERVED_15_MASK 103 | modifier_reserved_16_mask = C.GDK_MODIFIER_RESERVED_16_MASK 104 | modifier_reserved_17_mask = C.GDK_MODIFIER_RESERVED_17_MASK 105 | modifier_reserved_18_mask = C.GDK_MODIFIER_RESERVED_18_MASK 106 | modifier_reserved_19_mask = C.GDK_MODIFIER_RESERVED_19_MASK 107 | modifier_reserved_20_mask = C.GDK_MODIFIER_RESERVED_20_MASK 108 | modifier_reserved_21_mask = C.GDK_MODIFIER_RESERVED_21_MASK 109 | modifier_reserved_22_mask = C.GDK_MODIFIER_RESERVED_22_MASK 110 | modifier_reserved_23_mask = C.GDK_MODIFIER_RESERVED_23_MASK 111 | modifier_reserved_24_mask = C.GDK_MODIFIER_RESERVED_24_MASK 112 | modifier_reserved_25_mask = C.GDK_MODIFIER_RESERVED_25_MASK 113 | } 114 | 115 | pub enum ModifierIntent { 116 | primary_accelerator = C.GDK_MODIFIER_INTENT_PRIMARY_ACCELERATOR 117 | context_menu = C.GDK_MODIFIER_INTENT_CONTEXT_MENU 118 | extend_selection = C.GDK_MODIFIER_INTENT_EXTEND_SELECTION 119 | modify_selection = C.GDK_MODIFIER_INTENT_MODIFY_SELECTION 120 | no_text_input = C.GDK_MODIFIER_INTENT_NO_TEXT_INPUT 121 | shift_group = C.GDK_MODIFIER_INTENT_SHIFT_GROUP 122 | default_mod_mask = C.GDK_MODIFIER_INTENT_DEFAULT_MOD_MASK 123 | } 124 | 125 | pub struct Window { 126 | c &C.GdkWindow 127 | } 128 | 129 | pub fn (w Window) get_cptr() &C.GdkWindow { 130 | return w.c 131 | } 132 | -------------------------------------------------------------------------------- /gio/_cdefs.v: -------------------------------------------------------------------------------- 1 | module gio 2 | 3 | pub struct C.GActionGroup {} 4 | -------------------------------------------------------------------------------- /gio/action_group.v: -------------------------------------------------------------------------------- 1 | module gio 2 | 3 | pub struct ActionGroup { 4 | c &C.GActionGroup 5 | } 6 | 7 | pub fn (a &ActionGroup) get_cptr() &C.GActionGroup { 8 | return a.c 9 | } 10 | -------------------------------------------------------------------------------- /gio/gapplication.v: -------------------------------------------------------------------------------- 1 | module gio 2 | 3 | pub enum GApplicationFlags { 4 | flags_none = C.G_APPLICATION_FLAGS_NONE 5 | is_service = C.G_APPLICATION_IS_SERVICE 6 | is_launcher = C.G_APPLICATION_IS_LAUNCHER 7 | handles_open = C.G_APPLICATION_HANDLES_OPEN 8 | handles_command_line = C.G_APPLICATION_HANDLES_COMMAND_LINE 9 | send_environment = C.G_APPLICATION_SEND_ENVIRONMENT 10 | non_unique = C.G_APPLICATION_NON_UNIQUE 11 | can_override_app_id = C.G_APPLICATION_CAN_OVERRIDE_APP_ID 12 | allow_replacement = C.G_APPLICATION_ALLOW_REPLACEMENT 13 | replace = C.G_APPLICATION_REPLACE 14 | } 15 | -------------------------------------------------------------------------------- /gio/gio.v: -------------------------------------------------------------------------------- 1 | module gio 2 | 3 | #pkgconfig gio-2.0 4 | -------------------------------------------------------------------------------- /glib/_cdefs.v: -------------------------------------------------------------------------------- 1 | module glib 2 | 3 | #include 4 | #include 5 | [typedef] 6 | pub struct C.GList { 7 | data voidptr 8 | next &C.GList 9 | prev &C.GList 10 | } 11 | 12 | [typedef] 13 | pub struct C.GSList { 14 | data voidptr 15 | next &C.GSList 16 | prev &C.GSList 17 | } 18 | 19 | pub struct C.GArray { 20 | data charptr 21 | len u32 22 | } 23 | 24 | [typedef] 25 | pub struct C.GString { 26 | str charptr 27 | len int 28 | } 29 | 30 | pub struct C.GBytes {} 31 | 32 | pub struct C._GError { 33 | pub: 34 | message charptr 35 | } 36 | 37 | pub struct C._GType {} 38 | 39 | pub struct C._GValue {} 40 | 41 | pub struct C._GParamSpec {} 42 | 43 | pub struct C._GObjectClass {} 44 | 45 | pub struct C._GObject {} 46 | 47 | pub struct C._GMarkupParser {} 48 | 49 | pub struct C.GMenuModel {} 50 | 51 | pub struct C.GMenu {} 52 | 53 | pub struct C.GVariant {} 54 | 55 | pub struct C.GScanner {} 56 | 57 | // Arrays 58 | fn C.g_array_new(bool, bool, u32) &C.GArray 59 | 60 | fn C.g_array_sized_new(bool, bool, u32, u32) &C.GArray 61 | 62 | fn C.g_array_copy(&C.GArray) &C.GArray 63 | 64 | fn C.g_array_ref(&C.GArray) &C.GArray 65 | 66 | fn C.g_array_unref(&C.GArray) 67 | 68 | fn C.g_array_get_element_size(&C.GArray) u32 69 | 70 | fn C.g_array_append_val(&C.GArray, voidptr) &C.GArray 71 | 72 | fn C.g_array_append_vals(&C.GArray, voidptr, u32) &C.GArray 73 | 74 | fn C.g_array_prepend_val(&C.GArray, voidptr) &C.GArray 75 | 76 | fn C.g_array_prepend_vals(&C.GArray, voidptr, u32) &C.GArray 77 | 78 | fn C.g_array_insert_val(&C.GArray, u32, voidptr) &C.GArray 79 | 80 | fn C.g_array_insert_vals(&C.GArray, u32, voidptr, u32) &C.GArray 81 | 82 | fn C.g_array_remove_index(&C.GArray, u32) &C.GArray 83 | 84 | fn C.g_array_remove_index_fast(&C.GArray, u32) &C.GArray 85 | 86 | fn C.g_array_remove_range(&C.GArray, u32, u32) &C.GArray 87 | 88 | fn C.g_array_sort(&C.GArray, int) 89 | 90 | fn C.g_array_sort_with_data(&C.GArray, int, voidptr) 91 | 92 | fn C.g_array_binary_search(&C.GArray, voidptr, int, &u32) bool 93 | 94 | fn C.g_array_index(&C.GArray, voidptr, u32) voidptr 95 | 96 | fn C.g_array_set_size(&C.GArray, u32) &C.GArray 97 | 98 | fn C.g_array_set_clear_func(&C.GArray, voidptr) 99 | 100 | fn C.g_array_free(&C.GArray, bool) &charptr 101 | 102 | // Strings 103 | fn C.g_string_new(charptr) &C.GString 104 | 105 | fn C.g_string_new_len(charptr, int) &C.GString 106 | 107 | fn C.g_string_sized_new(int) &C.GString 108 | 109 | fn C.g_string_assign(&C.GString, charptr) &C.GString 110 | 111 | fn C.g_string_vprintf(&C.GString, charptr, va_list) 112 | 113 | fn C.g_string_append_vprintf(&C.GString, charptr, va_list) 114 | 115 | fn C.g_string_printf(&C.GString, charptr) 116 | 117 | fn C.g_string_append_printf(&C.GString, charptr) 118 | 119 | fn C.g_string_append(&C.GString, charptr) &C.GString 120 | 121 | fn C.g_string_append_c(&C.GString, charptr) &C.GString 122 | 123 | fn C.g_string_append_unichar(&C.GString, rune) &C.GString 124 | 125 | fn C.g_string_append_len(&C.GString, charptr, int) &C.GString 126 | 127 | fn C.g_string_append_uri_escaped(&C.GString, charptr, charptr, bool) &C.GString 128 | 129 | fn C.g_string_prepend(&C.GString, charptr) &C.GString 130 | 131 | fn C.g_string_prepend_c(&C.GString, charptr) &C.GString 132 | 133 | fn C.g_string_prepend_unichar(&C.GString, rune) &C.GString 134 | 135 | fn C.g_string_prepend_len(&C.GString, charptr, int) &C.GString 136 | 137 | fn C.g_string_insert(&C.GString, int, charptr) &C.GString 138 | 139 | fn C.g_string_insert_c(&C.GString, int, charptr) &C.GString 140 | 141 | fn C.g_string_insert_unichar(&C.GString, int, rune) &C.GString 142 | 143 | fn C.g_string_insert_len(&C.GString, int, charptr, int) &C.GString 144 | 145 | fn C.g_string_overwrite(&C.GString, int, charptr) &C.GString 146 | 147 | fn C.g_string_overwrite_len(&C.GString, int, charptr, int) &C.GString 148 | 149 | fn C.g_string_erase(&C.GString, int, int) &C.GString 150 | 151 | fn C.g_string_truncate(&C.GString, int) &C.GString 152 | 153 | fn C.g_string_set_size(&C.GString, int) &C.GString 154 | 155 | fn C.g_string_free(&C.GString, bool) charptr 156 | 157 | fn C.g_string_free_to_bytes(&C.GString) &GBytes 158 | 159 | fn C.g_string_up(&C.GString) &C.GString 160 | 161 | fn C.g_string_down(&C.GString) &C.GString 162 | 163 | fn C.g_string_hash(&C.GString) u32 164 | 165 | fn C.g_string_equal(&C.GString, &C.GString) bool 166 | 167 | // C.GSList 168 | fn C.g_slist_alloc() &C.GSList 169 | 170 | fn C.g_slist_append(&C.GSList, voidptr) &C.GSList 171 | 172 | fn C.g_slist_prepend(&C.GSList, voidptr) &C.GSList 173 | 174 | fn C.g_slist_insert(&C.GSList, voidptr, int) &C.GSList 175 | 176 | fn C.g_slist_insert_before(&C.GSList, &C.GSList, voidptr) &C.GSList 177 | 178 | fn C.g_slist_insert_sorted(&C.GSList, voidptr, int) &C.GSList 179 | 180 | fn C.g_slist_remove(&C.GSList, voidptr) &C.GSList 181 | 182 | fn C.g_slist_remove_link(&C.GSList, &C.GSList) &C.GSList 183 | 184 | fn C.g_slist_delete_link(&C.GSList, &C.GSList) &C.GSList 185 | 186 | fn C.g_slist_remove_all(&C.GSList, voidptr) &C.GSList 187 | 188 | fn C.g_slist_free(&C.GSList) 189 | 190 | fn C.g_slist_free_full(&C.GSList, voidptr) 191 | 192 | fn C.g_slist_free_1(&C.GSList) 193 | 194 | fn C.g_slist_length(&C.GSList) u32 195 | 196 | fn C.g_slist_copy(&C.GSList) &C.GSList 197 | 198 | fn C.g_slist_copy_deep(&C.GSList, int, voidptr) &C.GSList 199 | 200 | fn C.g_slist_reverse(&C.GSList) &C.GSList 201 | 202 | fn C.g_slist_insert_sorted_with_data(&C.GSList, voidptr, int, voidptr) &C.GSList 203 | 204 | fn C.g_slist_sort(&C.GSList, int) &C.GSList 205 | 206 | fn C.g_slist_sort_with_data(&C.GSList, int, voidptr) &C.GSList 207 | 208 | fn C.g_slist_concat(&C.GSList, &C.GSList) &C.GSList 209 | 210 | fn C.g_slist_foreach(&C.GSList, int, voidptr) 211 | 212 | fn C.g_slist_last(&C.GSList) &C.GSList 213 | 214 | fn C.g_slist_next(&C.GSList) &C.GSList 215 | 216 | fn C.g_slist_nth(&C.GSList, u32) &C.GSList 217 | 218 | fn C.g_slist_nth_data(&C.GSList, u32) voidptr 219 | 220 | fn C.g_slist_find(&C.GSList, voidptr) &C.GSList 221 | 222 | fn C.g_slist_find_custom(&C.GSList, voidptr, int) &C.GSList 223 | 224 | fn C.g_slist_position(&C.GSList, &C.GSList) int 225 | 226 | fn C.g_slist_index(&C.GSList, voidptr) int 227 | 228 | // GList 229 | fn C.g_list_append(&C.GList, voidptr) &C.GList 230 | 231 | fn C.g_list_prepend(&C.GList, voidptr) &C.GList 232 | 233 | fn C.g_list_insert(&C.GList, voidptr, int) &C.GList 234 | 235 | fn C.g_list_insert_before(&C.GList, &C.GList, voidptr) &C.GList 236 | 237 | fn C.g_list_insert_before_link(&C.GList, C.GList, C.GList) &C.GList 238 | 239 | fn C.g_list_insert_sorted(&C.GList, voidptr, int) &C.GList 240 | 241 | fn C.g_list_remove(&C.GList, voidptr) &C.GList 242 | 243 | fn C.g_list_remove_link(&C.GList, &C.GList) &C.GList 244 | 245 | fn C.g_list_delete_link(&C.GList, &C.GList) &C.GList 246 | 247 | fn C.g_list_remove_all(&C.GList, voidptr) &C.GList 248 | 249 | fn C.g_list_free(&C.GList) 250 | 251 | fn C.g_list_free_full(&C.GList, voidptr) 252 | 253 | fn C.g_list_alloc() &C.GList 254 | 255 | fn C.g_list_free_1(&C.GList) 256 | 257 | fn C.g_list_length(&C.GList) u32 258 | 259 | fn C.g_list_copy(&C.GList) &C.GList 260 | 261 | fn C.g_list_copy_deep(&C.GList, int, voidptr) &C.GList 262 | 263 | fn C.g_list_reverse(&C.GList) &C.GList 264 | 265 | fn C.g_list_sort(&C.GList, int) &C.GList 266 | 267 | fn C.g_list_insert_sorted_with_data(&C.GList, voidptr, int, voidptr) &C.GList 268 | 269 | fn C.g_list_sort_with_data(&C.GList, int, voidptr) &C.GList 270 | 271 | fn C.g_list_concat(&C.GList, &C.GList) &C.GList 272 | 273 | fn C.g_list_foreach(&C.GList, voidptr, voidptr) 274 | 275 | fn C.g_list_first(&C.GList) &C.GList 276 | 277 | fn C.g_list_last(&C.GList) &C.GList 278 | 279 | fn C.g_list_previous(&C.GList) &C.GList 280 | 281 | fn C.g_list_next(&C.GList) &C.GList 282 | 283 | fn C.g_list_nth(&C.GList, u32) &C.GList 284 | 285 | fn C.g_list_nth_data(&C.GList, u32) voidptr 286 | 287 | fn C.g_list_nth_prev(&C.GList, u32) &C.GList 288 | 289 | fn C.g_list_find(&C.GList, voidptr) &C.GList 290 | 291 | fn C.g_list_find_custom(&C.GList, voidptr, int) &C.GList 292 | 293 | fn C.g_list_position(&C.GList, &C.GList) int 294 | 295 | fn C.g_list_index(&C.GList, voidptr) int 296 | 297 | fn C.g_list_free1(&C.GList) 298 | 299 | fn C.g_timeout_add(u32, voidptr, voidptr) u32 300 | 301 | fn C.g_source_remove(u32) bool 302 | -------------------------------------------------------------------------------- /glib/array.v: -------------------------------------------------------------------------------- 1 | module glib 2 | 3 | pub struct Array { 4 | c &C.GArray 5 | } 6 | 7 | pub fn new_array(zero_terminated bool, clear_ bool, element_size u32) Array { 8 | return Array{C.g_array_new(zero_terminated, clear_, element_size)} 9 | } 10 | 11 | pub fn new_sized_array(zero_terminated bool, clear_ bool, element_size u32, reserved_size u32) Array { 12 | return Array{C.g_array_sized_new(zero_terminated, clear_, element_size, reserved_size)} 13 | } 14 | 15 | // TODO: GArray * C.g_array_copy (GArray *array) 16 | pub fn (a Array) ref() Array { 17 | return Array{C.g_array_ref(a.c)} 18 | } 19 | 20 | pub fn (a Array) unref() { 21 | C.g_array_unref(a.c) 22 | } 23 | 24 | pub fn (a Array) get_element_size() u32 { 25 | return C.g_array_get_element_size(a.c) 26 | } 27 | 28 | pub fn (a Array) append_val(val voidptr) Array { 29 | cptr := C.g_array_append_val(a.c, val) 30 | return Array{cptr} 31 | } 32 | 33 | pub fn (a Array) append_vals(data voidptr, len u32) Array { 34 | cptr := C.g_array_append_vals(a.c, data, len) 35 | return Array{cptr} 36 | } 37 | 38 | pub fn (a Array) prepend_val(val voidptr) Array { 39 | cptr := C.g_array_prepend_val(a.c, val) 40 | return Array{cptr} 41 | } 42 | 43 | pub fn (a Array) prepend_vals(data voidptr, len u32) Array { 44 | cptr := C.g_array_prepend_vals(a.c, data, len) 45 | return Array{cptr} 46 | } 47 | 48 | pub fn (a Array) insert_val(i u32, val voidptr) Array { 49 | cptr := C.g_array_insert_val(a.c, i, val) 50 | return Array{cptr} 51 | } 52 | 53 | pub fn (a Array) insert_vals(i u32, data voidptr, len u32) Array { 54 | cptr := C.g_array_insert_vals(a.c, i, data, len) 55 | return Array{cptr} 56 | } 57 | 58 | pub fn (a Array) remove_index(index u32) Array { 59 | cptr := C.g_array_remove_index(a.c, index) 60 | return Array{cptr} 61 | } 62 | 63 | pub fn (a Array) remove_index_fast(index u32) Array { 64 | cptr := C.g_array_remove_index_fast(a.c, index) 65 | return Array{cptr} 66 | } 67 | 68 | pub fn (a Array) remove_range(index u32, len u32) Array { 69 | cptr := C.g_array_remove_range(a.c, index, len) 70 | return Array{cptr} 71 | } 72 | 73 | pub fn (a Array) sort(compare_fn CompareFunc) { 74 | C.g_array_sort(a.c, compare_fn) 75 | } 76 | 77 | pub fn (a Array) sort_with_data(compare_fn CompareDataFunc, user_data voidptr) { 78 | C.g_array_sort_with_data(a.c, compare_fn, user_data) 79 | } 80 | 81 | // TODO: 82 | // pub fn (a Array) binary_search(target voidptr, compare_fn CompareFunc, out_match_index &u32) bool { 83 | // return C.g_array_binary_search(a.c, target, compare_fn, out_match_index) 84 | // } 85 | pub fn (a Array) set_size(len u32) Array { 86 | cptr := C.g_array_set_size(a.c, len) 87 | return Array{cptr} 88 | } 89 | 90 | pub fn (a Array) set_clear_func(clear_fn DestroyNotify) { 91 | C.g_array_set_clear_func(a.c, clear_fn) 92 | } 93 | 94 | pub fn (a Array) free(free_segment bool) { 95 | C.g_array_free(a.c, free_segment) 96 | } 97 | -------------------------------------------------------------------------------- /glib/datasets.v: -------------------------------------------------------------------------------- 1 | module glib 2 | 3 | pub type DestroyNotify = fn (voidptr) voidptr 4 | -------------------------------------------------------------------------------- /glib/glib.v: -------------------------------------------------------------------------------- 1 | module glib 2 | 3 | pub fn timeout_add(interval u32, function fn (voidptr) bool, data voidptr) u32 { 4 | return C.g_timeout_add(interval, function, data) 5 | } 6 | 7 | pub fn source_remove(tag u32) bool { 8 | return C.g_source_remove(tag) 9 | } 10 | -------------------------------------------------------------------------------- /glib/glib_nix.v: -------------------------------------------------------------------------------- 1 | module glib 2 | 3 | #pkgconfig glib-2.0 4 | -------------------------------------------------------------------------------- /glib/list.v: -------------------------------------------------------------------------------- 1 | module glib 2 | 3 | #include 4 | pub type Func = fn (voidptr, voidptr) 5 | 6 | pub struct List { 7 | c &C.GList 8 | } 9 | 10 | pub fn new_list() List { 11 | l := &C.GList{0, 0, 0} 12 | return List{l} 13 | } 14 | 15 | pub fn list_alloc() List { 16 | return List{C.g_list_alloc()} 17 | } 18 | 19 | pub fn (l List) append(data voidptr) List { 20 | return List{C.g_list_append(l.c, data)} 21 | } 22 | 23 | pub fn (l List) prepend(data voidptr) List { 24 | return List{C.g_list_prepend(l.c, data)} 25 | } 26 | 27 | pub fn (l List) insert(data voidptr, pos int) List { 28 | return List{C.g_list_insert(l.c, data, pos)} 29 | } 30 | 31 | pub fn (l List) insert_before(sibling List, data voidptr) List { 32 | return List{C.g_list_insert(l.c, sibling.c, data)} 33 | } 34 | 35 | // pub fn (l List) insert_before_link(sibling List, link List) List { 36 | // cptr := g_list_insert_before_link(l.c, sibling.c, link.c) 37 | // return List{cptr} 38 | // } 39 | // pub fn (l List) insert_sorted(data voidptr, func CompareFunc) List { 40 | // return List{g_list_insert_before_link(l.c, data, func)} 41 | // } 42 | pub fn (l List) remove(data voidptr) List { 43 | return List{C.g_list_remove(l.c, data)} 44 | } 45 | 46 | pub fn (l List) remove_link(llink List) List { 47 | return List{C.g_list_remove_link(l.c, llink.c)} 48 | } 49 | 50 | pub fn (l List) delete_link(link List) List { 51 | return List{C.g_list_delete_link(l.c, link.c)} 52 | } 53 | 54 | pub fn (l List) remove_all(data voidptr) List { 55 | return List{C.g_list_remove_all(l.c, data)} 56 | } 57 | 58 | pub fn (l List) free() { 59 | C.g_list_free(l.c) 60 | } 61 | 62 | pub fn (l List) free_full(free_func DestroyNotify) { 63 | C.g_list_free_full(l.c, free_func) 64 | } 65 | 66 | pub fn (l List) free_1() { 67 | C.g_list_free_1(l.c) 68 | } 69 | 70 | pub fn (l List) length() u32 { 71 | return C.g_list_length(l.c) 72 | } 73 | 74 | pub fn (l List) copy() List { 75 | return List{C.g_list_copy(l.c)} 76 | } 77 | 78 | pub fn (l List) copy_deep(func CopyFunc, user_data voidptr) List { 79 | return List{C.g_list_copy_deep(l.c, func, user_data)} 80 | } 81 | 82 | pub fn (l List) reverse() List { 83 | return List{C.g_list_reverse(l.c)} 84 | } 85 | 86 | pub fn (l List) sort(compare_func fn (voidptr, voidptr) int) List { 87 | return List{C.g_list_sort(l.c, compare_func)} 88 | } 89 | 90 | pub fn (l List) insert_sorted_with_data(data voidptr, func CompareFunc, user_data voidptr) List { 91 | return List{C.g_list_insert_sorted_with_data(l.c, data, func, user_data)} 92 | } 93 | 94 | pub fn (l List) sort_with_data(compare_func CompareDataFunc, user_data voidptr) List { 95 | return List{C.g_list_sort_with_data(l.c, compare_func, user_data)} 96 | } 97 | 98 | pub fn (l List) concat(list2 List) List { 99 | return List{C.g_list_concat(l.c, list2.c)} 100 | } 101 | 102 | pub fn (l List) foreach(func Func, user_data voidptr) { 103 | C.g_list_foreach(l.c, func, user_data) 104 | } 105 | 106 | pub fn (l List) first() List { 107 | return List{C.g_list_first(l.c)} 108 | } 109 | 110 | pub fn (l List) last() List { 111 | return List{C.g_list_last(l.c)} 112 | } 113 | 114 | pub fn (l List) previous() List { 115 | return List{C.g_list_previous(l.c)} 116 | } 117 | 118 | pub fn (l List) next() List { 119 | return List{C.g_list_next(l.c)} 120 | } 121 | 122 | pub fn (l List) nth(n u32) List { 123 | return List{C.g_list_nth(l.c, n)} 124 | } 125 | 126 | pub fn (l List) nth_data(n u32) voidptr { 127 | return C.g_list_nth_data(l.c, n) 128 | } 129 | 130 | pub fn (l List) nth_prev(n u32) List { 131 | return List{C.g_list_nth_prev(l.c, n)} 132 | } 133 | 134 | pub fn (l List) find(data voidptr) List { 135 | return List{C.g_list_find(l.c, data)} 136 | } 137 | 138 | pub fn (l List) find_custom(data voidptr, func CompareFunc) List { 139 | return List{C.g_list_find_custom(l.c, data, func)} 140 | } 141 | 142 | pub fn (l List) position(llink List) int { 143 | return C.g_list_position(l.c, llink.c) 144 | } 145 | 146 | pub fn (l List) index(data voidptr) int { 147 | return C.g_list_index(l.c, data) 148 | } 149 | 150 | pub fn (l List) free1() { 151 | C.g_list_free1(l.c) 152 | } 153 | 154 | pub fn (l List) data() voidptr { 155 | return l.c.data 156 | } 157 | 158 | pub fn (l &List) get_cptr() &C.GList { 159 | return l.c 160 | } 161 | -------------------------------------------------------------------------------- /glib/node.v: -------------------------------------------------------------------------------- 1 | module glib 2 | 3 | pub type CopyFunc = fn (src voidptr, data voidptr) voidptr 4 | -------------------------------------------------------------------------------- /glib/slist.v: -------------------------------------------------------------------------------- 1 | module glib 2 | 3 | pub type CompareFunc = fn (voidptr, voidptr) int 4 | 5 | pub type CompareDataFunc = fn (voidptr, voidptr, voidptr) int 6 | 7 | pub struct SList { 8 | c &C.GSList 9 | } 10 | 11 | pub fn new_slist() SList { 12 | return SList{&C.GSList(0)} 13 | } 14 | 15 | pub fn slist_alloc() SList { 16 | return SList{C.g_slist_alloc()} 17 | } 18 | 19 | pub fn (s SList) append(data voidptr) SList { 20 | return SList{C.g_slist_append(s.c, data)} 21 | } 22 | 23 | pub fn (s SList) prepend(data voidptr) SList { 24 | return SList{C.g_slist_prepend(s.c, data)} 25 | } 26 | 27 | pub fn (s SList) insert(data voidptr, position int) SList { 28 | return SList{C.g_slist_insert(s.c, data, position)} 29 | } 30 | 31 | pub fn (s SList) insert_before(sibling SList, data voidptr) SList { 32 | return SList{C.g_slist_insert_before(s.c, sibling.c, data)} 33 | } 34 | 35 | pub fn (s SList) insert_sorted(data voidptr, compare_fn CompareFunc) SList { 36 | return SList{C.g_slist_insert_sorted(s.c, data, compare_fn)} 37 | } 38 | 39 | pub fn (s SList) remove(data voidptr) SList { 40 | return SList{C.g_slist_remove(s.c, data)} 41 | } 42 | 43 | pub fn (s SList) remove_link(link SList) SList { 44 | return SList{C.g_slist_remove_link(s.c, link.c)} 45 | } 46 | 47 | pub fn (s SList) delete_link(link SList) SList { 48 | return SList{C.g_slist_delete_link(s.c, link.c)} 49 | } 50 | 51 | pub fn (s SList) remove_all(data voidptr) SList { 52 | return SList{C.g_slist_remove_all(s.c, data)} 53 | } 54 | 55 | pub fn (s SList) free() { 56 | C.g_slist_free(s.c) 57 | } 58 | 59 | pub fn (s SList) free_full(free_fn DestroyNotify) { 60 | C.g_slist_free_full(s.c, free_fn) 61 | } 62 | 63 | pub fn (s SList) free1() { 64 | C.g_slist_free_1(s.c) 65 | } 66 | 67 | pub fn (s SList) length() u32 { 68 | return C.g_slist_length(s.c) 69 | } 70 | 71 | pub fn (s SList) copy() SList { 72 | return SList{C.g_slist_copy(s.c)} 73 | } 74 | 75 | pub fn (s SList) copy_deep(func CopyFunc, user_data voidptr) SList { 76 | return SList{C.g_slist_copy_deep(s.c, func, user_data)} 77 | } 78 | 79 | pub fn (s SList) reverse() SList { 80 | return SList{C.g_slist_reverse(s.c)} 81 | } 82 | 83 | pub fn (s SList) insert_sorted_with_data(data voidptr, func CompareDataFunc, user_data voidptr) SList { 84 | return SList{C.g_slist_insert_sorted_with_data(s.c, data, func, user_data)} 85 | } 86 | 87 | pub fn (s SList) sort(compare_fn CompareFunc) SList { 88 | return SList{C.g_slist_sort(s.c, compare_fn)} 89 | } 90 | 91 | pub fn (s SList) sort_with_data(compare_fn CompareDataFunc, user_data voidptr) SList { 92 | return SList{C.g_slist_sort_with_data(s.c, compare_fn, user_data)} 93 | } 94 | 95 | pub fn (s SList) concat(list2 SList) SList { 96 | return SList{C.g_slist_concat(s.c, list2.c)} 97 | } 98 | 99 | pub fn (s SList) foreach(func Func, user_data voidptr) { 100 | C.g_slist_foreach(s.c, func, user_data) 101 | } 102 | 103 | pub fn (s SList) last() SList { 104 | return SList{C.g_slist_last(s.c)} 105 | } 106 | 107 | pub fn (s SList) next() SList { 108 | return SList{C.g_slist_next(s.c)} 109 | } 110 | 111 | pub fn (s SList) nth(n u32) SList { 112 | return SList{C.g_slist_nth(s.c, n)} 113 | } 114 | 115 | pub fn (s SList) nth_data(n u32) voidptr { 116 | return C.g_slist_nth_data(s.c, n) 117 | } 118 | 119 | pub fn (s SList) find(data voidptr) SList { 120 | return SList{C.g_slist_find(s.c, data)} 121 | } 122 | 123 | pub fn (s SList) find_custom(data voidptr, func CompareFunc) SList { 124 | return SList{C.g_slist_find_custom(s.c, data, func)} 125 | } 126 | 127 | pub fn (s SList) position(llink SList) int { 128 | return C.g_slist_position(s.c, llink.c) 129 | } 130 | 131 | pub fn (s SList) index(data voidptr) int { 132 | return C.g_slist_index(s.c, data) 133 | } 134 | 135 | pub fn (s SList) data() voidptr { 136 | return s.c.data 137 | } 138 | 139 | pub fn (s SList) get_cptr() &C.GSList { 140 | return s.c 141 | } 142 | -------------------------------------------------------------------------------- /glib/string.v: -------------------------------------------------------------------------------- 1 | module glib 2 | 3 | pub type VAList = voidptr 4 | 5 | pub struct String { 6 | c &C.GString 7 | } 8 | 9 | pub fn new_string(str string) String { 10 | return String{C.g_string_new(str.str)} 11 | } 12 | 13 | pub fn new_string_len(init string, len i64) String { 14 | return String{C.g_string_new_len(init.str, len)} 15 | } 16 | 17 | pub fn (s String) new_sized_string(dfl_size i64) String { 18 | return String{C.g_string_sized_new(dfl_size)} 19 | } 20 | 21 | pub fn (s String) assign(rval string) String { 22 | cptr := C.g_string_assign(s.c, rval.str) 23 | return String{cptr} 24 | } 25 | 26 | pub fn (s String) vprintf(format string, args VAList) { 27 | C.g_string_vprintf(s.c, format.str, args) 28 | } 29 | 30 | pub fn (s String) append_vprintf(format string, args VAList) { 31 | C.g_string_append_vprintf(s.c, format.str, args) 32 | } 33 | 34 | // TODO: Fix this after V suppor variadic with multiple types 35 | pub fn (s String) printf(format string, params voidptr) { 36 | C.g_string_printf(s.c, format.str, params) 37 | } 38 | 39 | pub fn (s String) append_printf(format string, params voidptr) { 40 | C.g_string_append_printf(s.c, format.str, params) 41 | } 42 | 43 | pub fn (s String) append(val string) String { 44 | cptr := C.g_string_append(s.c, val.str) 45 | return String{cptr} 46 | } 47 | 48 | pub fn (s String) append_c(val byte) String { 49 | cptr := C.g_string_append_c(s.c, val) 50 | return String{cptr} 51 | } 52 | 53 | pub fn (s String) append_unichar(wc rune) String { 54 | cptr := C.g_string_append_unichar(s.c, wc) 55 | return String{cptr} 56 | } 57 | 58 | pub fn (s String) append_len(val string, len i64) String { 59 | cptr := C.g_string_append_len(s.c, val.str, len) 60 | return String{cptr} 61 | } 62 | 63 | pub fn (s String) append_uri_escaped(unescaped string, reserved_chars_allowed string) String { 64 | cptr := C.g_string_append_uri_escaped(s.c, unescaped.str, reserved_chars_allowed.str, 65 | true) 66 | return String{cptr} 67 | } 68 | 69 | pub fn (s String) prepend(val string) String { 70 | cptr := C.g_string_prepend(s.c, val.str) 71 | return String{cptr} 72 | } 73 | 74 | pub fn (s String) prepend_c(val byte) String { 75 | cptr := C.g_string_prepend_c(s.c, val) 76 | return String{cptr} 77 | } 78 | 79 | pub fn (s String) prepend_unichar(wc rune) String { 80 | cptr := C.g_string_prepend_unichar(s.c, wc) 81 | return String{cptr} 82 | } 83 | 84 | pub fn (s String) prepend_len(val string, len i64) String { 85 | cptr := C.g_string_prepend_len(s.c, val.str, len) 86 | return String{cptr} 87 | } 88 | 89 | pub fn (s String) insert(pos i64, val string) String { 90 | cptr := C.g_string_insert(s.c, pos, val.str) 91 | return String{cptr} 92 | } 93 | 94 | pub fn (s String) insert_c(pos i64, c byte) String { 95 | cptr := C.g_string_insert_c(s.c, pos, c) 96 | return String{cptr} 97 | } 98 | 99 | pub fn (s String) insert_unichar(pos i64, wc rune) String { 100 | cptr := C.g_string_insert_unichar(s.c, pos, wc) 101 | return String{cptr} 102 | } 103 | 104 | pub fn (s String) insert_len(pos i64, val string, len i64) String { 105 | cptr := C.g_string_insert_len(s.c, pos, val.str, len) 106 | return String{cptr} 107 | } 108 | 109 | pub fn (s String) overwrite(pos i64, val string) String { 110 | cptr := C.g_string_overwrite(s.c, pos, val.str) 111 | return String{cptr} 112 | } 113 | 114 | pub fn (s String) overwrite_len(pos i64, val string, len i64) String { 115 | cptr := C.g_string_overwrite_len(s.c, pos, val.str, len) 116 | return String{cptr} 117 | } 118 | 119 | pub fn (s String) erase(pos i64, len i64) String { 120 | cptr := C.g_string_erase(s.c, pos, len) 121 | return String{cptr} 122 | } 123 | 124 | pub fn (s String) truncate(len i64) String { 125 | cptr := C.g_string_truncate(s.c, len) 126 | return String{cptr} 127 | } 128 | 129 | pub fn (s String) set_size(len i64) String { 130 | cptr := C.g_string_set_size(s.c, len) 131 | return String{cptr} 132 | } 133 | 134 | pub fn (s String) free(free_segment bool) string { 135 | cptr := C.g_string_free(s.c, free_segment) 136 | return tos3(cptr) 137 | } 138 | 139 | pub fn (s String) free_to_bytes() byteptr { 140 | return byteptr(C.g_string_free_to_bytes(s.c)) 141 | } 142 | 143 | pub fn (s String) hash() u32 { 144 | return C.g_string_hash(s.c) 145 | } 146 | 147 | pub fn (s String) equal(str2 String) bool { 148 | return C.g_string_equal(s.c, str2.c) 149 | } 150 | 151 | pub fn (s String) get_cptr() &C.GString { 152 | return s.c 153 | } 154 | 155 | pub fn (s String) len() i64 { 156 | return s.c.len 157 | } 158 | 159 | pub fn (s String) str() string { 160 | return tos3(s.c.str) 161 | } 162 | -------------------------------------------------------------------------------- /gtk/about_dialog.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | import gdk 4 | 5 | pub enum License { 6 | unknown = C.GTK_LICENSE_UNKNOWN 7 | custom = C.GTK_LICENSE_CUSTOM 8 | gpl_2_0 = C.GTK_LICENSE_GPL_2_0 9 | gpl_3_0 = C.GTK_LICENSE_GPL_3_0 10 | lgpl_2_1 = C.GTK_LICENSE_LGPL_2_1 11 | lgpl_3_0 = C.GTK_LICENSE_LGPL_3_0 12 | bsd = C.GTK_LICENSE_BSD 13 | mit_x11 = C.GTK_LICENSE_MIT_X11 14 | artistic = C.GTK_LICENSE_ARTISTIC 15 | gpl_2_0_only = C.GTK_LICENSE_GPL_2_0_ONLY 16 | gpl_3_0_only = C.GTK_LICENSE_GPL_3_0_ONLY 17 | lgpl_2_1_only = C.GTK_LICENSE_LGPL_2_1_ONLY 18 | lgpl_3_0_only = C.GTK_LICENSE_LGPL_3_0_ONLY 19 | agpl_3_0 = C.GTK_LICENSE_AGPL_3_0 20 | agpl_3_0_only = C.GTK_LICENSE_AGPL_3_0_ONLY 21 | bsd_3 = C.GTK_LICENSE_BSD_3 22 | apache_2_0 = C.GTK_LICENSE_APACHE_2_0 23 | mpl_2_0 = C.GTK_LICENSE_MPL_2_0 24 | } 25 | 26 | pub struct AboutDialog { 27 | c &C.GtkWidget 28 | } 29 | 30 | pub fn new_about_dialog() AboutDialog { 31 | return AboutDialog{C.gtk_about_dialog_new()} 32 | } 33 | 34 | pub fn (a AboutDialog) get_program_name() string { 35 | return tos3(C.gtk_about_dialog_get_program_name(a.c)) 36 | } 37 | 38 | pub fn (a AboutDialog) set_program_name(name string) { 39 | C.gtk_about_dialog_set_program_name(a.c, name.str) 40 | } 41 | 42 | pub fn (a AboutDialog) get_version() string { 43 | return tos3(C.gtk_about_dialog_get_version(a.c)) 44 | } 45 | 46 | pub fn (a AboutDialog) set_version(version string) { 47 | C.gtk_about_dialog_set_version(a.c, version.str) 48 | } 49 | 50 | pub fn (a AboutDialog) get_copyright() string { 51 | return tos3(C.gtk_about_dialog_get_copyright(a.c)) 52 | } 53 | 54 | pub fn (a AboutDialog) set_copyright(copyright string) { 55 | C.gtk_about_dialog_set_copyright(a.c, copyright.str) 56 | } 57 | 58 | pub fn (a AboutDialog) get_comments() string { 59 | return tos3(C.gtk_about_dialog_get_comments(a.c)) 60 | } 61 | 62 | pub fn (a AboutDialog) set_comments(comments string) { 63 | C.gtk_about_dialog_set_comments(a.c, comments.str) 64 | } 65 | 66 | pub fn (a AboutDialog) get_license() string { 67 | return tos3(C.gtk_about_dialog_get_license(a.c)) 68 | } 69 | 70 | pub fn (a AboutDialog) set_license(license string) { 71 | C.gtk_about_dialog_set_license(a.c, license.str) 72 | } 73 | 74 | pub fn (a AboutDialog) get_wrap_license() bool { 75 | return C.gtk_about_dialog_get_wrap_license(a.c) 76 | } 77 | 78 | pub fn (a AboutDialog) set_wrap_license(wrap_license bool) { 79 | C.gtk_about_dialog_set_wrap_license(a.c, wrap_license) 80 | } 81 | 82 | pub fn (a AboutDialog) get_license_type() License { 83 | return License(C.gtk_about_dialog_get_license_type(a.c)) 84 | } 85 | 86 | pub fn (a AboutDialog) set_license_type(license_type License) { 87 | C.gtk_about_dialog_set_license_type(a.c, license_type) 88 | } 89 | 90 | pub fn (a AboutDialog) get_website() string { 91 | return tos3(C.gtk_about_dialog_get_website(a.c)) 92 | } 93 | 94 | pub fn (a AboutDialog) set_website(website string) { 95 | C.gtk_about_dialog_set_website(a.c, website.str) 96 | } 97 | 98 | pub fn (a AboutDialog) get_website_label() string { 99 | return tos3(C.gtk_about_dialog_get_website_label(a.c)) 100 | } 101 | 102 | pub fn (a AboutDialog) set_website_label(website_label string) { 103 | C.gtk_about_dialog_set_website_label(a.c, website_label.str) 104 | } 105 | 106 | pub fn (a AboutDialog) get_authors() []string { 107 | return carray_string_to_array_string(C.gtk_about_dialog_get_authors(a.c)) 108 | } 109 | 110 | pub fn (a AboutDialog) set_authors(authors []string) { 111 | C.gtk_about_dialog_set_authors(a.c, authors.data) 112 | } 113 | 114 | pub fn (a AboutDialog) get_artists() []string { 115 | return carray_string_to_array_string(C.gtk_about_dialog_get_artists(a.c)) 116 | } 117 | 118 | pub fn (a AboutDialog) set_artists(artists []string) { 119 | C.gtk_about_dialog_set_artists(a.c, artists.data) 120 | } 121 | 122 | pub fn (a AboutDialog) get_documenters() []string { 123 | return carray_string_to_array_string(C.gtk_about_dialog_get_documenters(a.c)) 124 | } 125 | 126 | pub fn (a AboutDialog) set_documenters(documenters []string) { 127 | C.gtk_about_dialog_set_documenters(a.c, documenters.data) 128 | } 129 | 130 | pub fn (a AboutDialog) get_translator_credits() string { 131 | return tos3(C.gtk_about_dialog_get_translator_credits(a.c)) 132 | } 133 | 134 | pub fn (a AboutDialog) set_translator_credits(translator_credits []string) { 135 | C.gtk_about_dialog_set_translator_credits(a.c, translator_credits.data) 136 | } 137 | 138 | pub fn (a AboutDialog) get_logo() gdk.Pixbuf { 139 | return gdk.Pixbuf{C.gtk_about_dialog_get_logo(a.c)} 140 | } 141 | 142 | pub fn (a AboutDialog) set_logo(logo gdk.Pixbuf) { 143 | C.gtk_about_dialog_set_logo(a.c, logo.get_cptr()) 144 | } 145 | 146 | pub fn (a AboutDialog) get_logo_icon_name() string { 147 | return tos3(C.gtk_about_dialog_get_logo_icon_name(a.c)) 148 | } 149 | 150 | pub fn (a AboutDialog) set_logo_icon_name(icon_name string) { 151 | C.gtk_about_dialog_set_logo_icon_name(a.c, icon_name.str) 152 | } 153 | 154 | pub fn (a AboutDialog) add_credit_section(section_name string, people []string) { 155 | C.gtk_about_dialog_add_credit_section(a.c, section_name.str, people.data) 156 | } 157 | 158 | // TODO: Variadic 159 | pub fn show_about_dialog(parent Window) { 160 | C.gtk_show_about_dialog(parent.c, 0) 161 | } 162 | 163 | pub fn (a AboutDialog) on_activate_link(handler fn (AboutDialog, charptr, voidptr), user_data voidptr) { 164 | C.g_signal_connect(a.c, 'activate-link', handler, user_data) 165 | } 166 | 167 | // Inherited from Widget 168 | pub fn (a AboutDialog) show() { 169 | C.gtk_widget_show(a.c) 170 | } 171 | 172 | // Inherited from Window 173 | pub fn (a AboutDialog) set_title(title string) { 174 | C.gtk_window_set_title(a.c, title.str) 175 | } 176 | -------------------------------------------------------------------------------- /gtk/accel_map.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | pub type AccelMapForeach = fn (voidptr, charptr, u32, C.GdkModifierType, bool) 4 | 5 | pub struct AccelMap { 6 | c &C.GtkAccelMap 7 | } 8 | 9 | pub fn accel_map_add_entry(path string, key int, mod_type int) { 10 | C.gtk_accel_map_add_entry(path.str, key, mod_type) 11 | } 12 | 13 | // TODO 14 | pub fn accel_map_lookup_entry(accel_path string) (bool, &C.GtkAccelKey) { 15 | key := &C.GtkAccelKey(0) 16 | res := C.gtk_accel_map_lookup_entry(accel_path.str, &key) 17 | return res, key 18 | } 19 | 20 | /* 21 | pub fn accel_map_change_entry(accel_path string, accel_key u32, accel_mods C.GdkModifierType, replace bool) bool { 22 | return C.gtk_accel_map_change_entry(accel_path.str, accel_key, accel_mods, replace) 23 | } 24 | */ 25 | pub fn accel_map_load(filename string) { 26 | C.gtk_accel_map_load(filename.str) 27 | } 28 | 29 | pub fn accel_map_save(filename string) { 30 | C.gtk_accel_map_save(filename.str) 31 | } 32 | 33 | pub fn accel_map_foreach(data voidptr, foreach_func AccelMapForeach) { 34 | C.gtk_accel_map_foreach(data, C.gtk_accel_map_foreach) 35 | } 36 | 37 | pub fn accel_map_load_fd(fd int) { 38 | C.gtk_accel_map_load_fd(fd) 39 | } 40 | 41 | pub fn accel_map_save_fd(fd int) { 42 | C.gtk_accel_map_save_fd(fd) 43 | } 44 | 45 | /* 46 | pub fn accel_map_load_scanner(scanner &C.GScanner) { 47 | C.gtk_accel_map_load_scanner(scanner) 48 | } 49 | */ 50 | pub fn accel_map_add_filter(filter_pattern string) { 51 | C.gtk_accel_map_add_filter(filter_pattern.str) 52 | } 53 | 54 | pub fn accel_map_foreach_unfiltered(data voidptr, foreach_func AccelMapForeach) { 55 | C.gtk_accel_map_foreach_unfiltered(data, foreach_func) 56 | } 57 | 58 | pub fn accel_map_get() AccelMap { 59 | return AccelMap{C.gtk_accel_map_get()} 60 | } 61 | 62 | pub fn accel_map_lock_path(accel_path string) { 63 | C.gtk_accel_map_lock_path(accel_path.str) 64 | } 65 | 66 | pub fn accel_map_unlock_path(accel_path string) { 67 | C.gtk_accel_map_unlock_path(accel_path.str) 68 | } 69 | 70 | // TODO 71 | // pub type AccelMapOnChange fn(object AccelMap, accel_path charptr, accel_key u32, accel_mods GdkModifierType, user_data voidptr) 72 | /* 73 | pub fn (a &AccelMap) on_changed(cb fn(object AccelMap, accel_path charptr, accel_key u32, accel_mods C.GdkModifierType, user_data voidptr), data voidptr) int { 74 | return int(C.g_signal_connect(a.c ,'changed', cb, data)) 75 | } 76 | */ 77 | -------------------------------------------------------------------------------- /gtk/actionable.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | pub struct Actionable { 4 | c &C.GtkActionable 5 | } 6 | 7 | pub fn (a Actionable) get_action_name() string { 8 | return tos3(C.gtk_actionable_get_action_name(a.c)) 9 | } 10 | 11 | pub fn (a Actionable) set_action_name(action_name string) { 12 | C.gtk_actionable_set_action_name(a.c, action_name.str) 13 | } 14 | 15 | // TODO: 16 | pub fn (a Actionable) get_action_target_value() &C.GVariant { 17 | return C.gtk_actionable_get_action_target_value(a.c) 18 | } 19 | 20 | pub fn (a Actionable) set_action_target_value(target_value &C.GVariant) { 21 | C.gtk_actionable_set_action_target_value(a.c, target_value) 22 | } 23 | 24 | // TODO: void C.gtk_actionable_set_action_target (GtkActionable *actionable, const gchar *format_string, ...) 25 | pub fn (a Actionable) set_detailed_action_name(detailed_action_name string) { 26 | C.gtk_actionable_set_detailed_action_name(a.c, detailed_action_name.str) 27 | } 28 | -------------------------------------------------------------------------------- /gtk/allocation.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | pub struct Allocation { 4 | c &C.GtkAllocation 5 | } 6 | 7 | pub fn (a &Allocation) get_cptr() &C.GtkAllocation { 8 | return a.c 9 | } 10 | -------------------------------------------------------------------------------- /gtk/application.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | import glib 4 | import gio 5 | 6 | pub enum ApplicationInhibitFlags { 7 | logout = C.GTK_APPLICATION_INHIBIT_LOGOUT 8 | switch = C.GTK_APPLICATION_INHIBIT_SWITCH 9 | suspend = C.GTK_APPLICATION_INHIBIT_SUSPEND 10 | idle = C.GTK_APPLICATION_INHIBIT_IDLE 11 | } 12 | 13 | pub struct Application { 14 | c &C.GtkApplication 15 | } 16 | 17 | pub fn new_application(app_id string, flags gio.GApplicationFlags) Application { 18 | app := C.gtk_application_new(app_id.str, flags) 19 | return Application{app} 20 | } 21 | 22 | pub fn (app Application) new_window() Window { 23 | cptr := C.gtk_application_window_new(app.c) 24 | return Window{cptr} 25 | } 26 | 27 | pub fn (app Application) add_window(window Window) { 28 | window_ := window.get_gtk_widget() 29 | C.gtk_application_add_window(app.c, window_) 30 | } 31 | 32 | pub fn (app Application) remove_window(window Window) { 33 | C.gtk_application_remove_window(app.c, window.c) 34 | } 35 | 36 | pub fn (app Application) get_windows() glib.List { 37 | return glib.List{C.gtk_application_get_windows(app.c)} 38 | } 39 | 40 | pub fn (app Application) get_window_by_id(id u32) Window { 41 | window := C.gtk_application_get_window_by_id(app.c, id) 42 | return to_window(voidptr(window)) 43 | } 44 | 45 | pub fn (app Application) get_active_window() Window { 46 | window := C.gtk_application_get_active_window(app.c) 47 | return to_window(window) 48 | } 49 | 50 | pub fn (app Application) inhibit(window Window, flags ApplicationInhibitFlags, reason string) u32 { 51 | return C.gtk_application_inhibit(app.c, window.c, flags, reason.str) 52 | } 53 | 54 | pub fn (app Application) uninhibit(cookie u32) { 55 | C.gtk_application_uninhibit(app.c, cookie) 56 | } 57 | 58 | pub fn (app Application) is_inhibited(flags ApplicationInhibitFlags) bool { 59 | return C.gtk_application_is_inhibited(app.c, flags) 60 | } 61 | 62 | pub fn (app Application) prefers_app_menu() bool { 63 | return C.gtk_application_prefers_app_menu(app.c) 64 | } 65 | 66 | pub fn (app Application) get_app_menu() &C.GMenuModel { 67 | return C.gtk_application_get_app_menu(app.c) 68 | } 69 | 70 | pub fn (app Application) set_app_menu(app_menu &C.GMenuModel) { 71 | C.gtk_application_set_app_menu(app.c, app_menu) 72 | } 73 | 74 | pub fn (app Application) get_menubar() &C.GMenuModel { 75 | return C.gtk_application_get_menubar(app.c) 76 | } 77 | 78 | pub fn (app Application) set_menubar(menubar &C.GMenuModel) { 79 | C.gtk_application_set_menubar(app.c, menubar) 80 | } 81 | 82 | pub fn (app Application) get_menu_by_id(id string) &C.GMenu { 83 | return C.gtk_application_get_menu_by_id(app.c, id.str) 84 | } 85 | 86 | pub fn (app Application) list_action_descriptions() []string { 87 | list_action := C.gtk_application_list_action_descriptions(app.c) 88 | return carray_string_to_array_string(list_action) 89 | } 90 | 91 | pub fn (app Application) get_accels_for_action(detailed_action_name string) []string { 92 | accels := C.gtk_application_get_accels_for_action(app.c, detailed_action_name.str) 93 | return carray_string_to_array_string(accels) 94 | } 95 | 96 | pub fn (app Application) set_accels_for_action(detailed_action_name string, accels []string) { 97 | C.gtk_application_set_accels_for_action(app.c, detailed_action_name.str, accels.data) 98 | } 99 | 100 | pub fn (app Application) get_actions_for_accel(accel string) []string { 101 | actions := C.gtk_application_get_actions_for_accel(app.c, accel.str) 102 | return carray_string_to_array_string(actions) 103 | } 104 | 105 | // INHERITED FROM GAPPLICATION 106 | pub fn (app Application) run(argv []string) int { 107 | return C.g_application_run(app.c, argv.len, argv.data) 108 | } 109 | 110 | // INHERITED FROM GOBJECT 111 | pub fn (app Application) unref() { 112 | C.g_object_unref(app.c) 113 | } 114 | 115 | pub fn (app Application) on(event_name string, handler fn (Application, voidptr), data voidptr) u32 { 116 | return C.g_signal_connect(app.c, event_name.str, handler, data) 117 | } 118 | -------------------------------------------------------------------------------- /gtk/application_window.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | pub struct ApplicationWindow { 4 | c &C.GtkWidget 5 | } 6 | 7 | pub fn new_application_window(application Application) ApplicationWindow { 8 | return ApplicationWindow{C.gtk_application_window_new(application.c)} 9 | } 10 | 11 | pub fn (a ApplicationWindow) set_show_menubar(show_menubar bool) { 12 | C.gtk_application_window_set_show_menubar(a.c, show_menubar) 13 | } 14 | 15 | pub fn (a ApplicationWindow) get_show_menubar() bool { 16 | return C.gtk_application_window_get_show_menubar(a.c) 17 | } 18 | 19 | pub fn (a ApplicationWindow) get_id() u32 { 20 | return C.gtk_application_window_get_id(a.c) 21 | } 22 | 23 | /* 24 | // TODO: 25 | pub fn (a ApplicationWindow) set_help_overlay(help_overlay &C.GtkShortcutsWindow) { 26 | C.gtk_application_window_set_help_overlay(a.c, help_overlay) 27 | } 28 | 29 | // TODO: 30 | pub fn (a ApplicationWindow) get_help_overlay() &C.GtkShortcutsWindow { 31 | return C.gtk_application_window_get_help_overlay(a.c) 32 | } 33 | */ 34 | -------------------------------------------------------------------------------- /gtk/bin.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | pub struct Bin { 4 | c &C.GtkBin 5 | } 6 | 7 | pub fn (b Bin) get_child() Widget { 8 | return Widget{C.gtk_bin_get_child(b.c)} 9 | } 10 | -------------------------------------------------------------------------------- /gtk/box.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | pub struct Box { 4 | c &C.GtkWidget 5 | } 6 | 7 | pub struct BoxQuery { 8 | expand bool 9 | fill bool 10 | padding u32 11 | pack_type PackType 12 | } 13 | 14 | pub fn new_box(orientation Orientation, space int) Box { 15 | return Box{C.gtk_box_new(orientation, space)} 16 | } 17 | 18 | pub fn new_hbox(space int) Box { 19 | return new_box(.horizontal, space) 20 | } 21 | 22 | pub fn new_vbox(space int) Box { 23 | return new_box(.vertical, space) 24 | } 25 | 26 | pub fn (b Box) pack_start(child IWidget, expand bool, fill bool, padding u32) { 27 | child_ := child.get_gtk_widget() 28 | C.gtk_box_pack_start(voidptr(b.c), voidptr(child_), expand, fill, padding) 29 | } 30 | 31 | pub fn (b Box) pack_end(child IWidget, expand bool, fill bool, padding u32) { 32 | child_ := child.get_gtk_widget() 33 | C.gtk_box_pack_end(voidptr(b.c), voidptr(child_), expand, fill, padding) 34 | } 35 | 36 | pub fn (b Box) get_homogeneous() bool { 37 | return C.gtk_box_get_homogeneous(voidptr(b.c)) 38 | } 39 | 40 | pub fn (b Box) set_homogeneous(homogeneous bool) { 41 | C.gtk_box_set_homogeneous(voidptr(b.c), homogeneous) 42 | } 43 | 44 | pub fn (b Box) get_spacing() int { 45 | return C.gtk_box_get_spacing(voidptr(b.c)) 46 | } 47 | 48 | pub fn (b Box) set_spacing(spacing int) { 49 | C.gtk_box_set_spacing(voidptr(b.c), spacing) 50 | } 51 | 52 | pub fn (b Box) reorder_child(child IWidget, position int) { 53 | child_ := child.get_gtk_widget() 54 | C.gtk_box_reorder_child(voidptr(b.c), voidptr(child_), position) 55 | } 56 | 57 | pub fn (b Box) query_child_packing(child IWidget) BoxQuery { 58 | child_ := child.get_gtk_widget() 59 | expand := false 60 | fill := false 61 | padding := u32(0) 62 | pack_type := PackType(0) 63 | C.gtk_box_query_child_packing(voidptr(b.c), voidptr(child_), &expand, &fill, &padding, 64 | &pack_type) 65 | return BoxQuery{expand, fill, padding, pack_type} 66 | } 67 | 68 | pub fn (b Box) set_child_packing(child IWidget, expand bool, fill bool, padding u32, pack_type PackType) { 69 | child_ := child.get_gtk_widget() 70 | C.gtk_box_set_child_packing(b.c, child_, expand, fill, padding, pack_type) 71 | } 72 | 73 | pub fn (b Box) get_baseline_position() BaselinePosition { 74 | return BaselinePosition(C.gtk_box_get_baseline_position(b.c)) 75 | } 76 | 77 | pub fn (b Box) set_baseline_position(position BaselinePosition) { 78 | C.gtk_box_set_baseline_position(b.c, position) 79 | } 80 | 81 | pub fn (b Box) get_center_widget() &C.GtkWidget { 82 | return C.gtk_box_get_center_widget(b.c) 83 | } 84 | 85 | pub fn (b Box) set_center_widget(widget IWidget) { 86 | wgt := widget.get_gtk_widget() 87 | C.gtk_box_set_center_widget(b.c, wgt) 88 | } 89 | 90 | // Inherited from Widget 91 | pub fn (b Box) get_halign() Align { 92 | return Align(C.gtk_widget_get_halign(b.c)) 93 | } 94 | 95 | pub fn (b Box) set_halign(align Align) { 96 | C.gtk_widget_set_halign(b.c, align) 97 | } 98 | 99 | pub fn (b Box) get_valign() Align { 100 | return Align(C.gtk_widget_get_valign(b.c)) 101 | } 102 | 103 | pub fn (b Box) set_valign(align Align) { 104 | C.gtk_widget_set_valign(b.c, align) 105 | } 106 | 107 | // Inherited from Container 108 | pub fn (b Box) add(widget IWidget) { 109 | wgt := widget.get_gtk_widget() 110 | C.gtk_container_add(b.c, wgt) 111 | } 112 | 113 | pub fn (b Box) remove(widget IWidget) { 114 | wgt := widget.get_gtk_widget() 115 | C.gtk_container_remove(b.c, wgt) 116 | } 117 | 118 | // Implementing GtkOrientable 119 | pub fn (b Box) set_orientation(orientation Orientation) { 120 | C.gtk_orientable_set_orientation(b.c, orientation) 121 | } 122 | 123 | pub fn (b Box) get_orientation() Orientation { 124 | return Orientation(C.gtk_orientable_get_orientation(b.c)) 125 | } 126 | 127 | // Implementing IWidget 128 | pub fn (b &Box) get_gtk_widget() &C.GtkWidget { 129 | return b.c 130 | } 131 | -------------------------------------------------------------------------------- /gtk/buildable.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | pub struct Buildable { 4 | c &C.GtkBuildable 5 | } 6 | 7 | pub fn (b Buildable) set_name(name string) { 8 | C.gtk_buildable_set_name(b.c, name.str) 9 | } 10 | 11 | pub fn (b Buildable) get_name() string { 12 | return tos3(C.gtk_buildable_get_name(b.c)) 13 | } 14 | 15 | pub fn (b Buildable) add(builder Builder, child &C._GObject, type_ string) { 16 | C.gtk_buildable_add_child(b.c, builder.c, child, type_.str) 17 | } 18 | 19 | pub fn (b Buildable) set_property(builder Builder, name string, value &C._GValue) { 20 | C.gtk_buildable_set_buildable_property(b.c, builder.c, name.str, value) 21 | } 22 | 23 | pub fn (b Buildable) construct_child(builder Builder, name string) &C._GObject { 24 | return C.gtk_buildable_construct_child(b.c, builder.c, name.str) 25 | } 26 | 27 | pub fn (b Buildable) custom_tag_start(builder Builder, child &C._GObject, tagname string) (&C._GMarkupParser, voidptr) { 28 | parser := &C._GMarkupParser(0) 29 | data := voidptr(0) 30 | C.gtk_buildable_custom_tag_start(b.c, builder.c, child, tagname.str, &parser, &data) 31 | return parser, data 32 | } 33 | 34 | pub fn (b Buildable) custom_tag_end(builder Builder, child &C._GObject, tagname string, data voidptr) { 35 | C.gtk_buildable_custom_tag_end(b.c, builder.c, child, tagname.str, data) 36 | } 37 | 38 | pub fn (b Buildable) custom_finished(builder Builder, child &C._GObject, tagname string, data voidptr) { 39 | C.gtk_buildable_custom_finished(b.c, builder.c, child, tagname.str, data) 40 | } 41 | 42 | pub fn (b Buildable) parser_finished(builder Builder) { 43 | C.gtk_buildable_parser_finished(b.c, builder.c) 44 | } 45 | 46 | pub fn (b Buildable) get_internal_child(builder Builder, childname string) &C._GObject { 47 | return C.gtk_buildable_get_internal_child(b.c, builder.c, childname.str) 48 | } 49 | -------------------------------------------------------------------------------- /gtk/builder.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | import glib 4 | 5 | pub enum BuilderError { 6 | invalid_type_function = C.GTK_BUILDER_ERROR_INVALID_TYPE_FUNCTION 7 | unhandled_tag = C.GTK_BUILDER_ERROR_UNHANDLED_TAG 8 | missing_attribute = C.GTK_BUILDER_ERROR_MISSING_ATTRIBUTE 9 | invalid_attribute = C.GTK_BUILDER_ERROR_INVALID_ATTRIBUTE 10 | invalid_tag = C.GTK_BUILDER_ERROR_INVALID_TAG 11 | missing_property_value = C.GTK_BUILDER_ERROR_MISSING_PROPERTY_VALUE 12 | invalid_value = C.GTK_BUILDER_ERROR_INVALID_VALUE 13 | version_mismatch = C.GTK_BUILDER_ERROR_VERSION_MISMATCH 14 | duplicate_id = C.GTK_BUILDER_ERROR_DUPLICATE_ID 15 | object_type_refused = C.GTK_BUILDER_ERROR_OBJECT_TYPE_REFUSED 16 | template_mismatch = C.GTK_BUILDER_ERROR_TEMPLATE_MISMATCH 17 | invalid_property = C.GTK_BUILDER_ERROR_INVALID_PROPERTY 18 | invalid_signal = C.GTK_BUILDER_ERROR_INVALID_SIGNAL 19 | invalid_id = C.GTK_BUILDER_ERROR_INVALID_ID 20 | } 21 | 22 | pub struct Builder { 23 | c &C.GtkBuilder 24 | } 25 | 26 | pub fn new_builder() Builder { 27 | return Builder{C.gtk_builder_new()} 28 | } 29 | 30 | pub fn new_builder_from_file(filename string) Builder { 31 | return Builder{C.gtk_builder_new_from_file(filename.str)} 32 | } 33 | 34 | pub fn new_builder_from_resource(resource_path string) Builder { 35 | return Builder{C.gtk_builder_new_from_resource(resource_path.str)} 36 | } 37 | 38 | pub fn new_builder_from_string(str string) Builder { 39 | return Builder{C.gtk_builder_new_from_string(str.str, str.len)} 40 | } 41 | 42 | pub fn (b Builder) add_callback_symbol(callback_name string, callback fn ()) { 43 | C.gtk_builder_add_callback_symbol(b.c, callback_name.str, callback) 44 | } 45 | 46 | pub fn (b Builder) add_from_file(filename string) ?u32 { 47 | err := &C._GError{0} 48 | ret := C.gtk_builder_add_from_file(b.c, filename.str, &err) 49 | if err != 0 { 50 | return error(tos3(err.message)) 51 | } 52 | return ret 53 | } 54 | 55 | pub fn (b Builder) add_from_resource(resource_path string) ?u32 { 56 | err := &C._GError{0} 57 | ret := C.gtk_builder_add_from_resource(b.c, resource_path.str, &err) 58 | if err != 0 { 59 | return error(tos3(err.message)) 60 | } 61 | return ret 62 | } 63 | 64 | pub fn (b Builder) add_from_string(buffer string) ?u32 { 65 | err := &C._GError{0} 66 | ret := C.gtk_builder_add_from_string(b.c, buffer.str, buffer.len, &err) 67 | if err != 0 { 68 | return error(tos3(err.message)) 69 | } 70 | return ret 71 | } 72 | 73 | pub fn (b Builder) add_objects_from_file(filename string, object_ids []string) ?u32 { 74 | err := &C._GError{0} 75 | ret := C.gtk_builder_add_objects_from_file(b.c, filename.str, object_ids.data, &err) 76 | if err != 0 { 77 | return error(tos3(err.message)) 78 | } 79 | return ret 80 | } 81 | 82 | pub fn (b Builder) add_objects_from_string(buffer string, object_ids []string) ?u32 { 83 | err := &C._GError{0} 84 | ret := C.gtk_builder_add_objects_from_string(b.c, buffer.str, buffer.len, object_ids.data, 85 | &err) 86 | if err != 0 { 87 | return error(tos3(err.message)) 88 | } 89 | return ret 90 | } 91 | 92 | pub fn (b Builder) add_objects_from_resource(resource_path string, object_ids []string) ?u32 { 93 | err := &C._GError{0} 94 | ret := C.gtk_builder_add_objects_from_resource(b.c, resource_path.str, object_ids.data, 95 | &err) 96 | if err != 0 { 97 | return error(tos3(err.message)) 98 | } 99 | return ret 100 | } 101 | 102 | /* 103 | pub fn (b Builder) extend_with_template(widget IWidget, template_type C.GType, buffer string) ?u32 { 104 | err := &C._GError{0} 105 | wgt := widget.get_gtk_widget() 106 | ret := C.gtk_builder_extend_with_template(b.c, wgt, template_type, buffer.str, buffer.len, &err) 107 | if err != 0 { 108 | return error(tos3(err.message)) 109 | } 110 | return ret 111 | } 112 | */ 113 | pub fn (b Builder) get_object(name string) &C._GObject { 114 | return C.gtk_builder_get_object(b.c, name.str) 115 | } 116 | 117 | pub fn (b Builder) get_objects() &glib.SList { 118 | return &glib.SList{C.gtk_builder_get_objects(b.c)} 119 | } 120 | 121 | /* 122 | pub fn (b Builder) expose_object(name string, object C.GObject) { 123 | C.gtk_builder_expose_object(b.c, name.str, &object) 124 | } 125 | */ 126 | pub fn (b Builder) connect_signals(user_data voidptr) { 127 | C.gtk_builder_connect_signals(b.c, user_data) 128 | } 129 | 130 | // TODO: void C.gtk_builder_connect_signals_full (GtkBuilder *builder, GtkBuilderConnectFunc func, gpointer user_data) 131 | pub fn (b Builder) set_translation_domain(domain string) { 132 | C.gtk_builder_set_translation_domain(b.c, domain.str) 133 | } 134 | 135 | pub fn (b Builder) get_translation_domain() string { 136 | return tos3(C.gtk_builder_get_translation_domain(b.c)) 137 | } 138 | 139 | pub fn (b Builder) set_application(application Application) { 140 | C.gtk_builder_set_application(b.c, application.c) 141 | } 142 | 143 | pub fn (b Builder) get_application() Application { 144 | return Application{C.gtk_builder_get_application(b.c)} 145 | } 146 | 147 | /* 148 | pub fn (b Builder) get_type_from_name(type_name string) C.GType { 149 | return C.gtk_builder_get_type_from_name(b.c, type_name.str) 150 | } 151 | 152 | pub fn (b Builder) value_from_string(pspec &C.GParamSpec, str string, value &C.GValue) ?bool { 153 | err := &C._GError{0} 154 | ret := C.gtk_builder_value_from_string(b.c, pspec, str.str, value, &err) 155 | if err != 0 { 156 | return error(tos3(err.message)) 157 | } 158 | return ret 159 | } 160 | 161 | pub fn (b Builder) value_from_string_type(type_ C.GType, str string, value &C.GValue) ?bool { 162 | err := &C._GError{0} 163 | ret := C.gtk_builder_value_from_string_type(b.c, type_, str.str, value, &err) 164 | if err != 0 { 165 | return error(tos3(err.message)) 166 | } 167 | return ret 168 | } 169 | */ 170 | -------------------------------------------------------------------------------- /gtk/button.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | import gdk 4 | 5 | pub struct Button { 6 | c &C.GtkWidget 7 | } 8 | 9 | pub fn new_button() Button { 10 | return Button{C.gtk_button_new()} 11 | } 12 | 13 | pub fn new_button_with_label(label string) Button { 14 | return Button{C.gtk_button_new_with_label(label.str)} 15 | } 16 | 17 | pub fn new_button_with_mnemonic(label string) Button { 18 | return Button{C.gtk_button_new_with_mnemonic(label.str)} 19 | } 20 | 21 | pub fn new_button_from_icon_name(icon_name string, icon_size IconSize) Button { 22 | return Button{C.gtk_button_new_from_icon_name(icon_name.str, icon_size)} 23 | } 24 | 25 | pub fn (b Button) clicked() { 26 | C.gtk_button_clicked(b.c) 27 | } 28 | 29 | pub fn (b Button) set_relief(relief ReliefStyle) { 30 | C.gtk_button_set_relief(b.c, relief) 31 | } 32 | 33 | pub fn (b Button) get_relief() ReliefStyle { 34 | return ReliefStyle(C.gtk_button_get_relief(b.c)) 35 | } 36 | 37 | pub fn (b Button) get_label() string { 38 | return tos3(C.gtk_button_get_label(b.c)) 39 | } 40 | 41 | pub fn (b Button) set_label(label string) { 42 | C.gtk_button_set_label(b.c, label.str) 43 | } 44 | 45 | pub fn (b Button) set_size(width int, height int) { 46 | C.gtk_widget_set_size_request(b.c, width, height) 47 | } 48 | 49 | pub fn (b Button) get_use_underline() bool { 50 | return C.gtk_button_get_use_underline(b.c) 51 | } 52 | 53 | pub fn (b Button) set_use_underline(setting bool) { 54 | C.gtk_button_set_use_underline(b.c, setting) 55 | } 56 | 57 | pub fn (b Button) set_focus_on_click(focus_on_click bool) { 58 | C.gtk_button_set_focus_on_click(b.c, focus_on_click) 59 | } 60 | 61 | pub fn (b Button) get_focus_on_click() bool { 62 | return C.gtk_widget_get_focus_on_click(b.c) 63 | } 64 | 65 | pub fn (b Button) set_image(img_widget IWidget) { 66 | wi := img_widget.get_gtk_widget() 67 | C.gtk_button_set_image(b.c, wi) 68 | } 69 | 70 | pub fn (b Button) get_image() &C.GtkWidget { 71 | return C.gtk_button_get_image(b.c) 72 | } 73 | 74 | pub fn (b Button) set_image_position(pos Position) { 75 | C.gtk_button_set_image_position(b.c, pos) 76 | } 77 | 78 | pub fn (b Button) get_image_position() Position { 79 | return Position(C.gtk_button_get_image_position(b.c)) 80 | } 81 | 82 | pub fn (b Button) set_always_show_image(always_show bool) { 83 | C.gtk_button_set_always_show_image(b.c, always_show) 84 | } 85 | 86 | pub fn (b Button) get_always_show_image() bool { 87 | return C.gtk_button_get_always_show_image(b.c) 88 | } 89 | 90 | pub fn (b Button) get_event_window() gdk.Window { 91 | cptr := C.gtk_button_get_event_window(b.c) 92 | return gdk.Window{cptr} 93 | } 94 | 95 | // INHERITED FROM WIDGET 96 | pub fn (b &Button) show() { 97 | C.gtk_widget_show(b.c) 98 | } 99 | 100 | // IMPLEMENTING IWidget 101 | pub fn (b &Button) get_gtk_widget() &C.GtkWidget { 102 | return b.c 103 | } 104 | 105 | // CUSTOM API's 106 | pub fn (b &Button) on(event_name string, handler fn (Button, voidptr), data voidptr) int { 107 | return int(C.g_signal_connect(b.c, event_name.str, handler, data)) 108 | } 109 | -------------------------------------------------------------------------------- /gtk/buttonbox.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | pub struct ButtonBox { 4 | c &C.GtkWidget 5 | } 6 | 7 | pub fn new_hbutton_box() ButtonBox { 8 | return ButtonBox{C.gtk_hbutton_box_new()} 9 | } 10 | 11 | pub fn new_vbutton_box() ButtonBox { 12 | return ButtonBox{C.gtk_vbutton_box_new()} 13 | } 14 | 15 | pub fn (b ButtonBox) add(widget IWidget) { 16 | wgt := widget.get_gtk_widget() 17 | C.gtk_container_add(b.c, wgt) 18 | } 19 | 20 | pub fn (b ButtonBox) pack_start(child IWidget, expand bool, fill bool, padding u32) { 21 | child_ := child.get_gtk_widget() 22 | C.gtk_box_pack_start(voidptr(b.c), voidptr(child_), expand, fill, padding) 23 | } 24 | 25 | pub fn (b ButtonBox) pack_end(child IWidget, expand bool, fill bool, padding u32) { 26 | child_ := child.get_gtk_widget() 27 | C.gtk_box_pack_end(voidptr(b.c), voidptr(child_), expand, fill, padding) 28 | } 29 | 30 | pub fn (b ButtonBox) set_layout(layout ButtonBoxStyle) { 31 | C.gtk_button_box_set_layout(b.c, layout) 32 | } 33 | 34 | pub fn (b ButtonBox) set_child_secondary(child Widget, is_secondary bool) { 35 | C.gtk_button_box_set_child_secondary(b.c, child.c, is_secondary) 36 | } 37 | 38 | pub fn (b ButtonBox) set_child_non_homogeneous(child Widget, is_secondary bool) { 39 | C.gtk_button_box_set_child_non_homogeneous(b.c, child.c, is_secondary) 40 | } 41 | 42 | // INHERITED FROM WIDGET 43 | pub fn (b &ButtonBox) show() { 44 | C.gtk_widget_show(b.c) 45 | } 46 | 47 | // IMPLEMENTING IWidget 48 | pub fn (b &ButtonBox) get_gtk_widget() &C.GtkWidget { 49 | return b.c 50 | } 51 | 52 | // CUSTOM API's 53 | pub fn (b &ButtonBox) on(event_name string, handler fn (ButtonBox, voidptr), data voidptr) int { 54 | return int(C.g_signal_connect(b.c, event_name.str, handler, data)) 55 | } 56 | -------------------------------------------------------------------------------- /gtk/check_button.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | import gdk 4 | 5 | pub struct CheckButton { 6 | c &C.GtkWidget 7 | } 8 | 9 | pub fn new_check_button() CheckButton { 10 | return CheckButton{C.gtk_check_button_new()} 11 | } 12 | 13 | pub fn new_check_button_with_label(label string) CheckButton { 14 | return CheckButton{C.gtk_check_button_new_with_label(label.str)} 15 | } 16 | 17 | pub fn new_check_button_with_mnemonic(label string) CheckButton { 18 | return CheckButton{C.gtk_check_button_new_with_mnemonic(label.str)} 19 | } 20 | 21 | // Inherited from ToggleButton 22 | pub fn (c CheckButton) set_mode(draw_indicator bool) { 23 | C.gtk_toggle_button_set_mode(c.c, draw_indicator) 24 | } 25 | 26 | pub fn (c CheckButton) get_mode() bool { 27 | return C.gtk_toggle_button_get_mode(c.c) 28 | } 29 | 30 | pub fn (c CheckButton) toggled() { 31 | C.gtk_toggle_button_toggled(c.c) 32 | } 33 | 34 | pub fn (c CheckButton) get_active() bool { 35 | return C.gtk_toggle_button_get_active(c.c) 36 | } 37 | 38 | pub fn (c CheckButton) set_active(is_active bool) { 39 | C.gtk_toggle_button_set_active(c.c, is_active) 40 | } 41 | 42 | pub fn (c CheckButton) get_inconsistent() bool { 43 | return C.gtk_toggle_button_get_inconsistent(c.c) 44 | } 45 | 46 | pub fn (c CheckButton) set_inconsistent(setting bool) { 47 | C.gtk_toggle_button_set_inconsistent(c.c, setting) 48 | } 49 | 50 | // Inherited from Button 51 | pub fn (c CheckButton) clicked() { 52 | C.gtk_button_clicked(c.c) 53 | } 54 | 55 | pub fn (c CheckButton) set_relief(relief ReliefStyle) { 56 | C.gtk_button_set_relief(c.c, relief) 57 | } 58 | 59 | pub fn (c CheckButton) get_relief() ReliefStyle { 60 | return ReliefStyle(C.gtk_button_get_relief(c.c)) 61 | } 62 | 63 | pub fn (c CheckButton) get_label() string { 64 | return tos3(C.gtk_button_get_label(c.c)) 65 | } 66 | 67 | pub fn (c CheckButton) set_label(label string) { 68 | C.gtk_button_set_label(c.c, label.str) 69 | } 70 | 71 | pub fn (c CheckButton) set_size(width int, height int) { 72 | C.gtk_widget_set_size_request(c.c, width, height) 73 | } 74 | 75 | pub fn (c CheckButton) get_use_underline() bool { 76 | return C.gtk_button_get_use_underline(c.c) 77 | } 78 | 79 | pub fn (c CheckButton) set_use_underline(setting bool) { 80 | C.gtk_button_set_use_underline(c.c, setting) 81 | } 82 | 83 | pub fn (c CheckButton) set_focus_on_click(focus_on_click bool) { 84 | C.gtk_button_set_focus_on_click(c.c, focus_on_click) 85 | } 86 | 87 | pub fn (c CheckButton) get_focus_on_click() bool { 88 | return C.gtk_widget_get_focus_on_click(c.c) 89 | } 90 | 91 | pub fn (c CheckButton) set_image(img_widget IWidget) { 92 | wi := img_widget.get_gtk_widget() 93 | C.gtk_button_set_image(c.c, wi) 94 | } 95 | 96 | pub fn (c CheckButton) get_image() &C.GtkWidget { 97 | return C.gtk_button_get_image(c.c) 98 | } 99 | 100 | pub fn (c CheckButton) set_image_position(pos Position) { 101 | C.gtk_button_set_image_position(c.c, pos) 102 | } 103 | 104 | pub fn (c CheckButton) get_image_position() Position { 105 | return Position(C.gtk_button_get_image_position(c.c)) 106 | } 107 | 108 | pub fn (c CheckButton) set_always_show_image(always_show bool) { 109 | C.gtk_button_set_always_show_image(c.c, always_show) 110 | } 111 | 112 | pub fn (c CheckButton) get_always_show_image() bool { 113 | return C.gtk_button_get_always_show_image(c.c) 114 | } 115 | 116 | pub fn (c CheckButton) get_event_window() gdk.Window { 117 | return gdk.Window{C.gtk_button_get_event_window(c.c)} 118 | } 119 | 120 | pub fn (c &CheckButton) on(event_name string, handler fn (CheckButton, voidptr), data voidptr) int { 121 | return int(C.g_signal_connect(c.c, event_name.str, handler, data)) 122 | } 123 | 124 | // Inherited from Bin 125 | pub fn (c CheckButton) get_child() Widget { 126 | return Widget{C.gtk_bin_get_child(c.c)} 127 | } 128 | 129 | // Inherited from Container 130 | // Inherited from Widget 131 | // Implemented from Buildable 132 | // Implemented from Actionable 133 | // Implemented from Activatable 134 | // Implemented from IWidget 135 | pub fn (c &CheckButton) get_gtk_widget() &C.GtkWidget { 136 | return c.c 137 | } 138 | -------------------------------------------------------------------------------- /gtk/color_chooser.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | pub struct ColorChooser { 4 | c &C.GtkColorChooser 5 | } 6 | 7 | // TODO 8 | pub fn (c ColorChooser) get_rgba() &C.GdkRGBA { 9 | color := &C.GdkRGBA(0) 10 | C.gtk_color_chooser_get_rgba(c.c, &color) 11 | return color 12 | } 13 | 14 | // TODO 15 | pub fn (c ColorChooser) set_rgba(color &C.GdkRGBA) { 16 | C.gtk_color_chooser_set_rgba(c.c, color) 17 | } 18 | 19 | pub fn (c ColorChooser) get_use_alpha() bool { 20 | return C.gtk_color_chooser_get_use_alpha(c.c) 21 | } 22 | 23 | pub fn (c ColorChooser) set_use_alpha(use_alpha bool) { 24 | C.gtk_color_chooser_set_use_alpha(c.c, use_alpha) 25 | } 26 | 27 | // TODO 28 | pub fn (c ColorChooser) add_palette(orientation Orientation, colors_per_line int, colors []&C.GdkRGBA) { 29 | C.gtk_color_chooser_add_palette(c.c, orientation, colors_per_line, colors.len, colors.data) 30 | } 31 | -------------------------------------------------------------------------------- /gtk/consts.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | pub const ( 4 | major_version = C.gtk_major_version 5 | minor_version = C.gtk_minor_version 6 | micro_version = C.gtk_micro_version 7 | version = major_version.str() + '.' + minor_version.str() + '.' + micro_version.str() 8 | ) 9 | -------------------------------------------------------------------------------- /gtk/container.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | pub enum ResizeMode { 4 | parent = C.GTK_RESIZE_PARENT 5 | queue = C.GTK_RESIZE_QUEUE 6 | immediate = C.GTK_RESIZE_IMMEDIATE 7 | } 8 | 9 | pub struct Container { 10 | c &C.GtkContainer 11 | } 12 | 13 | pub fn (c &Container) add(widget IWidget) { 14 | wgt := widget.get_gtk_widget() 15 | C.gtk_container_add(c.c, wgt) 16 | } 17 | 18 | pub fn (c &Container) set_border_width(border_width int) { 19 | C.gtk_container_set_border_width(c.c, border_width) 20 | } 21 | -------------------------------------------------------------------------------- /gtk/dialog.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | pub enum DialogFlags { 4 | modal = C.GTK_DIALOG_MODAL 5 | destroy_with_parent = C.GTK_DIALOG_DESTROY_WITH_PARENT 6 | use_header_bar = C.GTK_DIALOG_USE_HEADER_BAR 7 | } 8 | 9 | pub enum ResponseType { 10 | none_ = C.GTK_RESPONSE_NONE 11 | reject = C.GTK_RESPONSE_REJECT 12 | accept = C.GTK_RESPONSE_ACCEPT 13 | delete_event = C.GTK_RESPONSE_DELETE_EVENT 14 | ok = C.GTK_RESPONSE_OK 15 | cancel = C.GTK_RESPONSE_CANCEL 16 | close = C.GTK_RESPONSE_CLOSE 17 | yes = C.GTK_RESPONSE_YES 18 | no = C.GTK_RESPONSE_NO 19 | apply = C.GTK_RESPONSE_APPLY 20 | help = C.GTK_RESPONSE_HELP 21 | } 22 | 23 | pub struct Dialog { 24 | c &C.GtkWidget 25 | } 26 | 27 | pub fn new_dialog() Dialog { 28 | return Dialog{C.gtk_dialog_new()} 29 | } 30 | 31 | pub fn new_dialog_from_parent(title string, parent Window, flags DialogFlags) Dialog { 32 | parent_ := parent.get_gtk_widget() 33 | return Dialog{C.gtk_dialog_new_with_buttons(title.str, parent_, flags, 0, 0)} 34 | } 35 | 36 | // TODO: GtkWidget * C.gtk_dialog_new_with_buttons (const gchar *title, GtkWindow *parent, GtkDialogFlags flags, const gchar *first_button_text, ...) 37 | pub fn (d Dialog) run() ResponseType { 38 | return ResponseType(C.gtk_dialog_run(d.c)) 39 | } 40 | 41 | pub fn (d Dialog) response(response_id ResponseType) { 42 | C.gtk_dialog_response(d.c, response_id) 43 | } 44 | 45 | pub fn (d Dialog) add_button(button_text string, response_id ResponseType) Button { 46 | return Button{C.gtk_dialog_add_button(d.c, button_text.str, response_id)} 47 | } 48 | 49 | // TODO: void C.gtk_dialog_add_buttons (GtkDialog *dialog, const gchar *first_button_text, ...) 50 | pub fn (d Dialog) add_action_widget(child IWidget, response_id ResponseType) { 51 | child_ := child.get_gtk_widget() 52 | C.gtk_dialog_add_action_widget(d.c, child_, response_id) 53 | } 54 | 55 | pub fn (d Dialog) set_default_response(response_id ResponseType) { 56 | C.gtk_dialog_set_default_response(d.c, response_id) 57 | } 58 | 59 | pub fn (d Dialog) set_response_sensitive(response_id ResponseType, setting bool) { 60 | C.gtk_dialog_set_response_sensitive(d.c, response_id, setting) 61 | } 62 | 63 | pub fn (d Dialog) get_response_for_widget(widget IWidget) int { 64 | widget_ := widget.get_gtk_widget() 65 | return C.gtk_dialog_get_response_for_widget(d.c, widget_) 66 | } 67 | 68 | pub fn (d Dialog) get_widget_for_response(response_id ResponseType) &Widget { 69 | widget := C.gtk_dialog_get_widget_for_response(d.c, response_id) 70 | if widget == 0 { 71 | return 0 72 | } 73 | return &Widget{widget} 74 | } 75 | 76 | pub fn (d Dialog) get_content_area() Box { 77 | widget := C.gtk_dialog_get_content_area(d.c) 78 | return Box{widget} 79 | } 80 | 81 | pub fn (d Dialog) get_header_bar() &Widget { 82 | widget := C.gtk_dialog_get_header_bar(d.c) 83 | if widget == 0 { 84 | return 0 85 | } 86 | return &Widget{widget} 87 | } 88 | 89 | // INHERITED FROM WIDGET 90 | pub fn (d Dialog) destroy() { 91 | C.gtk_widget_destroy(d.c) 92 | } 93 | 94 | pub fn (d Dialog) in_destruction() bool { 95 | return C.gtk_widget_in_destruction(d.c) 96 | } 97 | 98 | pub fn (d Dialog) destroyed(widget IWidget) { 99 | wgt := widget.get_gtk_widget() 100 | C.gtk_widget_destroyed(d.c, wgt) 101 | } 102 | 103 | pub fn (d Dialog) unparent() { 104 | C.gtk_widget_unparent(d.c) 105 | } 106 | 107 | pub fn (d Dialog) show() { 108 | C.gtk_widget_show(d.c) 109 | } 110 | 111 | pub fn (d Dialog) show_now() { 112 | C.gtk_widget_show_now(d.c) 113 | } 114 | 115 | pub fn (d Dialog) hide() { 116 | C.gtk_widget_hide(d.c) 117 | } 118 | 119 | pub fn (d Dialog) show_all() { 120 | C.gtk_widget_show_all(d.c) 121 | } 122 | 123 | pub fn (d Dialog) map() { 124 | C.gtk_widget_map(d.c) 125 | } 126 | 127 | pub fn (d Dialog) unmap() { 128 | C.gtk_widget_unmap(d.c) 129 | } 130 | 131 | pub fn (d Dialog) realize() { 132 | C.gtk_widget_realize(d.c) 133 | } 134 | 135 | pub fn (d Dialog) unrealize() { 136 | C.gtk_widget_unrealize(d.c) 137 | } 138 | 139 | pub fn (d Dialog) queue_draw() { 140 | C.gtk_widget_queue_draw(d.c) 141 | } 142 | 143 | pub fn (d Dialog) queue_resize() { 144 | C.gtk_widget_queue_resize(d.c) 145 | } 146 | 147 | pub fn (d Dialog) queue_resize_no_redraw() { 148 | C.gtk_widget_queue_resize_no_redraw(d.c) 149 | } 150 | 151 | pub fn (d Dialog) queue_allocate() { 152 | C.gtk_widget_queue_allocate(d.c) 153 | } 154 | 155 | pub fn (d Dialog) get_scale_factor() int { 156 | return C.gtk_widget_get_scale_factor(d.c) 157 | } 158 | 159 | pub fn (d Dialog) remove_tick_callback(id u32) { 160 | C.gtk_widget_remove_tick_callback(d.c, id) 161 | } 162 | 163 | pub fn (d Dialog) can_activate_accel(signal_id int) bool { 164 | return C.gtk_widget_can_activate_accel(d.c, signal_id) 165 | } 166 | 167 | pub fn (d Dialog) activate() bool { 168 | return C.gtk_widget_activate(d.c) 169 | } 170 | 171 | pub fn (d Dialog) is_focus() bool { 172 | return C.gtk_widget_is_focus(d.c) 173 | } 174 | 175 | pub fn (d Dialog) grab_focus() { 176 | C.gtk_widget_grab_focus(d.c) 177 | } 178 | 179 | pub fn (d Dialog) grab_default() { 180 | C.gtk_widget_grab_default(d.c) 181 | } 182 | 183 | pub fn (d Dialog) set_name(name string) { 184 | C.gtk_widget_set_name(d.c, name.str) 185 | } 186 | 187 | pub fn (d Dialog) set_sensitive(sensitive bool) { 188 | C.gtk_widget_set_sensitive(d.c, sensitive) 189 | } 190 | 191 | pub fn (d Dialog) set_parent(parent IWidget) { 192 | parent_ := parent.get_gtk_widget() 193 | C.gtk_widget_set_parent(d.c, parent_) 194 | } 195 | 196 | pub fn (d Dialog) set_events(events int) { 197 | C.gtk_widget_set_events(d.c, events) 198 | } 199 | 200 | pub fn (d Dialog) get_events() int { 201 | return C.gtk_widget_get_events(d.c) 202 | } 203 | 204 | pub fn (d Dialog) add_events(events int) { 205 | C.gtk_widget_add_events(d.c, events) 206 | } 207 | 208 | pub fn (d Dialog) get_toplevel() &C.GtkWidget { 209 | return C.gtk_widget_get_toplevel(d.c) 210 | } 211 | 212 | /* 213 | pub fn (d Dialog) get_ancestor(widget_type C._GType) &C.GtkWidget { 214 | return C.gtk_widget_get_ancestor(d.c, widget_type) 215 | } 216 | */ 217 | pub fn (d Dialog) is_ancestor(ancestor IWidget) bool { 218 | ancestor_ := ancestor.get_gtk_widget() 219 | return C.gtk_widget_is_ancestor(d.c, ancestor_) 220 | } 221 | 222 | pub fn (d Dialog) translate_coordinates(dest_widget IWidget, x int, y int) (int, int) { 223 | dest_widget_ := dest_widget.get_gtk_widget() 224 | out_x := 0 225 | out_y := 0 226 | C.gtk_widget_translate_coordinates(d.c, dest_widget_, x, y, &out_x, &out_y) 227 | return out_x, out_y 228 | } 229 | 230 | pub fn (d Dialog) hide_on_delete() bool { 231 | return C.gtk_widget_hide_on_delete(d.c) 232 | } 233 | 234 | pub fn (d Dialog) set_direction(direction TextDirection) { 235 | C.gtk_widget_set_direction(d.c, direction) 236 | } 237 | 238 | pub fn (d Dialog) get_direction() TextDirection { 239 | return TextDirection(C.gtk_widget_get_direction(d.c)) 240 | } 241 | 242 | pub fn (d Dialog) set_default_direction(direction TextDirection) { 243 | C.gtk_widget_set_default_direction(direction) 244 | } 245 | 246 | pub fn (d Dialog) get_default_direction() TextDirection { 247 | return TextDirection(C.gtk_widget_get_default_direction()) 248 | } 249 | 250 | // INHERITED FROM WINDOW 251 | pub fn (d Dialog) set_default_size(width int, height int) { 252 | C.gtk_window_set_default_size(d.c, width, height) 253 | } 254 | 255 | pub fn (d Dialog) get_title() string { 256 | return tos3(C.gtk_window_get_title(d.c)) 257 | } 258 | 259 | // IMPLEMENTING IWidget 260 | pub fn (d &Dialog) get_gtk_widget() &C.GtkWidget { 261 | return d.c 262 | } 263 | 264 | // CUSTOM API's 265 | pub fn (d &Dialog) on(event_name string, handler fn (Dialog, voidptr), data voidptr) int { 266 | return int(C.g_signal_connect(d.c, event_name.str, handler, 0)) 267 | } 268 | -------------------------------------------------------------------------------- /gtk/entry.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | pub enum EntryIconPosition { 4 | primary = C.GTK_ENTRY_ICON_PRIMARY 5 | secondary = C.GTK_ENTRY_ICON_SECONDARY 6 | } 7 | 8 | pub enum InputPurpose { 9 | free_form = C.GTK_INPUT_PURPOSE_FREE_FORM 10 | alpha = C.GTK_INPUT_PURPOSE_ALPHA 11 | digits = C.GTK_INPUT_PURPOSE_DIGITS 12 | number = C.GTK_INPUT_PURPOSE_NUMBER 13 | phone = C.GTK_INPUT_PURPOSE_PHONE 14 | url = C.GTK_INPUT_PURPOSE_URL 15 | email = C.GTK_INPUT_PURPOSE_EMAIL 16 | name = C.GTK_INPUT_PURPOSE_NAME 17 | password = C.GTK_INPUT_PURPOSE_PASSWORD 18 | pin = C.GTK_INPUT_PURPOSE_PIN 19 | terminal = C.GTK_INPUT_PURPOSE_TERMINAL 20 | } 21 | 22 | pub enum InputHints { 23 | none_ = C.GTK_INPUT_HINT_NONE 24 | spellcheck = C.GTK_INPUT_HINT_SPELLCHECK 25 | no_spellcheck = C.GTK_INPUT_HINT_NO_SPELLCHECK 26 | word_completion = C.GTK_INPUT_HINT_WORD_COMPLETION 27 | lowercase = C.GTK_INPUT_HINT_LOWERCASE 28 | uppercase_chars = C.GTK_INPUT_HINT_UPPERCASE_CHARS 29 | uppercase_words = C.GTK_INPUT_HINT_UPPERCASE_WORDS 30 | uppercase_sentences = C.GTK_INPUT_HINT_UPPERCASE_SENTENCES 31 | inhibit_osk = C.GTK_INPUT_HINT_INHIBIT_OSK 32 | vertical_writing = C.GTK_INPUT_HINT_VERTICAL_WRITING 33 | emoji = C.GTK_INPUT_HINT_EMOJI 34 | no_emoji = C.GTK_INPUT_HINT_NO_EMOJI 35 | } 36 | 37 | pub struct Entry { 38 | c &C.GtkWidget 39 | } 40 | 41 | pub fn new_entry() Entry { 42 | return Entry{C.gtk_entry_new()} 43 | } 44 | 45 | pub fn (e Entry) set_text(text string) { 46 | C.gtk_entry_set_text(e.c, text.str) 47 | } 48 | 49 | pub fn (e Entry) get_text() string { 50 | return tos3(C.gtk_entry_get_text(e.c)) 51 | } 52 | 53 | pub fn (e Entry) get_text_length() u16 { 54 | return u16(C.gtk_entry_get_text_length(e.c)) 55 | } 56 | 57 | // TODO: void C.gtk_entry_get_text_area (GtkEntry *entry, GdkRectangle *text_area) 58 | pub fn (e Entry) set_visibility(visible bool) { 59 | C.gtk_entry_set_visibility(e.c, visible) 60 | } 61 | 62 | pub fn (e Entry) set_invisible_char(ch rune) { 63 | C.gtk_entry_set_invisible_char(e.c, ch) 64 | } 65 | 66 | pub fn (e Entry) unset_invisible_char() { 67 | C.gtk_entry_unset_invisible_char(e.c) 68 | } 69 | 70 | pub fn (e Entry) set_max_length(max int) { 71 | C.gtk_entry_set_max_length(e.c, max) 72 | } 73 | 74 | pub fn (e Entry) get_activates_default() bool { 75 | return C.gtk_entry_get_activates_default(e.c) 76 | } 77 | 78 | pub fn (e Entry) gtk_entry_get_has_frame() bool { 79 | return C.gtk_entry_get_has_frame(e.c) 80 | } 81 | 82 | // WARNING: Has been deprecated since version 3.4 83 | // TODO: const GtkBorder * C.gtk_entry_get_inner_border (GtkEntry *entry) 84 | pub fn (e Entry) get_width_chars() int { 85 | return int(C.gtk_entry_get_width_chars(e.c)) 86 | } 87 | 88 | pub fn (e Entry) get_max_width_chars() int { 89 | return int(C.gtk_entry_get_max_width_chars(e.c)) 90 | } 91 | 92 | pub fn (e Entry) set_activates_default(setting bool) { 93 | C.gtk_entry_set_activates_default(e.c, setting) 94 | } 95 | 96 | pub fn (e Entry) set_has_frame(setting bool) { 97 | C.gtk_entry_set_has_frame(e.c, setting) 98 | } 99 | 100 | // TODO: void C.gtk_entry_set_inner_border (GtkEntry *entry, const GtkBorder *border) 101 | pub fn (e Entry) set_width_chars(n_chars int) { 102 | C.gtk_entry_set_width_chars(e.c, n_chars) 103 | } 104 | 105 | pub fn (e Entry) set_max_width_chars(n_chars int) { 106 | C.gtk_entry_set_max_width_chars(e.c, n_chars) 107 | } 108 | 109 | pub fn (e Entry) get_invisible_char() rune { 110 | return C.gtk_entry_get_invisible_char(e.c) 111 | } 112 | 113 | pub fn (e Entry) set_alignment(xalign f32) { 114 | C.gtk_entry_set_alignment(e.c, xalign) 115 | } 116 | 117 | pub fn (e Entry) get_alignment() f32 { 118 | return C.gtk_entry_get_alignment(e.c) 119 | } 120 | 121 | pub fn (e Entry) set_placeholder_text(text string) { 122 | C.gtk_entry_set_placeholder_text(e.c, text.str) 123 | } 124 | 125 | pub fn (e Entry) get_placeholder_text() string { 126 | return tos3(C.gtk_entry_get_placeholder_text(e.c)) 127 | } 128 | 129 | pub fn (e Entry) set_overwrite_mode(setting bool) { 130 | C.gtk_entry_set_overwrite_mode(e.c, setting) 131 | } 132 | 133 | pub fn (e Entry) get_overwrite_mode() bool { 134 | return C.gtk_entry_get_overwrite_mode(e.c) 135 | } 136 | 137 | // TODO: PangoLayout * C.gtk_entry_get_layout (GtkEntry *entry) 138 | pub fn (e Entry) get_layout_offsets() (int, int) { 139 | x := 0 140 | y := 0 141 | C.gtk_entry_get_layout_offsets(e.c, &x, &y) 142 | return x, y 143 | } 144 | 145 | pub fn (e Entry) layout_index_to_text_index(layout_index int) int { 146 | return int(C.gtk_entry_layout_index_to_text_index(e.c, layout_index)) 147 | } 148 | 149 | pub fn (e Entry) index_to_layout_index(layout_index int) int { 150 | return int(C.gtk_entry_text_index_to_layout_index(e.c, layout_index)) 151 | } 152 | 153 | // TODO: void C.gtk_entry_set_attributes (GtkEntry *entry, PangoAttrList *attrs) 154 | // TODO: PangoAttrList * C.gtk_entry_get_attributes (GtkEntry *entry) 155 | pub fn (e Entry) get_max_length() int { 156 | return int(C.gtk_entry_get_max_length(e.c)) 157 | } 158 | 159 | pub fn (e Entry) get_visibility() bool { 160 | return C.gtk_entry_get_visibility(e.c) 161 | } 162 | 163 | // TODO: void C.gtk_entry_set_completion (GtkEntry *entry, GtkEntryCompletion *completion) 164 | // TODO: GtkEntryCompletion * C.gtk_entry_get_completion (GtkEntry *entry) 165 | // TODO: void C.gtk_entry_set_cursor_hadjustment (GtkEntry *entry, GtkAdjustment *adjustment) 166 | // TODO: GtkAdjustment * C.gtk_entry_get_cursor_hadjustment (GtkEntry *entry) 167 | pub fn (e Entry) set_progress_fraction(fraction f32) { 168 | C.gtk_entry_set_progress_fraction(e.c, fraction) 169 | } 170 | 171 | pub fn (e Entry) get_progress_fraction() f32 { 172 | return f32(C.gtk_entry_get_progress_fraction(e.c)) 173 | } 174 | 175 | pub fn (e Entry) set_progress_pulse_step(fraction f32) { 176 | C.gtk_entry_set_progress_pulse_step(e.c, fraction) 177 | } 178 | 179 | pub fn (e Entry) get_progress_pulse_step() f32 { 180 | return f32(C.gtk_entry_get_progress_pulse_step(e.c)) 181 | } 182 | 183 | pub fn (e Entry) progress_pulse() { 184 | C.gtk_entry_progress_pulse(e.c) 185 | } 186 | 187 | // TODO: gboolean C.gtk_entry_im_context_filter_keypress (GtkEntry *entry, GdkEventKey *event) 188 | pub fn (e Entry) reset_im_context() { 189 | C.gtk_entry_reset_im_context(e.c) 190 | } 191 | 192 | // TODO: PangoTabArray * C.gtk_entry_get_tabs (GtkEntry *entry) 193 | // TODO: void C.gtk_entry_set_tabs (GtkEntry *entry, PangoTabArray *tabs) 194 | pub fn (e Entry) set_icon_from_icon_name(icon_pos EntryIconPosition, icon_name string) { 195 | if icon_name == '' { 196 | C.gtk_entry_set_icon_from_icon_name(e.c, icon_pos, 0) 197 | return 198 | } 199 | C.gtk_entry_set_icon_from_icon_name(e.c, icon_pos, icon_name.str) 200 | } 201 | 202 | // TODO: void C.gtk_entry_set_icon_from_gicon (GtkEntry *entry, GtkEntryIconPosition icon_pos, GIcon *icon) 203 | pub fn (e Entry) get_icon_storage_type(icon_pos EntryIconPosition) ImageType { 204 | return ImageType(C.gtk_entry_get_icon_storage_type(e.c, icon_pos)) 205 | } 206 | 207 | // TODO: GdkPixbuf * C.gtk_entry_get_icon_pixbuf (GtkEntry *entry, GtkEntryIconPosition icon_pos) 208 | pub fn (e Entry) get_icon_name(icon_pos EntryIconPosition) string { 209 | return tos3(C.gtk_entry_get_icon_name(e.c, icon_pos)) 210 | } 211 | 212 | // TODO: GIcon * C.gtk_entry_get_icon_gicon (GtkEntry *entry, GtkEntryIconPosition icon_pos) 213 | pub fn (e Entry) set_icon_activatable(icon_pos EntryIconPosition, activatable bool) { 214 | C.gtk_entry_set_icon_activatable(e.c, icon_pos, activatable) 215 | } 216 | 217 | pub fn (e Entry) get_icon_activatable(icon_pos EntryIconPosition) bool { 218 | return C.gtk_entry_get_icon_activatable(e.c, icon_pos) 219 | } 220 | 221 | pub fn (e Entry) set_icon_sensitive(icon_pos EntryIconPosition, sensitive bool) { 222 | C.gtk_entry_set_icon_sensitive(e.c, icon_pos, sensitive) 223 | } 224 | 225 | pub fn (e Entry) get_icon_sensitive(icon_pos EntryIconPosition) bool { 226 | return C.gtk_entry_get_icon_sensitive(e.c, icon_pos) 227 | } 228 | 229 | pub fn (e Entry) get_icon_at_pos(x int, y int) int { 230 | return int(C.gtk_entry_get_icon_at_pos(e.c, x, y)) 231 | } 232 | 233 | pub fn (e Entry) set_icon_tooltip_text(icon_pos EntryIconPosition, tooltip string) { 234 | if tooltip == '' { 235 | C.gtk_entry_set_icon_tooltip_text(e.c, icon_pos, 0) 236 | } 237 | C.gtk_entry_set_icon_tooltip_text(e.c, icon_pos, tooltip.str) 238 | } 239 | 240 | pub fn (e Entry) get_icon_tooltip_text(icon_pos EntryIconPosition) string { 241 | res := C.gtk_entry_get_icon_tooltip_text(e.c, icon_pos) 242 | return tos3(res) 243 | } 244 | 245 | pub fn (e Entry) set_icon_tooltip_markup(icon_pos EntryIconPosition, tooltip string) { 246 | if tooltip == '' { 247 | C.gtk_entry_set_icon_tooltip_markup(e.c, icon_pos, 0) 248 | } 249 | C.gtk_entry_set_icon_tooltip_markup(e.c, icon_pos, tooltip.str) 250 | } 251 | 252 | pub fn (e Entry) get_icon_tooltip_markup(icon_pos EntryIconPosition) string { 253 | res := C.gtk_entry_get_icon_tooltip_markup(e.c, icon_pos) 254 | return tos3(res) 255 | } 256 | 257 | // TODO: void C.gtk_entry_set_icon_drag_source (GtkEntry *entry, GtkEntryIconPosition icon_pos, GtkTargetList *target_list, GdkDragAction actions) 258 | pub fn (e Entry) get_current_icon_drag_source() int { 259 | return int(C.gtk_entry_get_current_icon_drag_source(e.c)) 260 | } 261 | 262 | // TODO void C.gtk_entry_get_icon_area (GtkEntry *entry, GtkEntryIconPosition icon_pos, GdkRectangle *icon_area) 263 | pub fn (e Entry) set_input_purpose(purpose InputPurpose) { 264 | C.gtk_entry_set_input_purpose(e.c, purpose) 265 | } 266 | 267 | pub fn (e Entry) get_input_purpose() InputPurpose { 268 | return InputPurpose(C.gtk_entry_get_input_purpose(e.c)) 269 | } 270 | 271 | pub fn (e Entry) set_input_hints(hints InputHints) { 272 | C.gtk_entry_set_input_hints(e.c, hints) 273 | } 274 | 275 | pub fn (e Entry) get_input_hints() InputHints { 276 | return InputHints(C.gtk_entry_get_input_hints(e.c)) 277 | } 278 | 279 | pub fn (e Entry) grab_focus_without_selecting() { 280 | C.gtk_entry_grab_focus_without_selecting(e.c) 281 | } 282 | 283 | // IMPLEMENTING EDITABLE 284 | pub fn (e Entry) set_editable(setting bool) { 285 | C.gtk_editable_set_editable(e.c, setting) 286 | } 287 | 288 | pub fn (e Entry) set_direction(direction TextDirection) { 289 | C.gtk_widget_set_direction(e.c, direction) 290 | } 291 | 292 | // INHERITED FROM WIDGET 293 | pub fn (e Entry) show() { 294 | C.gtk_widget_show(e.c) 295 | } 296 | 297 | pub fn (e Entry) show_all() { 298 | C.gtk_widget_show_all(e.c) 299 | } 300 | 301 | // IMPLEMENTING IWidget 302 | pub fn (e &Entry) get_gtk_widget() &C.GtkWidget { 303 | return e.c 304 | } 305 | 306 | // CUSTOM API's 307 | pub fn (e &Entry) on(event_name string, handler fn (Entry, voidptr), data voidptr) int { 308 | return int(C.g_signal_connect(e.c, event_name.str, handler, data)) 309 | } 310 | -------------------------------------------------------------------------------- /gtk/enums.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | pub enum Justification { 4 | left = C.GTK_JUSTIFY_LEFT 5 | right = C.GTK_JUSTIFY_RIGHT 6 | center = C.GTK_JUSTIFY_CENTER 7 | fill = C.GTK_JUSTIFY_FILL 8 | } 9 | 10 | pub enum IconSize { 11 | invalid = C.GTK_ICON_SIZE_INVALID 12 | menu = C.GTK_ICON_SIZE_MENU 13 | small_toolbar = C.GTK_ICON_SIZE_SMALL_TOOLBAR 14 | large_toolbar = C.GTK_ICON_SIZE_LARGE_TOOLBAR 15 | button = C.GTK_ICON_SIZE_BUTTON 16 | dnd = C.GTK_ICON_SIZE_DND 17 | dialog = C.GTK_ICON_SIZE_DIALOG 18 | } 19 | 20 | pub enum ReliefStyle { 21 | normal = C.GTK_RELIEF_NORMAL 22 | half = C.GTK_RELIEF_HALF 23 | none_ = C.GTK_RELIEF_NONE 24 | } 25 | 26 | pub enum TextDirection { 27 | none_ = C.GTK_TEXT_DIR_NONE 28 | ltr = C.GTK_TEXT_DIR_LTR 29 | rtl = C.GTK_TEXT_DIR_RTL 30 | } 31 | 32 | pub enum StateFlags { 33 | normal = C.GTK_STATE_FLAG_NORMAL 34 | active = C.GTK_STATE_FLAG_ACTIVE 35 | prelight = C.GTK_STATE_FLAG_PRELIGHT 36 | selected = C.GTK_STATE_FLAG_SELECTED 37 | insensitive = C.GTK_STATE_FLAG_INSENSITIVE 38 | inconsistent = C.GTK_STATE_FLAG_INCONSISTENT 39 | focused = C.GTK_STATE_FLAG_FOCUSED 40 | backdrop = C.GTK_STATE_FLAG_BACKDROP 41 | dir_ltr = C.GTK_STATE_FLAG_DIR_LTR 42 | dir_rtl = C.GTK_STATE_FLAG_DIR_RTL 43 | link = C.GTK_STATE_FLAG_LINK 44 | visited = C.GTK_STATE_FLAG_VISITED 45 | checked = C.GTK_STATE_FLAG_CHECKED 46 | drop_active = C.GTK_STATE_FLAG_DROP_ACTIVE 47 | } 48 | 49 | pub enum SizeRequestMode { 50 | height_for_width = C.GTK_SIZE_REQUEST_HEIGHT_FOR_WIDTH 51 | width_for_height = C.GTK_SIZE_REQUEST_WIDTH_FOR_HEIGHT 52 | constant_size = C.GTK_SIZE_REQUEST_CONSTANT_SIZE 53 | } 54 | 55 | pub enum Align { 56 | fill = C.GTK_ALIGN_FILL 57 | start = C.GTK_ALIGN_START 58 | end = C.GTK_ALIGN_END 59 | center = C.GTK_ALIGN_CENTER 60 | baseline = C.GTK_ALIGN_BASELINE 61 | } 62 | 63 | pub enum Orientation { 64 | horizontal = C.GTK_ORIENTATION_HORIZONTAL 65 | vertical = C.GTK_ORIENTATION_VERTICAL 66 | } 67 | 68 | pub enum Position { 69 | left = C.GTK_POS_LEFT 70 | right = C.GTK_POS_RIGHT 71 | top = C.GTK_POS_TOP 72 | bottom = C.GTK_POS_BOTTOM 73 | } 74 | 75 | pub enum PackType { 76 | start = C.GTK_PACK_START 77 | end = C.GTK_PACK_END 78 | } 79 | 80 | pub enum BaselinePosition { 81 | top = C.GTK_BASELINE_POSITION_TOP 82 | center = C.GTK_BASELINE_POSITION_CENTER 83 | bottom = C.GTK_BASELINE_POSITION_BOTTOM 84 | } 85 | 86 | pub enum DirectionType { 87 | tab_forward = C.GTK_DIR_TAB_FORWARD 88 | tab_backward = C.GTK_DIR_TAB_BACKWARD 89 | up = C.GTK_DIR_UP 90 | down = C.GTK_DIR_DOWN 91 | left = C.GTK_DIR_LEFT 92 | right = C.GTK_DIR_RIGHT 93 | } 94 | -------------------------------------------------------------------------------- /gtk/grid.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | pub struct Grid { 4 | c &C.GtkWidget 5 | } 6 | 7 | pub fn new_grid() Grid { 8 | return Grid{C.gtk_grid_new()} 9 | } 10 | 11 | pub fn (g Grid) attach(child IWidget, left int, top int, width int, height int) { 12 | wgt := child.get_gtk_widget() 13 | C.gtk_grid_attach(g.c, wgt, left, top, width, height) 14 | } 15 | 16 | pub fn (g Grid) attach_next_to(child IWidget, sibling IWidget, side Position, width int, height int) { 17 | child_ := child.get_gtk_widget() 18 | sibling_ := sibling.get_gtk_widget() 19 | C.gtk_grid_attach_next_to(g.c, child_, sibling_, side, width, height) 20 | } 21 | 22 | pub fn (g Grid) get_child_at(left int, top int) &C.GtkWidget { 23 | return C.gtk_grid_get_child_at(g.c, left, top) 24 | } 25 | 26 | pub fn (g Grid) insert_row(position int) { 27 | C.gtk_grid_insert_row(g.c, position) 28 | } 29 | 30 | pub fn (g Grid) insert_column(position int) { 31 | C.gtk_grid_insert_column(g.c, position) 32 | } 33 | 34 | pub fn (g Grid) remove_row(position int) { 35 | C.gtk_grid_remove_row(g.c, position) 36 | } 37 | 38 | pub fn (g Grid) remove_column(position int) { 39 | C.gtk_grid_remove_column(g.c, position) 40 | } 41 | 42 | pub fn (g Grid) insert_next_to(sibling IWidget, side Position) { 43 | sibling_ := sibling.get_gtk_widget() 44 | C.gtk_grid_insert_next_to(g.c, sibling_, side) 45 | } 46 | 47 | pub fn (g Grid) set_row_homogeneous(homogeneous bool) { 48 | C.gtk_grid_set_row_homogeneous(g.c, homogeneous) 49 | } 50 | 51 | pub fn (g Grid) get_row_homogeneous() bool { 52 | return C.gtk_grid_get_row_homogeneous(g.c) 53 | } 54 | 55 | pub fn (g Grid) set_row_spacing(spacing u32) { 56 | C.gtk_grid_set_row_spacing(g.c, spacing) 57 | } 58 | 59 | pub fn (g Grid) get_row_spacing() u32 { 60 | return C.gtk_grid_get_row_spacing(g.c) 61 | } 62 | 63 | pub fn (g Grid) set_column_homogeneous(homogeneous bool) { 64 | C.gtk_grid_set_column_homogeneous(g.c, homogeneous) 65 | } 66 | 67 | pub fn (g Grid) get_column_homogeneous() bool { 68 | return C.gtk_grid_get_column_homogeneous(g.c) 69 | } 70 | 71 | pub fn (g Grid) set_column_spacing(spacing u32) { 72 | C.gtk_grid_set_column_spacing(g.c, spacing) 73 | } 74 | 75 | pub fn (g Grid) get_column_spacing() u32 { 76 | return C.gtk_grid_get_column_spacing(g.c) 77 | } 78 | 79 | pub fn (g Grid) get_baseline_row() int { 80 | return C.gtk_grid_get_baseline_row(g.c) 81 | } 82 | 83 | pub fn (g Grid) set_baseline_row(row int) { 84 | C.gtk_grid_set_baseline_row(g.c, row) 85 | } 86 | 87 | pub fn (g Grid) get_row_baseline_position(row int) BaselinePosition { 88 | return BaselinePosition(C.gtk_grid_get_row_baseline_position(g.c, row)) 89 | } 90 | 91 | pub fn (g Grid) set_row_baseline_position(row int, pos BaselinePosition) { 92 | C.gtk_grid_set_row_baseline_position(g.c, row, pos) 93 | } 94 | 95 | // INHERITED FROM CONTAINER 96 | pub fn (g Grid) add(widget IWidget) { 97 | wgt := widget.get_gtk_widget() 98 | C.gtk_container_add(g.c, wgt) 99 | } 100 | 101 | pub fn (g Grid) remove(widget IWidget) { 102 | wgt := widget.get_gtk_widget() 103 | C.gtk_container_remove(g.c, wgt) 104 | } 105 | 106 | // IMPLEMENTING GtkOrientable 107 | pub fn (g Grid) set_orientation(orientation Orientation) { 108 | C.gtk_orientable_set_orientation(g.c, orientation) 109 | } 110 | 111 | pub fn (g Grid) get_orientation() Orientation { 112 | return Orientation(C.gtk_orientable_get_orientation(g.c)) 113 | } 114 | 115 | // IMPLEMENTING IWidget 116 | pub fn (g &Grid) get_gtk_widget() &C.GtkWidget { 117 | return g.c 118 | } 119 | -------------------------------------------------------------------------------- /gtk/gtk3.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | #include 4 | // Actual code 5 | fn init() { 6 | C.gtk_init(0, [''].data) // TODO: use os library for arguments 7 | } 8 | 9 | // This function is blocking! 10 | pub fn main() { 11 | C.gtk_main() 12 | } 13 | 14 | pub fn main_quit() { 15 | C.gtk_main_quit() 16 | } 17 | 18 | pub fn add_custom_signal(widget IWidget, name string, handler fn (&C.GtkWidget, IWidget)) int { 19 | w := widget.get_gtk_widget() // must be stored in a variable to avoid some weird C compilation bugs 20 | return int(C.g_signal_connect(voidptr(w), name.str, handler, voidptr(&widget))) 21 | } 22 | 23 | // Castings 24 | pub fn to_widget(widget voidptr) &Widget { 25 | return &Widget(widget) 26 | } 27 | 28 | pub fn to_window(widget voidptr) Window { 29 | return Window{widget} 30 | } 31 | -------------------------------------------------------------------------------- /gtk/gtk3_nix.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | #pkgconfig gtk+-3.0 4 | #pkgconfig harfbuzz 5 | -------------------------------------------------------------------------------- /gtk/image.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | pub enum ImageType { 4 | empty = C.GTK_IMAGE_EMPTY 5 | pixbuf = C.GTK_IMAGE_PIXBUF 6 | stock = C.GTK_IMAGE_STOCK 7 | icon_set = C.GTK_IMAGE_ICON_SET 8 | animation = C.GTK_IMAGE_ANIMATION 9 | icon_name = C.GTK_IMAGE_ICON_NAME 10 | gicon = C.GTK_IMAGE_GICON 11 | surface = C.GTK_IMAGE_SURFACE 12 | } 13 | -------------------------------------------------------------------------------- /gtk/interfaces.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | pub interface IWidget { 4 | get_gtk_widget() &C.GtkWidget 5 | } 6 | 7 | pub interface IContainer { 8 | add(IWidget) 9 | } 10 | -------------------------------------------------------------------------------- /gtk/label.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | pub struct Label { 4 | c &C.GtkWidget 5 | } 6 | 7 | pub fn new_label(label string) Label { 8 | return Label{C.gtk_label_new(label.str)} 9 | } 10 | 11 | pub fn new_empty_label() Label { 12 | return Label{C.gtk_label_new(0)} 13 | } 14 | 15 | pub fn (l Label) set_text(label string) { 16 | C.gtk_label_set_text(l.c, label.str) 17 | } 18 | 19 | // TODO: C.gtk_label_set_attributes() 20 | pub fn (l Label) set_markup(str string) { 21 | C.gtk_label_set_markup(l.c, str.str) 22 | } 23 | 24 | pub fn (l Label) set_markup_with_mnemonic(str string) { 25 | C.gtk_label_set_markup_with_mnemonic(l.c, str.str) 26 | } 27 | 28 | pub fn (l Label) set_pattern(pattern string) { 29 | C.gtk_label_set_pattern(l.c, pattern.str) 30 | } 31 | 32 | pub fn (l Label) set_justify(jtype Justification) { 33 | C.gtk_label_set_justify(l.c, jtype) 34 | } 35 | 36 | pub fn (l Label) set_xalign(xalign f32) { 37 | if xalign > 1 || xalign < 0 { 38 | panic('vgtk3.gtk.label.set_xalign: val must between 0 and 1') 39 | } 40 | C.gtk_label_set_xalign(l.c, xalign) 41 | } 42 | 43 | pub fn (l Label) set_yalign(yalign f32) { 44 | if yalign > 1 || yalign < 0 { 45 | panic('vgtk3.gtk.label.set_yalign: val must between 0 and 1') 46 | } 47 | C.gtk_label_set_yalign(l.c, yalign) 48 | } 49 | 50 | // TODO: C.gtk_label_set_ellipsize() 51 | pub fn (l Label) set_width_chars(n_chars int) { 52 | C.gtk_label_set_width_chars(l.c, n_chars) 53 | } 54 | 55 | pub fn (l Label) set_max_width_chars(n_chars int) { 56 | C.gtk_label_set_max_width_chars(l.c, n_chars) 57 | } 58 | 59 | pub fn (l Label) set_line_wrap(setting bool) { 60 | C.gtk_label_set_line_wrap(l.c, setting) 61 | } 62 | 63 | // TODO: C.gtk_label_set_line_wrap_mode() 64 | pub fn (l Label) set_lines(lines int) { 65 | C.gtk_label_set_lines(l.c, lines) 66 | } 67 | 68 | pub fn (l Label) get_layout_offsets() (int, int) { 69 | x := 0 70 | y := 0 71 | C.gtk_label_get_layout_offsets(l.c, &x, &y) 72 | return x, y 73 | } 74 | 75 | pub fn (l Label) get_mnemonic_keyval() u32 { 76 | return C.gtk_label_get_mnemonic_keyval(l.c) 77 | } 78 | 79 | pub fn (l Label) get_selectable() bool { 80 | return C.gtk_label_get_selectable(l.c) 81 | } 82 | 83 | pub fn (l Label) get_text() string { 84 | return tos3(C.gtk_label_get_text(l.c)) 85 | } 86 | 87 | pub fn new_label_with_mnemonic(label string) Label { 88 | return Label{C.gtk_label_new_with_mnemonic(label.str)} 89 | } 90 | 91 | pub fn (l Label) select_region(start_offset int, end_offset int) { 92 | C.gtk_label_select_region(l.c, start_offset, end_offset) 93 | } 94 | 95 | pub fn (l Label) set_mnemonic_widget(widget IWidget) { 96 | wgt := widget.get_gtk_widget() 97 | C.gtk_label_set_mnemonic_widget(l.c, wgt) 98 | } 99 | 100 | pub fn (l Label) set_selectable(setting bool) { 101 | C.gtk_label_set_selectable(l.c, setting) 102 | } 103 | 104 | pub fn (l Label) set_text_with_mnemonic(str string) { 105 | C.gtk_label_set_text_with_mnemonic(l.c, str.str) 106 | } 107 | 108 | pub fn (l Label) get_justify() Justification { 109 | return Justification(C.gtk_label_get_justify(l.c)) 110 | } 111 | 112 | pub fn (l Label) get_xalign() f32 { 113 | return C.gtk_label_get_xalign(l.c) 114 | } 115 | 116 | pub fn (l Label) get_yalign() f32 { 117 | return C.gtk_label_get_yalign(l.c) 118 | } 119 | 120 | // TODO: PangoEllipsizeMode C.gtk_label_get_ellipsize (GtkLabel *label) 121 | pub fn (l Label) get_width_chars() int { 122 | return C.gtk_label_get_width_chars(l.c) 123 | } 124 | 125 | pub fn (l Label) get_max_width_chars() int { 126 | return C.gtk_label_get_max_width_chars(l.c) 127 | } 128 | 129 | pub fn (l Label) get_label() string { 130 | return tos3(C.gtk_label_get_label(l.c)) 131 | } 132 | 133 | // TODO: PangoLayout * C.gtk_label_get_layout (GtkLabel *label) 134 | pub fn (l Label) get_line_wrap() bool { 135 | return C.gtk_label_get_line_wrap(l.c) 136 | } 137 | 138 | // TODO: PangoWrapMode C.gtk_label_get_line_wrap_mode (GtkLabel *label) 139 | pub fn (l Label) get_lines() int { 140 | return C.gtk_label_get_lines(l.c) 141 | } 142 | 143 | pub fn (l Label) get_mnemonic_widget() &C.GtkWidget { 144 | return C.gtk_label_get_mnemonic_widget(l.c) 145 | } 146 | 147 | pub fn (l Label) get_selection_bounds() (int, int) { 148 | start := 0 149 | end := 0 150 | C.gtk_label_get_selection_bounds(l.c, &start, &end) 151 | return start, end 152 | } 153 | 154 | pub fn (l Label) get_use_markup() bool { 155 | return C.gtk_label_get_use_markup(l.c) 156 | } 157 | 158 | pub fn (l Label) get_use_underline() bool { 159 | return C.gtk_label_get_use_underline(l.c) 160 | } 161 | 162 | pub fn (l Label) get_single_line_mode() bool { 163 | return C.gtk_label_get_single_line_mode(l.c) 164 | } 165 | 166 | pub fn (l Label) get_angle() f64 { 167 | return C.gtk_label_get_angle(l.c) 168 | } 169 | 170 | pub fn (l Label) set_label(str string) { 171 | C.gtk_label_set_label(l.c, str.str) 172 | } 173 | 174 | pub fn (l Label) set_use_markup(setting bool) { 175 | C.gtk_label_set_use_markup(l.c, setting) 176 | } 177 | 178 | pub fn (l Label) set_use_underline(setting bool) { 179 | C.gtk_label_set_use_underline(l.c, setting) 180 | } 181 | 182 | pub fn (l Label) set_single_line_mode(setting bool) { 183 | C.gtk_label_set_single_line_mode(l.c, setting) 184 | } 185 | 186 | pub fn (l Label) set_angle(angle f64) { 187 | C.gtk_label_set_angle(l.c, angle) 188 | } 189 | 190 | pub fn (l Label) get_current_uri() string { 191 | return tos3(C.gtk_label_get_current_uri(l.c)) 192 | } 193 | 194 | pub fn (l Label) set_track_visited_links(setting bool) { 195 | C.gtk_label_set_track_visited_links(l.c, setting) 196 | } 197 | 198 | pub fn (l Label) get_track_visited_links() bool { 199 | return C.gtk_label_get_track_visited_links(l.c) 200 | } 201 | 202 | pub fn (l &Label) get_gtk_widget() &C.GtkWidget { 203 | return l.c 204 | } 205 | 206 | // Implemented Widget 207 | pub fn (l Label) show() { 208 | C.gtk_widget_show(l.c) 209 | } 210 | -------------------------------------------------------------------------------- /gtk/menu.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | pub struct MenuBar { 4 | c &C.GtkWidget 5 | } 6 | 7 | pub struct Menu { 8 | c &C.GtkWidget 9 | } 10 | 11 | pub struct MenuItem { 12 | c &C.GtkWidget 13 | } 14 | 15 | /// CONSTRUCTORS 16 | pub fn new_menu_bar() MenuBar { 17 | return MenuBar{C.gtk_menu_bar_new()} 18 | } 19 | 20 | pub fn new_menu() Menu { 21 | return Menu{C.gtk_menu_new()} 22 | } 23 | 24 | pub fn new_separator_menu_item() MenuItem { 25 | return MenuItem{C.gtk_separator_menu_item_new()} 26 | } 27 | 28 | pub fn new_menu_item_with_label(label string) MenuItem { 29 | return MenuItem{C.gtk_menu_item_new_with_label(label.str)} 30 | } 31 | 32 | pub fn new_menu_item() MenuItem { 33 | return MenuItem{C.gtk_menu_item_new()} 34 | } 35 | 36 | // MENUBAR 37 | pub fn (mb &MenuBar) get_gtk_widget() &C.GtkWidget { 38 | return mb.c 39 | } 40 | 41 | pub fn (mb MenuBar) append(item MenuItem) { 42 | C.gtk_menu_shell_append(mb.c, item.c) 43 | } 44 | 45 | // MENU 46 | pub fn (m &Menu) get_gtk_widget() &C.GtkWidget { 47 | return m.c 48 | } 49 | 50 | pub fn (m Menu) append(item MenuItem) { 51 | C.gtk_menu_shell_append(m.c, item.c) 52 | } 53 | 54 | // MENUITEM 55 | pub fn (mi MenuItem) set_submenu(menu Menu) { 56 | C.gtk_menu_item_set_submenu(mi.c, menu.c) 57 | } 58 | 59 | pub fn (mi &MenuItem) on(event_name string, handler fn (MenuItem, voidptr), data voidptr) int { 60 | return int(C.g_signal_connect(mi.c, event_name.str, handler, data)) 61 | } 62 | 63 | pub fn (mi MenuItem) set_label(label string) { 64 | C.gtk_menu_item_set_label(mi.c, label.str) 65 | } 66 | 67 | pub fn (mi MenuItem) get_label() string { 68 | return tos3(C.gtk_menu_item_get_label(mi.c)) 69 | } 70 | 71 | pub fn (mi MenuItem) get_use_underline() bool { 72 | return C.gtk_menu_item_get_use_underline(mi.c) 73 | } 74 | 75 | pub fn (mi MenuItem) set_use_underline(under bool) { 76 | C.gtk_menu_item_set_use_underline(mi.c, under) 77 | } 78 | 79 | pub fn (mi MenuItem) set_accel_path(label string) { 80 | C.gtk_menu_item_set_accel_path(mi.c, label.str) 81 | } 82 | 83 | pub fn (mi MenuItem) get_accel_path() string { 84 | return tos3(C.gtk_menu_item_get_accel_path(mi.c)) 85 | } 86 | 87 | pub fn (mi &MenuItem) get_gtk_widget() &C.GtkWidget { 88 | return mi.c 89 | } 90 | -------------------------------------------------------------------------------- /gtk/message_dialog.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | pub enum MessageType { 4 | info = C.GTK_MESSAGE_INFO 5 | warning = C.GTK_MESSAGE_WARNING 6 | question = C.GTK_MESSAGE_QUESTION 7 | error = C.GTK_MESSAGE_ERROR 8 | other = C.GTK_MESSAGE_OTHER 9 | } 10 | 11 | pub enum ButtonsType { 12 | none_ = C.GTK_BUTTONS_NONE 13 | ok = C.GTK_BUTTONS_OK 14 | close = C.GTK_BUTTONS_CLOSE 15 | cancel = C.GTK_BUTTONS_CANCEL 16 | yes_no = C.GTK_BUTTONS_YES_NO 17 | ok_cancel = C.GTK_BUTTONS_OK_CANCEL 18 | } 19 | 20 | pub struct MessageDialog { 21 | c &C.GtkWidget 22 | } 23 | 24 | pub fn new_message_dialog(parent Window, flags DialogFlags, message_type MessageType, buttons ButtonsType, message_format string) MessageDialog { 25 | return MessageDialog{C.gtk_message_dialog_new(parent.c, flags, message_type, buttons, 26 | message_format.str)} 27 | } 28 | 29 | pub fn new_message_dialog_with_markup(parent Window, flags DialogFlags, message_type MessageType, buttons ButtonsType, message_format string) MessageDialog { 30 | return MessageDialog{C.gtk_message_dialog_new_with_markup(parent.c, flags, message_type, 31 | buttons, message_format.str)} 32 | } 33 | 34 | pub fn (m MessageDialog) dialog_set_markup(str string) { 35 | C.gtk_message_dialog_set_markup(m.c, str.str) 36 | } 37 | 38 | pub fn (m MessageDialog) format_secondary_text(message_format string) { 39 | C.gtk_message_dialog_format_secondary_text(m.c, message_format.str) 40 | } 41 | 42 | pub fn (m MessageDialog) format_secondary_markup(message_format string) { 43 | C.gtk_message_dialog_format_secondary_markup(m.c, message_format.str) 44 | } 45 | 46 | pub fn (m MessageDialog) get_message_area() Widget { 47 | return Widget{C.gtk_message_dialog_get_message_area(m.c)} 48 | } 49 | 50 | // Inherited from Dialog 51 | pub fn (m MessageDialog) run() ResponseType { 52 | return ResponseType(C.gtk_dialog_run(m.c)) 53 | } 54 | 55 | pub fn (m MessageDialog) response(response_id ResponseType) { 56 | C.gtk_dialog_response(m.c, response_id) 57 | } 58 | 59 | pub fn (m MessageDialog) add_button(button_text string, response_id ResponseType) Button { 60 | return Button{C.gtk_dialog_add_button(m.c, button_text.str, response_id)} 61 | } 62 | 63 | // TODO: void C.gtk_dialog_add_buttons (GtkDialog *dialog, const gchar *first_button_text, ...) 64 | pub fn (m MessageDialog) add_action_widget(child IWidget, response_id ResponseType) { 65 | child_ := child.get_gtk_widget() 66 | C.gtk_dialog_add_action_widget(m.c, child_, response_id) 67 | } 68 | 69 | pub fn (m MessageDialog) set_default_response(response_id ResponseType) { 70 | C.gtk_dialog_set_default_response(m.c, response_id) 71 | } 72 | 73 | pub fn (m MessageDialog) set_response_sensitive(response_id ResponseType, setting bool) { 74 | C.gtk_dialog_set_response_sensitive(m.c, response_id, setting) 75 | } 76 | 77 | pub fn (m MessageDialog) get_response_for_widget(widget IWidget) int { 78 | widget_ := widget.get_gtk_widget() 79 | return C.gtk_dialog_get_response_for_widget(m.c, widget_) 80 | } 81 | 82 | pub fn (m MessageDialog) get_widget_for_response(response_id ResponseType) &Widget { 83 | widget := C.gtk_dialog_get_widget_for_response(m.c, response_id) 84 | if widget == 0 { 85 | return 0 86 | } 87 | return &Widget{widget} 88 | } 89 | 90 | pub fn (m MessageDialog) get_content_area() Box { 91 | widget := C.gtk_dialog_get_content_area(m.c) 92 | return Box{widget} 93 | } 94 | 95 | pub fn (m MessageDialog) get_header_bar() &Widget { 96 | widget := C.gtk_dialog_get_header_bar(m.c) 97 | if widget == 0 { 98 | return 0 99 | } 100 | return &Widget{widget} 101 | } 102 | 103 | // Inherited from Window 104 | // TODO 105 | // Inherited from Widget 106 | pub fn (m MessageDialog) destroy() { 107 | C.gtk_widget_destroy(m.c) 108 | } 109 | -------------------------------------------------------------------------------- /gtk/paned.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | pub struct Paned { 4 | c &C.GtkWidget 5 | } 6 | 7 | pub fn new_paned(orientation Orientation) Paned { 8 | return Paned{C.gtk_paned_new(orientation)} 9 | } 10 | 11 | pub fn (b Paned) add1(widget IWidget) { 12 | wgt := widget.get_gtk_widget() 13 | C.gtk_paned_add1(b.c, wgt) 14 | } 15 | 16 | pub fn (b Paned) add2(widget IWidget) { 17 | wgt := widget.get_gtk_widget() 18 | C.gtk_paned_add2(b.c, wgt) 19 | } 20 | 21 | pub fn (b Paned) set_wide_handle(wide bool) { 22 | C.gtk_paned_set_wide_handle(b.c, wide) 23 | } 24 | 25 | pub fn (b Paned) set_position(pos int) { 26 | C.gtk_paned_set_position(b.c, pos) 27 | } 28 | 29 | // INHERITED FROM WIDGET 30 | pub fn (b &Paned) show() { 31 | C.gtk_widget_show(b.c) 32 | } 33 | 34 | // IMPLEMENTING IWidget 35 | pub fn (b &Paned) get_gtk_widget() &C.GtkWidget { 36 | return b.c 37 | } 38 | 39 | // CUSTOM API's 40 | pub fn (b &Paned) on(event_name string, handler fn (Paned, voidptr), data voidptr) int { 41 | return int(C.g_signal_connect(b.c, event_name.str, handler, data)) 42 | } 43 | -------------------------------------------------------------------------------- /gtk/radio_button.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | import glib 4 | 5 | pub struct RadioButton { 6 | c &C.GtkWidget 7 | } 8 | 9 | pub fn new_radio_button(group glib.SList) RadioButton { 10 | return RadioButton{C.gtk_radio_button_new(group.get_cptr())} 11 | } 12 | 13 | pub fn new_radio_button_from_widget(radio_group_member RadioButton) RadioButton { 14 | return RadioButton{C.gtk_radio_button_new_from_widget(radio_group_member.c)} 15 | } 16 | 17 | pub fn new_radio_button_with_label(group glib.SList, label string) RadioButton { 18 | return RadioButton{C.gtk_radio_button_new_with_label(group.get_cptr(), label.str)} 19 | } 20 | 21 | pub fn new_radio_button_with_label_from_widget(radio_group_member RadioButton, label string) RadioButton { 22 | return RadioButton{C.gtk_radio_button_new_with_label_from_widget(radio_group_member.c, 23 | label.str)} 24 | } 25 | 26 | pub fn new_radio_button_with_mnemonic(group glib.SList, label string) RadioButton { 27 | return RadioButton{C.gtk_radio_button_new_with_mnemonic(group.get_cptr(), label.str)} 28 | } 29 | 30 | pub fn new_radio_button_with_mnemonic_from_widget(radio_group_member RadioButton, label string) RadioButton { 31 | return RadioButton{C.gtk_radio_button_new_with_mnemonic_from_widget(radio_group_member.c, 32 | label.str)} 33 | } 34 | 35 | pub fn (r RadioButton) set_group(group glib.SList) { 36 | C.gtk_radio_button_set_group(r.c, group.get_cptr()) 37 | } 38 | 39 | pub fn (r RadioButton) get_group() glib.SList { 40 | return glib.SList{C.gtk_radio_button_get_group(r.c)} 41 | } 42 | 43 | pub fn (r RadioButton) join_group(group_source RadioButton) { 44 | C.gtk_radio_button_join_group(r.c, group_source.c) 45 | } 46 | -------------------------------------------------------------------------------- /gtk/requested_size.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | pub struct RequestedSize { 4 | c &C.GtkRequestedSize 5 | } 6 | -------------------------------------------------------------------------------- /gtk/requisition.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | pub struct Requisition { 4 | c &C.GtkRequisition 5 | } 6 | 7 | pub fn new_requisition() Requisition { 8 | return Requisition{C.gtk_requisition_new()} 9 | } 10 | 11 | pub fn (r Requisition) copy() Requisition { 12 | return Requisition{C.gtk_requisition_copy(r.c)} 13 | } 14 | 15 | [unsafe] 16 | pub fn (r Requisition) free() { 17 | C.gtk_requisition_free(r.c) 18 | } 19 | -------------------------------------------------------------------------------- /gtk/scrolled_window.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | pub struct ScrolledWindow { 4 | c &C.GtkWidget 5 | } 6 | 7 | pub fn new_scrolled_window() ScrolledWindow { 8 | return ScrolledWindow{C.gtk_scrolled_window_new(0, 0)} 9 | } 10 | 11 | pub fn (b ScrolledWindow) add(widget IWidget) { 12 | wgt := widget.get_gtk_widget() 13 | C.gtk_container_add(b.c, wgt) 14 | } 15 | 16 | // INHERITED FROM WIDGET 17 | pub fn (b &ScrolledWindow) show() { 18 | C.gtk_widget_show(b.c) 19 | } 20 | 21 | // IMPLEMENTING IWidget 22 | pub fn (b &ScrolledWindow) get_gtk_widget() &C.GtkWidget { 23 | return b.c 24 | } 25 | 26 | // CUSTOM API's 27 | pub fn (b &ScrolledWindow) on(event_name string, handler fn (ScrolledWindow, voidptr), data voidptr) int { 28 | return int(C.g_signal_connect(b.c, event_name.str, handler, data)) 29 | } 30 | -------------------------------------------------------------------------------- /gtk/style_context.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | pub struct StyleContext { 4 | c &C.GtkStyleContext 5 | } 6 | 7 | pub fn (sc &StyleContext) get_cptr() &C.GtkStyleContext { 8 | return sc.c 9 | } 10 | -------------------------------------------------------------------------------- /gtk/text_view.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | pub struct TextView { 4 | c &C.GtkWidget 5 | } 6 | 7 | pub fn new_text_view() TextView { 8 | return TextView{C.gtk_text_view_new()} 9 | } 10 | 11 | pub fn (b TextView) set_editable(e bool) { 12 | C.gtk_text_view_set_editable(b.c, e) 13 | } 14 | 15 | pub fn (tv TextView) set_text(text string) { 16 | // TODO. add the Gtk.TextBuffer API 17 | tt := C.gtk_text_tag_table_new() 18 | b := C.gtk_text_buffer_new(tt) 19 | C.gtk_text_buffer_set_text(b, text.str, -1) 20 | C.gtk_text_view_set_buffer(tv.c, b) 21 | } 22 | 23 | pub fn (tv TextView) get_text() string { 24 | b := C.gtk_text_view_get_buffer(tv.c) 25 | mut start := GtkTextIter{} 26 | mut end := GtkTextIter{} 27 | C.gtk_text_buffer_get_bounds(b, &start, &end) 28 | text := C.gtk_text_buffer_get_text(b, &start, &end, false) 29 | if text != 0 { 30 | return tos2(text) 31 | } 32 | return '' 33 | } 34 | 35 | // INHERITED FROM WIDGET 36 | pub fn (b &TextView) show() { 37 | C.gtk_widget_show(b.c) 38 | } 39 | 40 | // IMPLEMENTING IWidget 41 | pub fn (b &TextView) get_gtk_widget() &C.GtkWidget { 42 | return b.c 43 | } 44 | 45 | // CUSTOM API's 46 | pub fn (b &TextView) on(event_name string, handler fn (TextView, voidptr), data voidptr) int { 47 | return int(C.g_signal_connect(b.c, event_name.str, handler, data)) 48 | } 49 | -------------------------------------------------------------------------------- /gtk/toggle_button.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | pub struct ToggleButton { 4 | c &C.GtkWidget 5 | } 6 | 7 | pub fn new_toggle_button() ToggleButton { 8 | return ToggleButton{C.gtk_toggle_button_new()} 9 | } 10 | 11 | pub fn new_toggle_button_with_label(label string) ToggleButton { 12 | return ToggleButton{C.gtk_toggle_button_new_with_label(label.str)} 13 | } 14 | 15 | pub fn new_toggle_button_with_mnemonic(label string) ToggleButton { 16 | return ToggleButton{C.gtk_toggle_button_new_with_mnemonic(label.str)} 17 | } 18 | 19 | pub fn (t ToggleButton) set_mode(draw_indicator bool) { 20 | C.gtk_toggle_button_set_mode(t.c, draw_indicator) 21 | } 22 | 23 | pub fn (t ToggleButton) get_mode() bool { 24 | return C.gtk_toggle_button_get_mode(t.c) 25 | } 26 | 27 | pub fn (t ToggleButton) toggled() { 28 | C.gtk_toggle_button_toggled(t.c) 29 | } 30 | 31 | pub fn (t ToggleButton) get_active() bool { 32 | return C.gtk_toggle_button_get_active(t.c) 33 | } 34 | 35 | pub fn (t ToggleButton) set_active(is_active bool) { 36 | C.gtk_toggle_button_set_active(t.c, is_active) 37 | } 38 | 39 | pub fn (t ToggleButton) get_inconsistent() bool { 40 | return C.gtk_toggle_button_get_inconsistent(t.c) 41 | } 42 | 43 | pub fn (t ToggleButton) set_inconsistent(setting bool) { 44 | C.gtk_toggle_button_set_inconsistent(t.c, setting) 45 | } 46 | -------------------------------------------------------------------------------- /gtk/utils.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | fn carray_string_to_array_string(arr &charptr) []string { 4 | mut arr_str := []string{} 5 | if isnil(arr) { 6 | return arr_str 7 | } 8 | mut i := 0 9 | for { 10 | elem := unsafe { byteptr(arr[i]) } 11 | if elem == 0 { 12 | break 13 | } 14 | arr_str << tos_clone(elem) 15 | i++ 16 | } 17 | unsafe { free(arr) } 18 | return arr_str 19 | } 20 | 21 | // intptr 22 | fn carray_int_to_array_int(arr &voidptr) []int { 23 | mut arr_int := []int{} 24 | if isnil(arr) { 25 | return arr_int 26 | } 27 | mut i := 0 28 | for { 29 | elem := unsafe { int(arr[i]) } 30 | if elem == 0 { 31 | break 32 | } 33 | arr_int << elem 34 | i++ 35 | } 36 | unsafe { free(arr) } 37 | return arr_int 38 | } 39 | -------------------------------------------------------------------------------- /gtk/widget.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | import gdk 4 | import gio 5 | 6 | pub struct Widget { 7 | c &C.GtkWidget 8 | } 9 | 10 | pub fn (w Widget) destroy() { 11 | C.gtk_widget_destroy(w.c) 12 | } 13 | 14 | pub fn (w Widget) in_destruction() bool { 15 | return C.gtk_widget_in_destruction(w.c) 16 | } 17 | 18 | pub fn (w Widget) destroyed(widget IWidget) { 19 | wgt := widget.get_gtk_widget() 20 | C.gtk_widget_destroyed(w.c, wgt) 21 | } 22 | 23 | pub fn (w Widget) unparent() { 24 | C.gtk_widget_unparent(w.c) 25 | } 26 | 27 | pub fn (w Widget) show() { 28 | C.gtk_widget_show(w.c) 29 | } 30 | 31 | pub fn (w Widget) show_now() { 32 | C.gtk_widget_show_now(w.c) 33 | } 34 | 35 | pub fn (w Widget) hide() { 36 | C.gtk_widget_hide(w.c) 37 | } 38 | 39 | pub fn (w Widget) show_all() { 40 | C.gtk_widget_show_all(w.c) 41 | } 42 | 43 | pub fn (w Widget) map() { 44 | C.gtk_widget_map(w.c) 45 | } 46 | 47 | pub fn (w Widget) unmap() { 48 | C.gtk_widget_unmap(w.c) 49 | } 50 | 51 | pub fn (w Widget) realize() { 52 | C.gtk_widget_realize(w.c) 53 | } 54 | 55 | pub fn (w Widget) unrealize() { 56 | C.gtk_widget_unrealize(w.c) 57 | } 58 | 59 | // TODO: void C.gtk_widget_draw (GtkWidget *widget, cairo_t *cr) 60 | pub fn (w Widget) queue_draw() { 61 | C.gtk_widget_queue_draw(w.c) 62 | } 63 | 64 | pub fn (w Widget) queue_resize() { 65 | C.gtk_widget_queue_resize(w.c) 66 | } 67 | 68 | pub fn (w Widget) queue_resize_no_redraw() { 69 | C.gtk_widget_queue_resize_no_redraw(w.c) 70 | } 71 | 72 | pub fn (w Widget) queue_allocate() { 73 | C.gtk_widget_queue_allocate(w.c) 74 | } 75 | 76 | // TODO: GdkFrameClock * C.gtk_widget_get_frame_clock (GtkWidget *widget) 77 | pub fn (w Widget) get_scale_factor() int { 78 | return C.gtk_widget_get_scale_factor(w.c) 79 | } 80 | 81 | pub fn (w Widget) remove_tick_callback(id u32) { 82 | C.gtk_widget_remove_tick_callback(w.c, id) 83 | } 84 | 85 | // TODO: void C.gtk_widget_size_allocate (GtkWidget *widget, GtkAllocation *allocation) 86 | // TODO: void C.gtk_widget_size_allocate_with_baseline (GtkWidget *widget, GtkAllocation *allocation, gint baseline) 87 | // TODO: void C.gtk_widget_add_accelerator (GtkWidget *widget, const gchar *accel_signal, GtkAccelGroup *accel_group, guint accel_key, GdkModifierType accel_mods, GtkAccelFlags accel_flags) 88 | // TODO: gboolean C.gtk_widget_remove_accelerator (GtkWidget *widget, GtkAccelGroup *accel_group, guint accel_key, GdkModifierType accel_mods) 89 | // TODO: void C.gtk_widget_set_accel_path (GtkWidget *widget, const gchar *accel_path, GtkAccelGroup *accel_group) 90 | // TODO: GList * C.gtk_widget_list_accel_closures (GtkWidget *widget) 91 | pub fn (w Widget) can_activate_accel(signal_id int) bool { 92 | return C.gtk_widget_can_activate_accel(w.c, signal_id) 93 | } 94 | 95 | // TODO: gboolean C.gtk_widget_event (GtkWidget *widget, GdkEvent *event) 96 | pub fn (w Widget) activate() bool { 97 | return C.gtk_widget_activate(w.c) 98 | } 99 | 100 | // TODO: gboolean C.gtk_widget_intersect (GtkWidget *widget, const GdkRectangle *area, GdkRectangle *intersection) 101 | pub fn (w Widget) is_focus() bool { 102 | return C.gtk_widget_is_focus(w.c) 103 | } 104 | 105 | pub fn (w Widget) grab_focus() { 106 | C.gtk_widget_grab_focus(w.c) 107 | } 108 | 109 | pub fn (w Widget) grab_default() { 110 | C.gtk_widget_grab_default(w.c) 111 | } 112 | 113 | pub fn (w Widget) set_name(name string) { 114 | C.gtk_widget_set_name(w.c, name.str) 115 | } 116 | 117 | pub fn (w Widget) set_sensitive(sensitive bool) { 118 | C.gtk_widget_set_sensitive(w.c, sensitive) 119 | } 120 | 121 | pub fn (w Widget) set_parent(parent IWidget) { 122 | parent_ := parent.get_gtk_widget() 123 | C.gtk_widget_set_parent(w.c, parent_) 124 | } 125 | 126 | // TODO: void C.gtk_widget_set_parent_window (GtkWidget *widget, GdkWindow *parent_window) 127 | // TODO: GdkWindow * C.gtk_widget_get_parent_window (GtkWidget *widget) 128 | pub fn (w Widget) set_events(events int) { 129 | C.gtk_widget_set_events(w.c, events) 130 | } 131 | 132 | pub fn (w Widget) get_events() int { 133 | return C.gtk_widget_get_events(w.c) 134 | } 135 | 136 | pub fn (w Widget) add_events(events int) { 137 | C.gtk_widget_add_events(w.c, events) 138 | } 139 | 140 | // TODO: void C.gtk_widget_set_device_events (GtkWidget *widget, GdkDevice *device, GdkEventMask events) 141 | // TODO: GdkEventMask C.gtk_widget_get_device_events (GtkWidget *widget, GdkDevice *device) 142 | // TODO: void C.gtk_widget_add_device_events (GtkWidget *widget, GdkDevice *device, GdkEventMask events) 143 | // TODO: void C.gtk_widget_set_device_enabled (GtkWidget *widget, GdkDevice *device, gboolean enabled) 144 | // TODO: gboolean C.gtk_widget_get_device_enabled (GtkWidget *widget, GdkDevice *device) 145 | pub fn (w Widget) get_toplevel() &C.GtkWidget { 146 | return C.gtk_widget_get_toplevel(w.c) 147 | } 148 | 149 | /* 150 | pub fn (w Widget) get_ancestor(widget_type C._GType) &C.GtkWidget { 151 | return C.gtk_widget_get_ancestor(w.c, widget_type) 152 | } 153 | */ 154 | // TODO: GdkVisual * C.gtk_widget_get_visual (GtkWidget *widget) 155 | // TODO: void C.gtk_widget_set_visual (GtkWidget *widget, GdkVisual *visual) 156 | pub fn (w Widget) is_ancestor(ancestor IWidget) bool { 157 | ancestor_ := ancestor.get_gtk_widget() 158 | return C.gtk_widget_is_ancestor(w.c, ancestor_) 159 | } 160 | 161 | pub fn (w Widget) translate_coordinates(dest_widget IWidget, x int, y int) (int, int) { 162 | dest_widget_ := dest_widget.get_gtk_widget() 163 | out_x := 0 164 | out_y := 0 165 | C.gtk_widget_translate_coordinates(w.c, dest_widget_, x, y, &out_x, &out_y) 166 | return out_x, out_y 167 | } 168 | 169 | pub fn (w Widget) hide_on_delete() bool { 170 | return C.gtk_widget_hide_on_delete(w.c) 171 | } 172 | 173 | pub fn (w Widget) set_direction(direction TextDirection) { 174 | C.gtk_widget_set_direction(w.c, direction) 175 | } 176 | 177 | pub fn (w Widget) get_direction() TextDirection { 178 | return TextDirection(C.gtk_widget_get_direction(w.c)) 179 | } 180 | 181 | pub fn (w Widget) set_default_direction(direction TextDirection) { 182 | C.gtk_widget_set_default_direction(direction) 183 | } 184 | 185 | pub fn (w Widget) get_default_direction() TextDirection { 186 | return TextDirection(C.gtk_widget_get_default_direction()) 187 | } 188 | 189 | // TODO: void C.gtk_widget_shape_combine_region (GtkWidget *widget, cairo_region_t *region) 190 | // TODO: void C.gtk_widget_input_shape_combine_region (GtkWidget *widget, cairo_region_t *region) 191 | // TODO: PangoContext * C.gtk_widget_create_pango_context (GtkWidget *widget) 192 | // TODO: PangoContext * C.gtk_widget_get_pango_context (GtkWidget *widget) 193 | // TODO: void C.gtk_widget_set_font_options (GtkWidget *widget, const cairo_font_options_t *options) 194 | // TODO: const cairo_font_options_t * C.gtk_widget_get_font_options (GtkWidget *widget) 195 | // TODO: void C.gtk_widget_set_font_map (GtkWidget *widget, PangoFontMap *font_map) 196 | // TODO: PangoFontMap * C.gtk_widget_get_font_map (GtkWidget *widget) 197 | // PangoLayout * C.gtk_widget_create_pango_layout (GtkWidget *widget, const gchar *text) 198 | pub fn (w Widget) queue_draw_area(x int, y int, width int, height int) { 199 | C.gtk_widget_queue_draw_area(w.c, x, y, width, height) 200 | } 201 | 202 | // TODO: void C.gtk_widget_queue_draw_region (GtkWidget *widget, const cairo_region_t *region) 203 | pub fn (w Widget) set_app_paintable(paintable bool) { 204 | C.gtk_widget_set_app_paintable(w.c, paintable) 205 | } 206 | 207 | pub fn (w Widget) set_redraw_on_allocate(redraw_on_allocate bool) { 208 | C.gtk_widget_set_redraw_on_allocate(w.c, redraw_on_allocate) 209 | } 210 | 211 | pub fn (w Widget) mnemonic_activate(group_cycling bool) bool { 212 | return C.gtk_widget_mnemonic_activate(w.c, group_cycling) 213 | } 214 | 215 | // TODO: void C.gtk_widget_class_install_style_property (GtkWidgetClass *klass, GParamSpec *pspec) 216 | // TODO: void C.gtk_widget_class_install_style_property_parser (GtkWidgetClass *klass, GParamSpec *pspec, GtkRcPropertyParser parser) 217 | // TODO: GParamSpec * C.gtk_widget_class_find_style_property (GtkWidgetClass *klass, const gchar *property_name) 218 | // TODO: GParamSpec ** C.gtk_widget_class_list_style_properties (GtkWidgetClass *klass, guint *n_properties) 219 | // TODO: gboolean C.gtk_widget_send_focus_change (GtkWidget *widget, GdkEvent *event) 220 | // TODO: void C.gtk_widget_style_get (GtkWidget *widget, const gchar *first_property_name, ...) 221 | pub fn (w Widget) style_get_property(property_name string) voidptr { 222 | // TODO: ret is GValue, fix this after Gobject is implemented 223 | ret := voidptr(0) 224 | C.gtk_widget_style_get_property(w.c, property_name.str, &ret) 225 | return ret 226 | } 227 | 228 | // TODO: void C.gtk_widget_style_get_valist (GtkWidget *widget, const gchar *first_property_name, va_list var_args) 229 | // TODO: void C.gtk_widget_class_set_accessible_type (GtkWidgetClass *widget_class, GType type) 230 | // TODO: void C.gtk_widget_class_set_accessible_role (GtkWidgetClass *widget_class, AtkRole role) 231 | // TODO: AtkObject * C.gtk_widget_get_accessible (GtkWidget *widget) 232 | pub fn (w Widget) child_focus(direction DirectionType) bool { 233 | return C.gtk_widget_child_focus(w.c, direction) 234 | } 235 | 236 | pub fn (w Widget) child_notify(child_property string) { 237 | C.gtk_widget_child_notify(w.c, child_property.str) 238 | } 239 | 240 | pub fn (w Widget) freeze_child_notify() { 241 | C.gtk_widget_freeze_child_notify(w.c) 242 | } 243 | 244 | pub fn (w Widget) get_child_visible() bool { 245 | return C.gtk_widget_get_child_visible(w.c) 246 | } 247 | 248 | pub fn (w Widget) get_parent() Widget { 249 | parent := C.gtk_widget_get_parent(w.c) 250 | return Widget{parent} 251 | } 252 | 253 | // TODO: GtkSettings * C.gtk_widget_get_settings (GtkWidget *widget) 254 | // TODO: GtkClipboard * C.gtk_widget_get_clipboard (GtkWidget *widget, GdkAtom selection) 255 | // TODO: GdkDisplay * C.gtk_widget_get_display (GtkWidget *widget) 256 | // TODO: GdkScreen * C.gtk_widget_get_screen (GtkWidget *widget) 257 | pub fn (w Widget) has_screen() bool { 258 | return C.gtk_widget_has_screen(w.c) 259 | } 260 | 261 | pub fn (w Widget) get_size_request() (int, int) { 262 | width := 0 263 | height := 0 264 | C.gtk_widget_get_size_request(w.c, &width, &height) 265 | return width, height 266 | } 267 | 268 | pub fn (w Widget) set_child_visible(visible bool) { 269 | C.gtk_widget_set_child_visible(w.c, visible) 270 | } 271 | 272 | pub fn (w Widget) set_size_request(width int, height int) { 273 | C.gtk_widget_set_size_request(w.c, width, height) 274 | } 275 | 276 | pub fn (w Widget) thaw_child_notify() { 277 | C.gtk_widget_thaw_child_notify(w.c) 278 | } 279 | 280 | pub fn (w Widget) set_no_show_all(no_show_all bool) { 281 | C.gtk_widget_set_no_show_all(w.c, no_show_all) 282 | } 283 | 284 | pub fn (w Widget) get_no_show_all() bool { 285 | return C.gtk_widget_get_no_show_all(w.c) 286 | } 287 | 288 | // TODO: GList * C.gtk_widget_list_mnemonic_labels (GtkWidget *widget) 289 | pub fn (w Widget) add_mnemonic_label(label IWidget) { 290 | l := label.get_gtk_widget() 291 | C.gtk_widget_add_mnemonic_label(w.c, l) 292 | } 293 | 294 | pub fn (w Widget) remove_mnemonic_label(label IWidget) { 295 | l := label.get_gtk_widget() 296 | C.gtk_widget_remove_mnemonic_label(w.c, l) 297 | } 298 | 299 | pub fn (w Widget) error_bell() { 300 | C.gtk_widget_error_bell(w.c) 301 | } 302 | 303 | pub fn (w Widget) keynav_failed(direction DirectionType) bool { 304 | return C.gtk_widget_keynav_failed(w.c, direction) 305 | } 306 | 307 | pub fn (w Widget) get_tooltip_markup() string { 308 | return tos3(C.gtk_widget_get_tooltip_markup(w.c)) 309 | } 310 | 311 | pub fn (w Widget) set_tooltip_markup(markup string) { 312 | C.gtk_widget_set_tooltip_markup(w.c, markup.str) 313 | } 314 | 315 | pub fn (w Widget) get_tooltip_text() string { 316 | return tos3(C.gtk_widget_get_tooltip_text(w.c)) 317 | } 318 | 319 | pub fn (w Widget) set_tooltip_text(tooltip string) { 320 | C.gtk_widget_set_tooltip_text(w.c, tooltip.str) 321 | } 322 | 323 | pub fn (w Widget) get_tooltip_window() Window { 324 | window := C.gtk_widget_get_tooltip_window(w.c) 325 | return Window{window} 326 | } 327 | 328 | pub fn (w Widget) set_tooltip_window(window Window) { 329 | window_ := window.get_gtk_widget() 330 | C.gtk_widget_set_tooltip_window(w.c, window_) 331 | } 332 | 333 | pub fn (w Widget) get_has_tooltip() bool { 334 | return C.gtk_widget_get_has_tooltip(w.c) 335 | } 336 | 337 | pub fn (w Widget) set_has_tooltip(has_tooltip bool) { 338 | C.gtk_widget_set_has_tooltip(w.c, has_tooltip) 339 | } 340 | 341 | pub fn (w Widget) trigger_tooltip_query() { 342 | C.gtk_widget_trigger_tooltip_query(w.c) 343 | } 344 | 345 | pub fn (w Widget) get_window() gdk.Window { 346 | window := C.gtk_widget_get_window(w.c) 347 | return gdk.Window{window} 348 | } 349 | 350 | pub fn (w Widget) register_window(window gdk.Window) { 351 | window_ := window.get_cptr() 352 | C.gtk_widget_register_window(w.c, window_) 353 | } 354 | 355 | pub fn (w Widget) unregister_window(window gdk.Window) { 356 | window_ := window.get_cptr() 357 | C.gtk_widget_unregister_window(w.c, window_) 358 | } 359 | 360 | // TODO: gboolean C.gtk_cairo_should_draw_window (cairo_t *cr, GdkWindow *window) 361 | // TODO: void C.gtk_cairo_transform_to_window (cairo_t *cr, GtkWidget *widget, GdkWindow *window) 362 | pub fn (w Widget) get_allocated_width() int { 363 | return C.gtk_widget_get_allocated_width(w.c) 364 | } 365 | 366 | pub fn (w Widget) get_allocated_height() int { 367 | return C.gtk_widget_get_allocated_height(w.c) 368 | } 369 | 370 | pub fn (w Widget) get_allocation() Allocation { 371 | allocation := &C.GtkAllocation(0) 372 | C.gtk_widget_get_allocation(w.c, &allocation) 373 | return Allocation{allocation} 374 | } 375 | 376 | pub fn (w Widget) set_allocation(allocation Allocation) { 377 | allocation_ := allocation.get_cptr() 378 | C.gtk_widget_set_allocation(w.c, allocation_) 379 | } 380 | 381 | pub fn (w Widget) get_allocated_baseline() int { 382 | return C.gtk_widget_get_allocated_baseline(w.c) 383 | } 384 | 385 | pub fn (w Widget) get_allocated_size() (Allocation, int) { 386 | allocation := &C.GtkAllocation(0) 387 | baseline := 0 388 | C.gtk_widget_get_allocated_size(w.c, &allocation, &baseline) 389 | return Allocation{allocation}, baseline 390 | } 391 | 392 | pub fn (w Widget) get_clip() Allocation { 393 | allocation := &C.GtkAllocation(0) 394 | C.gtk_widget_get_clip(w.c, &allocation) 395 | return Allocation{allocation} 396 | } 397 | 398 | pub fn (w Widget) set_clip(allocation Allocation) { 399 | allocation_ := allocation.get_cptr() 400 | C.gtk_widget_set_clip(w.c, allocation_) 401 | } 402 | 403 | pub fn (w Widget) get_app_paintable() bool { 404 | return C.gtk_widget_get_app_paintable(w.c) 405 | } 406 | 407 | pub fn (w Widget) get_can_default() bool { 408 | return C.gtk_widget_get_can_default(w.c) 409 | } 410 | 411 | pub fn (w Widget) set_can_default(can_default bool) { 412 | C.gtk_widget_set_can_default(w.c, can_default) 413 | } 414 | 415 | pub fn (w Widget) set_can_focus(can_focus bool) { 416 | C.gtk_widget_set_can_focus(w.c, can_focus) 417 | } 418 | 419 | pub fn (w Widget) get_focus_on_click() bool { 420 | return C.gtk_widget_get_focus_on_click(w.c) 421 | } 422 | 423 | pub fn (w Widget) set_focus_on_click(focus_on_click bool) { 424 | C.gtk_widget_set_focus_on_click(w.c, focus_on_click) 425 | } 426 | 427 | pub fn (w Widget) get_has_window() bool { 428 | return C.gtk_widget_get_has_window(w.c) 429 | } 430 | 431 | pub fn (w Widget) set_has_window(has_window bool) { 432 | C.gtk_widget_set_has_window(w.c, has_window) 433 | } 434 | 435 | pub fn (w Widget) get_sensitive() bool { 436 | return C.gtk_widget_get_sensitive(w.c) 437 | } 438 | 439 | pub fn (w Widget) is_sensitive() bool { 440 | return C.gtk_widget_is_sensitive(w.c) 441 | } 442 | 443 | pub fn (w Widget) get_visible() bool { 444 | return C.gtk_widget_get_visible(w.c) 445 | } 446 | 447 | pub fn (w Widget) is_visible() bool { 448 | return C.gtk_widget_is_visible(w.c) 449 | } 450 | 451 | pub fn (w Widget) set_visible(visible bool) { 452 | C.gtk_widget_set_visible(w.c, visible) 453 | } 454 | 455 | pub fn (w Widget) set_state_flags(flags StateFlags, clear bool) { 456 | C.gtk_widget_set_state_flags(w.c, flags, clear) 457 | } 458 | 459 | pub fn (w Widget) unset_state_flags(flags StateFlags) { 460 | C.gtk_widget_unset_state_flags(w.c, flags) 461 | } 462 | 463 | pub fn (w Widget) get_state_flags() StateFlags { 464 | return StateFlags(C.gtk_widget_get_state_flags(w.c)) 465 | } 466 | 467 | pub fn (w Widget) has_default() bool { 468 | return C.gtk_widget_has_default(w.c) 469 | } 470 | 471 | pub fn (w Widget) has_focus() bool { 472 | return C.gtk_widget_has_focus(w.c) 473 | } 474 | 475 | pub fn (w Widget) has_visible_focus() bool { 476 | return C.gtk_widget_has_visible_focus(w.c) 477 | } 478 | 479 | pub fn (w Widget) has_grab() bool { 480 | return C.gtk_widget_has_grab(w.c) 481 | } 482 | 483 | pub fn (w Widget) is_drawable() bool { 484 | return C.gtk_widget_is_drawable(w.c) 485 | } 486 | 487 | pub fn (w Widget) is_toplevel() bool { 488 | return C.gtk_widget_is_toplevel(w.c) 489 | } 490 | 491 | pub fn (w Widget) set_window(window gdk.Window) { 492 | window_ := window.get_cptr() 493 | C.gtk_widget_set_window(w.c, window_) 494 | } 495 | 496 | pub fn (w Widget) set_receives_default(receives_default bool) { 497 | C.gtk_widget_set_receives_default(w.c, receives_default) 498 | } 499 | 500 | pub fn (w Widget) get_receives_default() bool { 501 | return C.gtk_widget_get_receives_default(w.c) 502 | } 503 | 504 | pub fn (w Widget) set_support_multidevice(support_multidevice bool) { 505 | C.gtk_widget_set_support_multidevice(w.c, support_multidevice) 506 | } 507 | 508 | pub fn (w Widget) get_support_multidevice() bool { 509 | return C.gtk_widget_get_support_multidevice(w.c) 510 | } 511 | 512 | pub fn (w Widget) set_realized(realized bool) { 513 | C.gtk_widget_set_realized(w.c, realized) 514 | } 515 | 516 | pub fn (w Widget) get_realized() bool { 517 | return C.gtk_widget_get_realized(w.c) 518 | } 519 | 520 | pub fn (w Widget) set_mapped(realized bool) { 521 | C.gtk_widget_set_mapped(w.c, realized) 522 | } 523 | 524 | pub fn (w Widget) get_mapped() bool { 525 | return C.gtk_widget_get_mapped(w.c) 526 | } 527 | 528 | pub fn (w Widget) device_is_shadowed(device gdk.Device) bool { 529 | device_ := device.get_cptr() 530 | return C.gtk_widget_device_is_shadowed(w.c, device_) 531 | } 532 | 533 | pub fn (w Widget) get_modifier_mask(intent gdk.ModifierIntent) gdk.ModifierType { 534 | return gdk.ModifierType(C.gtk_widget_get_modifier_mask(w.c, intent)) 535 | } 536 | 537 | pub fn (w Widget) insert_action_group(name string, group gio.ActionGroup) { 538 | group_ := group.get_cptr() 539 | C.gtk_widget_insert_action_group(w.c, name.str, group_) 540 | } 541 | 542 | pub fn (w Widget) get_opacity() f32 { 543 | return f32(C.gtk_widget_get_opacity(w.c)) 544 | } 545 | 546 | pub fn (w Widget) set_opacity(opacity f32) { 547 | C.gtk_widget_set_opacity(w.c, opacity) 548 | } 549 | 550 | pub fn (w Widget) list_action_prefixes() []string { 551 | c_arr_str := C.gtk_widget_list_action_prefixes(w.c) 552 | v_arr_str := carray_string_to_array_string(c_arr_str) 553 | return v_arr_str 554 | } 555 | 556 | pub fn (w Widget) get_action_group(prefix string) gio.ActionGroup { 557 | cptr := C.gtk_widget_get_action_group(w.c, prefix.str) 558 | return gio.ActionGroup{cptr} 559 | } 560 | 561 | pub fn (w Widget) get_path() WidgetPath { 562 | cptr := C.gtk_widget_get_path(w.c) 563 | return WidgetPath{cptr} 564 | } 565 | 566 | pub fn (w Widget) get_style_context() StyleContext { 567 | cptr := C.gtk_widget_get_style_context(w.c) 568 | return StyleContext{cptr} 569 | } 570 | 571 | pub fn (w Widget) reset_style() { 572 | C.gtk_widget_reset_style(w.c) 573 | } 574 | 575 | pub fn (w Widget) get_preferred_width() (int, int) { 576 | minimum_width := 0 577 | natural_width := 0 578 | C.gtk_widget_get_preferred_width(w.c, &minimum_width, &natural_width) 579 | return minimum_width, natural_width 580 | } 581 | 582 | pub fn (w Widget) get_preferred_height_for_width(width int) (int, int) { 583 | minimum_height := 0 584 | natural_height := 0 585 | C.gtk_widget_get_preferred_height_for_width(w.c, width, &minimum_height, &natural_height) 586 | return minimum_height, natural_height 587 | } 588 | 589 | pub fn (w Widget) get_preferred_width_for_height(height int) (int, int) { 590 | minimum_width := 0 591 | natural_width := 0 592 | C.gtk_widget_get_preferred_width_for_height(w.c, height, &minimum_width, &natural_width) 593 | return minimum_width, natural_width 594 | } 595 | 596 | pub fn (w Widget) get_preferred_height_and_baseline_for_width(width int) (int, int, int, int) { 597 | minimum_height := 0 598 | natural_height := 0 599 | minimum_baseline := 0 600 | natural_baseline := 0 601 | C.gtk_widget_get_preferred_height_and_baseline_for_width(w.c, width, &minimum_height, 602 | &natural_height, &minimum_baseline, &natural_baseline) 603 | return minimum_height, natural_height, minimum_baseline, natural_baseline 604 | } 605 | 606 | pub fn (w Widget) get_request_mode() SizeRequestMode { 607 | return SizeRequestMode(C.gtk_widget_get_request_mode(w.c)) 608 | } 609 | 610 | pub fn (w Widget) get_preferred_size() (Requisition, Requisition) { 611 | minimum_size := &C.GtkRequisition(0) 612 | natural_size := &C.GtkRequisition(0) 613 | C.gtk_widget_get_preferred_size(w.c, &minimum_size, &natural_size) 614 | return Requisition{minimum_size}, Requisition{natural_size} 615 | } 616 | 617 | pub fn (w Widget) get_halign() Align { 618 | return Align(C.gtk_widget_get_halign(w.c)) 619 | } 620 | 621 | pub fn (w Widget) set_halign(align Align) { 622 | C.gtk_widget_set_halign(w.c, align) 623 | } 624 | 625 | pub fn (w Widget) get_valign() Align { 626 | return Align(C.gtk_widget_get_valign(w.c)) 627 | } 628 | 629 | pub fn (w Widget) get_valign_with_baseline() Align { 630 | return Align(C.gtk_widget_get_valign_with_baseline(w.c)) 631 | } 632 | 633 | pub fn (w Widget) set_valign(align Align) { 634 | C.gtk_widget_set_valign(w.c, align) 635 | } 636 | 637 | pub fn (w Widget) get_margin_start() int { 638 | return C.gtk_widget_get_margin_start(w.c) 639 | } 640 | 641 | pub fn (w Widget) set_margin_start(margin int) { 642 | C.gtk_widget_set_margin_start(w.c, margin) 643 | } 644 | 645 | pub fn (w Widget) get_margin_end() int { 646 | return C.gtk_widget_get_margin_end(w.c) 647 | } 648 | 649 | pub fn (w Widget) set_margin_end(margin int) { 650 | C.gtk_widget_set_margin_end(w.c, margin) 651 | } 652 | 653 | pub fn (w Widget) get_margin_top() int { 654 | return C.gtk_widget_get_margin_top(w.c) 655 | } 656 | 657 | pub fn (w Widget) set_margin_top(margin int) { 658 | C.gtk_widget_set_margin_top(w.c, margin) 659 | } 660 | 661 | pub fn (w Widget) get_margin_bottom() int { 662 | return C.gtk_widget_get_margin_bottom(w.c) 663 | } 664 | 665 | pub fn (w Widget) set_margin_bottom(margin int) { 666 | C.gtk_widget_set_margin_bottom(w.c, margin) 667 | } 668 | 669 | pub fn (w Widget) get_hexpand() bool { 670 | return C.gtk_widget_get_hexpand(w.c) 671 | } 672 | 673 | pub fn (w Widget) set_hexpand(hexpand bool) { 674 | C.gtk_widget_set_hexpand(w.c, hexpand) 675 | } 676 | 677 | pub fn (w Widget) get_hexpand_set() bool { 678 | return C.gtk_widget_get_hexpand_set(w.c) 679 | } 680 | 681 | pub fn (w Widget) set_hexpand_set(set bool) { 682 | C.gtk_widget_set_hexpand_set(w.c, set) 683 | } 684 | 685 | pub fn (w Widget) get_vexpand() bool { 686 | return C.gtk_widget_get_vexpand(w.c) 687 | } 688 | 689 | pub fn (w Widget) set_vexpand(expand bool) { 690 | C.gtk_widget_set_vexpand(w.c, expand) 691 | } 692 | 693 | pub fn (w Widget) get_vexpand_set() bool { 694 | return C.gtk_widget_get_vexpand_set(w.c) 695 | } 696 | 697 | pub fn (w Widget) set_vexpand_set(set bool) { 698 | C.gtk_widget_set_vexpand_set(w.c, set) 699 | } 700 | 701 | pub fn (w Widget) queue_compute_expand() { 702 | C.gtk_widget_queue_compute_expand(w.c) 703 | } 704 | 705 | pub fn (w Widget) compute_expand(orientation Orientation) bool { 706 | return C.gtk_widget_compute_expand(w.c, orientation) 707 | } 708 | 709 | pub fn (w Widget) init_template() { 710 | C.gtk_widget_init_template(w.c) 711 | } 712 | 713 | // TODO: GObject * C.gtk_widget_get_template_child (GtkWidget *widget, GType widget_type, const gchar *name) 714 | // Functions 715 | fn distribute_natural_allocation(extra_space int, n_requested_sizes u32, sizes RequestedSize) int { 716 | return C.gtk_distribute_natural_allocation(extra_space, n_requested_sizes, sizes.c) 717 | } 718 | -------------------------------------------------------------------------------- /gtk/widget_path.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | pub struct WidgetPath { 4 | c &C.GtkWidgetPath 5 | } 6 | 7 | pub fn (wp &WidgetPath) get_cptr() &C.GtkWidgetPath { 8 | return wp.c 9 | } 10 | -------------------------------------------------------------------------------- /gtk/window.v: -------------------------------------------------------------------------------- 1 | module gtk 2 | 3 | import gdk 4 | 5 | pub enum WindowType { 6 | toplevel = C.GTK_WINDOW_TOPLEVEL 7 | popup = C.GTK_WINDOW_POPUP 8 | } 9 | 10 | pub enum WindowPosition { 11 | none_ = C.GTK_WIN_POS_NONE 12 | center = C.GTK_WIN_POS_CENTER 13 | mouse = C.GTK_WIN_POS_MOUSE 14 | center_always = C.GTK_WIN_POS_CENTER_ALWAYS 15 | center_on_parent = C.GTK_WIN_POS_CENTER_ON_PARENT 16 | } 17 | 18 | pub struct Window { 19 | c &C.GtkWidget 20 | } 21 | 22 | pub fn new_window() Window { 23 | return Window{C.gtk_window_new(C.GTK_WINDOW_TOPLEVEL)} 24 | } 25 | 26 | pub fn new_window_type(type_ WindowType) Window { 27 | return Window{C.gtk_window_new(type_)} 28 | } 29 | 30 | pub fn (w Window) set_title(title string) { 31 | C.gtk_window_set_title(w.c, title.str) 32 | } 33 | 34 | pub fn (w Window) set_wmclass(name string, class string) { 35 | C.gtk_window_set_wmclass(w.c, name.str, class.str) 36 | } 37 | 38 | pub fn (w Window) set_resizable(setting bool) { 39 | C.gtk_window_set_resizable(w.c, setting) 40 | } 41 | 42 | pub fn (w Window) get_resizable() bool { 43 | return C.gtk_window_get_resizable(w.c) 44 | } 45 | 46 | pub fn (w Window) activate_focus() bool { 47 | return C.gtk_window_activate_focus(w.c) 48 | } 49 | 50 | pub fn (w Window) activate_default() bool { 51 | return C.gtk_window_activate_default(w.c) 52 | } 53 | 54 | pub fn (w Window) set_modal(modal bool) { 55 | C.gtk_window_set_modal(w.c, modal) 56 | } 57 | 58 | pub fn (w Window) set_default_size(width int, height int) { 59 | C.gtk_window_set_default_size(w.c, width, height) 60 | } 61 | 62 | pub fn (w Window) set_default_geometry(width int, height int) { 63 | C.gtk_window_set_default_geometry(w.c, width, height) 64 | } 65 | 66 | pub fn (w Window) set_gravity(gravity gdk.Gravity) { 67 | C.gtk_window_set_gravity(w.c, gravity) 68 | } 69 | 70 | pub fn (w Window) get_gravity() gdk.Gravity { 71 | return C.gtk_window_get_gravity(w.c) 72 | } 73 | 74 | pub fn (w Window) set_position(position WindowPosition) { 75 | C.gtk_window_set_position(w.c, position) 76 | } 77 | 78 | pub fn (w Window) set_transient_for(parrent Window) { 79 | C.gtk_window_set_transient_for(w.c, parrent.c) 80 | } 81 | 82 | pub fn (w Window) set_attached_to(widget IWidget) { 83 | wi := widget.get_gtk_widget() 84 | C.gtk_window_set_attached_to(w.c, wi) 85 | } 86 | 87 | pub fn (w Window) set_destroy_with_parent(setting bool) { 88 | C.gtk_window_set_destroy_with_parent(w.c, setting) 89 | } 90 | 91 | pub fn (w Window) set_hide_titlebar_when_maximized(setting bool) { 92 | C.gtk_window_set_hide_titlebar_when_maximized(w.c, setting) 93 | } 94 | 95 | pub fn (w Window) get_default_size() (int, int) { 96 | width := 0 97 | height := 0 98 | C.gtk_window_get_default_size(w.c, &width, &height) 99 | return width, height 100 | } 101 | 102 | pub fn (w Window) center() { 103 | C.gtk_window_set_position(w.c, WindowPosition.center) 104 | } 105 | 106 | pub fn (w Window) get_title() string { 107 | return tos3(C.gtk_window_get_title(w.c)) 108 | } 109 | 110 | // GdkWindowTypeHint C.gtk_window_get_type_hint (GtkWindow *window) 111 | pub fn (w Window) get_skip_taskbar_hint() bool { 112 | return C.gtk_window_get_skip_taskbar_hint(w.c) 113 | } 114 | 115 | pub fn (w Window) get_skip_pager_hint() bool { 116 | return C.gtk_window_get_skip_pager_hint(w.c) 117 | } 118 | 119 | pub fn (w Window) get_urgency_hint() bool { 120 | return C.gtk_window_get_urgency_hint(w.c) 121 | } 122 | 123 | pub fn (w Window) get_accept_focus() bool { 124 | return C.gtk_window_get_accept_focus(w.c) 125 | } 126 | 127 | pub fn (w Window) get_focus_on_map() bool { 128 | return C.gtk_window_get_focus_on_map(w.c) 129 | } 130 | 131 | // GtkWindowGroup * C.gtk_window_get_group (GtkWindow *window) 132 | pub fn (w Window) has_group() bool { 133 | return C.gtk_window_has_group(w.c) 134 | } 135 | 136 | pub fn (w Window) get_window_type() WindowType { 137 | return WindowType(C.gtk_window_get_window_type(w.c)) 138 | } 139 | 140 | pub fn (w Window) move(x int, y int) { 141 | C.gtk_window_move(w.c, x, y) 142 | } 143 | 144 | pub fn (w Window) parse_geometry(geometry string) bool { 145 | return C.gtk_window_parse_geometry(w.c, geometry.str) 146 | } 147 | 148 | pub fn (w Window) reshow_with_initial_size() { 149 | C.gtk_window_reshow_with_initial_size(w.c) 150 | } 151 | 152 | pub fn (w Window) resize(width int, height int) { 153 | C.gtk_window_resize(w.c, width, height) 154 | } 155 | 156 | pub fn (w Window) resize_to_geometry(width int, height int) { 157 | C.gtk_window_resize_to_geometry(w.c, width, height) 158 | } 159 | 160 | // TODO: void C.gtk_window_set_default_icon_list (GList *list) 161 | // TODO: void C.gtk_window_set_default_icon (GdkPixbuf *icon) 162 | pub fn (w Window) set_default_icon_from_file(filename string) bool { 163 | return C.gtk_window_set_default_icon_from_file(filename.str, 0) 164 | } 165 | 166 | pub fn (w Window) set_default_icon_name(name string) { 167 | C.gtk_window_set_default_icon_name(name.str) 168 | } 169 | 170 | // TODO: void C.gtk_window_set_icon (GtkWindow *window, GdkPixbuf *icon) 171 | // TODO: void C.gtk_window_set_icon_list (GtkWindow *window, GList *list) 172 | pub fn (w Window) set_icon_from_file(filename string) bool { 173 | return C.gtk_window_set_icon_from_file(w.c, filename.str, 0) 174 | } 175 | 176 | pub fn (w Window) set_icon_name(name string) { 177 | C.gtk_window_set_icon_name(w.c, name.str) 178 | } 179 | 180 | pub fn (w Window) set_auto_startup_notification(setting bool) { 181 | C.gtk_window_set_auto_startup_notification(setting) 182 | } 183 | 184 | pub fn (w Window) get_opacity() f32 { 185 | return f32(C.gtk_window_get_opacity(w.c)) 186 | } 187 | 188 | pub fn (w Window) set_opacity(opacity f32) { 189 | C.gtk_window_set_opacity(w.c, opacity) 190 | } 191 | 192 | pub fn (w Window) get_mnemonics_visible() bool { 193 | return C.gtk_window_get_mnemonics_visible(w.c) 194 | } 195 | 196 | pub fn (w Window) set_mnemonics_visible(setting bool) { 197 | C.gtk_window_set_mnemonics_visible(w.c, setting) 198 | } 199 | 200 | pub fn (w Window) get_focus_visible() bool { 201 | return C.gtk_window_get_focus_visible(w.c) 202 | } 203 | 204 | pub fn (w Window) set_focus_visible(setting bool) { 205 | C.gtk_window_set_focus_visible(w.c, setting) 206 | } 207 | 208 | pub fn (w Window) set_has_resize_grip(value bool) { 209 | C.gtk_window_set_has_resize_grip(w.c, value) 210 | } 211 | 212 | pub fn (w Window) get_has_resize_grip() bool { 213 | return C.gtk_window_get_has_resize_grip(w.c) 214 | } 215 | 216 | pub fn (w Window) resize_grip_is_visible() bool { 217 | return C.gtk_window_resize_grip_is_visible(w.c) 218 | } 219 | 220 | // gboolean C.gtk_window_get_resize_grip_area (GtkWindow *window, GdkRectangle *rect) 221 | pub fn (w Window) get_application() &Application { 222 | cptr := C.gtk_window_get_application(w.c) 223 | if cptr == 0 { 224 | return 0 225 | } 226 | return &Application{cptr} 227 | } 228 | 229 | pub fn (w Window) set_application(application Application) { 230 | C.gtk_window_set_application(w.c, application.c) 231 | } 232 | 233 | pub fn (w Window) set_has_user_ref_count(setting bool) { 234 | C.gtk_window_set_has_user_ref_count(w.c, setting) 235 | } 236 | 237 | pub fn (w Window) set_titlebar(widget IWidget) { 238 | wgt := widget.get_gtk_widget() 239 | C.gtk_window_set_titlebar(w.c, wgt) 240 | } 241 | 242 | pub fn (w Window) get_titlebar() &C.GtkWidget { 243 | return C.gtk_window_get_titlebar(w.c) 244 | } 245 | 246 | pub fn (w Window) set_interactive_debugging(enable bool) { 247 | C.gtk_window_set_interactive_debugging(enable) 248 | } 249 | 250 | // INHERITED FROM CONTAINER 251 | pub fn (w Window) add(widget IWidget) { 252 | wgt := widget.get_gtk_widget() 253 | C.gtk_container_add(w.c, wgt) 254 | } 255 | 256 | pub fn (w Window) set_border_width(border_width int) { 257 | w.to_container().set_border_width(border_width) 258 | } 259 | 260 | // INHERITED FROM WIDGET 261 | pub fn (w Window) show() { 262 | C.gtk_widget_show(w.c) 263 | } 264 | 265 | pub fn (w Window) show_all() { 266 | C.gtk_widget_show_all(w.c) 267 | } 268 | 269 | // IMPLEMENTING IWidget 270 | pub fn (w &Window) get_gtk_widget() &C.GtkWidget { 271 | return voidptr(w.c) 272 | } 273 | 274 | // CUSTOM API's 275 | pub fn (w &Window) on(event_name string, handler fn (Window, voidptr), data voidptr) int { 276 | return int(C.g_signal_connect(w.c, event_name.str, handler, 0)) 277 | } 278 | 279 | pub fn (w &Window) to_container() &Container { 280 | unsafe { 281 | cptr := &C.GtkContainer(w.c) 282 | return &Container{cptr} 283 | } 284 | } 285 | -------------------------------------------------------------------------------- /pango/_cdefs.v: -------------------------------------------------------------------------------- 1 | module pango 2 | 3 | import glib 4 | 5 | // struct C.PangoAttrType 6 | struct C.PangoAttrClass {} 7 | 8 | struct C.PangoAttribute {} 9 | 10 | struct C.PangoLanguage {} 11 | 12 | struct C.PangoStyle {} 13 | 14 | struct C.PangoVariant {} 15 | 16 | struct C.PangoStretch {} 17 | 18 | struct C.PangoWeight {} 19 | 20 | struct C.PangoFontDescription {} 21 | 22 | struct C.PangoUnderline {} 23 | 24 | struct C.PangoRectangle {} 25 | 26 | struct C.GDestroyNotify {} 27 | 28 | struct C.PangoGravity {} 29 | 30 | struct C.PangoGravityHint {} 31 | 32 | struct C.PangoShowFlags {} 33 | 34 | struct C.PangoAttrList {} 35 | 36 | struct C.PangoAttrIterator {} 37 | 38 | struct C.PangoAttrType {} 39 | 40 | struct C.PangoAttrFilterFunc {} 41 | 42 | fn C.pango_attr_type_register(charptr) int 43 | 44 | // PangoAttrType 45 | fn C.pango_attr_type_get_name(int PangoAttrType) charptr 46 | 47 | fn C.pango_attribute_init(&PangoAttribute, &PangoAttrClass) 48 | 49 | fn C.pango_attribute_copy(&PangoAttribute) &PangoAttribute 50 | 51 | fn C.pango_attribute_equal(&PangoAttribute, &PangoAttribute) bool 52 | 53 | fn C.pango_attribute_destroy(&PangoAttribute) 54 | 55 | fn C.pango_attr_language_new(&PangoLanguage) &PangoAttribute 56 | 57 | fn C.pango_attr_family_new(&char) &PangoAttribute 58 | 59 | fn C.pango_attr_style_new(PangoStyle) &PangoAttribute 60 | 61 | fn C.pango_attr_variant_new(PangoVariant) &PangoAttribute 62 | 63 | fn C.pango_attr_stretch_new(PangoStretch) &PangoAttribute 64 | 65 | fn C.pango_attr_weight_new(PangoWeight) &PangoAttribute 66 | 67 | fn C.pango_attr_size_new(int) &PangoAttribute 68 | 69 | fn C.pango_attr_size_new_absolute(int) &PangoAttribute 70 | 71 | fn C.pango_attr_font_desc_new(&PangoFontDescription) &PangoAttribute 72 | 73 | fn C.pango_attr_foreground_new(u32, u32, u32) &PangoAttribute 74 | 75 | fn C.pango_attr_background_new(u32, u32, u32) &PangoAttribute 76 | 77 | fn C.pango_attr_strikethrough_new(bool) &PangoAttribute 78 | 79 | fn C.pango_attr_strikethrough_color_new(u32, u32, u32) &PangoAttribute 80 | 81 | fn C.pango_attr_underline_new(PangoUnderline) &PangoAttribute 82 | 83 | fn C.pango_attr_underline_color_new(u32, u32, u32) &PangoAttribute 84 | 85 | fn C.pango_attr_shape_new(&PangoRectangle, &PangoRectangle) &PangoAttribute 86 | 87 | fn C.pango_attr_shape_new_with_data(&PangoRectangle, &PangoRectangle, voidptr, voidptr, GDestroyNotify) &PangoAttribute 88 | 89 | fn C.pango_attr_scale_new(f32) &PangoAttribute 90 | 91 | fn C.pango_attr_rise_new(int) &PangoAttribute 92 | 93 | fn C.pango_attr_letter_spacing_new(int) &PangoAttribute 94 | 95 | fn C.pango_attr_fallback_new(bool) &PangoAttribute 96 | 97 | fn C.pango_attr_gravity_new(PangoGravity) &PangoAttribute 98 | 99 | fn C.pango_attr_gravity_hint_new(PangoGravityHint) &PangoAttribute 100 | 101 | fn C.pango_attr_font_features_new(&charptr) &PangoAttribute 102 | 103 | fn C.pango_attr_foreground_alpha_new(u32) &PangoAttribute 104 | 105 | fn C.pango_attr_background_alpha_new(u32) &PangoAttribute 106 | 107 | fn C.pango_attr_allow_breaks_new(bool) &PangoAttribute 108 | 109 | fn C.pango_attr_insert_hyphens_new(bool) &PangoAttribute 110 | 111 | fn C.pango_attr_show_new(PangoShowFlags) &PangoAttribute 112 | 113 | fn C.pango_attr_list_new() &PangoAttrList 114 | 115 | fn C.pango_attr_list_ref(&PangoAttrList) &PangoAttrList 116 | 117 | fn C.pango_attr_list_unref(&PangoAttrList) 118 | 119 | fn C.pango_attr_list_copy(&PangoAttrList) &PangoAttrList 120 | 121 | fn C.pango_attr_list_insert(&PangoAttrList, &PangoAttribute) 122 | 123 | fn C.pango_attr_list_insert_before(&PangoAttrList, &PangoAttribute) 124 | 125 | fn C.pango_attr_list_change(&PangoAttrList, &PangoAttribute) 126 | 127 | fn C.pango_attr_list_splice(&PangoAttrList, &PangoAttrList, int, int) 128 | 129 | fn C.pango_attr_list_filter(&PangoAttrList, PangoAttrFilterFunc, voidptr) &PangoAttrList 130 | 131 | fn C.pango_attr_list_update(&PangoAttrList, int, int, int) 132 | 133 | fn C.pango_attr_list_get_attributes(&PangoAttrList) &GSList 134 | 135 | fn C.pango_attr_list_get_iterator(&PangoAttrList) &PangoAttrIterator 136 | 137 | fn C.pango_attr_iterator_copy(&PangoAttrIterator) &PangoAttrIterator 138 | 139 | fn C.pango_attr_iterator_next(&PangoAttrIterator) bool 140 | 141 | fn C.pango_attr_iterator_range(&PangoAttrIterator, &int, &int) 142 | 143 | fn C.pango_attr_iterator_get(&PangoAttrIterator, PangoAttrType) &PangoAttribute 144 | 145 | fn C.pango_attr_iterator_get_font(&PangoAttrIterator, &PangoFontDescription, &PangoLanguage, &GSList) 146 | 147 | fn C.pango_attr_iterator_get_attrs(&PangoAttrIterator) &GSList 148 | 149 | fn C.pango_attr_iterator_destroy(&PangoAttrIterator) 150 | -------------------------------------------------------------------------------- /pango/attributes.v: -------------------------------------------------------------------------------- 1 | module pango 2 | 3 | pub enum AttrType { 4 | invalid = C.PANGO_ATTR_INVALID 5 | language = C.PANGO_ATTR_LANGUAGE 6 | family = C.PANGO_ATTR_FAMILY 7 | style = C.PANGO_ATTR_STYLE 8 | weight = C.PANGO_ATTR_WEIGHT 9 | variant = C.PANGO_ATTR_VARIANT 10 | stretch = C.PANGO_ATTR_STRETCH 11 | size = C.PANGO_ATTR_SIZE 12 | font_desc = C.PANGO_ATTR_FONT_DESC 13 | foreground = C.PANGO_ATTR_FOREGROUND 14 | background = C.PANGO_ATTR_BACKGROUND 15 | underline = C.PANGO_ATTR_UNDERLINE 16 | strikethrough = C.PANGO_ATTR_STRIKETHROUGH 17 | rise = C.PANGO_ATTR_RISE 18 | shape = C.PANGO_ATTR_SHAPE 19 | scale = C.PANGO_ATTR_SCALE 20 | fallback = C.PANGO_ATTR_FALLBACK 21 | letter_spacing = C.PANGO_ATTR_LETTER_SPACING 22 | underline_color = C.PANGO_ATTR_UNDERLINE_COLOR 23 | strikethrough_color = C.PANGO_ATTR_STRIKETHROUGH_COLOR 24 | absolute_size = C.PANGO_ATTR_ABSOLUTE_SIZE 25 | gravity = C.PANGO_ATTR_GRAVITY 26 | gravity_hint = C.PANGO_ATTR_GRAVITY_HINT 27 | font_features = C.PANGO_ATTR_FONT_FEATURES 28 | foreground_alpha = C.PANGO_ATTR_FOREGROUND_ALPHA 29 | background_alpha = C.PANGO_ATTR_BACKGROUND_ALPHA 30 | allow_breaks = C.PANGO_ATTR_ALLOW_BREAKS 31 | show = C.PANGO_ATTR_SHOW 32 | insert_hyphens = C.PANGO_ATTR_INSERT_HYPHENS 33 | } 34 | 35 | pub struct AttrClass { 36 | c &PangoAttrClass 37 | } 38 | 39 | pub struct Attribute { 40 | c &PangoAttribute 41 | } 42 | 43 | pub fn attr_type_register(name string) AttrType { 44 | return AttrType(pango_attr_type_register(name.str)) 45 | } 46 | 47 | pub fn attr_type_get_name(type_ AttrType) string { 48 | return tos3(pango_attr_type_get_name(type_)) 49 | } 50 | 51 | pub fn (a AttrClass) init(klass AttrClass) { 52 | pango_attribute_init(a.c, klass.c) 53 | } 54 | 55 | pub fn (a Attribute) copy() Attribute { 56 | return Attribute{pango_attribute_copy(a.c)} 57 | } 58 | 59 | pub fn (a Attribute) equal(attr2 Attribute) bool { 60 | return pango_attribute_equal(a.c, attr2.c) 61 | } 62 | 63 | pub fn (a Attribute) destroy() { 64 | pango_attribute_destroy(a.c) 65 | } 66 | 67 | pub fn new_attr_family(family string) Attribute { 68 | return Attribute{pango_attr_family_new(family.str)} 69 | } 70 | 71 | pub fn new_attr_style(style Style) Attribute { 72 | return Attribute{pango_attr_style_new(style)} 73 | } 74 | 75 | pub fn new_attr_variant(variant Variant) Attribute { 76 | return Attribute{pango_attr_variant_new(variant.c)} 77 | } 78 | 79 | pub fn new_attr_stretch(stretch Stretch) Attribute { 80 | return Attribute{pango_attr_stretch_new(stretch.c)} 81 | } 82 | 83 | pub fn new_attr_weight(weight Weight) Attribute { 84 | return Attribute{pango_attr_weight_new(weight.c)} 85 | } 86 | 87 | pub fn new_attr_size(size int) Attribute { 88 | return Attribute{pango_attr_size_new(size)} 89 | } 90 | 91 | pub fn new_attr_absolute_size(size int) Attribute { 92 | return Attribute{pango_attr_size_new_absolute(size)} 93 | } 94 | 95 | pub fn new_attr_font_desc(desc FontDescription) Attribute { 96 | return Attribute{pango_attr_font_desc_new(desc.c)} 97 | } 98 | 99 | pub fn new_attr_foreground(red u16, green u16, blue u16) Attribute { 100 | return Attribute{pango_attr_foreground_new(red, green, blue)} 101 | } 102 | 103 | pub fn new_attr_background(red u16, green u16, blue u16) Attribute { 104 | return Attribute{pango_attr_background_new(red, green, blue)} 105 | } 106 | 107 | pub fn new_attr_strikethrough(strikethrough bool) Attribute { 108 | return Attribute{pango_attr_strikethrough_new(strikethrough)} 109 | } 110 | 111 | pub fn new_attr_strikethrough_color(red u16, green u16, blue u16) Attribute { 112 | return Attribute{pango_attr_strikethrough_color_new(red, green, blue)} 113 | } 114 | 115 | pub fn new_attr_underline(underline Underline) Attribute { 116 | return Attribute{pango_attr_underline_new(underline.c)} 117 | } 118 | 119 | pub fn new_attr_underline_color(red u16, green u16, blue u16) Attribute { 120 | return Attribute{pango_attr_underline_color_new(red, green, blue)} 121 | } 122 | 123 | // 124 | -------------------------------------------------------------------------------- /pango/font_description.v: -------------------------------------------------------------------------------- 1 | module pango 2 | 3 | pub struct FontDescription { 4 | c &PangoFontDescription 5 | } 6 | -------------------------------------------------------------------------------- /pango/fonts.v: -------------------------------------------------------------------------------- 1 | module pango 2 | 3 | pub enum Style { 4 | normal = C.PANGO_STYLE_NORMAL 5 | oblique = C.PANGO_STYLE_OBLIQUE 6 | italic = C.PANGO_STYLE_ITALIC 7 | } 8 | -------------------------------------------------------------------------------- /pango/language.v: -------------------------------------------------------------------------------- 1 | module pango 2 | 3 | pub struct Language { 4 | c &PangoLanguage 5 | } 6 | -------------------------------------------------------------------------------- /pango/pango.v: -------------------------------------------------------------------------------- 1 | module pango 2 | -------------------------------------------------------------------------------- /pango/stretch.v: -------------------------------------------------------------------------------- 1 | module pango 2 | 3 | pub struct Stretch { 4 | c &PangoStretch 5 | } 6 | -------------------------------------------------------------------------------- /pango/underline.v: -------------------------------------------------------------------------------- 1 | module pango 2 | 3 | pub struct Underline { 4 | c &PangoUnderline 5 | } 6 | -------------------------------------------------------------------------------- /pango/variant.v: -------------------------------------------------------------------------------- 1 | module pango 2 | 3 | pub struct Variant { 4 | c &PangoVariant 5 | } 6 | -------------------------------------------------------------------------------- /pango/weight.v: -------------------------------------------------------------------------------- 1 | module pango 2 | 3 | pub struct Weight { 4 | c &PangoWeight 5 | } 6 | -------------------------------------------------------------------------------- /tests/glib_lists_test.v: -------------------------------------------------------------------------------- 1 | import glib 2 | 3 | const ( 4 | test_nums = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] 5 | // more_nums = [ 8, 9, 7, 0, 3, 2, 5, 1, 4, 6 ] 6 | ) 7 | 8 | fn test_list() { 9 | mut list := glib.new_list() 10 | for i := 0; i < 10; i++ { 11 | x := test_nums[i] 12 | list = list.append(voidptr(x)) 13 | } 14 | list = list.reverse() 15 | for i := 0; i < 10; i++ { 16 | t := list.nth(u32(i)) 17 | x := int(t.data()) 18 | assert x == 9 - i 19 | } 20 | for i := 0; i < 10; i++ { 21 | l := list.nth(u32(i)) 22 | pos := list.position(l) 23 | assert pos == i 24 | } 25 | list.free() 26 | } 27 | 28 | fn test_slist() { 29 | /* 30 | mut slist := glib.new_slist() 31 | for i := 0; i < 10; i++ { 32 | slist = slist.append(test_nums[i]) 33 | } 34 | slist = slist.reverse() 35 | for i := 0; i < 10; i++ { 36 | st := slist.nth(u32(i)) 37 | assert int(st.data()) == 9 - i 38 | } 39 | for i := 0; i < 10; i++ { 40 | s := slist.nth(u32(i)) 41 | assert slist.position(s) == i 42 | } 43 | slist.free() 44 | */ 45 | } 46 | -------------------------------------------------------------------------------- /tests/glib_string_test.v: -------------------------------------------------------------------------------- 1 | import glib 2 | 3 | fn test_gstring_append() { 4 | str := glib.new_string('Hey...') 5 | str.append(' What') 6 | str.append(' are ') 7 | str.append('you ') 8 | str.append('doing?') 9 | assert str.str() == 'Hey... What are you doing?' 10 | assert str.str().len == 26 11 | str2 := glib.new_string('') 12 | str2.append('Vgtk is') 13 | str2.append('') 14 | str2.append(' awesome !!!') 15 | assert str2.str() == 'Vgtk is awesome !!!' 16 | assert str2.str().len == 21 17 | } 18 | 19 | fn test_gstring_new_len() { 20 | str := glib.new_string_len('dddddd', 90) 21 | assert str.str().len == 6 22 | assert str.str() == 'dddddd' 23 | } 24 | -------------------------------------------------------------------------------- /tests/importing_gdb_glib_and_gtk_works_test.v: -------------------------------------------------------------------------------- 1 | import gdk 2 | import glib 3 | import gtk 4 | 5 | fn test_all() { 6 | assert true 7 | } 8 | -------------------------------------------------------------------------------- /tests/window_test.v: -------------------------------------------------------------------------------- 1 | import gtk 2 | 3 | fn test_window_title() { 4 | w := gtk.new_window() 5 | w.set_title('gtk window') 6 | assert w.get_title() == 'gtk window' 7 | ////////////////////////////////////////////////////////////////// 8 | // TODO: remove this workaround. Without it, with V 0.1.29 be02ee9 9 | // there is a C error about a missing gtk__IWidget_name_table 10 | label := gtk.new_label('This is a normal label') 11 | w.add(label) 12 | ////////////////////////////////////////////////////////////////// 13 | w.show() 14 | gtk.main_quit() 15 | } 16 | 17 | fn test_window_size() { 18 | window := gtk.new_window() 19 | window.set_default_size(500, 250) 20 | w, h := window.get_default_size() 21 | assert w == 500 22 | assert h == 250 23 | window.show() 24 | gtk.main_quit() 25 | } 26 | -------------------------------------------------------------------------------- /v.mod: -------------------------------------------------------------------------------- 1 | Module { 2 | name: 'vgtk3' 3 | license: 'MIT' 4 | description: 'manual wrapper api for gtk3' 5 | author: 'Don Alfons Nisnoni, zenith391' 6 | repo_url: 'https://github.com/vgtk/vgtk3' 7 | version: '0.3.0' 8 | deps: [] 9 | } 10 | -------------------------------------------------------------------------------- /vpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "vgtk3", 3 | "version": "0.3.0", 4 | "author": ["Don Alfons Nisnoni ", "zenith391 "], 5 | "repo": "https://github.com/vgtk/vgtk3", 6 | "sources": [ 7 | "https://vpkg-project.github.io/registry/" 8 | ], 9 | "dependencies": [] 10 | } 11 | --------------------------------------------------------------------------------