comparison dwtest.c @ 2008:74facb490f5a

GTK: Fix html changed callbacks when using webkit1. Fix the code to disable javascript, it only worked on webkit2. Add code to the test program to demonstrate the callback.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 07 Nov 2019 00:37:23 +0000
parents a2931caa3422
children 8577d533b371
comparison
equal deleted inserted replaced
2007:3a26e6f6691d 2008:74facb490f5a
1694 dw_event_close(&controlevent); 1694 dw_event_close(&controlevent);
1695 update_mle("Control thread finished.\r\n", TRUE); 1695 update_mle("Control thread finished.\r\n", TRUE);
1696 dw_window_enable(startbutton); 1696 dw_window_enable(startbutton);
1697 } 1697 }
1698 1698
1699 /* Handle web html changed */
1700 int DWSIGNAL web_html_changed(HWND html, int status, char *url, void *data)
1701 {
1702 HWND hwndstatus = (HWND)data;
1703 char *statusnames[] = { "none", "started", "redirect", "loading", "complete", NULL };
1704
1705 if(hwndstatus && url && status < 5)
1706 {
1707 int length = strlen(url) + strlen(statusnames[status]) + 10;
1708 char *text = calloc(1, length+1);
1709
1710 snprintf(text, length, "Status %s: %s", statusnames[status], url);
1711 dw_window_set_text(hwndstatus, text);
1712 free(text);
1713 }
1714 return FALSE;
1715 }
1699 1716
1700 /* 1717 /*
1701 * Let's demonstrate the functionality of this library. :) 1718 * Let's demonstrate the functionality of this library. :)
1702 */ 1719 */
1703 int main(int argc, char *argv[]) 1720 int main(int argc, char *argv[])
1777 dw_notebook_page_set_text( notebook, notebookpage7, "html"); 1794 dw_notebook_page_set_text( notebook, notebookpage7, "html");
1778 1795
1779 rawhtml = dw_html_new(1001); 1796 rawhtml = dw_html_new(1001);
1780 if(rawhtml) 1797 if(rawhtml)
1781 { 1798 {
1799 HWND htmlstatus;
1800
1782 dw_box_pack_start( notebookbox7, rawhtml, 0, 100, TRUE, FALSE, 0); 1801 dw_box_pack_start( notebookbox7, rawhtml, 0, 100, TRUE, FALSE, 0);
1783 dw_html_raw(rawhtml, "<html><body><center><h1>dwtest</h1></center></body></html>"); 1802 dw_html_raw(rawhtml, "<html><body><center><h1>dwtest</h1></center></body></html>");
1784 html = dw_html_new(1002); 1803 html = dw_html_new(1002);
1785 dw_box_pack_start( notebookbox7, html, 0, 100, TRUE, TRUE, 0); 1804 dw_box_pack_start( notebookbox7, html, 0, 100, TRUE, TRUE, 0);
1786 dw_html_url(html, "http://dwindows.netlabs.org"); 1805 dw_html_url(html, "http://dwindows.netlabs.org");
1806 htmlstatus = dw_status_text_new("HTML status loading...", 0);
1807 dw_box_pack_start( notebookbox7, htmlstatus, 100, -1, TRUE, FALSE, 1);
1808 dw_signal_connect(html, DW_SIGNAL_HTML_CHANGED, DW_SIGNAL_FUNC(web_html_changed), DW_POINTER(htmlstatus));
1787 } 1809 }
1788 else 1810 else
1789 { 1811 {
1790 html = dw_text_new("HTML widget not available.", 0); 1812 html = dw_text_new("HTML widget not available.", 0);
1791 dw_box_pack_start( notebookbox7, html, 0, 100, TRUE, TRUE, 0); 1813 dw_box_pack_start( notebookbox7, html, 0, 100, TRUE, TRUE, 0);