Skip to content

Commit

Permalink
Patch Tinyfd, support multi-thread calls, add functions
Browse files Browse the repository at this point in the history
* Patch Tinyfd again
  -> To fix zenity inputbox behavior (it behaves like passwordbox before fix)
* Add multi-thread call support for webview
* Add functions into window library for linux (will be added for Window asap)
  • Loading branch information
malisipi committed Nov 21, 2022
1 parent 7ac9108 commit 7db5b2d
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 12 deletions.
2 changes: 1 addition & 1 deletion examples/demo_no_console.v
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn add_user(event_details m.EventDetails, mut app &m.Window, mut app_data voidpt
}
}

w.hide_console_window()
w.hide_console()

mut app:=m.create(m.WindowConfig{ title:"MUI Demo"})

Expand Down
4 changes: 3 additions & 1 deletion tinyfiledialogs/tinyfiledialogs.c
Original file line number Diff line number Diff line change
Expand Up @@ -5513,7 +5513,9 @@ char * tinyfd_inputBox(
}
else
{
strcat(lDialogString, " --hide-text") ;
if ( ! aDefaultInput ) {
strcat(lDialogString, " --hide-text") ;
}
}
if (tinyfd_silent) strcat( lDialogString , " 2>/dev/null ");
strcat( lDialogString ,
Expand Down
12 changes: 9 additions & 3 deletions webview/webview.v
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,15 @@ pub fn create(debug int) Webview_t {
}

pub fn (webview Webview_t) destroy (){
C.webview_destroy(webview)
C.webview_dispatch(webview, fn (webview Webview_t, void voidptr){
C.webview_destroy(webview)
}, voidptr(0))
}

pub fn (webview Webview_t) terminate (){
C.webview_terminate(webview)
C.webview_dispatch(webview, fn (webview Webview_t, void voidptr){
C.webview_terminate(webview)
}, voidptr(0))
}

pub fn (webview Webview_t) run (){
Expand Down Expand Up @@ -109,5 +113,7 @@ pub fn (webview Webview_t) rturn (seq &char, the_string string){ //this is not a
}

pub fn (webview Webview_t) init (code string){
C.webview_init(webview, &char(code.str))
C.webview_dispatch(webview, fn [code](webview Webview_t, void voidptr){
C.webview_init(webview, &char(code.str))
}, voidptr(0))
}
5 changes: 5 additions & 0 deletions window/calls_linux.c.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module window

fn C.gtk_widget_hide(win voidptr)
fn C.gtk_widget_show(win voidptr)
fn C.putenv(&char) int
6 changes: 6 additions & 0 deletions window/calls_windows.c.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module window

fn C.FreeConsole()
fn C.AllocConsole()
fn C.GetConsoleWindow() voidptr
fn C.ShowWindow(voidptr, bool)
27 changes: 20 additions & 7 deletions window/window.v
Original file line number Diff line number Diff line change
@@ -1,15 +1,28 @@
module window

fn C.FreeConsole()
fn C.AllocConsole()
fn C.GetConsoleWindow() voidptr
fn C.ShowWindow(voidptr, bool)

pub fn hide_console_window(){
pub fn hide_console(){ // only windows
$if windows {
C.FreeConsole()
C.AllocConsole()
hwnd:=C.GetConsoleWindow()
C.ShowWindow(hwnd, false)
}
}
}

pub fn prefer_x11(){ // only linux (if display server is wayland, try to use x11 [xwayland])
$if linux {
C.putenv(c"GDK_BACKEND=x11,wayland")
}
}

pub fn hide(window voidptr){
$if linux {
C.gtk_widget_hide(window)
}
}

pub fn show(window voidptr){
$if linux {
C.gtk_widget_show(window)
}
}

0 comments on commit 7db5b2d

Please sign in to comment.