Mercurial > godwindows
changeset 109:d121081ebf09
Add notifications to the two test programs.
author | Brian Smith <brian@dbsoft.org> |
---|---|
date | Thu, 11 Nov 2021 17:42:34 -0600 |
parents | 279735652a39 |
children | 692733612332 |
files | dw/dw.go dwootest/dwootest.go dwtest/dwtest.go |
diffstat | 3 files changed, 36 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/dw/dw.go Thu Nov 11 15:35:31 2021 -0600 +++ b/dw/dw.go Thu Nov 11 17:42:34 2021 -0600 @@ -903,7 +903,7 @@ } func (notification HNOTIFICATION) GetType() C.uint { - return 0 + return 23 } // Initializes the Dynamic Windows engine. @@ -4897,7 +4897,7 @@ } // Creates a new notificaiton -func NotificatioNew(title string, imagepath string, description string) HNOTIFICATION { +func NotificationNew(title string, imagepath string, description string) HNOTIFICATION { return Notification_new(title, imagepath, description) } @@ -5195,6 +5195,14 @@ C.go_signal_connect(window.GetHandle(), csigname, unsafe.Pointer(cgo.NewHandle(sigfunc)), nil, (window.GetType()<<8)|go_flags_no_data) } +// Connect a function or closure to a widget clicked event. +func (window HNOTIFICATION) ConnectClicked(sigfunc func(window HNOTIFICATION) int) { + csigname := C.CString(C.DW_SIGNAL_CLICKED) + defer C.free(unsafe.Pointer(csigname)) + + C.go_signal_connect(window.GetHandle(), csigname, unsafe.Pointer(cgo.NewHandle(sigfunc)), nil, (window.GetType()<<8)|go_flags_no_data) +} + // Connect a function or closure to a HTML javascript result event. func (window HHTML) ConnectResult(sigfunc func(window HHTML, status int, result string, script_data POINTER) int) { csigname := C.CString(C.DW_SIGNAL_HTML_RESULT) @@ -5304,6 +5312,9 @@ case (21 << 8): // HSPLITBAR thisfunc := pfunc.Value().(func(HSPLITBAR, POINTER) int) return C.int(thisfunc(HSPLITBAR{window}, POINTER(data))) + case (23 << 8): // HNOTIFICATION + thisfunc := pfunc.Value().(func(HNOTIFICATION, POINTER) int) + return C.int(thisfunc(HNOTIFICATION{window}, POINTER(data))) case go_flags_no_data: thisfunc := pfunc.Value().(func(HANDLE) int) return C.int(thisfunc(HGENERIC{window})) @@ -5374,6 +5385,9 @@ case (21 << 8) | go_flags_no_data: // HSPLITBAR thisfunc := pfunc.Value().(func(HSPLITBAR) int) return C.int(thisfunc(HSPLITBAR{window})) + case (23 << 8) | go_flags_no_data: // HNOTIFICATION + thisfunc := pfunc.Value().(func(HNOTIFICATION) int) + return C.int(thisfunc(HNOTIFICATION{window})) } thisfunc := pfunc.Value().(func(HANDLE, POINTER) int) return C.int(thisfunc(HGENERIC{window}, POINTER(data)))
--- a/dwootest/dwootest.go Thu Nov 11 15:35:31 2021 -0600 +++ b/dwootest/dwootest.go Thu Nov 11 17:42:34 2021 -0600 @@ -628,12 +628,19 @@ browsefilebutton.ConnectClicked(func(window dw.HBUTTON) int { tmp := dw.FileBrowse("Pick a file", "dwootest.go", "go", dw.FILE_OPEN) if len(tmp) > 0 { + notification := dw.NotificationNew("New file loaded", "image/test.png", "dwtest loaded \""+tmp+"\" into the file browser on the Render tab, with \"File Display\" selected from the drop down list.") + current_file = tmp entryfield.SetText(current_file) read_file() current_col = 0 current_row = 0 update_render() + notification.ConnectClicked(func(notif dw.HNOTIFICATION) int { + fmt.Printf("Notification clicked\n") + return dw.TRUE + }) + notification.Send() } copypastefield.SetFocus() return dw.FALSE @@ -1431,11 +1438,11 @@ } /* Setup the Application ID for sending notifications */ - dw.App_id_set("org.dbsoft.dwindows.dwtest", "Dynamic Windows Test") + dw.AppIdSet("org.dbsoft.dwindows.dwtest", "Dynamic Windows Test") /* Enable full dark mode on platforms that support it */ if os.Getenv("DW_DARK_MODE") != "" { - dw.Feature_set(dw.FEATURE_DARK_MODE, dw.DARK_MODE_FULL) + dw.FeatureSet(dw.FEATURE_DARK_MODE, dw.DARK_MODE_FULL) } /* Initialize the Dynamic Windows engine */ @@ -1443,7 +1450,7 @@ /* Test all the features and display the results */ for feat := 0; feat < dw.FEATURE_MAX && feat < len(DWFeatureList); feat++ { - result := dw.Feature_get(feat) + result := dw.FeatureGet(feat) status := "Unsupported" if result == 0 {
--- a/dwtest/dwtest.go Thu Nov 11 15:35:31 2021 -0600 +++ b/dwtest/dwtest.go Thu Nov 11 17:42:34 2021 -0600 @@ -215,15 +215,24 @@ return TRUE } +func notification_clicked_callback(button dw.HNOTIFICATION, data dw.POINTER) int { + fmt.Printf("Notification clicked\n") + return TRUE +} + func browse_file_callback(window dw.HBUTTON, data dw.POINTER) int { - tmp := dw.File_browse("Pick a file", "dwtest.c", "c", dw.FILE_OPEN) + tmp := dw.File_browse("Pick a file", "dwtest.c", "go", dw.FILE_OPEN) if len(tmp) > 0 { + notification := dw.Notification_new("New file loaded", "image/test.png", "dwtest loaded \""+tmp+"\" into the file browser on the Render tab, with \"File Display\" selected from the drop down list.") + current_file = tmp dw.Window_set_text(entryfield, current_file) read_file() current_col = 0 current_row = 0 update_render() + dw.Signal_connect(notification, dw.SIGNAL_CLICKED, dw.SIGNAL_FUNC(notification_clicked_callback), nil) + dw.Notification_send(notification) } dw.Window_set_focus(copypastefield) return FALSE