diff --git a/examples/app-with-systray/assets/icon.ico b/examples/app-with-systray/assets/icon.ico new file mode 100644 index 0000000..06bede1 Binary files /dev/null and b/examples/app-with-systray/assets/icon.ico differ diff --git a/examples/app-with-systray/assets/icon.png b/examples/app-with-systray/assets/icon.png new file mode 100644 index 0000000..46233bc Binary files /dev/null and b/examples/app-with-systray/assets/icon.png differ diff --git a/examples/app-with-systray/index.html b/examples/app-with-systray/index.html new file mode 100644 index 0000000..2914cc1 --- /dev/null +++ b/examples/app-with-systray/index.html @@ -0,0 +1,8 @@ + + + Desktop App with notification tray + + +

Basic App with VTray!

+ + diff --git a/examples/app-with-systray/main.v b/examples/app-with-systray/main.v new file mode 100644 index 0000000..edc3adf --- /dev/null +++ b/examples/app-with-systray/main.v @@ -0,0 +1,53 @@ +module main + +import webview +import ouri028.vtray + +enum MenuItems { + edit = 1 + quit = 2 +} + +fn main() { + icon := $if macos { + '${@VMODROOT}/assets/icon.png' + } $else { + '${@VMODROOT}/assets/icon.ico' + } + mut systray := &vtray.VTrayApp{ + identifier: 'VTray!' + tooltip: 'VTray Demo!' + icon: icon + items: [ + &vtray.VTrayMenuItem{ + id: int(MenuItems.edit) + text: 'Edit' + }, + &vtray.VTrayMenuItem{ + id: int(MenuItems.quit) + text: 'Quit' + }, + ] + } + on_click := fn [systray] (menu_id int) { + match menu_id { + int(MenuItems.edit) { + println('EDIT!') + } + int(MenuItems.quit) { + systray.destroy() + } + else {} + } + } + systray.on_click = on_click + systray.vtray_init() + w := webview.create(debug: true) + w.set_title('VTray Example!') + w.set_size(600, 400, .@none) + w.navigate('file://${@VMODROOT}/index.html') + spawn systray.run() + w.run() + w.destroy() + systray.destroy() +} diff --git a/examples/app-with-systray/v.mod b/examples/app-with-systray/v.mod new file mode 100644 index 0000000..2f47fee --- /dev/null +++ b/examples/app-with-systray/v.mod @@ -0,0 +1,7 @@ +Module { + name: 'VTray-Test' + description: '' + version: '0.0.1' + license: 'MIT' + dependencies: ['ouri028.vtray'] +}