comparison gtk/dw.c @ 643:9ab89d89e6b4

Add dw_listview_insert() Default to using webkit for Gtk+ HTML widget Add option to build with libgtkhtml2 - incomplete Initial attempt to use customdraw for Win32 container - not working Added dw_window_get_font() for Gtk+ - not implemented in other ports yet Change package name from dw to dwindows for Linux ports - use dwindows-config now Add debian package build target
author mhessling@81767d24-ef19-dc11-ae90-00e081727c95
date Sun, 03 Oct 2010 00:34:36 +0000
parents 06be879f5137
children c60a4f6cfae8
comparison
equal deleted inserted replaced
642:fda03b13ebda 643:9ab89d89e6b4
29 #include <unistd.h> 29 #include <unistd.h>
30 #include <gdk/gdkkeysyms.h> 30 #include <gdk/gdkkeysyms.h>
31 #ifdef USE_IMLIB 31 #ifdef USE_IMLIB
32 #include <gdk_imlib.h> 32 #include <gdk_imlib.h>
33 #endif 33 #endif
34
34 #ifdef USE_GTKMOZEMBED 35 #ifdef USE_GTKMOZEMBED
35 #include <gtkmozembed.h> 36 # include <gtkmozembed.h>
36 #undef GTK_TYPE_MOZ_EMBED 37 # undef GTK_TYPE_MOZ_EMBED
37 #define GTK_TYPE_MOZ_EMBED (_dw_moz_embed_get_type()) 38 # define GTK_TYPE_MOZ_EMBED (_dw_moz_embed_get_type())
38 #endif 39 #endif
40
41 #ifdef USE_LIBGTKHTML2
42 # include <libgtkhtml/gtkhtml.h>
43 #endif
44
45 #ifdef USE_WEBKIT
46 # if defined(USE_WEBKIT10) || defined(USE_WEBKIT11)
47 # include <webkit/webkit.h>
48 # else
49 # include <webkit.h>
50 # endif
51 #endif
52
39 #if GTK_MAJOR_VERSION > 1 53 #if GTK_MAJOR_VERSION > 1
40 #include <gdk-pixbuf/gdk-pixbuf.h> 54 #include <gdk-pixbuf/gdk-pixbuf.h>
41 #endif 55 #endif
42 56
43 #if __STDC_VERSION__ < 199901L 57 #if __STDC_VERSION__ < 199901L
81 { 0, 0xffff, 0x0000, 0xffff }, /* 13 bright magenta */ 95 { 0, 0xffff, 0x0000, 0xffff }, /* 13 bright magenta */
82 { 0, 0x0000, 0xeeee, 0xeeee }, /* 14 bright cyan */ 96 { 0, 0x0000, 0xeeee, 0xeeee }, /* 14 bright cyan */
83 { 0, 0xffff, 0xffff, 0xffff }, /* 15 bright white */ 97 { 0, 0xffff, 0xffff, 0xffff }, /* 15 bright white */
84 }; 98 };
85 99
100 /*
101 * List those icons that have transparency first
102 */
86 #define NUM_EXTS 5 103 #define NUM_EXTS 5
87 char *image_exts[NUM_EXTS] = 104 char *image_exts[NUM_EXTS] =
88 { 105 {
89 ".xpm", 106 ".xpm",
90 ".png", 107 ".png",
108 ".ico",
109 ".jpg",
91 ".bmp", 110 ".bmp",
92 ".jpg",
93 ".ico",
94 }; 111 };
95 112
96 #define DW_THREAD_LIMIT 50 113 #define DW_THREAD_LIMIT 50
97 114
98 #ifndef max 115 #ifndef max
121 static pthread_t _dw_thread = (pthread_t)-1; 138 static pthread_t _dw_thread = (pthread_t)-1;
122 static int _dw_mutex_locked[DW_THREAD_LIMIT]; 139 static int _dw_mutex_locked[DW_THREAD_LIMIT];
123 /* Use default border size for the default enlightenment theme */ 140 /* Use default border size for the default enlightenment theme */
124 static int _dw_border_width = 12, _dw_border_height = 28; 141 static int _dw_border_width = 12, _dw_border_height = 28;
125 142
126 #define DW_MUTEX_LOCK { int index = _find_thread_index(dw_thread_id()); if(pthread_self() != _dw_thread && _dw_mutex_locked[index] == FALSE) { gdk_threads_enter(); _dw_mutex_locked[index] = TRUE; _locked_by_me = TRUE; } } 143 #define DW_MUTEX_LOCK { int index = _find_thread_index(dw_thread_id()); if(pthread_self() != _dw_thread && _dw_mutex_locked[index] == FALSE) { gdk_threads_enter(); _dw_mutex_locked[index] = TRUE; _locked_by_me = TRUE; } }
127 #define DW_MUTEX_UNLOCK { if(pthread_self() != _dw_thread && _locked_by_me == TRUE) { gdk_threads_leave(); _dw_mutex_locked[_find_thread_index(dw_thread_id())] = FALSE; _locked_by_me = FALSE; } } 144 #define DW_MUTEX_UNLOCK { if(pthread_self() != _dw_thread && _locked_by_me == TRUE) { gdk_threads_leave(); _dw_mutex_locked[_find_thread_index(dw_thread_id())] = FALSE; _locked_by_me = FALSE; } }
128 145
129 #define DEFAULT_SIZE_WIDTH 12 146 #define DEFAULT_SIZE_WIDTH 12
130 #define DEFAULT_SIZE_HEIGHT 6 147 #define DEFAULT_SIZE_HEIGHT 6
131 #define DEFAULT_TITLEBAR_HEIGHT 22 148 #define DEFAULT_TITLEBAR_HEIGHT 22
168 void (*_gtk_moz_embed_render_data)(GtkMozEmbed *, const char *, guint32, const char *, const char *) = NULL; 185 void (*_gtk_moz_embed_render_data)(GtkMozEmbed *, const char *, guint32, const char *, const char *) = NULL;
169 GtkWidget *(*_gtk_moz_embed_new)(void) = NULL; 186 GtkWidget *(*_gtk_moz_embed_new)(void) = NULL;
170 GtkType (*_dw_moz_embed_get_type)(void) = NULL; 187 GtkType (*_dw_moz_embed_get_type)(void) = NULL;
171 gboolean (*_gtk_moz_embed_can_go_back)(GtkMozEmbed *) = NULL; 188 gboolean (*_gtk_moz_embed_can_go_back)(GtkMozEmbed *) = NULL;
172 gboolean (*_gtk_moz_embed_can_go_forward)(GtkMozEmbed *) = NULL; 189 gboolean (*_gtk_moz_embed_can_go_forward)(GtkMozEmbed *) = NULL;
190 void (*_gtk_moz_embed_set_comp_path)(const char *) = NULL;
191 void (*_gtk_moz_embed_set_profile_path)(const char *, const char *) = NULL;
192 void (*_gtk_moz_embed_push_startup)(void) = NULL;
193 #endif
194
195 #ifdef USE_LIBGTKHTML2
196 GtkHtmlContext *(*_gtk_html_context_get)(void) = NULL;
197 HtmlDocument *(*_html_document_new)(void) = NULL;
198 GtkWidget *(*_html_view_new)(void) = NULL;
199 #endif
200
201 #ifdef USE_WEBKIT
202 /*
203 * we need to add these equivalents from webkitwebview.h so we can refer to
204 * our own pointers to functions (we don't link with the webkit libraries
205 */
206 # define DW_WEBKIT_TYPE_WEB_VIEW (_webkit_web_view_get_type())
207 # define DW_WEBKIT_WEB_VIEW(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), DW_WEBKIT_TYPE_WEB_VIEW, WebKitWebView))
208 WEBKIT_API GType (*_webkit_web_view_get_type)(void) = NULL;
209 WEBKIT_API void (*_webkit_web_view_load_html_string)(WebKitWebView *, const gchar *, const gchar *) = NULL;
210 WEBKIT_API void (*_webkit_web_view_open)(WebKitWebView *, const gchar *) = NULL;
211 WEBKIT_API GtkWidget *(*_webkit_web_view_new)(void) = NULL;
212 WEBKIT_API void (*_webkit_web_view_go_back)(WebKitWebView *) = NULL;
213 WEBKIT_API void (*_webkit_web_view_go_forward)(WebKitWebView *) = NULL;
214 WEBKIT_API void (*_webkit_web_view_reload)(WebKitWebView *) = NULL;
215 WEBKIT_API void (*_webkit_web_view_stop_loading)(WebKitWebView *) = NULL;
216 # ifdef WEBKIT_CHECK_VERSION
217 # if WEBKIT_CHECK_VERSION(1,1,5)
218 WEBKIT_API void (*_webkit_web_frame_print)(WebKitWebFrame *) = NULL;
219 WEBKIT_API WebKitWebFrame *(*_webkit_web_view_get_focused_frame)(WebKitWebView *) = NULL;
220 # endif
221 # endif
173 #endif 222 #endif
174 223
175 typedef struct 224 typedef struct
176 { 225 {
177 GdkPixmap *pixmap; 226 GdkPixmap *pixmap;
230 279
231 /* Alignment flags */ 280 /* Alignment flags */
232 #define DW_CENTER 0.5f 281 #define DW_CENTER 0.5f
233 #define DW_LEFT 0.0f 282 #define DW_LEFT 0.0f
234 #define DW_RIGHT 1.0f 283 #define DW_RIGHT 1.0f
284 #define DW_TOP 0.0f
285 #define DW_BOTTOM 1.0f
235 286
236 /* MDI Support Code */ 287 /* MDI Support Code */
237 #if GTK_MAJOR_VERSION > 1 288 #if GTK_MAJOR_VERSION > 1
238 #define GTK_MDI(obj) GTK_CHECK_CAST (obj, gtk_mdi_get_type (), GtkMdi) 289 #define GTK_MDI(obj) GTK_CHECK_CAST (obj, gtk_mdi_get_type (), GtkMdi)
239 #define GTK_MDI_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_mdi_get_type (), GtkMdiClass) 290 #define GTK_MDI_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gtk_mdi_get_type (), GtkMdiClass)
1977 _gtk_moz_embed_render_data = dlsym(handle, "gtk_moz_embed_render_data"); 2028 _gtk_moz_embed_render_data = dlsym(handle, "gtk_moz_embed_render_data");
1978 _dw_moz_embed_get_type = dlsym(handle, "gtk_moz_embed_get_type"); 2029 _dw_moz_embed_get_type = dlsym(handle, "gtk_moz_embed_get_type");
1979 _gtk_moz_embed_new = dlsym(handle, "gtk_moz_embed_new"); 2030 _gtk_moz_embed_new = dlsym(handle, "gtk_moz_embed_new");
1980 _gtk_moz_embed_can_go_back = dlsym(handle, "gtk_moz_embed_can_go_back"); 2031 _gtk_moz_embed_can_go_back = dlsym(handle, "gtk_moz_embed_can_go_back");
1981 _gtk_moz_embed_can_go_forward = dlsym(handle, "gtk_moz_embed_can_go_forward"); 2032 _gtk_moz_embed_can_go_forward = dlsym(handle, "gtk_moz_embed_can_go_forward");
1982 gtk_moz_embed_set_comp_path( "/usr/lib/mozilla"); 2033 _gtk_moz_embed_set_comp_path = dlsym(handle, "gtk_moz_embed_set_comp_path");
1983 gtk_moz_embed_set_comp_path( "/usr/lib/firefox"); 2034 _gtk_moz_embed_set_profile_path = dlsym(handle, "gtk_moz_embed_set_profile_path");
2035 _gtk_moz_embed_push_startup = dlsym(handle, "gtk_moz_embed_push_startup");
2036 _gtk_moz_embed_set_comp_path( "/usr/lib/mozilla");
2037 _gtk_moz_embed_set_comp_path( "/usr/lib/firefox");
1984 profile = g_build_filename(g_get_home_dir(), ".dwindows/mozilla", NULL); 2038 profile = g_build_filename(g_get_home_dir(), ".dwindows/mozilla", NULL);
1985 2039
1986 /* initialize profile */ 2040 /* initialize profile */
1987 gtk_moz_embed_set_profile_path(profile, "dwindows"); 2041 _gtk_moz_embed_set_profile_path(profile, "dwindows");
1988 g_free(profile); 2042 g_free(profile);
1989 2043
1990 /* startup done */ 2044 /* startup done */
1991 gtk_moz_embed_push_startup(); 2045 _gtk_moz_embed_push_startup();
2046 }
2047 }
2048 #endif
2049
2050 /* Try to load the libgtkhtml2 shared libary */
2051 #ifdef USE_LIBGTKHTML2
2052 #include <ctype.h>
2053
2054 void init_libgtkhtml2 (void)
2055 {
2056 void *handle = NULL;
2057 handle = dlopen( "libgtkhtml-2.so", RTLD_LAZY );
2058
2059 /* If we loaded it, grab the symbols we want */
2060 if ( handle )
2061 {
2062 _html_document_new = dlsym(handle, "html_document_new");
2063 _html_view_new = dlsym(handle, "html_view_new");
2064 //...
2065 _gtk_html_context_get = dlsym(handle, "gtk_html_context_get" );
2066 g_object_set( G_OBJECT(_gtk_html_context_get()), "debug_painting", FALSE, NULL );
2067 }
2068 }
2069 #endif
2070
2071 /* Try to load the WebKitGtk shared libary */
2072 #ifdef USE_WEBKIT
2073 void init_webkit(void)
2074 {
2075 char libname[100];
2076 void *handle = NULL;
2077
2078 sprintf( libname, "lib%s.so", WEBKIT_LIB);
2079 handle = dlopen( libname, RTLD_LAZY );
2080
2081 /* If we loaded it, grab the symbols we want */
2082 if ( handle )
2083 {
2084 _webkit_web_view_get_type = dlsym( handle, "webkit_web_view_get_type" );
2085 _webkit_web_view_load_html_string = dlsym( handle, "webkit_web_view_load_html_string" );
2086 _webkit_web_view_open = dlsym( handle, "webkit_web_view_open" );
2087 _webkit_web_view_new = dlsym( handle, "webkit_web_view_new" );
2088 _webkit_web_view_go_back = dlsym( handle, "webkit_web_view_go_back" );
2089 _webkit_web_view_go_forward = dlsym( handle, "webkit_web_view_go_forward" );
2090 _webkit_web_view_reload = dlsym( handle, "webkit_web_view_reload" );
2091 _webkit_web_view_stop_loading = dlsym( handle, "webkit_web_view_stop_loading" );
2092 # ifdef WEBKIT_CHECK_VERSION
2093 # if WEBKIT_CHECK_VERSION(1,1,5)
2094 _webkit_web_frame_print = dlsym( handle, "webkit_web_frame_print" );
2095 _webkit_web_view_get_focused_frame = dlsym( handle, "webkit_web_view_get_focused_frame" );
2096 # endif
2097 # endif
1992 } 2098 }
1993 } 2099 }
1994 #endif 2100 #endif
1995 2101
1996 /* 2102 /*
2038 2144
2039 gtk_rc_parse_string("style \"gtk-tooltips-style\" { bg[NORMAL] = \"#eeee00\" } widget \"gtk-tooltips\" style \"gtk-tooltips-style\""); 2145 gtk_rc_parse_string("style \"gtk-tooltips-style\" { bg[NORMAL] = \"#eeee00\" } widget \"gtk-tooltips\" style \"gtk-tooltips-style\"");
2040 2146
2041 #ifdef USE_GTKMOZEMBED 2147 #ifdef USE_GTKMOZEMBED
2042 init_mozembed(); 2148 init_mozembed();
2149 #endif
2150
2151 #ifdef USE_LIBGTKHTML2
2152 init_libgtkhtml2();
2153 #endif
2154
2155 #ifdef USE_WEBKIT
2156 init_webkit();
2043 #endif 2157 #endif
2044 /* 2158 /*
2045 * Setup logging/debugging 2159 * Setup logging/debugging
2046 */ 2160 */
2047 if ( (fname = getenv( "DWINDOWS_DEBUGFILE" ) ) != NULL ) 2161 if ( (fname = getenv( "DWINDOWS_DEBUGFILE" ) ) != NULL )
2137 */ 2251 */
2138 DWDialog *dw_dialog_new(void *data) 2252 DWDialog *dw_dialog_new(void *data)
2139 { 2253 {
2140 DWDialog *tmp = malloc(sizeof(DWDialog)); 2254 DWDialog *tmp = malloc(sizeof(DWDialog));
2141 2255
2142 tmp->eve = dw_event_new(); 2256 if ( tmp )
2143 dw_event_reset(tmp->eve); 2257 {
2144 tmp->data = data; 2258 tmp->eve = dw_event_new();
2145 tmp->done = FALSE; 2259 dw_event_reset(tmp->eve);
2146 tmp->method = FALSE; 2260 tmp->data = data;
2147 tmp->result = NULL; 2261 tmp->done = FALSE;
2148 2262 tmp->method = FALSE;
2149 return tmp; 2263 tmp->result = NULL;
2264 }
2265 return tmp;
2150 } 2266 }
2151 2267
2152 /* 2268 /*
2153 * Accepts a dialog struct and returns the given data to the 2269 * Accepts a dialog struct and returns the given data to the
2154 * initial called of dw_dialog_wait(). 2270 * initial called of dw_dialog_wait().
2338 text_width = 240; 2454 text_width = 240;
2339 text_height = 0; 2455 text_height = 0;
2340 stext = dw_text_new(outbuf, 0); 2456 stext = dw_text_new(outbuf, 0);
2341 dw_window_set_style(stext, DW_DT_WORDBREAK, DW_DT_WORDBREAK); 2457 dw_window_set_style(stext, DW_DT_WORDBREAK, DW_DT_WORDBREAK);
2342 dw_font_text_extents_get(stext, NULL, outbuf, &width, &height); 2458 dw_font_text_extents_get(stext, NULL, outbuf, &width, &height);
2459 #if 0
2343 height = height+3; 2460 height = height+3;
2344 if(width < text_width) 2461 if(width < text_width)
2345 text_height = height*2; 2462 text_height = height*2;
2346 else if(width < text_width*2) 2463 else if(width < text_width*2)
2347 text_height = height*3; 2464 text_height = height*3;
2350 else /* width > (3*text_width) */ 2467 else /* width > (3*text_width) */
2351 { 2468 {
2352 text_width = (width / 3) + 60; 2469 text_width = (width / 3) + 60;
2353 text_height = height*4; 2470 text_height = height*4;
2354 } 2471 }
2472 #else
2473 text_width = min( width, dw_screen_width() - extra_width - 100 );
2474 text_height = min( height, dw_screen_height() );
2475 #endif
2355 dw_box_pack_start(texttargetbox, stext, text_width, text_height, TRUE, TRUE, 2); 2476 dw_box_pack_start(texttargetbox, stext, text_width, text_height, TRUE, TRUE, 2);
2356 2477
2357 /* Buttons */ 2478 /* Buttons */
2358 buttonbox = dw_box_new(DW_HORZ, 10); 2479 buttonbox = dw_box_new(DW_HORZ, 10);
2359 2480
2398 dw_box_pack_start(buttonbox, cancelbutton, 50, 30, TRUE, FALSE, 2); 2519 dw_box_pack_start(buttonbox, cancelbutton, 50, 30, TRUE, FALSE, 2);
2399 dw_signal_connect(cancelbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_cancel_func), (void *)dwwait); 2520 dw_signal_connect(cancelbutton, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_cancel_func), (void *)dwwait);
2400 } 2521 }
2401 2522
2402 height = max(50,text_height)+100; 2523 height = max(50,text_height)+100;
2403 x = (dw_screen_width() - (text_width+60+extra_width))/2; 2524 x = ( - (text_width+60+extra_width))/2;
2404 y = (dw_screen_height() - height)/2; 2525 y = (dw_screen_height() - height)/2;
2405 2526
2406 dw_window_set_pos_size(entrywindow, x, y, (text_width+60+extra_width), height); 2527 dw_window_set_pos_size(entrywindow, x, y, (text_width+60+extra_width), height);
2407 2528
2408 dw_window_show(entrywindow); 2529 dw_window_show(entrywindow);
2700 pango_font_description_free(pfont); 2821 pango_font_description_free(pfont);
2701 } 2822 }
2702 #endif 2823 #endif
2703 DW_MUTEX_UNLOCK; 2824 DW_MUTEX_UNLOCK;
2704 return TRUE; 2825 return TRUE;
2826 }
2827
2828 /*
2829 * Gets the font used by a specified window (widget) handle.
2830 * Parameters:
2831 * handle: The window (widget) handle.
2832 */
2833 char *dw_window_get_font(HWND handle)
2834 {
2835 #if GTK_MAJOR_VERSION > 1
2836 PangoFontDescription *pfont;
2837 PangoContext *pcontext;
2838 #else
2839 GdkFont *gdkfont;
2840 #endif
2841 GtkWidget *handle2 = handle;
2842 char *font;
2843 char *retfont=NULL;
2844 int _locked_by_me = FALSE;
2845 gpointer data;
2846
2847 DW_MUTEX_LOCK;
2848 if(GTK_IS_SCROLLED_WINDOW(handle))
2849 {
2850 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
2851 if(tmp)
2852 handle2 = tmp;
2853 }
2854
2855 #if GTK_MAJOR_VERSION < 2
2856 ????
2857 /* Free old font if it exists */
2858 gdkfont = (GdkFont *)gtk_object_get_data(GTK_OBJECT(handle2), "_dw_gdkfont");
2859 if(gdkfont)
2860 gdk_font_unref(gdkfont);
2861 gdkfont = gdk_font_load(fontname);
2862 if(!gdkfont)
2863 gdkfont = gdk_font_load("fixed");
2864 gtk_object_set_data(GTK_OBJECT(handle2), "_dw_gdkfont", (gpointer)gdkfont);
2865 #endif
2866
2867 #if 0
2868 /* Free old font name if one is allocated */
2869 data = gtk_object_get_data(GTK_OBJECT(handle2), "_dw_fontname");
2870 if(data)
2871 free(data);
2872
2873 gtk_object_set_data(GTK_OBJECT(handle2), "_dw_fontname", (gpointer)font);
2874 #endif
2875
2876 #if GTK_MAJOR_VERSION > 1
2877 pcontext = gtk_widget_get_pango_context( handle2 );
2878 if ( pcontext )
2879 {
2880 pfont = pango_context_get_font_description( pcontext );
2881 if ( pfont )
2882 {
2883 font = pango_font_description_to_string( pfont );
2884 retfont = strdup(font);
2885 g_free( font );
2886 }
2887 }
2888 #endif
2889 DW_MUTEX_UNLOCK;
2890 return retfont;
2705 } 2891 }
2706 2892
2707 void _free_gdk_colors(HWND handle) 2893 void _free_gdk_colors(HWND handle)
2708 { 2894 {
2709 GdkColor *old = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_foregdk"); 2895 GdkColor *old = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_foregdk");
3281 } 3467 }
3282 3468
3283 /* 3469 /*
3284 * Adds a menuitem or submenu to an existing menu. 3470 * Adds a menuitem or submenu to an existing menu.
3285 * Parameters: 3471 * Parameters:
3286 * menu: The handle the the existing menu. 3472 * menu: The handle to the existing menu.
3287 * title: The title text on the menu item to be added. 3473 * title: The title text on the menu item to be added.
3288 * id: An ID to be used for message passing. 3474 * id: An ID to be used for message passing.
3289 * flags: Extended attributes to set on the menu. 3475 * flags: Extended attributes to set on the menu.
3290 * end: If TRUE memu is positioned at the end of the menu. 3476 * end: If TRUE memu is positioned at the end of the menu.
3291 * check: If TRUE menu is "check"able. 3477 * check: If TRUE menu is "check"able.
4197 strcpy(file, filename); 4383 strcpy(file, filename);
4198 4384
4199 /* check if we can read from this file (it exists and read permission) */ 4385 /* check if we can read from this file (it exists and read permission) */
4200 if ( access(file, 04 ) != 0 ) 4386 if ( access(file, 04 ) != 0 )
4201 { 4387 {
4202 /* Try with .xpm extention */ 4388 /* Try with various extentions */
4203 for ( i = 0; i < NUM_EXTS; i++ ) 4389 for ( i = 0; i < NUM_EXTS; i++ )
4204 { 4390 {
4205 strcpy( file, filename ); 4391 strcpy( file, filename );
4206 strcat( file, image_exts[i] ); 4392 strcat( file, image_exts[i] );
4207 if ( access( file, 04 ) == 0 ) 4393 if ( access( file, 04 ) == 0 )
6189 #elif defined(USE_IMLIB) 6375 #elif defined(USE_IMLIB)
6190 GdkImlibImage *image; 6376 GdkImlibImage *image;
6191 #endif 6377 #endif
6192 char *file = alloca(strlen(filename) + 5); 6378 char *file = alloca(strlen(filename) + 5);
6193 unsigned long z, ret = 0; 6379 unsigned long z, ret = 0;
6380 int found_ext = 0;
6381 int i;
6194 6382
6195 if (!file) 6383 if (!file)
6196 return 0; 6384 return 0;
6197 6385
6198 strcpy(file, filename); 6386 strcpy(file, filename);
6199 6387
6200 /* check if we can read from this file (it exists and read permission) */ 6388 /* check if we can read from this file (it exists and read permission) */
6201 if (access(file, 04) != 0) 6389 if (access(file, 04) != 0)
6202 { 6390 {
6203 /* Try with .xpm extention */ 6391 /* Try with various extentions */
6204 strcat(file, ".xpm"); 6392 for ( i = 0; i < NUM_EXTS; i++ )
6205 if(access(file, 04) != 0) 6393 {
6394 strcpy( file, filename );
6395 strcat( file, image_exts[i] );
6396 if ( access( file, 04 ) == 0 )
6397 {
6398 found_ext = 1;
6399 break;
6400 }
6401 }
6402 if ( found_ext == 0 )
6403 {
6206 return 0; 6404 return 0;
6405 }
6207 } 6406 }
6208 6407
6209 DW_MUTEX_LOCK; 6408 DW_MUTEX_LOCK;
6210 /* Find a free entry in the array */ 6409 /* Find a free entry in the array */
6211 for (z=0;z<_PixmapCount;z++) 6410 for (z=0;z<_PixmapCount;z++)
7535 PangoFontDescription *font; 7734 PangoFontDescription *font;
7536 #else 7735 #else
7537 GdkFont *font; 7736 GdkFont *font;
7538 #endif 7737 #endif
7539 char *fontname = NULL; 7738 char *fontname = NULL;
7739 int free_fontname = 0;
7540 7740
7541 if(!text) 7741 if(!text)
7542 return; 7742 return;
7543 7743
7544 DW_MUTEX_LOCK; 7744 DW_MUTEX_LOCK;
7545 if(handle) 7745 if(handle)
7746 {
7546 fontname = (char *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_fontname"); 7747 fontname = (char *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_fontname");
7748 if ( fontname == NULL )
7749 {
7750 fontname = dw_window_get_font(handle);
7751 free_fontname = 1;
7752 }
7753 }
7547 else if(pixmap) 7754 else if(pixmap)
7548 fontname = (char *)gtk_object_get_data(GTK_OBJECT(pixmap->handle), "_dw_fontname"); 7755 fontname = (char *)gtk_object_get_data(GTK_OBJECT(pixmap->handle), "_dw_fontname");
7549 7756
7550 #if GTK_MAJOR_VERSION > 1 7757 #if GTK_MAJOR_VERSION > 1
7551 font = pango_font_description_from_string(fontname ? fontname : "monospace 10"); 7758 font = pango_font_description_from_string(fontname ? fontname : "monospace 10");
7588 if(height) 7795 if(height)
7589 *height = gdk_string_height(font, text); 7796 *height = gdk_string_height(font, text);
7590 gdk_font_unref(font); 7797 gdk_font_unref(font);
7591 } 7798 }
7592 #endif 7799 #endif
7800 if ( free_fontname )
7801 free( fontname );
7593 DW_MUTEX_UNLOCK; 7802 DW_MUTEX_UNLOCK;
7594 } 7803 }
7595 7804
7596 /* 7805 /*
7597 * Creates a pixmap with given parameters. 7806 * Creates a pixmap with given parameters.
7647 GdkPixbuf *pixbuf; 7856 GdkPixbuf *pixbuf;
7648 #elif defined(USE_IMLIB) 7857 #elif defined(USE_IMLIB)
7649 GdkImlibImage *image; 7858 GdkImlibImage *image;
7650 #endif 7859 #endif
7651 char *file = alloca(strlen(filename) + 5); 7860 char *file = alloca(strlen(filename) + 5);
7861 int found_ext = 0;
7862 int i;
7652 7863
7653 if (!file || !(pixmap = calloc(1,sizeof(struct _hpixmap)))) 7864 if (!file || !(pixmap = calloc(1,sizeof(struct _hpixmap))))
7654 return NULL; 7865 return NULL;
7655 7866
7656 strcpy(file, filename); 7867 strcpy(file, filename);
7657 7868
7658 /* check if we can read from this file (it exists and read permission) */ 7869 /* check if we can read from this file (it exists and read permission) */
7659 if(access(file, 04) != 0) 7870 if(access(file, 04) != 0)
7660 { 7871 {
7661 /* Try with .xpm extention */ 7872 /* Try with various extentions */
7662 strcat(file, ".xpm"); 7873 for ( i = 0; i < NUM_EXTS; i++ )
7663 if(access(file, 04) != 0) 7874 {
7875 strcpy( file, filename );
7876 strcat( file, image_exts[i] );
7877 if ( access( file, 04 ) == 0 )
7878 {
7879 found_ext = 1;
7880 break;
7881 }
7882 }
7883 if ( found_ext == 0 )
7664 { 7884 {
7665 free(pixmap); 7885 free(pixmap);
7666 return NULL; 7886 return NULL;
7667 } 7887 }
7668 } 7888 }
9047 { 9267 {
9048 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_label"); 9268 GtkWidget *tmp = (GtkWidget *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_label");
9049 if(tmp && GTK_IS_LABEL(tmp)) 9269 if(tmp && GTK_IS_LABEL(tmp))
9050 handle2 = tmp; 9270 handle2 = tmp;
9051 } 9271 }
9052 if(GTK_IS_LABEL(handle2)) 9272 if ( GTK_IS_LABEL(handle2) )
9053 { 9273 {
9054 if(style & DW_DT_CENTER || style & DW_DT_VCENTER) 9274 gfloat x=DW_LEFT, y=DW_CENTER;
9055 { 9275 /* horizontal... */
9056 gfloat x, y; 9276 if ( style & DW_DT_CENTER )
9057 9277 x = DW_CENTER;
9058 x = y = DW_LEFT; 9278 if ( style & DW_DT_RIGHT )
9059 9279 x = DW_RIGHT;
9060 if(style & DW_DT_CENTER) 9280 if ( style & DW_DT_LEFT )
9061 x = DW_CENTER; 9281 x = DW_LEFT;
9062 9282 /* vertical... */
9063 if(style & DW_DT_VCENTER) 9283 if ( style & DW_DT_VCENTER )
9064 y = DW_CENTER; 9284 y = DW_CENTER;
9065 9285 if ( style & DW_DT_TOP )
9066 gtk_misc_set_alignment(GTK_MISC(handle2), x, y); 9286 y = DW_TOP;
9067 } 9287 if ( style & DW_DT_BOTTOM )
9068 if(style & DW_DT_WORDBREAK) 9288 y = DW_BOTTOM;
9069 gtk_label_set_line_wrap(GTK_LABEL(handle), TRUE); 9289 gtk_misc_set_alignment( GTK_MISC(handle2), x, y );
9290 if ( style & DW_DT_WORDBREAK )
9291 gtk_label_set_line_wrap( GTK_LABEL(handle), TRUE );
9070 } 9292 }
9071 DW_MUTEX_UNLOCK; 9293 DW_MUTEX_UNLOCK;
9072 } 9294 }
9073 9295
9074 /* 9296 /*
9343 GList *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2)); 9565 GList *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2));
9344 char *addtext = strdup(text); 9566 char *addtext = strdup(text);
9345 9567
9346 if(addtext) 9568 if(addtext)
9347 { 9569 {
9570 char *defstr = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(handle2)->entry));
9348 tmp = g_list_append(tmp, addtext); 9571 tmp = g_list_append(tmp, addtext);
9572 gtk_object_set_user_data(GTK_OBJECT(handle2), tmp);
9573 gtk_combo_set_popdown_strings(GTK_COMBO(handle2), tmp);
9574 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(handle2)->entry), defstr);
9575 }
9576 }
9577 gtk_object_set_data(GTK_OBJECT(handle), "_dw_appending", NULL);
9578 DW_MUTEX_UNLOCK;
9579 }
9580
9581 /*
9582 * Inserts the specified text int the listbox's (or combobox) entry list at the
9583 * position indicated.
9584 * Parameters:
9585 * handle: Handle to the listbox to be appended to.
9586 * text: Text to insert into listbox.
9587 * pos: 0-based index into listbox. -1 will append
9588 */
9589 void dw_listbox_insert(HWND handle, char *text, int pos)
9590 {
9591 GtkWidget *handle2 = handle;
9592 int _locked_by_me = FALSE;
9593
9594 DW_MUTEX_LOCK;
9595 if(GTK_IS_SCROLLED_WINDOW(handle))
9596 {
9597 GtkWidget *tmp = (GtkWidget *)gtk_object_get_user_data(GTK_OBJECT(handle));
9598 if(tmp)
9599 handle2 = tmp;
9600 }
9601 gtk_object_set_data(GTK_OBJECT(handle), "_dw_appending", GINT_TO_POINTER(1));
9602 if(GTK_IS_LIST(handle2))
9603 {
9604 GtkWidget *list_item;
9605 GList *tmp;
9606 char *font = (char *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_font");
9607 GdkColor *fore = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle2), "_dw_foregdk");
9608 GdkColor *back = (GdkColor *)gtk_object_get_data(GTK_OBJECT(handle2), "_dw_backgdk");
9609
9610 list_item=gtk_list_item_new_with_label(text);
9611
9612 if(font)
9613 _set_font(GTK_LIST_ITEM(list_item)->item.bin.child, font);
9614 if(fore && back)
9615 _set_color(GTK_LIST_ITEM(list_item)->item.bin.child,
9616 DW_RGB(fore->red, fore->green, fore->blue),
9617 DW_RGB(back->red, back->green, back->blue));
9618
9619 tmp = g_list_insert(NULL, list_item, pos);
9620 gtk_widget_show(list_item);
9621 gtk_list_append_items(GTK_LIST(handle2),tmp);
9622 }
9623 else if(GTK_IS_COMBO(handle2))
9624 {
9625 GList *tmp = (GList *)gtk_object_get_user_data(GTK_OBJECT(handle2));
9626 char *addtext = strdup(text);
9627
9628 if(addtext)
9629 {
9630 tmp = g_list_insert(tmp, addtext, pos);
9349 gtk_object_set_user_data(GTK_OBJECT(handle2), tmp); 9631 gtk_object_set_user_data(GTK_OBJECT(handle2), tmp);
9350 gtk_combo_set_popdown_strings(GTK_COMBO(handle2), tmp); 9632 gtk_combo_set_popdown_strings(GTK_COMBO(handle2), tmp);
9351 } 9633 }
9352 } 9634 }
9353 gtk_object_set_data(GTK_OBJECT(handle), "_dw_appending", NULL); 9635 gtk_object_set_data(GTK_OBJECT(handle), "_dw_appending", NULL);
10719 return; 11001 return;
10720 11002
10721 DW_MUTEX_LOCK; 11003 DW_MUTEX_LOCK;
10722 switch(action) 11004 switch(action)
10723 { 11005 {
10724 case DW_HTML_GOBACK: 11006 case DW_HTML_GOBACK:
10725 _gtk_moz_embed_go_back(GTK_MOZ_EMBED(handle)); 11007 _gtk_moz_embed_go_back(GTK_MOZ_EMBED(handle));
10726 break; 11008 break;
10727 case DW_HTML_GOFORWARD: 11009 case DW_HTML_GOFORWARD:
10728 _gtk_moz_embed_go_forward(GTK_MOZ_EMBED(handle)); 11010 _gtk_moz_embed_go_forward(GTK_MOZ_EMBED(handle));
10729 break; 11011 break;
10730 case DW_HTML_GOHOME: 11012 case DW_HTML_GOHOME:
10731 _gtk_moz_embed_load_url(GTK_MOZ_EMBED(handle), "http://dwindows.netlabs.org"); 11013 _gtk_moz_embed_load_url(GTK_MOZ_EMBED(handle), "http://dwindows.netlabs.org");
10732 break; 11014 break;
10733 case DW_HTML_RELOAD: 11015 case DW_HTML_RELOAD:
10734 _gtk_moz_embed_reload(GTK_MOZ_EMBED(handle), 0); 11016 _gtk_moz_embed_reload(GTK_MOZ_EMBED(handle), 0);
10735 break; 11017 break;
10736 case DW_HTML_STOP: 11018 case DW_HTML_STOP:
10737 _gtk_moz_embed_stop_load(GTK_MOZ_EMBED(handle)); 11019 _gtk_moz_embed_stop_load(GTK_MOZ_EMBED(handle));
10738 break; 11020 break;
10739 } 11021 }
10740 DW_MUTEX_UNLOCK; 11022 DW_MUTEX_UNLOCK;
10741 #endif 11023 #elif defined(USE_WEBKIT)
10742 } 11024 int _locked_by_me = FALSE;
10743 11025 WebKitWebView *web_view;
11026 WebKitWebFrame *frame;
11027
11028 if (!_webkit_web_view_open)
11029 return;
11030
11031 DW_MUTEX_LOCK;
11032 web_view = (WebKitWebView *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_web_view");
11033 if ( web_view )
11034 {
11035 switch( action )
11036 {
11037 case DW_HTML_GOBACK:
11038 _webkit_web_view_go_back( web_view );
11039 break;
11040 case DW_HTML_GOFORWARD:
11041 _webkit_web_view_go_forward( web_view );
11042 break;
11043 case DW_HTML_GOHOME:
11044 _webkit_web_view_open( web_view, "http://dwindows.netlabs.org" );
11045 break;
11046 case DW_HTML_RELOAD:
11047 _webkit_web_view_reload( web_view );
11048 break;
11049 case DW_HTML_STOP:
11050 _webkit_web_view_stop_loading( web_view );
11051 break;
11052 # ifdef WEBKIT_CHECK_VERSION
11053 # if WEBKIT_CHECK_VERSION(1,1,5)
11054 case DW_HTML_PRINT:
11055 frame = _webkit_web_view_get_focused_frame( web_view );
11056 _webkit_web_frame_print( frame );
11057 break;
11058 # endif
11059 # endif
11060 }
11061 }
11062 DW_MUTEX_UNLOCK;
11063 #endif
11064 }
11065
11066 #ifdef USE_LIBGTKHTML2
11067 void _dw_html_render_data( HWND handle, char *string, int i )
11068 {
11069 HtmlDocument *document;
11070
11071 html_view_set_document (HTML_VIEW(handle), NULL);
11072 document = (HtmlDocument *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_html_document" );
11073 /* html_document_clear (document);*/
11074 if ( document )
11075 {
11076 html_view_set_document (HTML_VIEW(handle), document);
11077 if ( html_document_open_stream( document, "text/html" ) )
11078 {
11079 html_document_write_stream( document, string, i );
11080 }
11081 html_document_close_stream (document);
11082 }
11083 }
11084 #endif
10744 /* 11085 /*
10745 * Render raw HTML code in the embedded HTML widget.. 11086 * Render raw HTML code in the embedded HTML widget..
10746 * Parameters: 11087 * Parameters:
10747 * handle: Handle to the window. 11088 * handle: Handle to the window.
10748 * string: String buffer containt HTML code to 11089 * string: String buffer containt HTML code to
10753 int dw_html_raw(HWND handle, char *string) 11094 int dw_html_raw(HWND handle, char *string)
10754 { 11095 {
10755 #ifdef USE_GTKMOZEMBED 11096 #ifdef USE_GTKMOZEMBED
10756 int _locked_by_me = FALSE; 11097 int _locked_by_me = FALSE;
10757 11098
10758 if(!_gtk_moz_embed_new) 11099 if (!_gtk_moz_embed_new)
10759 return -1; 11100 return -1;
10760 11101
10761 DW_MUTEX_LOCK; 11102 DW_MUTEX_LOCK;
10762 _gtk_moz_embed_render_data(GTK_MOZ_EMBED(handle), string, strlen(string), "file:///", "text/html"); 11103 _gtk_moz_embed_render_data(GTK_MOZ_EMBED(handle), string, strlen(string), "file:///", "text/html");
10763 gtk_widget_show(GTK_WIDGET(handle)); 11104 gtk_widget_show(GTK_WIDGET(handle));
11105 DW_MUTEX_UNLOCK;
11106 return 0;
11107 #elif defined(USE_LIBGTKHTML2)
11108 int _locked_by_me = FALSE;
11109
11110 if ( !_html_document_new )
11111 return -1;
11112
11113 DW_MUTEX_LOCK;
11114 _dw_html_render_data( handle, string, strlen(string) );
11115 gtk_widget_show( GTK_WIDGET(handle) );
11116 DW_MUTEX_UNLOCK;
11117 return 0;
11118 #elif defined(USE_WEBKIT)
11119 int _locked_by_me = FALSE;
11120 WebKitWebView *web_view;
11121
11122 if (!_webkit_web_view_open)
11123 return -1;
11124
11125 DW_MUTEX_LOCK;
11126 web_view = (WebKitWebView *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_web_view");
11127 if ( web_view )
11128 {
11129 _webkit_web_view_load_html_string( web_view, string, "file:///");
11130 gtk_widget_show( GTK_WIDGET(handle) );
11131 }
10764 DW_MUTEX_UNLOCK; 11132 DW_MUTEX_UNLOCK;
10765 return 0; 11133 return 0;
10766 #endif 11134 #endif
10767 return -1; 11135 return -1;
10768 } 11136 }
10785 return -1; 11153 return -1;
10786 11154
10787 DW_MUTEX_LOCK; 11155 DW_MUTEX_LOCK;
10788 _gtk_moz_embed_load_url( GTK_MOZ_EMBED(handle), url ); 11156 _gtk_moz_embed_load_url( GTK_MOZ_EMBED(handle), url );
10789 gtk_widget_show(GTK_WIDGET(handle)); 11157 gtk_widget_show(GTK_WIDGET(handle));
11158 DW_MUTEX_UNLOCK;
11159 return 0;
11160 #elif defined( USE_WEBKIT )
11161 int _locked_by_me = FALSE;
11162 WebKitWebView *web_view;
11163
11164 if (!_webkit_web_view_open)
11165 return -1;
11166
11167 DW_MUTEX_LOCK;
11168 web_view = (WebKitWebView *)gtk_object_get_data(GTK_OBJECT(handle), "_dw_web_view");
11169 if ( web_view )
11170 {
11171 _webkit_web_view_open( web_view, url );
11172 gtk_widget_show(GTK_WIDGET(handle));
11173 }
10790 DW_MUTEX_UNLOCK; 11174 DW_MUTEX_UNLOCK;
10791 return 0; 11175 return 0;
10792 #endif 11176 #endif
10793 return -1; 11177 return -1;
10794 } 11178 }
10881 } 11265 }
10882 return rc; 11266 return rc;
10883 } 11267 }
10884 #endif 11268 #endif
10885 11269
11270 #ifdef USE_LIBGTKHTML2
11271 static gboolean dom_mouse_down( HtmlDocument *doc, DomMouseEvent *event, gpointer data )
11272 {
11273 fprintf(stderr,"mouse down\n");
11274 return TRUE;
11275 }
11276 static gboolean dom_mouse_up( HtmlDocument *doc, DomMouseEvent *event, gpointer data )
11277 {
11278 fprintf(stderr,"mouse up\n");
11279 return TRUE;
11280 }
11281 static gboolean dom_mouse_click( HtmlDocument *doc, DomMouseEvent *event, gpointer data )
11282 {
11283 fprintf(stderr,"mouse click\n");
11284 return TRUE;
11285 }
11286 static gboolean url_requested (HtmlDocument *doc, const gchar *url, HtmlStream *stream)
11287 {
11288 fprintf(stderr,"URL IS REQUESTED: %s\n",url);
11289 return TRUE;
11290 }
11291 static void link_clicked (HtmlDocument *doc, const gchar *url)
11292 {
11293 fprintf(stderr,"link clicked: %s!\n", url);
11294 }
11295 #endif
11296
11297 #ifdef USE_WEBKIT
11298 # ifdef WEBKIT_CHECK_VERSION
11299 # if WEBKIT_CHECK_VERSION(1,1,5)
11300 static void _dw_html_print_cb( GtkWidget *widget, gpointer *data )
11301 {
11302 WebKitWebView *web_view = DW_WEBKIT_WEB_VIEW(data);
11303 WebKitWebFrame *frame;
11304
11305 frame = _webkit_web_view_get_focused_frame( web_view );
11306 _webkit_web_frame_print( frame );
11307 }
11308 /*
11309 * Fired when the user right-clicks to get the popup-menu on the HTML widget
11310 * We add a "Print" menu item to enable printing
11311 * user_data is not used
11312 */
11313 static void _dw_html_populate_popup_cb( WebKitWebView *web_view, GtkMenu *menu, gpointer user_data )
11314 {
11315 GtkWidget *image = gtk_image_new_from_stock( GTK_STOCK_PRINT, GTK_ICON_SIZE_MENU );
11316 GtkWidget *item = gtk_image_menu_item_new_with_label( "Print" );
11317
11318 gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(item), image );
11319 gtk_menu_append( GTK_MENU(menu), item);
11320 g_signal_connect( item, "activate", G_CALLBACK(_dw_html_print_cb), web_view );
11321 gtk_widget_show(item);
11322 }
11323 # endif
11324 # endif
11325 #endif
11326
10886 /* 11327 /*
10887 * Create a new Entryfield window (widget) to be packed. 11328 * Create a new Entryfield window (widget) to be packed.
10888 * Parameters: 11329 * Parameters:
10889 * text: The default text to be in the entryfield widget. 11330 * text: The default text to be in the entryfield widget.
10890 * id: An ID to be used with dw_window_from_id() or 0L. 11331 * id: An ID to be used with dw_window_from_id() or 0L.
10909 * Connect some signals 11350 * Connect some signals
10910 */ 11351 */
10911 gtk_signal_connect( GTK_OBJECT(widget), "net-stop", GTK_SIGNAL_FUNC(_dw_html_net_stop_cb), widget ); 11352 gtk_signal_connect( GTK_OBJECT(widget), "net-stop", GTK_SIGNAL_FUNC(_dw_html_net_stop_cb), widget );
10912 gtk_signal_connect( GTK_OBJECT(widget), "dom_mouse_click", GTK_SIGNAL_FUNC(_dw_dom_mouse_click_cb), widget ); 11353 gtk_signal_connect( GTK_OBJECT(widget), "dom_mouse_click", GTK_SIGNAL_FUNC(_dw_dom_mouse_click_cb), widget );
10913 } 11354 }
11355 #elif defined(USE_LIBGTKHTML2)
11356 if ( !_html_document_new )
11357 {
11358 widget = dw_box_new(DW_HORZ, 0);
11359 stext = dw_text_new( "HTML widget not available; you do not have access to libgtkhtml-2.", 0);
11360 dw_box_pack_start(widget, stext, 0, 0, TRUE, TRUE, 10);
11361 }
11362 else
11363 {
11364 HtmlDocument *document;
11365 document = html_document_new ();
11366 g_signal_connect (G_OBJECT (document), "dom_mouse_down", G_CALLBACK (dom_mouse_down), NULL);
11367 g_signal_connect (G_OBJECT (document), "dom_mouse_up", G_CALLBACK (dom_mouse_up), NULL);
11368 g_signal_connect (G_OBJECT (document), "dom_mouse_click", G_CALLBACK (dom_mouse_click), NULL);
11369 g_signal_connect (G_OBJECT (document), "request_url", G_CALLBACK (url_requested), NULL);
11370 g_signal_connect (G_OBJECT (document), "link_clicked", G_CALLBACK (link_clicked), NULL);
11371 widget = _html_view_new();
11372 gtk_object_set_data(GTK_OBJECT(widget), "_dw_html_document", (gpointer)document);
11373 }
11374 #elif defined(USE_WEBKIT)
11375 if (!_webkit_web_view_open)
11376 {
11377 widget = dw_box_new(DW_HORZ, 0);
11378 stext = dw_text_new( "HTML widget not available; you do not have access to webkit.", 0);
11379 dw_box_pack_start(widget, stext, 0, 0, TRUE, TRUE, 10);
11380 }
11381 else
11382 {
11383 WebKitWebView *web_view;
11384 widget = gtk_scrolled_window_new (NULL, NULL);
11385 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW (widget), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC );
11386 web_view = (WebKitWebView *)_webkit_web_view_new();
11387 /* web_view = WEBKIT_WEB_VIEW(_webkit_web_view_new() ); */
11388 gtk_container_add( GTK_CONTAINER (widget), GTK_WIDGET(web_view) );
11389 gtk_widget_show( GTK_WIDGET(web_view) );
11390 gtk_object_set_data( GTK_OBJECT(widget), "_dw_web_view", (gpointer)web_view );
11391 # ifdef WEBKIT_CHECK_VERSION
11392 # if WEBKIT_CHECK_VERSION(1,1,5)
11393 g_signal_connect( web_view, "populate-popup", G_CALLBACK(_dw_html_populate_popup_cb), NULL );
11394 # endif
11395 # endif
11396 }
10914 #else 11397 #else
10915 widget = dw_box_new(DW_HORZ, 0); 11398 widget = dw_box_new(DW_HORZ, 0);
10916 stext = dw_text_new( "HTML widget not available; you do not have access to gtkmozembed.", 0); 11399 stext = dw_text_new( "HTML widget not available; you do not have access to gtkmozembed.", 0);
10917 dw_box_pack_start(widget, stext, 0, 0, TRUE, TRUE, 10); 11400 dw_box_pack_start(widget, stext, 0, 0, TRUE, TRUE, 10);
10918 #endif 11401 #endif
11402 gtk_widget_show(widget);
10919 DW_MUTEX_UNLOCK; 11403 DW_MUTEX_UNLOCK;
10920 return widget; 11404 return widget;
10921 } 11405 }
10922 11406
10923 /* 11407 /*