func handleKeyPress(ctx *glib.CallbackContext) { arg := ctx.Args(0) kev := *(**gdk.EventKey)(unsafe.Pointer(&arg)) kpe := kh.GTKKeyPressEvent{int(kev.Keyval), 0} if (gdk.ModifierType(kev.State) & gdk.CONTROL_MASK) != 0 { kpe.Modifier = gdk.CONTROL_MASK } _, keyh = keyh.Handle(kpe, µemacs) }
func runGUI(argv []string) { conf, err := config.Load(getConfigurationFile()) if err != nil { log.Printf("[WARN] No configuration file or invalid configuration. Use default settings") conf = config.New() } window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL) window.SetTitle(getApplicationTitle()) terminal := vte3.NewTerminal() widget := terminal.VteToGtk() keyboardEventsChan := make(chan *events.KeyPressEvent) // Events window.Connect("destroy", gtk.MainQuit) widget.Connect("child-exited", gtk.MainQuit) window.Connect("key-press-event", func(ctx *glib.CallbackContext) { arg := ctx.Args(0) kev := *(**gdk.EventKey)(unsafe.Pointer(&arg)) kpe := events.KeyPressEvent{int(kev.Keyval), 0} if (gdk.ModifierType(kev.State) & gdk.CONTROL_MASK) != 0 { kpe.Modifier = gdk.CONTROL_MASK } keyboardEventsChan <- &kpe }) widget.Connect("decrease-font-size", func() { log.Printf("[DEBUG] Font -------") }) widget.Connect("increase-font-size", func() { log.Printf("[DEBUG] Font +++++++") }) window.Add(widget) window.SetSizeRequest(defaultWinWidth, defaultWinHeight) window.ShowAll() configure(terminal, conf) terminal.Fork(argv) // Handlers go events.KeyboardHandler(keyboardEventsChan, terminal) gtk.Main() }
func runGUI() { window := gtk.NewWindow(gtk.WINDOW_TOPLEVEL) window.SetTitle(getApplicationTitle()) window.Connect("destroy", gtk.MainQuit) keyboardEventsChan := make(chan *keyhandler.KeyPressEvent) window.Connect("key-press-event", func(ctx *glib.CallbackContext) { arg := ctx.Args(0) kev := *(**gdk.EventKey)(unsafe.Pointer(&arg)) kpe := keyhandler.KeyPressEvent{int(kev.Keyval), 0} if (gdk.ModifierType(kev.State) & gdk.CONTROL_MASK) != 0 { kpe.Modifier = gdk.CONTROL_MASK } keyboardEventsChan <- &kpe }) // motionEvent := make(chan interface{}) // window.Connect("motion-notify-event", func(ctx *glib.CallbackContext) { // arg := ctx.Args(0) // motionEvent <- *(**gdk.EventMotion)(unsafe.Pointer(&arg)) // }) // go events.MotionHandler(motionEvent) buttonEventChan := make(chan interface{}) window.Connect("button-press-event", func(ctx *glib.CallbackContext) { arg := ctx.Args(0) buttonEventChan <- *(**gdk.EventButton)(unsafe.Pointer(&arg)) }) go events.ButtonHandler(buttonEventChan) setupProxy() vbox := gtk.NewVBox(false, 1) notebook := gtk.NewNotebook() tab := ui.NewBrowser(homePage) page := gtk.NewFrame("") notebook.AppendPage(page, gtk.NewLabel("Home")) page.Add(tab.VBox) vbox.PackStart(notebook, true, true, 0) statusbar := gtk.NewStatusbar() contextID := statusbar.GetContextId("actarus") statusbar.Push(contextID, "Welcome to Actarus.") vbox.PackStart(statusbar, false, false, 0) replEntry := gtk.NewEntry() replEntry.Hide() vbox.PackEnd(replEntry, false, false, 0) window.Add(vbox) window.SetSizeRequest(defaultWinWidth, defaultWinHeight) window.ShowAll() replEntry.GrabFocus() replEntry.SetVisible(false) // Handlers go events.KeyboardHandler( keyboardEventsChan, window, replEntry, tab.URLEntry, notebook) gtk.Main() }