"-------------------------------------------------- " GTK-server demo " tested with GVim 7 and GTK-server 2.1.1 on Linux " (c) PvE - sept. 21, 2006 " " Put program below in your .vimrc file and activate " demo by running ':Demo'. " " Or run standalone with: " vim -u script.in " " Console output may not function properly. "-------------------------------------------------- function! Gtk(args) call writefile([a:args], "/tmp/vim.gtk") return get(readfile("/tmp/vim.gtk"), 0) endfunction function! Demo() call system("gtk-server -fifo=/tmp/vim.gtk -detach") call Gtk("gtk_init NULL NULL") let win = Gtk("gtk_window_new 0") call Gtk("gtk_window_set_title " . win . " 'A very cool VIM GTK demo'") call Gtk("gtk_window_set_default_size " . win . " 100 100") call Gtk("gtk_window_set_position " . win . " 1") let table = Gtk("gtk_table_new 30 30 1") call Gtk("gtk_container_add " . win . " " . table) let button1 = Gtk("gtk_button_new_with_label Exit") call Gtk("gtk_table_attach_defaults " . table . " " . button1 . " 17 28 20 25") let button2 = Gtk("gtk_button_new_with_label 'Print text'") call Gtk("gtk_table_attach_defaults " . table . " " . button2 . " 2 13 20 25") let entry = Gtk("gtk_entry_new") call Gtk("gtk_table_attach_defaults " . table . " " . entry . " 2 28 5 15") call Gtk("gtk_widget_show_all " . win) " Mainloop let event = "0" while event != button1 && event != win let event = Gtk("gtk_server_callback wait") if event == button2 echo Gtk("gtk_entry_get_text " . entry . "\n") endif endwhile call Gtk("gtk_server_exit") endfunction " Call GTK GUI with a Vim command within VIM - uncomment "command! -complete=function Demo :call Demo() " Or run demo in standalone mode call Demo() quit