Author: echatellier Date: 2013-07-26 23:09:49 +0200 (Fri, 26 Jul 2013) New Revision: 2917 Url: http://chorem.org/projects/jtimer/repository/revisions/2917 Log: Start chromium and add systray menu Added: branches/ng-jtimer/jtimer-server/src/main/go/systray.go branches/ng-jtimer/jtimer-server/src/main/go/ui.go Modified: branches/ng-jtimer/jtimer-server/src/main/go/jtimer.go branches/ng-jtimer/jtimer-server/src/main/go/readme.txt Modified: branches/ng-jtimer/jtimer-server/src/main/go/jtimer.go =================================================================== --- branches/ng-jtimer/jtimer-server/src/main/go/jtimer.go 2013-07-26 20:04:45 UTC (rev 2916) +++ branches/ng-jtimer/jtimer-server/src/main/go/jtimer.go 2013-07-26 21:09:49 UTC (rev 2917) @@ -27,13 +27,14 @@ import ( "fmt" + "log" + "time" + "os" "net/http" - "time" "github.com/BurntSushi/xgb" "github.com/BurntSushi/xgb/xproto" "github.com/BurntSushi/xgb/screensaver" "code.google.com/p/go.net/websocket" - "log" ) func RunIdleReporting() { @@ -74,5 +75,9 @@ func main() { go StartWebsocketServer() - RunIdleReporting() + go RunIdleReporting() + cmd := RunClient() + cmd.Start() + InstallSystray(&os.Args) + cmd.Process.Kill() } Modified: branches/ng-jtimer/jtimer-server/src/main/go/readme.txt =================================================================== --- branches/ng-jtimer/jtimer-server/src/main/go/readme.txt 2013-07-26 20:04:45 UTC (rev 2916) +++ branches/ng-jtimer/jtimer-server/src/main/go/readme.txt 2013-07-26 21:09:49 UTC (rev 2917) @@ -5,12 +5,13 @@ -------------------- go get github.com/BurntSushi/xgb/screensaver go get code.google.com/p/go.net/websocket +go get github.com/mattn/go-gtk/gtk Lancement --------- -go run *.go +go run [^j]*.go jtimer.go Compilation ----------- -go build -o jtimer *.go +go build -o jtimer [^j]*.go jtimer.go Added: branches/ng-jtimer/jtimer-server/src/main/go/systray.go =================================================================== --- branches/ng-jtimer/jtimer-server/src/main/go/systray.go (rev 0) +++ branches/ng-jtimer/jtimer-server/src/main/go/systray.go 2013-07-26 21:09:49 UTC (rev 2917) @@ -0,0 +1,48 @@ +package main + +import ( + "github.com/mattn/go-gtk/gtk" + "github.com/mattn/go-gtk/glib" +) + +func InstallSystray(args *[]string) { + gtk.Init(args) + + glib.SetApplicationName("go-gtk-statusicon-example") + + // Popup menu + popupMenu := gtk.NewMenu() + + // Hide menu item + miHide := gtk.NewMenuItemWithLabel("Cacher") + miHide.Connect("activate", func() { + + }) + popupMenu.Append(miHide) + + // Stop all task + popupMenu.Append(gtk.NewSeparatorMenuItem()) + miStop := gtk.NewMenuItemWithLabel("Arrêter toutes les tâches") + miStop.Connect("activate", func() { + + }) + popupMenu.Append(miStop) + + // Quit + miQuit := gtk.NewMenuItemWithLabel("Quitter") + miQuit.Connect("activate", func() { + gtk.MainQuit() + }) + popupMenu.Append(miQuit) + + // install systray with popup menu + popupMenu.ShowAll() + si := gtk.NewStatusIconFromFile("jtimer-40-green.png") + si.SetTitle("jTimer") + si.SetTooltipMarkup("jTimer 2.0") + si.Connect("popup-menu", func(cbx *glib.CallbackContext) { + popupMenu.Popup(nil, nil, gtk.StatusIconPositionMenu, si, uint(cbx.Args(0)), uint32(cbx.Args(1))) + }) + + gtk.Main() +} \ No newline at end of file Added: branches/ng-jtimer/jtimer-server/src/main/go/ui.go =================================================================== --- branches/ng-jtimer/jtimer-server/src/main/go/ui.go (rev 0) +++ branches/ng-jtimer/jtimer-server/src/main/go/ui.go 2013-07-26 21:09:49 UTC (rev 2917) @@ -0,0 +1,11 @@ +package main + +import ( + "os/exec" +) + +func RunClient() *exec.Cmd { + binary, _ := exec.LookPath("chromium") + return exec.Command(binary, "--app=http://localhost:8080", + "--user-data-dir=/tmp/jtimer") +}
participants (1)
-
echatellier@users.chorem.org