Mercurial > dwindows
comparison gtk3/dw.c @ 1320:6bebcfa03b2b
Added support for dw_font_set_default() on GTK for appropriate widgets.
Removed GtkMozEmbed, GtkHtml2 and old versions of webkit from GTK3.
GTK3 only support webkit 3.0 and higher.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 06 Nov 2011 10:39:57 +0000 |
parents | c969db49606e |
children | 3f1ac800bf65 |
comparison
equal
deleted
inserted
replaced
1319:03f0bc85e7be | 1320:6bebcfa03b2b |
---|---|
29 #include <fcntl.h> | 29 #include <fcntl.h> |
30 #include <unistd.h> | 30 #include <unistd.h> |
31 #include <math.h> | 31 #include <math.h> |
32 #include <gdk/gdkkeysyms.h> | 32 #include <gdk/gdkkeysyms.h> |
33 | 33 |
34 #ifdef USE_GTKMOZEMBED | |
35 # include <gtkmozembed.h> | |
36 # undef GTK_TYPE_MOZ_EMBED | |
37 # define GTK_TYPE_MOZ_EMBED (_dw_moz_embed_get_type()) | |
38 #endif | |
39 | |
40 #ifdef USE_LIBGTKHTML2 | |
41 # include <libgtkhtml/gtkhtml.h> | |
42 #endif | |
43 | |
44 #ifdef USE_WEBKIT | 34 #ifdef USE_WEBKIT |
45 # if defined(USE_WEBKIT10) || defined(USE_WEBKIT11) | 35 #include <webkit/webkit.h> |
46 # include <webkit/webkit.h> | |
47 # else | |
48 # include <webkit.h> | |
49 # endif | |
50 #endif | 36 #endif |
51 | 37 |
52 #include <gdk-pixbuf/gdk-pixbuf.h> | 38 #include <gdk-pixbuf/gdk-pixbuf.h> |
53 | 39 |
54 #if __STDC_VERSION__ < 199901L | 40 #if __STDC_VERSION__ < 199901L |
61 | 47 |
62 #include "gtk/messagebox_error.xpm" | 48 #include "gtk/messagebox_error.xpm" |
63 #include "gtk/messagebox_warning.xpm" | 49 #include "gtk/messagebox_warning.xpm" |
64 #include "gtk/messagebox_information.xpm" | 50 #include "gtk/messagebox_information.xpm" |
65 #include "gtk/messagebox_question.xpm" | 51 #include "gtk/messagebox_question.xpm" |
66 | |
67 #ifdef USE_GTKMOZEMBED | |
68 extern gint mozilla_get_mouse_event_button(gpointer event); | |
69 extern gint mozilla_get_mouse_location( gpointer event, glong *x, glong *y); | |
70 #endif | |
71 | 52 |
72 /* These are used for resource management */ | 53 /* These are used for resource management */ |
73 #if defined(DW_RESOURCES) && !defined(BUILD_DLL) | 54 #if defined(DW_RESOURCES) && !defined(BUILD_DLL) |
74 extern DWResources _resources; | 55 extern DWResources _resources; |
75 #endif | 56 #endif |
160 static gint _tree_select_event(GtkTreeSelection *sel, gpointer data); | 141 static gint _tree_select_event(GtkTreeSelection *sel, gpointer data); |
161 static gint _tree_expand_event(GtkTreeView *treeview, GtkTreeIter *arg1, GtkTreePath *arg2, gpointer data); | 142 static gint _tree_expand_event(GtkTreeView *treeview, GtkTreeIter *arg1, GtkTreePath *arg2, gpointer data); |
162 static gint _switch_page_event(GtkNotebook *notebook, GtkWidget *page, guint page_num, gpointer data); | 143 static gint _switch_page_event(GtkNotebook *notebook, GtkWidget *page, guint page_num, gpointer data); |
163 static gint _column_click_event(GtkWidget *widget, gpointer data); | 144 static gint _column_click_event(GtkWidget *widget, gpointer data); |
164 | 145 |
165 /* Embedable Mozilla functions*/ | |
166 #ifdef USE_GTKMOZEMBED | |
167 void (*_gtk_moz_embed_go_back)(GtkMozEmbed *) = NULL; | |
168 void (*_gtk_moz_embed_go_forward)(GtkMozEmbed *) = NULL; | |
169 void (*_gtk_moz_embed_load_url)(GtkMozEmbed *, const char *) = NULL; | |
170 void (*_gtk_moz_embed_reload)(GtkMozEmbed *, guint32) = NULL; | |
171 void (*_gtk_moz_embed_stop_load)(GtkMozEmbed *) = NULL; | |
172 void (*_gtk_moz_embed_render_data)(GtkMozEmbed *, const char *, guint32, const char *, const char *) = NULL; | |
173 GtkWidget *(*_gtk_moz_embed_new)(void) = NULL; | |
174 GtkType (*_dw_moz_embed_get_type)(void) = NULL; | |
175 gboolean (*_gtk_moz_embed_can_go_back)(GtkMozEmbed *) = NULL; | |
176 gboolean (*_gtk_moz_embed_can_go_forward)(GtkMozEmbed *) = NULL; | |
177 void (*_gtk_moz_embed_set_comp_path)(const char *) = NULL; | |
178 void (*_gtk_moz_embed_set_profile_path)(const char *, const char *) = NULL; | |
179 void (*_gtk_moz_embed_push_startup)(void) = NULL; | |
180 #endif | |
181 | |
182 #ifdef USE_LIBGTKHTML2 | |
183 GtkHtmlContext *(*_gtk_html_context_get)(void) = NULL; | |
184 HtmlDocument *(*_html_document_new)(void) = NULL; | |
185 GtkWidget *(*_html_view_new)(void) = NULL; | |
186 #endif | |
187 | |
188 #ifdef USE_WEBKIT | 146 #ifdef USE_WEBKIT |
189 /* | 147 /* |
190 * we need to add these equivalents from webkitwebview.h so we can refer to | 148 * we need to add these equivalents from webkitwebview.h so we can refer to |
191 * our own pointers to functions (we don't link with the webkit libraries | 149 * our own pointers to functions (we don't link with the webkit libraries |
192 */ | 150 */ |
198 WEBKIT_API GtkWidget *(*_webkit_web_view_new)(void) = NULL; | 156 WEBKIT_API GtkWidget *(*_webkit_web_view_new)(void) = NULL; |
199 WEBKIT_API void (*_webkit_web_view_go_back)(WebKitWebView *) = NULL; | 157 WEBKIT_API void (*_webkit_web_view_go_back)(WebKitWebView *) = NULL; |
200 WEBKIT_API void (*_webkit_web_view_go_forward)(WebKitWebView *) = NULL; | 158 WEBKIT_API void (*_webkit_web_view_go_forward)(WebKitWebView *) = NULL; |
201 WEBKIT_API void (*_webkit_web_view_reload)(WebKitWebView *) = NULL; | 159 WEBKIT_API void (*_webkit_web_view_reload)(WebKitWebView *) = NULL; |
202 WEBKIT_API void (*_webkit_web_view_stop_loading)(WebKitWebView *) = NULL; | 160 WEBKIT_API void (*_webkit_web_view_stop_loading)(WebKitWebView *) = NULL; |
203 # ifdef WEBKIT_CHECK_VERSION | |
204 # if WEBKIT_CHECK_VERSION(1,1,5) | |
205 WEBKIT_API void (*_webkit_web_frame_print)(WebKitWebFrame *) = NULL; | 161 WEBKIT_API void (*_webkit_web_frame_print)(WebKitWebFrame *) = NULL; |
206 WEBKIT_API WebKitWebFrame *(*_webkit_web_view_get_focused_frame)(WebKitWebView *) = NULL; | 162 WEBKIT_API WebKitWebFrame *(*_webkit_web_view_get_focused_frame)(WebKitWebView *) = NULL; |
207 # endif | |
208 # endif | |
209 #endif | 163 #endif |
210 | 164 |
211 GObject *_DWObject = NULL; | 165 GObject *_DWObject = NULL; |
166 char *_DWDefaultFont = NULL; | |
212 | 167 |
213 typedef struct | 168 typedef struct |
214 { | 169 { |
215 void *func; | 170 void *func; |
216 char name[30]; | 171 char name[30]; |
1795 foreground->pixel = foreground->red = foreground->green = foreground->blue = 0; | 1750 foreground->pixel = foreground->red = foreground->green = foreground->blue = 0; |
1796 pthread_setspecific(_dw_fg_color_key, foreground); | 1751 pthread_setspecific(_dw_fg_color_key, foreground); |
1797 pthread_setspecific(_dw_bg_color_key, NULL); | 1752 pthread_setspecific(_dw_bg_color_key, NULL); |
1798 } | 1753 } |
1799 | 1754 |
1800 /* Try to load the mozilla embed shared libary */ | |
1801 #ifdef USE_GTKMOZEMBED | |
1802 #include <ctype.h> | |
1803 | |
1804 void init_mozembed(void) | |
1805 { | |
1806 void *handle = NULL; | |
1807 gchar *profile; | |
1808 handle = dlopen( "libgtkembedmoz.so", RTLD_LAZY ); | |
1809 | |
1810 /* If we loaded it, grab the symbols we want */ | |
1811 if ( handle ) | |
1812 { | |
1813 _gtk_moz_embed_go_back = dlsym(handle, "gtk_moz_embed_go_back"); | |
1814 _gtk_moz_embed_go_forward = dlsym(handle, "gtk_moz_embed_go_forward"); | |
1815 _gtk_moz_embed_load_url = dlsym(handle, "gtk_moz_embed_load_url"); | |
1816 _gtk_moz_embed_reload = dlsym(handle, "gtk_moz_embed_reload"); | |
1817 _gtk_moz_embed_stop_load = dlsym(handle, "gtk_moz_embed_stop_load"); | |
1818 _gtk_moz_embed_render_data = dlsym(handle, "gtk_moz_embed_render_data"); | |
1819 _dw_moz_embed_get_type = dlsym(handle, "gtk_moz_embed_get_type"); | |
1820 _gtk_moz_embed_new = dlsym(handle, "gtk_moz_embed_new"); | |
1821 _gtk_moz_embed_can_go_back = dlsym(handle, "gtk_moz_embed_can_go_back"); | |
1822 _gtk_moz_embed_can_go_forward = dlsym(handle, "gtk_moz_embed_can_go_forward"); | |
1823 _gtk_moz_embed_set_comp_path = dlsym(handle, "gtk_moz_embed_set_comp_path"); | |
1824 _gtk_moz_embed_set_profile_path = dlsym(handle, "gtk_moz_embed_set_profile_path"); | |
1825 _gtk_moz_embed_push_startup = dlsym(handle, "gtk_moz_embed_push_startup"); | |
1826 _gtk_moz_embed_set_comp_path( "/usr/lib/mozilla"); | |
1827 _gtk_moz_embed_set_comp_path( "/usr/lib/firefox"); | |
1828 profile = g_build_filename(g_get_home_dir(), ".dwindows/mozilla", NULL); | |
1829 | |
1830 /* initialize profile */ | |
1831 _gtk_moz_embed_set_profile_path(profile, "dwindows"); | |
1832 g_free(profile); | |
1833 | |
1834 /* startup done */ | |
1835 _gtk_moz_embed_push_startup(); | |
1836 } | |
1837 } | |
1838 #endif | |
1839 | |
1840 /* Try to load the libgtkhtml2 shared libary */ | |
1841 #ifdef USE_LIBGTKHTML2 | |
1842 #include <ctype.h> | |
1843 | |
1844 void init_libgtkhtml2 (void) | |
1845 { | |
1846 void *handle = NULL; | |
1847 handle = dlopen( "libgtkhtml-2.so", RTLD_LAZY ); | |
1848 | |
1849 /* If we loaded it, grab the symbols we want */ | |
1850 if ( handle ) | |
1851 { | |
1852 _html_document_new = dlsym(handle, "html_document_new"); | |
1853 _html_view_new = dlsym(handle, "html_view_new"); | |
1854 //... | |
1855 _gtk_html_context_get = dlsym(handle, "gtk_html_context_get" ); | |
1856 g_object_set( G_OBJECT(_gtk_html_context_get()), "debug_painting", FALSE, NULL ); | |
1857 } | |
1858 } | |
1859 #endif | |
1860 | |
1861 /* Try to load the WebKitGtk shared libary */ | 1755 /* Try to load the WebKitGtk shared libary */ |
1862 #ifdef USE_WEBKIT | 1756 #ifdef USE_WEBKIT |
1863 void init_webkit(void) | 1757 void init_webkit(void) |
1864 { | 1758 { |
1865 char libname[100]; | 1759 char libname[100]; |
1877 _webkit_web_view_new = dlsym( handle, "webkit_web_view_new" ); | 1771 _webkit_web_view_new = dlsym( handle, "webkit_web_view_new" ); |
1878 _webkit_web_view_go_back = dlsym( handle, "webkit_web_view_go_back" ); | 1772 _webkit_web_view_go_back = dlsym( handle, "webkit_web_view_go_back" ); |
1879 _webkit_web_view_go_forward = dlsym( handle, "webkit_web_view_go_forward" ); | 1773 _webkit_web_view_go_forward = dlsym( handle, "webkit_web_view_go_forward" ); |
1880 _webkit_web_view_reload = dlsym( handle, "webkit_web_view_reload" ); | 1774 _webkit_web_view_reload = dlsym( handle, "webkit_web_view_reload" ); |
1881 _webkit_web_view_stop_loading = dlsym( handle, "webkit_web_view_stop_loading" ); | 1775 _webkit_web_view_stop_loading = dlsym( handle, "webkit_web_view_stop_loading" ); |
1882 # ifdef WEBKIT_CHECK_VERSION | |
1883 # if WEBKIT_CHECK_VERSION(1,1,5) | |
1884 _webkit_web_frame_print = dlsym( handle, "webkit_web_frame_print" ); | 1776 _webkit_web_frame_print = dlsym( handle, "webkit_web_frame_print" ); |
1885 _webkit_web_view_get_focused_frame = dlsym( handle, "webkit_web_view_get_focused_frame" ); | 1777 _webkit_web_view_get_focused_frame = dlsym( handle, "webkit_web_view_get_focused_frame" ); |
1886 # endif | |
1887 # endif | |
1888 } | 1778 } |
1889 } | 1779 } |
1890 #endif | 1780 #endif |
1891 | 1781 |
1892 /* | 1782 /* |
1925 | 1815 |
1926 /* Create a global object for glib activities */ | 1816 /* Create a global object for glib activities */ |
1927 _DWObject = g_object_new(G_TYPE_OBJECT, NULL); | 1817 _DWObject = g_object_new(G_TYPE_OBJECT, NULL); |
1928 | 1818 |
1929 gtk_rc_parse_string("style \"gtk-tooltips-style\" { bg[NORMAL] = \"#eeee00\" } widget \"gtk-tooltips\" style \"gtk-tooltips-style\""); | 1819 gtk_rc_parse_string("style \"gtk-tooltips-style\" { bg[NORMAL] = \"#eeee00\" } widget \"gtk-tooltips\" style \"gtk-tooltips-style\""); |
1930 | |
1931 #ifdef USE_GTKMOZEMBED | |
1932 init_mozembed(); | |
1933 #endif | |
1934 | |
1935 #ifdef USE_LIBGTKHTML2 | |
1936 init_libgtkhtml2(); | |
1937 #endif | |
1938 | 1820 |
1939 #ifdef USE_WEBKIT | 1821 #ifdef USE_WEBKIT |
1940 init_webkit(); | 1822 init_webkit(); |
1941 #endif | 1823 #endif |
1942 | 1824 |
2488 * Parameters: | 2370 * Parameters: |
2489 * fontname: Font name in Dynamic Windows format. | 2371 * fontname: Font name in Dynamic Windows format. |
2490 */ | 2372 */ |
2491 void API dw_font_set_default(char *fontname) | 2373 void API dw_font_set_default(char *fontname) |
2492 { | 2374 { |
2375 char *oldfont = _DWDefaultFont; | |
2376 | |
2377 _DWDefaultFont = strdup(fontname); | |
2378 | |
2379 if(oldfont) | |
2380 free(oldfont); | |
2493 } | 2381 } |
2494 | 2382 |
2495 /* Convert DW style font to pango style */ | 2383 /* Convert DW style font to pango style */ |
2496 void _convert_font(char *font) | 2384 void _convert_font(char *font) |
2497 { | 2385 { |
2533 } | 2421 } |
2534 /* If it is a groupox we want to operate on the frame label */ | 2422 /* If it is a groupox we want to operate on the frame label */ |
2535 else if(GTK_IS_FRAME(handle)) | 2423 else if(GTK_IS_FRAME(handle)) |
2536 { | 2424 { |
2537 GtkWidget *tmp = gtk_frame_get_label_widget(GTK_FRAME(handle)); | 2425 GtkWidget *tmp = gtk_frame_get_label_widget(GTK_FRAME(handle)); |
2426 if(tmp) | |
2427 handle2 = tmp; | |
2428 } | |
2429 else if(GTK_IS_COMBO_BOX(handle) || GTK_IS_BUTTON(handle)) | |
2430 { | |
2431 GtkWidget *tmp = gtk_bin_get_child(GTK_BIN(handle)); | |
2538 if(tmp) | 2432 if(tmp) |
2539 handle2 = tmp; | 2433 handle2 = tmp; |
2540 } | 2434 } |
2541 | 2435 |
2542 _convert_font(font); | 2436 _convert_font(font); |
3134 g_object_set_data(G_OBJECT(tmp), "_dw_boxpad", GINT_TO_POINTER(pad)); | 3028 g_object_set_data(G_OBJECT(tmp), "_dw_boxpad", GINT_TO_POINTER(pad)); |
3135 g_object_set_data(G_OBJECT(frame), "_dw_boxhandle", (gpointer)tmp); | 3029 g_object_set_data(G_OBJECT(frame), "_dw_boxhandle", (gpointer)tmp); |
3136 gtk_container_add(GTK_CONTAINER(frame), tmp); | 3030 gtk_container_add(GTK_CONTAINER(frame), tmp); |
3137 gtk_widget_show(tmp); | 3031 gtk_widget_show(tmp); |
3138 gtk_widget_show(frame); | 3032 gtk_widget_show(frame); |
3033 if(_DWDefaultFont) | |
3034 dw_window_set_font(frame, _DWDefaultFont); | |
3139 DW_MUTEX_UNLOCK; | 3035 DW_MUTEX_UNLOCK; |
3140 return frame; | 3036 return frame; |
3141 } | 3037 } |
3142 | 3038 |
3143 /* | 3039 /* |
3653 | 3549 |
3654 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); | 3550 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree)); |
3655 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE); | 3551 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE); |
3656 gtk_widget_show(tree); | 3552 gtk_widget_show(tree); |
3657 | 3553 |
3554 if(_DWDefaultFont) | |
3555 dw_window_set_font(tmp, _DWDefaultFont); | |
3658 DW_MUTEX_UNLOCK; | 3556 DW_MUTEX_UNLOCK; |
3659 return tmp; | 3557 return tmp; |
3660 } | 3558 } |
3661 | 3559 |
3662 | 3560 |
3677 /* Left and centered */ | 3575 /* Left and centered */ |
3678 gtk_misc_set_alignment(GTK_MISC(tmp), 0.0f, 0.5f); | 3576 gtk_misc_set_alignment(GTK_MISC(tmp), 0.0f, 0.5f); |
3679 gtk_widget_show(tmp); | 3577 gtk_widget_show(tmp); |
3680 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); | 3578 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); |
3681 gtk_misc_set_alignment(GTK_MISC(tmp), DW_LEFT, DW_LEFT); | 3579 gtk_misc_set_alignment(GTK_MISC(tmp), DW_LEFT, DW_LEFT); |
3580 if(_DWDefaultFont) | |
3581 dw_window_set_font(tmp, _DWDefaultFont); | |
3682 DW_MUTEX_UNLOCK; | 3582 DW_MUTEX_UNLOCK; |
3683 return tmp; | 3583 return tmp; |
3684 } | 3584 } |
3685 | 3585 |
3686 /* | 3586 /* |
3704 | 3604 |
3705 /* Left and centered */ | 3605 /* Left and centered */ |
3706 gtk_misc_set_alignment(GTK_MISC(tmp), 0.0f, 0.5f); | 3606 gtk_misc_set_alignment(GTK_MISC(tmp), 0.0f, 0.5f); |
3707 g_object_set_data(G_OBJECT(frame), "_dw_id", GINT_TO_POINTER(id)); | 3607 g_object_set_data(G_OBJECT(frame), "_dw_id", GINT_TO_POINTER(id)); |
3708 g_object_set_data(G_OBJECT(frame), "_dw_label", (gpointer)tmp); | 3608 g_object_set_data(G_OBJECT(frame), "_dw_label", (gpointer)tmp); |
3609 if(_DWDefaultFont) | |
3610 dw_window_set_font(tmp, _DWDefaultFont); | |
3709 DW_MUTEX_UNLOCK; | 3611 DW_MUTEX_UNLOCK; |
3710 return frame; | 3612 return frame; |
3711 } | 3613 } |
3712 | 3614 |
3713 /* | 3615 /* |
3731 | 3633 |
3732 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); | 3634 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); |
3733 g_object_set_data(G_OBJECT(tmpbox), "_dw_user", (gpointer)tmp); | 3635 g_object_set_data(G_OBJECT(tmpbox), "_dw_user", (gpointer)tmp); |
3734 gtk_widget_show(tmp); | 3636 gtk_widget_show(tmp); |
3735 gtk_widget_show(tmpbox); | 3637 gtk_widget_show(tmpbox); |
3638 if(_DWDefaultFont) | |
3639 dw_window_set_font(tmpbox, _DWDefaultFont); | |
3736 DW_MUTEX_UNLOCK; | 3640 DW_MUTEX_UNLOCK; |
3737 return tmpbox; | 3641 return tmpbox; |
3738 } | 3642 } |
3739 | 3643 |
3740 /* | 3644 /* |
3754 gtk_entry_set_text(GTK_ENTRY(tmp), text); | 3658 gtk_entry_set_text(GTK_ENTRY(tmp), text); |
3755 | 3659 |
3756 gtk_widget_show(tmp); | 3660 gtk_widget_show(tmp); |
3757 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); | 3661 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); |
3758 | 3662 |
3663 if(_DWDefaultFont) | |
3664 dw_window_set_font(tmp, _DWDefaultFont); | |
3759 DW_MUTEX_UNLOCK; | 3665 DW_MUTEX_UNLOCK; |
3760 return tmp; | 3666 return tmp; |
3761 } | 3667 } |
3762 | 3668 |
3763 /* | 3669 /* |
3778 gtk_entry_set_text(GTK_ENTRY(tmp), text); | 3684 gtk_entry_set_text(GTK_ENTRY(tmp), text); |
3779 | 3685 |
3780 gtk_widget_show(tmp); | 3686 gtk_widget_show(tmp); |
3781 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); | 3687 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); |
3782 | 3688 |
3689 if(_DWDefaultFont) | |
3690 dw_window_set_font(tmp, _DWDefaultFont); | |
3783 DW_MUTEX_UNLOCK; | 3691 DW_MUTEX_UNLOCK; |
3784 return tmp; | 3692 return tmp; |
3785 } | 3693 } |
3786 | 3694 |
3787 /* | 3695 /* |
3802 gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(tmp), 0); | 3710 gtk_combo_box_set_entry_text_column(GTK_COMBO_BOX(tmp), 0); |
3803 gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(tmp))), text); | 3711 gtk_entry_set_text(GTK_ENTRY(gtk_bin_get_child(GTK_BIN(tmp))), text); |
3804 gtk_widget_show(tmp); | 3712 gtk_widget_show(tmp); |
3805 g_object_set_data(G_OBJECT(tmp), "_dw_tree_type", GINT_TO_POINTER(_DW_TREE_TYPE_COMBOBOX)); | 3713 g_object_set_data(G_OBJECT(tmp), "_dw_tree_type", GINT_TO_POINTER(_DW_TREE_TYPE_COMBOBOX)); |
3806 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); | 3714 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); |
3715 if(_DWDefaultFont) | |
3716 dw_window_set_font(tmp, _DWDefaultFont); | |
3807 DW_MUTEX_UNLOCK; | 3717 DW_MUTEX_UNLOCK; |
3808 return tmp; | 3718 return tmp; |
3809 } | 3719 } |
3810 | 3720 |
3811 /* | 3721 /* |
3821 | 3731 |
3822 DW_MUTEX_LOCK; | 3732 DW_MUTEX_LOCK; |
3823 tmp = gtk_button_new_with_label(text); | 3733 tmp = gtk_button_new_with_label(text); |
3824 gtk_widget_show(tmp); | 3734 gtk_widget_show(tmp); |
3825 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); | 3735 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); |
3736 if(_DWDefaultFont) | |
3737 dw_window_set_font(tmp, _DWDefaultFont); | |
3826 DW_MUTEX_UNLOCK; | 3738 DW_MUTEX_UNLOCK; |
3827 return tmp; | 3739 return tmp; |
3828 } | 3740 } |
3829 | 3741 |
3830 /* | 3742 /* |
3972 gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(tmp), TRUE); | 3884 gtk_spin_button_set_wrap(GTK_SPIN_BUTTON(tmp), TRUE); |
3973 gtk_widget_show(tmp); | 3885 gtk_widget_show(tmp); |
3974 g_object_set_data(G_OBJECT(tmp), "_dw_adjustment", (gpointer)adj); | 3886 g_object_set_data(G_OBJECT(tmp), "_dw_adjustment", (gpointer)adj); |
3975 g_object_set_data(G_OBJECT(adj), "_dw_spinbutton", (gpointer)tmp); | 3887 g_object_set_data(G_OBJECT(adj), "_dw_spinbutton", (gpointer)tmp); |
3976 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); | 3888 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); |
3889 if(_DWDefaultFont) | |
3890 dw_window_set_font(tmp, _DWDefaultFont); | |
3977 DW_MUTEX_UNLOCK; | 3891 DW_MUTEX_UNLOCK; |
3978 return tmp; | 3892 return tmp; |
3979 } | 3893 } |
3980 | 3894 |
3981 /* | 3895 /* |
3993 DW_MUTEX_LOCK; | 3907 DW_MUTEX_LOCK; |
3994 tmp = gtk_radio_button_new_with_label(NULL, text); | 3908 tmp = gtk_radio_button_new_with_label(NULL, text); |
3995 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); | 3909 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); |
3996 gtk_widget_show(tmp); | 3910 gtk_widget_show(tmp); |
3997 | 3911 |
3912 if(_DWDefaultFont) | |
3913 dw_window_set_font(tmp, _DWDefaultFont); | |
3998 DW_MUTEX_UNLOCK; | 3914 DW_MUTEX_UNLOCK; |
3999 return tmp; | 3915 return tmp; |
4000 } | 3916 } |
4001 | 3917 |
4002 /* | 3918 /* |
4087 | 4003 |
4088 DW_MUTEX_LOCK; | 4004 DW_MUTEX_LOCK; |
4089 tmp = gtk_check_button_new_with_label(text); | 4005 tmp = gtk_check_button_new_with_label(text); |
4090 gtk_widget_show(tmp); | 4006 gtk_widget_show(tmp); |
4091 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); | 4007 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); |
4008 if(_DWDefaultFont) | |
4009 dw_window_set_font(tmp, _DWDefaultFont); | |
4092 DW_MUTEX_UNLOCK; | 4010 DW_MUTEX_UNLOCK; |
4093 return tmp; | 4011 return tmp; |
4094 } | 4012 } |
4095 | 4013 |
4096 /* | 4014 /* |
4136 else | 4054 else |
4137 { | 4055 { |
4138 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE); | 4056 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE); |
4139 } | 4057 } |
4140 gtk_widget_show(tree); | 4058 gtk_widget_show(tree); |
4059 if(_DWDefaultFont) | |
4060 dw_window_set_font(tmp, _DWDefaultFont); | |
4141 DW_MUTEX_UNLOCK; | 4061 DW_MUTEX_UNLOCK; |
4142 return tmp; | 4062 return tmp; |
4143 } | 4063 } |
4144 | 4064 |
4145 /* | 4065 /* |
5538 { | 5458 { |
5539 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE); | 5459 gtk_tree_selection_set_mode(sel, GTK_SELECTION_SINGLE); |
5540 } | 5460 } |
5541 gtk_widget_show(tree); | 5461 gtk_widget_show(tree); |
5542 free(array); | 5462 free(array); |
5463 if(_DWDefaultFont) | |
5464 dw_window_set_font(handle, _DWDefaultFont); | |
5543 DW_MUTEX_UNLOCK; | 5465 DW_MUTEX_UNLOCK; |
5544 return DW_ERROR_NONE; | 5466 return DW_ERROR_NONE; |
5545 } | 5467 } |
5546 | 5468 |
5547 /* | 5469 /* |
6574 | GDK_POINTER_MOTION_MASK | 6496 | GDK_POINTER_MOTION_MASK |
6575 | GDK_POINTER_MOTION_HINT_MASK); | 6497 | GDK_POINTER_MOTION_HINT_MASK); |
6576 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); | 6498 g_object_set_data(G_OBJECT(tmp), "_dw_id", GINT_TO_POINTER(id)); |
6577 gtk_widget_set_can_focus(tmp, TRUE); | 6499 gtk_widget_set_can_focus(tmp, TRUE); |
6578 gtk_widget_show(tmp); | 6500 gtk_widget_show(tmp); |
6501 if(_DWDefaultFont) | |
6502 dw_window_set_font(tmp, _DWDefaultFont); | |
6579 DW_MUTEX_UNLOCK; | 6503 DW_MUTEX_UNLOCK; |
6580 return tmp; | 6504 return tmp; |
6581 } | 6505 } |
6582 | 6506 |
6583 /* Returns a GdkColor from a DW color */ | 6507 /* Returns a GdkColor from a DW color */ |
10034 * handle: Handle to the window. | 9958 * handle: Handle to the window. |
10035 * action: One of the DW_HTML_* constants. | 9959 * action: One of the DW_HTML_* constants. |
10036 */ | 9960 */ |
10037 void dw_html_action(HWND handle, int action) | 9961 void dw_html_action(HWND handle, int action) |
10038 { | 9962 { |
10039 #ifdef USE_GTKMOZEMBED | 9963 #ifdef USE_WEBKIT |
10040 int _locked_by_me = FALSE; | |
10041 | |
10042 if(!_gtk_moz_embed_new) | |
10043 return; | |
10044 | |
10045 DW_MUTEX_LOCK; | |
10046 switch(action) | |
10047 { | |
10048 case DW_HTML_GOBACK: | |
10049 _gtk_moz_embed_go_back(GTK_MOZ_EMBED(handle)); | |
10050 break; | |
10051 case DW_HTML_GOFORWARD: | |
10052 _gtk_moz_embed_go_forward(GTK_MOZ_EMBED(handle)); | |
10053 break; | |
10054 case DW_HTML_GOHOME: | |
10055 _gtk_moz_embed_load_url(GTK_MOZ_EMBED(handle), "http://dwindows.netlabs.org"); | |
10056 break; | |
10057 case DW_HTML_RELOAD: | |
10058 _gtk_moz_embed_reload(GTK_MOZ_EMBED(handle), 0); | |
10059 break; | |
10060 case DW_HTML_STOP: | |
10061 _gtk_moz_embed_stop_load(GTK_MOZ_EMBED(handle)); | |
10062 break; | |
10063 } | |
10064 DW_MUTEX_UNLOCK; | |
10065 #elif defined(USE_WEBKIT) | |
10066 int _locked_by_me = FALSE; | 9964 int _locked_by_me = FALSE; |
10067 WebKitWebView *web_view; | 9965 WebKitWebView *web_view; |
10068 WebKitWebFrame *frame; | 9966 WebKitWebFrame *frame; |
10069 | 9967 |
10070 if (!_webkit_web_view_open) | 9968 if (!_webkit_web_view_open) |
10089 _webkit_web_view_reload( web_view ); | 9987 _webkit_web_view_reload( web_view ); |
10090 break; | 9988 break; |
10091 case DW_HTML_STOP: | 9989 case DW_HTML_STOP: |
10092 _webkit_web_view_stop_loading( web_view ); | 9990 _webkit_web_view_stop_loading( web_view ); |
10093 break; | 9991 break; |
10094 # ifdef WEBKIT_CHECK_VERSION | |
10095 # if WEBKIT_CHECK_VERSION(1,1,5) | |
10096 case DW_HTML_PRINT: | 9992 case DW_HTML_PRINT: |
10097 frame = _webkit_web_view_get_focused_frame( web_view ); | 9993 frame = _webkit_web_view_get_focused_frame( web_view ); |
10098 _webkit_web_frame_print( frame ); | 9994 _webkit_web_frame_print( frame ); |
10099 break; | 9995 break; |
10100 # endif | |
10101 # endif | |
10102 } | 9996 } |
10103 } | 9997 } |
10104 DW_MUTEX_UNLOCK; | 9998 DW_MUTEX_UNLOCK; |
10105 #endif | 9999 #endif |
10106 } | 10000 } |
10107 | 10001 |
10108 #ifdef USE_LIBGTKHTML2 | |
10109 void _dw_html_render_data( HWND handle, char *string, int i ) | |
10110 { | |
10111 HtmlDocument *document; | |
10112 | |
10113 html_view_set_document (HTML_VIEW(handle), NULL); | |
10114 document = (HtmlDocument *)g_object_get_data(G_OBJECT(handle), "_dw_html_document" ); | |
10115 /* html_document_clear (document);*/ | |
10116 if ( document ) | |
10117 { | |
10118 html_view_set_document (HTML_VIEW(handle), document); | |
10119 if ( html_document_open_stream( document, "text/html" ) ) | |
10120 { | |
10121 html_document_write_stream( document, string, i ); | |
10122 } | |
10123 html_document_close_stream (document); | |
10124 } | |
10125 } | |
10126 #endif | |
10127 /* | 10002 /* |
10128 * Render raw HTML code in the embedded HTML widget.. | 10003 * Render raw HTML code in the embedded HTML widget.. |
10129 * Parameters: | 10004 * Parameters: |
10130 * handle: Handle to the window. | 10005 * handle: Handle to the window. |
10131 * string: String buffer containt HTML code to | 10006 * string: String buffer containt HTML code to |
10133 * Returns: | 10008 * Returns: |
10134 * 0 on success. | 10009 * 0 on success. |
10135 */ | 10010 */ |
10136 int dw_html_raw(HWND handle, char *string) | 10011 int dw_html_raw(HWND handle, char *string) |
10137 { | 10012 { |
10138 #ifdef USE_GTKMOZEMBED | 10013 #ifdef USE_WEBKIT |
10139 int _locked_by_me = FALSE; | |
10140 | |
10141 if (!_gtk_moz_embed_new) | |
10142 return -1; | |
10143 | |
10144 DW_MUTEX_LOCK; | |
10145 _gtk_moz_embed_render_data(GTK_MOZ_EMBED(handle), string, strlen(string), "file:///", "text/html"); | |
10146 gtk_widget_show(GTK_WIDGET(handle)); | |
10147 DW_MUTEX_UNLOCK; | |
10148 return 0; | |
10149 #elif defined(USE_LIBGTKHTML2) | |
10150 int _locked_by_me = FALSE; | |
10151 | |
10152 if ( !_html_document_new ) | |
10153 return -1; | |
10154 | |
10155 DW_MUTEX_LOCK; | |
10156 _dw_html_render_data( handle, string, strlen(string) ); | |
10157 gtk_widget_show( GTK_WIDGET(handle) ); | |
10158 DW_MUTEX_UNLOCK; | |
10159 return 0; | |
10160 #elif defined(USE_WEBKIT) | |
10161 int _locked_by_me = FALSE; | 10014 int _locked_by_me = FALSE; |
10162 WebKitWebView *web_view; | 10015 WebKitWebView *web_view; |
10163 | 10016 |
10164 if (!_webkit_web_view_open) | 10017 if (!_webkit_web_view_open) |
10165 return -1; | 10018 return -1; |
10171 _webkit_web_view_load_html_string( web_view, string, "file:///"); | 10024 _webkit_web_view_load_html_string( web_view, string, "file:///"); |
10172 gtk_widget_show( GTK_WIDGET(handle) ); | 10025 gtk_widget_show( GTK_WIDGET(handle) ); |
10173 } | 10026 } |
10174 DW_MUTEX_UNLOCK; | 10027 DW_MUTEX_UNLOCK; |
10175 return 0; | 10028 return 0; |
10029 #else | |
10030 return -1; | |
10176 #endif | 10031 #endif |
10177 return -1; | |
10178 } | 10032 } |
10179 | 10033 |
10180 /* | 10034 /* |
10181 * Render file or web page in the embedded HTML widget.. | 10035 * Render file or web page in the embedded HTML widget.. |
10182 * Parameters: | 10036 * Parameters: |
10186 * Returns: | 10040 * Returns: |
10187 * 0 on success. | 10041 * 0 on success. |
10188 */ | 10042 */ |
10189 int dw_html_url(HWND handle, char *url) | 10043 int dw_html_url(HWND handle, char *url) |
10190 { | 10044 { |
10191 #ifdef USE_GTKMOZEMBED | 10045 #ifdef USE_WEBKIT |
10192 int _locked_by_me = FALSE; | |
10193 | |
10194 if (!_gtk_moz_embed_new) | |
10195 return -1; | |
10196 | |
10197 DW_MUTEX_LOCK; | |
10198 _gtk_moz_embed_load_url( GTK_MOZ_EMBED(handle), url ); | |
10199 gtk_widget_show(GTK_WIDGET(handle)); | |
10200 DW_MUTEX_UNLOCK; | |
10201 return 0; | |
10202 #elif defined( USE_WEBKIT ) | |
10203 int _locked_by_me = FALSE; | 10046 int _locked_by_me = FALSE; |
10204 WebKitWebView *web_view; | 10047 WebKitWebView *web_view; |
10205 | 10048 |
10206 if (!_webkit_web_view_open) | 10049 if (!_webkit_web_view_open) |
10207 return -1; | 10050 return -1; |
10213 _webkit_web_view_open( web_view, url ); | 10056 _webkit_web_view_open( web_view, url ); |
10214 gtk_widget_show(GTK_WIDGET(handle)); | 10057 gtk_widget_show(GTK_WIDGET(handle)); |
10215 } | 10058 } |
10216 DW_MUTEX_UNLOCK; | 10059 DW_MUTEX_UNLOCK; |
10217 return 0; | 10060 return 0; |
10061 #else | |
10062 return -1; | |
10218 #endif | 10063 #endif |
10219 return -1; | 10064 } |
10220 } | |
10221 | |
10222 #ifdef USE_GTKMOZEMBED | |
10223 /* | |
10224 * Callback for a HTML widget when the "Forward" menu item is selected | |
10225 */ | |
10226 static int _dw_html_forward_callback(HWND window, void *data) | |
10227 { | |
10228 HWND handle=(HWND)data; | |
10229 dw_html_action( handle, DW_HTML_GOFORWARD ); | |
10230 return TRUE; | |
10231 } | |
10232 | |
10233 /* | |
10234 * Callback for a HTML widget when the "Back" menu item is selected | |
10235 */ | |
10236 static int _dw_html_backward_callback(HWND window, void *data) | |
10237 { | |
10238 HWND handle=(HWND)data; | |
10239 dw_html_action( handle, DW_HTML_GOBACK ); | |
10240 return TRUE; | |
10241 } | |
10242 | |
10243 /* | |
10244 * Callback for a HTML widget when the "Reload" menu item is selected | |
10245 */ | |
10246 static int _dw_html_reload_callback(HWND window, void *data) | |
10247 { | |
10248 HWND handle=(HWND)data; | |
10249 dw_html_action( handle, DW_HTML_RELOAD ); | |
10250 return TRUE; | |
10251 } | |
10252 | |
10253 /* | |
10254 * Callback for a HTML widget when a page has completed loading | |
10255 * Once the page has finished loading, show the widget. | |
10256 */ | |
10257 void _dw_html_net_stop_cb( GtkMozEmbed *embed, gpointer data ) | |
10258 { | |
10259 gtk_widget_show(GTK_WIDGET(data)); | |
10260 } | |
10261 | |
10262 /* | |
10263 * Callback for a HTML widget when a mouse button is clicked inside the widget | |
10264 * If the right mouse button is clicked, popup a context menu | |
10265 */ | |
10266 static gint _dw_dom_mouse_click_cb (GtkMozEmbed *dummy, gpointer dom_event, gpointer embed) | |
10267 { | |
10268 gint button,rc; | |
10269 glong x,y; | |
10270 int flags; | |
10271 | |
10272 button = mozilla_get_mouse_event_button( dom_event ); | |
10273 if ( button == 2 ) | |
10274 { | |
10275 HWND menuitem; | |
10276 HMENUI popup; | |
10277 /* | |
10278 * Right mouse button; display context menu | |
10279 */ | |
10280 rc = mozilla_get_mouse_location( dom_event, &x, &y); | |
10281 popup = dw_menu_new( 0 ); | |
10282 if ( _gtk_moz_embed_can_go_forward(GTK_MOZ_EMBED(embed) ) ) | |
10283 flags = DW_MIS_ENABLED; | |
10284 else | |
10285 flags = DW_MIS_DISABLED; | |
10286 menuitem = dw_menu_append_item( popup, "Forward", 1, flags, TRUE, FALSE, 0 ); | |
10287 dw_signal_connect( menuitem, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_html_forward_callback), embed ); | |
10288 | |
10289 if ( _gtk_moz_embed_can_go_back(GTK_MOZ_EMBED(embed) ) ) | |
10290 flags = DW_MIS_ENABLED; | |
10291 else | |
10292 flags = DW_MIS_DISABLED; | |
10293 menuitem = dw_menu_append_item( popup, "Back", 2, flags, TRUE, FALSE, 0 ); | |
10294 dw_signal_connect( menuitem, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_html_backward_callback), embed ); | |
10295 | |
10296 dw_menu_append_item( popup, DW_MENU_SEPARATOR, 99, 0, TRUE, FALSE, 0 ); | |
10297 | |
10298 menuitem = dw_menu_append_item( popup, "Reload", 3, 0, TRUE, FALSE, 0 ); | |
10299 dw_signal_connect( menuitem, DW_SIGNAL_CLICKED, DW_SIGNAL_FUNC(_dw_html_reload_callback), embed ); | |
10300 | |
10301 dw_menu_popup( &popup, embed, x, y ); | |
10302 rc = TRUE; | |
10303 } | |
10304 else | |
10305 { | |
10306 rc = FALSE; | |
10307 } | |
10308 return rc; | |
10309 } | |
10310 #endif | |
10311 | |
10312 #ifdef USE_LIBGTKHTML2 | |
10313 static gboolean dom_mouse_down( HtmlDocument *doc, DomMouseEvent *event, gpointer data ) | |
10314 { | |
10315 fprintf(stderr,"mouse down\n"); | |
10316 return TRUE; | |
10317 } | |
10318 static gboolean dom_mouse_up( HtmlDocument *doc, DomMouseEvent *event, gpointer data ) | |
10319 { | |
10320 fprintf(stderr,"mouse up\n"); | |
10321 return TRUE; | |
10322 } | |
10323 static gboolean dom_mouse_click( HtmlDocument *doc, DomMouseEvent *event, gpointer data ) | |
10324 { | |
10325 fprintf(stderr,"mouse click\n"); | |
10326 return TRUE; | |
10327 } | |
10328 static gboolean url_requested (HtmlDocument *doc, const gchar *url, HtmlStream *stream) | |
10329 { | |
10330 fprintf(stderr,"URL IS REQUESTED: %s\n",url); | |
10331 return TRUE; | |
10332 } | |
10333 static void link_clicked (HtmlDocument *doc, const gchar *url) | |
10334 { | |
10335 fprintf(stderr,"link clicked: %s!\n", url); | |
10336 } | |
10337 #endif | |
10338 | 10065 |
10339 #ifdef USE_WEBKIT | 10066 #ifdef USE_WEBKIT |
10340 # ifdef WEBKIT_CHECK_VERSION | |
10341 # if WEBKIT_CHECK_VERSION(1,1,5) | |
10342 static void _dw_html_print_cb( GtkWidget *widget, gpointer *data ) | 10067 static void _dw_html_print_cb( GtkWidget *widget, gpointer *data ) |
10343 { | 10068 { |
10344 WebKitWebView *web_view = DW_WEBKIT_WEB_VIEW(data); | 10069 WebKitWebView *web_view = DW_WEBKIT_WEB_VIEW(data); |
10345 WebKitWebFrame *frame; | 10070 WebKitWebFrame *frame; |
10346 | 10071 |
10360 gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(item), image ); | 10085 gtk_image_menu_item_set_image( GTK_IMAGE_MENU_ITEM(item), image ); |
10361 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | 10086 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
10362 g_signal_connect( item, "activate", G_CALLBACK(_dw_html_print_cb), web_view ); | 10087 g_signal_connect( item, "activate", G_CALLBACK(_dw_html_print_cb), web_view ); |
10363 gtk_widget_show(item); | 10088 gtk_widget_show(item); |
10364 } | 10089 } |
10365 # endif | |
10366 # endif | |
10367 #endif | 10090 #endif |
10368 | 10091 |
10369 /* | 10092 /* |
10370 * Create a new Entryfield window (widget) to be packed. | 10093 * Create a new Entryfield window (widget) to be packed. |
10371 * Parameters: | 10094 * Parameters: |
10376 { | 10099 { |
10377 GtkWidget *widget,*stext; | 10100 GtkWidget *widget,*stext; |
10378 int _locked_by_me = FALSE; | 10101 int _locked_by_me = FALSE; |
10379 | 10102 |
10380 DW_MUTEX_LOCK; | 10103 DW_MUTEX_LOCK; |
10381 #ifdef USE_GTKMOZEMBED | 10104 #ifdef USE_WEBKIT |
10382 if (!_gtk_moz_embed_new) | |
10383 { | |
10384 widget = dw_box_new(DW_HORZ, 0); | |
10385 stext = dw_text_new( "HTML widget not available; you do not have access to gtkmozembed.", 0); | |
10386 dw_box_pack_start(widget, stext, 0, 0, TRUE, TRUE, 10); | |
10387 } | |
10388 else | |
10389 { | |
10390 widget = _gtk_moz_embed_new(); | |
10391 /* | |
10392 * Connect some signals | |
10393 */ | |
10394 g_signal_connect( G_OBJECT(widget), "net-stop", G_CALLBACK(_dw_html_net_stop_cb), widget ); | |
10395 g_signal_connect( G_OBJECT(widget), "dom_mouse_click", G_CALLBACK(_dw_dom_mouse_click_cb), widget ); | |
10396 } | |
10397 #elif defined(USE_LIBGTKHTML2) | |
10398 if ( !_html_document_new ) | |
10399 { | |
10400 widget = dw_box_new(DW_HORZ, 0); | |
10401 stext = dw_text_new( "HTML widget not available; you do not have access to libgtkhtml-2.", 0); | |
10402 dw_box_pack_start(widget, stext, 0, 0, TRUE, TRUE, 10); | |
10403 } | |
10404 else | |
10405 { | |
10406 HtmlDocument *document; | |
10407 document = html_document_new (); | |
10408 g_signal_connect (G_OBJECT (document), "dom_mouse_down", G_CALLBACK (dom_mouse_down), NULL); | |
10409 g_signal_connect (G_OBJECT (document), "dom_mouse_up", G_CALLBACK (dom_mouse_up), NULL); | |
10410 g_signal_connect (G_OBJECT (document), "dom_mouse_click", G_CALLBACK (dom_mouse_click), NULL); | |
10411 g_signal_connect (G_OBJECT (document), "request_url", G_CALLBACK (url_requested), NULL); | |
10412 g_signal_connect (G_OBJECT (document), "link_clicked", G_CALLBACK (link_clicked), NULL); | |
10413 widget = _html_view_new(); | |
10414 g_object_set_data(G_OBJECT(widget), "_dw_html_document", (gpointer)document); | |
10415 } | |
10416 #elif defined(USE_WEBKIT) | |
10417 if (!_webkit_web_view_open) | 10105 if (!_webkit_web_view_open) |
10418 { | 10106 { |
10419 widget = dw_box_new(DW_HORZ, 0); | 10107 widget = dw_box_new(DW_HORZ, 0); |
10420 stext = dw_text_new( "HTML widget not available; you do not have access to webkit.", 0); | 10108 stext = dw_text_new( "HTML widget not available; you do not have access to webkit.", 0); |
10421 dw_box_pack_start(widget, stext, 0, 0, TRUE, TRUE, 10); | 10109 dw_box_pack_start(widget, stext, 0, 0, TRUE, TRUE, 10); |
10424 { | 10112 { |
10425 WebKitWebView *web_view; | 10113 WebKitWebView *web_view; |
10426 widget = gtk_scrolled_window_new (NULL, NULL); | 10114 widget = gtk_scrolled_window_new (NULL, NULL); |
10427 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW (widget), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); | 10115 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW (widget), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC ); |
10428 web_view = (WebKitWebView *)_webkit_web_view_new(); | 10116 web_view = (WebKitWebView *)_webkit_web_view_new(); |
10429 /* web_view = WEBKIT_WEB_VIEW(_webkit_web_view_new() ); */ | 10117 /* web_view = WEBKIT_WEB_VIEW(_webkit_web_view_new() ); */ |
10430 gtk_container_add( GTK_CONTAINER (widget), GTK_WIDGET(web_view) ); | 10118 gtk_container_add( GTK_CONTAINER (widget), GTK_WIDGET(web_view) ); |
10431 gtk_widget_show( GTK_WIDGET(web_view) ); | 10119 gtk_widget_show( GTK_WIDGET(web_view) ); |
10432 g_object_set_data(G_OBJECT(widget), "_dw_web_view", (gpointer)web_view); | 10120 g_object_set_data(G_OBJECT(widget), "_dw_web_view", (gpointer)web_view); |
10433 # ifdef WEBKIT_CHECK_VERSION | |
10434 # if WEBKIT_CHECK_VERSION(1,1,5) | |
10435 g_signal_connect( web_view, "populate-popup", G_CALLBACK(_dw_html_populate_popup_cb), NULL ); | 10121 g_signal_connect( web_view, "populate-popup", G_CALLBACK(_dw_html_populate_popup_cb), NULL ); |
10436 # endif | |
10437 # endif | |
10438 } | 10122 } |
10439 #else | 10123 #else |
10440 widget = dw_box_new(DW_HORZ, 0); | 10124 widget = dw_box_new(DW_HORZ, 0); |
10441 stext = dw_text_new( "HTML widget not available; you do not have access to gtkmozembed.", 0); | 10125 stext = dw_text_new( "HTML widget not available; you do not have access to webkit.", 0); |
10442 dw_box_pack_start(widget, stext, 0, 0, TRUE, TRUE, 10); | 10126 dw_box_pack_start(widget, stext, 0, 0, TRUE, TRUE, 10); |
10443 #endif | 10127 #endif |
10444 gtk_widget_show(widget); | 10128 gtk_widget_show(widget); |
10445 DW_MUTEX_UNLOCK; | 10129 DW_MUTEX_UNLOCK; |
10446 return widget; | 10130 return widget; |