comparison gtk/dw.c @ 1354:1f22addc2722

Changed the behavior of dw_html_new() to return NULL on failure like the documentation indicates... Instead of creating a text widget with an error message. This error message is now sent to the console. This allows programs to be able to gracefully handle the failure to create the HTML widget. Also updated the dwtest program to create a text widget in a similar fashion on failure. Also updated the dw_calendar_* comments to no longer be unsupported on OS/2.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 18 Nov 2011 13:34:36 +0000
parents e4ef8d86dfc4
children dd252596227b
comparison
equal deleted inserted replaced
1353:f4ad4ba39b61 1354:1f22addc2722
12269 * text: The default text to be in the entryfield widget. 12269 * text: The default text to be in the entryfield widget.
12270 * id: An ID to be used with dw_window_from_id() or 0L. 12270 * id: An ID to be used with dw_window_from_id() or 0L.
12271 */ 12271 */
12272 HWND dw_html_new(unsigned long id) 12272 HWND dw_html_new(unsigned long id)
12273 { 12273 {
12274 GtkWidget *widget,*stext; 12274 GtkWidget *widget = NULL,*stext;
12275 int _locked_by_me = FALSE; 12275 int _locked_by_me = FALSE;
12276 12276
12277 DW_MUTEX_LOCK; 12277 DW_MUTEX_LOCK;
12278 #ifdef USE_GTKMOZEMBED 12278 #ifdef USE_GTKMOZEMBED
12279 if (!_gtk_moz_embed_new) 12279 if (!_gtk_moz_embed_new)
12280 { 12280 {
12281 widget = dw_box_new(DW_HORZ, 0); 12281 dw_debug( "HTML widget not available; you do not have access to gtkmozembed." );
12282 stext = dw_text_new( "HTML widget not available; you do not have access to gtkmozembed.", 0);
12283 dw_box_pack_start(widget, stext, 0, 0, TRUE, TRUE, 10);
12284 } 12282 }
12285 else 12283 else
12286 { 12284 {
12287 widget = _gtk_moz_embed_new(); 12285 widget = _gtk_moz_embed_new();
12288 /* 12286 /*
12289 * Connect some signals 12287 * Connect some signals
12290 */ 12288 */
12291 gtk_signal_connect( GTK_OBJECT(widget), "net-stop", GTK_SIGNAL_FUNC(_dw_html_net_stop_cb), widget ); 12289 gtk_signal_connect( GTK_OBJECT(widget), "net-stop", GTK_SIGNAL_FUNC(_dw_html_net_stop_cb), widget );
12292 gtk_signal_connect( GTK_OBJECT(widget), "dom_mouse_click", GTK_SIGNAL_FUNC(_dw_dom_mouse_click_cb), widget ); 12290 gtk_signal_connect( GTK_OBJECT(widget), "dom_mouse_click", GTK_SIGNAL_FUNC(_dw_dom_mouse_click_cb), widget );
12291 gtk_widget_show(widget);
12293 } 12292 }
12294 #elif defined(USE_LIBGTKHTML2) 12293 #elif defined(USE_LIBGTKHTML2)
12295 if ( !_html_document_new ) 12294 if ( !_html_document_new )
12296 { 12295 {
12297 widget = dw_box_new(DW_HORZ, 0); 12296 dw_debug( "HTML widget not available; you do not have access to libgtkhtml-2." );
12298 stext = dw_text_new( "HTML widget not available; you do not have access to libgtkhtml-2.", 0);
12299 dw_box_pack_start(widget, stext, 0, 0, TRUE, TRUE, 10);
12300 } 12297 }
12301 else 12298 else
12302 { 12299 {
12303 HtmlDocument *document; 12300 HtmlDocument *document;
12304 document = html_document_new (); 12301 document = html_document_new ();
12307 g_signal_connect (G_OBJECT (document), "dom_mouse_click", G_CALLBACK (dom_mouse_click), NULL); 12304 g_signal_connect (G_OBJECT (document), "dom_mouse_click", G_CALLBACK (dom_mouse_click), NULL);
12308 g_signal_connect (G_OBJECT (document), "request_url", G_CALLBACK (url_requested), NULL); 12305 g_signal_connect (G_OBJECT (document), "request_url", G_CALLBACK (url_requested), NULL);
12309 g_signal_connect (G_OBJECT (document), "link_clicked", G_CALLBACK (link_clicked), NULL); 12306 g_signal_connect (G_OBJECT (document), "link_clicked", G_CALLBACK (link_clicked), NULL);
12310 widget = _html_view_new(); 12307 widget = _html_view_new();
12311 gtk_object_set_data(GTK_OBJECT(widget), "_dw_html_document", (gpointer)document); 12308 gtk_object_set_data(GTK_OBJECT(widget), "_dw_html_document", (gpointer)document);
12309 gtk_widget_show(widget);
12312 } 12310 }
12313 #elif defined(USE_WEBKIT) 12311 #elif defined(USE_WEBKIT)
12314 if (!_webkit_web_view_open) 12312 if (!_webkit_web_view_open)
12315 { 12313 {
12316 widget = dw_box_new(DW_HORZ, 0); 12314 dw_debug( "HTML widget not available; you do not have access to webkit." );
12317 stext = dw_text_new( "HTML widget not available; you do not have access to webkit.", 0);
12318 dw_box_pack_start(widget, stext, 0, 0, TRUE, TRUE, 10);
12319 } 12315 }
12320 else 12316 else
12321 { 12317 {
12322 WebKitWebView *web_view; 12318 WebKitWebView *web_view;
12323 widget = gtk_scrolled_window_new (NULL, NULL); 12319 widget = gtk_scrolled_window_new (NULL, NULL);
12324 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW (widget), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); 12320 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW (widget), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
12325 web_view = (WebKitWebView *)_webkit_web_view_new(); 12321 web_view = (WebKitWebView *)_webkit_web_view_new();
12326 /* web_view = WEBKIT_WEB_VIEW(_webkit_web_view_new() ); */
12327 gtk_container_add( GTK_CONTAINER (widget), GTK_WIDGET(web_view) ); 12322 gtk_container_add( GTK_CONTAINER (widget), GTK_WIDGET(web_view) );
12328 gtk_widget_show( GTK_WIDGET(web_view) ); 12323 gtk_widget_show( GTK_WIDGET(web_view) );
12329 gtk_object_set_data( GTK_OBJECT(widget), "_dw_web_view", (gpointer)web_view ); 12324 gtk_object_set_data( GTK_OBJECT(widget), "_dw_web_view", (gpointer)web_view );
12330 # ifdef WEBKIT_CHECK_VERSION 12325 # ifdef WEBKIT_CHECK_VERSION
12331 # if WEBKIT_CHECK_VERSION(1,1,5) 12326 # if WEBKIT_CHECK_VERSION(1,1,5)
12332 g_signal_connect( web_view, "populate-popup", G_CALLBACK(_dw_html_populate_popup_cb), NULL ); 12327 g_signal_connect( web_view, "populate-popup", G_CALLBACK(_dw_html_populate_popup_cb), NULL );
12333 # endif 12328 # endif
12334 # endif 12329 # endif
12330 gtk_widget_show(widget);
12335 } 12331 }
12336 #else 12332 #else
12337 widget = dw_box_new(DW_HORZ, 0); 12333 dw_debug( "HTML widget not available; you do not have access to gtkmozembed, webkit nor libgtkhtml-2.", 0);
12338 stext = dw_text_new( "HTML widget not available; you do not have access to gtkmozembed.", 0); 12334 #endif
12339 dw_box_pack_start(widget, stext, 0, 0, TRUE, TRUE, 10);
12340 #endif
12341 gtk_widget_show(widget);
12342 DW_MUTEX_UNLOCK; 12335 DW_MUTEX_UNLOCK;
12343 return widget; 12336 return widget;
12344 } 12337 }
12345 12338
12346 /* 12339 /*