Support > General Discussions

MTSB

<< < (2/2)

Support:
Here is a Gtk example instantiated multiple times as threads.


--- Code: Text ---INCLUDE curl.bas ch = curl::init() curl::option(ch,"NOBODY")curl::option(ch,"URL","http://127.0.0.1:8080/mtsb/mtgtk.sb")curl::perform(ch) curl::option(ch,"NOBODY")curl::option(ch,"URL","http://127.0.0.1:8080/mtsb/mtgtk.sb")curl::perform(ch) curl::finish(ch) 

--- Code: Text ---PRINT "Status: 200\nContent-Type: text/html\n\n" DECLARE SUB DLL ALIAS "_idll" LIB "gtk-server"DECLARE SUB DEFINE ALIAS "_idll_define" LIB "gtk-server" DEFINE "gtk_init NONE NONE 2 NULL NULL"DEFINE "gtk_window_new delete-event WIDGET 1 INT"DEFINE "gtk_window_set_title NONE NONE 2 WIDGET STRING"DEFINE "gtk_table_new NONE WIDGET 3 INT INT BOOL"DEFINE "gtk_container_add NONE NONE 2 WIDGET WIDGET"DEFINE "gtk_button_new_with_label clicked WIDGET 1 STRING"DEFINE "gtk_table_attach_defaults NONE NONE 6 WIDGET WIDGET INT INT INT INT"DEFINE "gtk_widget_show_all NONE NONE 1 WIDGET"DEFINE "gtk_server_callback NONE STRING 1 STRING"DEFINE "gtk_widget_destroy NONE NONE 1 WIDGET"DEFINE "g_thread_init NONE NONE 1 NULL"DEFINE "gdk_threads_init NONE NONE 0"DEFINE "gdk_threads_enter NONE NONE 0"DEFINE "gdk_threads_leave NONE NONE 0" DLL("g_thread_init NULL")DLL("gdk_threads_init")DLL("gdk_threads_enter")DLL("gtk_init NULL NULL")win = DLL("gtk_window_new 0")DLL("gtk_window_set_title " & win & " \"SB Gtk\"")tbl = DLL("gtk_table_new 10 10 1")DLL("gtk_container_add " & win & " " & tbl)but = DLL("gtk_button_new_with_label \"Quit\"")DLL("gtk_table_attach_defaults " & tbl & " " & but & " 5 9 5 9")DLL("gtk_widget_show_all " & win) REPEAT  event = DLL("gtk_server_callback WAIT")UNTIL event = win OR event = but DLL("gtk_widget_destroy " & win)DLL("gtk_server_callback 1")DLL("gdk_threads_leave") END 
Both Gtk windows are independent of each other but can share common variables (read/write lockable) provided by the MT module.

Note: The threading support will be incorporated into a new forked version of GTK-Server that is ScriptBasic extension module specific and static linked in the upcoming mtsb.so extension module. (API scripting and SB embedding in a common module)

Support:
Here is an example of embedding a web browser in a ScriptBasic application.


--- Code: ---DECLARE SUB DLL ALIAS "_idll" LIB "iDLL-Server"
DECLARE SUB REQUIRE ALIAS "_idll_require" LIB "iDLL-Server"
DECLARE SUB DEFINE ALIAS "_idll_define" LIB "iDLL-Server"

REQUIRE "libgtkembedmoz.so"

DEFINE "gtk_init NONE NONE 2 NULL NULL"
DEFINE "gtk_window_new delete-event WIDGET 1 INT"
DEFINE "gtk_window_set_title NONE NONE 2 WIDGET STRING"
DEFINE "gtk_window_set_position NONE NONE 2 WIDGET INT"
DEFINE "gtk_widget_set_size_request NONE NONE 3 WIDGET INT INT"
DEFINE "gtk_window_set_icon_name NONE NONE 2 WIDGET STRING"
DEFINE "gtk_widget_show_all NONE NONE 1 WIDGET"
DEFINE "gtk_moz_embed_set_comp_path NONE NONE 1 STRING"
DEFINE "gtk_moz_embed_set_profile_path NONE NONE 2 STRING STRING"
DEFINE "gtk_moz_embed_new NONE WIDGET 0"
DEFINE "gtk_moz_embed_load_url NONE NONE 2 WIDGET STRING"
DEFINE "gtk_moz_embed_open_stream NONE NONE 3 WIDGET STRING STRING"
DEFINE "gtk_moz_embed_append_data NONE NONE 3 WIDGET STRING INT"
DEFINE "gtk_server_callback NONE STRING 1 STRING"
DEFINE "gtk_server_exit NONE NONE 0"

DLL("gtk_init NULL NULL")
window = DLL("gtk_window_new 0")
DLL("gtk_window_set_title " & window & " \"ScriptBasic Open Source Project\"")
DLL("gtk_window_set_position " & window & " 1")
DLL("gtk_widget_set_size_request " & window & " 700 500")
DLL("gtk_window_set_icon_name " & window & " mozilla")
DLL("gtk_moz_embed_set_comp_path \"/usr/lib/kompozer/\"")
DLL("gtk_moz_embed_set_profile_path \"/tmp\" \"mozilla\"")
moz = DLL("gtk_moz_embed_new")
DLL("gtk_container_add " & window & " " & moz)
DLL("gtk_moz_embed_load_url " & moz & " \"http://www.scriptbasic.org/forum\"")
DLL("gtk_widget_show_all " & window)

REPEAT
  event = DLL("gtk_server_callback WAIT")
UNTIL event = window

DLL("gtk_server_exit")

--- End code ---


--- Quote ---GtkMozEmbed is an easy-to-use widget that will allow you to embed a Mozilla browser window into your Gtk application.

--- End quote ---

patforkin:
Hello!.
When I look at the MTSB posts I am overwhelmed by an initial complexity.
I do however get the feeling, as I read more, that there is much in it that would help me with the text processing in my translation framework.
How can I begin to explore this potential?
Where should I begin?
Regards, patforkin.

Support:
Pat.

MTSB was an effort to use the sbhttpd web server as a multi-threaded application server. Scriba (using cURL) would send request to the server? I was trying to find an easy way to run Gtk in a multi threaded SB desktop environment.

John

Navigation

[0] Message Index

[*] Previous page

Go to full version