Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a basic example of how to use webview with VTray to create a de… #28

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added examples/app-with-systray/assets/icon.ico
Binary file not shown.
Binary file added examples/app-with-systray/assets/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions examples/app-with-systray/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<html>
<head>
<title>Desktop App with notification tray</title>
</head>
<body>
<h2>Basic App with VTray!</h2>
</body>
</html>
53 changes: 53 additions & 0 deletions examples/app-with-systray/main.v
Original file line number Diff line number Diff line change
@@ -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()
}
7 changes: 7 additions & 0 deletions examples/app-with-systray/v.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Module {
name: 'VTray-Test'
description: ''
version: '0.0.1'
license: 'MIT'
dependencies: ['ouri028.vtray']
}