Mercurial > dwindows
comparison gtk/dw.c @ 588:1b398af1ec38
Implemented dynamic loading of the Mozilla renderer.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 23 May 2005 01:43:36 +0000 |
parents | 9e81f23b57ae |
children | 2111cdb6c451 |
comparison
equal
deleted
inserted
replaced
587:9e81f23b57ae | 588:1b398af1ec38 |
---|---|
29 #ifdef USE_IMLIB | 29 #ifdef USE_IMLIB |
30 #include <gdk_imlib.h> | 30 #include <gdk_imlib.h> |
31 #endif | 31 #endif |
32 #ifdef USE_GTKMOZEMBED | 32 #ifdef USE_GTKMOZEMBED |
33 #include <gtkmozembed.h> | 33 #include <gtkmozembed.h> |
34 #undef GTK_TYPE_MOZ_EMBED | |
35 #define GTK_TYPE_MOZ_EMBED (_dw_moz_embed_get_type()) | |
34 #endif | 36 #endif |
35 #if GTK_MAJOR_VERSION > 1 | 37 #if GTK_MAJOR_VERSION > 1 |
36 #include <gdk-pixbuf/gdk-pixbuf.h> | 38 #include <gdk-pixbuf/gdk-pixbuf.h> |
37 #endif | 39 #endif |
38 | 40 |
121 static gint _tree_select_event(GtkTree *tree, GtkWidget *child, gpointer data); | 123 static gint _tree_select_event(GtkTree *tree, GtkWidget *child, gpointer data); |
122 static gint _tree_expand_event(GtkTreeItem *treeitem, gpointer data); | 124 static gint _tree_expand_event(GtkTreeItem *treeitem, gpointer data); |
123 #endif | 125 #endif |
124 static gint _switch_page_event(GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, gpointer data); | 126 static gint _switch_page_event(GtkNotebook *notebook, GtkNotebookPage *page, guint page_num, gpointer data); |
125 static gint _column_click_event(GtkWidget *widget, gint column_num, gpointer data); | 127 static gint _column_click_event(GtkWidget *widget, gint column_num, gpointer data); |
128 | |
129 /* Embedable Mozilla functions*/ | |
130 #ifdef USE_GTKMOZEMBED | |
131 void (*_gtk_moz_embed_go_back)(GtkMozEmbed *) = NULL; | |
132 void (*_gtk_moz_embed_go_forward)(GtkMozEmbed *) = NULL; | |
133 void (*_gtk_moz_embed_load_url)(GtkMozEmbed *, const char *) = NULL; | |
134 void (*_gtk_moz_embed_reload)(GtkMozEmbed *, guint32) = NULL; | |
135 void (*_gtk_moz_embed_stop_load)(GtkMozEmbed *) = NULL; | |
136 void (*_gtk_moz_embed_render_data)(GtkMozEmbed *, const char *, guint32, const char *, const char *) = NULL; | |
137 GtkWidget *(*_gtk_moz_embed_new)(void) = NULL; | |
138 GtkType (*_dw_moz_embed_get_type)(void) = NULL; | |
139 #endif | |
126 | 140 |
127 typedef struct | 141 typedef struct |
128 { | 142 { |
129 GdkPixmap *pixmap; | 143 GdkPixmap *pixmap; |
130 GdkBitmap *mask; | 144 GdkBitmap *mask; |
1858 if(_dw_thread_list[z] == (DWTID)tid) | 1872 if(_dw_thread_list[z] == (DWTID)tid) |
1859 _dw_thread_list[z] = (DWTID)-1; | 1873 _dw_thread_list[z] = (DWTID)-1; |
1860 } | 1874 } |
1861 } | 1875 } |
1862 | 1876 |
1877 /* Try to load the mozilla embed shared libary */ | |
1878 #ifdef USE_GTKMOZEMBED | |
1879 #include <ctype.h> | |
1880 void init_mozembed(void) | |
1881 { | |
1882 void *handle = NULL; | |
1883 FILE *fp = popen("pkg-config --libs-only-L mozilla-gtkmozembed", "r"); | |
1884 char output[1024]; | |
1885 | |
1886 /* First we try to get the correct location | |
1887 * from pkg-config. | |
1888 */ | |
1889 if(fp) | |
1890 { | |
1891 fgets(output, 1024, fp); | |
1892 | |
1893 printf("Output: %s\n", output); | |
1894 if(output[0] == '-' && output[1] == 'L') | |
1895 { | |
1896 int x, len = strlen(output); | |
1897 | |
1898 for(x=len;x>0;x--) | |
1899 { | |
1900 if(!isalpha(output[x]) && !isnumber(output[x]) && output[x] != '/') | |
1901 output[x] = 0; | |
1902 } | |
1903 strncat(output, "/libgtkembedmoz.so", 1024); | |
1904 handle = dlopen(&output[2], RTLD_NOW); | |
1905 if(!handle) | |
1906 printf("Output: %s Error: %s\n", &output[2], dlerror()); | |
1907 } | |
1908 fclose(fp); | |
1909 } | |
1910 /* Try the default path */ | |
1911 if(!handle) | |
1912 handle = dlopen("libgtkembedmoz.so", RTLD_NOW); | |
1913 /* Finally try some common locations */ | |
1914 if(!handle) | |
1915 handle = dlopen("/usr/X11R6/lib/mozilla/libgtkembedmoz.so", RTLD_NOW); | |
1916 if(!handle) | |
1917 handle = dlopen("/usr/lib/mozilla/libgtkembedmoz.so", RTLD_NOW); | |
1918 if(!handle) | |
1919 handle = dlopen("/usr/local/lib/mozilla/libgtkembedmoz.so", RTLD_NOW); | |
1920 | |
1921 /* If we loaded it, grab the symbols we want */ | |
1922 if(handle) | |
1923 { | |
1924 _gtk_moz_embed_go_back = dlsym(handle, "gtk_moz_embed_go_back"); | |
1925 _gtk_moz_embed_go_forward = dlsym(handle, "gtk_moz_embed_go_forward"); | |
1926 _gtk_moz_embed_load_url = dlsym(handle, "gtk_moz_embed_load_url"); | |
1927 _gtk_moz_embed_reload = dlsym(handle, "gtk_moz_embed_reload"); | |
1928 _gtk_moz_embed_stop_load = dlsym(handle, "gtk_moz_embed_stop_load"); | |
1929 _gtk_moz_embed_render_data = dlsym(handle, "gtk_moz_embed_render_data"); | |
1930 _dw_moz_embed_get_type = dlsym(handle, "gtk_moz_embed_get_type"); | |
1931 _gtk_moz_embed_new = dlsym(handle, "gtk_moz_embed_new"); | |
1932 } | |
1933 } | |
1934 #endif | |
1935 | |
1863 /* | 1936 /* |
1864 * Initializes the Dynamic Windows engine. | 1937 * Initializes the Dynamic Windows engine. |
1865 * Parameters: | 1938 * Parameters: |
1866 * newthread: True if this is the only thread. | 1939 * newthread: True if this is the only thread. |
1867 * False if there is already a message loop running. | 1940 * False if there is already a message loop running. |
1901 | 1974 |
1902 for(z=0;z<DW_THREAD_LIMIT;z++) | 1975 for(z=0;z<DW_THREAD_LIMIT;z++) |
1903 _dw_thread_list[z] = (DWTID)-1; | 1976 _dw_thread_list[z] = (DWTID)-1; |
1904 | 1977 |
1905 gtk_rc_parse_string("style \"gtk-tooltips-style\" { bg[NORMAL] = \"#eeee00\" } widget \"gtk-tooltips\" style \"gtk-tooltips-style\""); | 1978 gtk_rc_parse_string("style \"gtk-tooltips-style\" { bg[NORMAL] = \"#eeee00\" } widget \"gtk-tooltips\" style \"gtk-tooltips-style\""); |
1979 | |
1980 #ifdef USE_GTKMOZEMBED | |
1981 init_mozembed(); | |
1982 #endif | |
1906 | 1983 |
1907 return TRUE; | 1984 return TRUE; |
1908 } | 1985 } |
1909 | 1986 |
1910 /* | 1987 /* |
9853 void dw_html_action(HWND handle, int action) | 9930 void dw_html_action(HWND handle, int action) |
9854 { | 9931 { |
9855 #ifdef USE_GTKMOZEMBED | 9932 #ifdef USE_GTKMOZEMBED |
9856 int _locked_by_me = FALSE; | 9933 int _locked_by_me = FALSE; |
9857 | 9934 |
9935 if(!_gtk_moz_embed_new) | |
9936 return; | |
9937 | |
9858 DW_MUTEX_LOCK; | 9938 DW_MUTEX_LOCK; |
9859 switch(action) | 9939 switch(action) |
9860 { | 9940 { |
9861 case DW_HTML_GOBACK: | 9941 case DW_HTML_GOBACK: |
9862 gtk_moz_embed_go_back(GTK_MOZ_EMBED(handle)); | 9942 _gtk_moz_embed_go_back(GTK_MOZ_EMBED(handle)); |
9863 break; | 9943 break; |
9864 case DW_HTML_GOFORWARD: | 9944 case DW_HTML_GOFORWARD: |
9865 gtk_moz_embed_go_forward(GTK_MOZ_EMBED(handle)); | 9945 _gtk_moz_embed_go_forward(GTK_MOZ_EMBED(handle)); |
9866 break; | 9946 break; |
9867 case DW_HTML_GOHOME: | 9947 case DW_HTML_GOHOME: |
9868 gtk_moz_embed_load_url(GTK_MOZ_EMBED(handle), "http://dwindows.netlabs.org"); | 9948 _gtk_moz_embed_load_url(GTK_MOZ_EMBED(handle), "http://dwindows.netlabs.org"); |
9869 break; | 9949 break; |
9870 case DW_HTML_RELOAD: | 9950 case DW_HTML_RELOAD: |
9871 gtk_moz_embed_reload(GTK_MOZ_EMBED(handle), 0); | 9951 _gtk_moz_embed_reload(GTK_MOZ_EMBED(handle), 0); |
9872 break; | 9952 break; |
9873 case DW_HTML_STOP: | 9953 case DW_HTML_STOP: |
9874 gtk_moz_embed_stop_load(GTK_MOZ_EMBED(handle)); | 9954 _gtk_moz_embed_stop_load(GTK_MOZ_EMBED(handle)); |
9875 break; | 9955 break; |
9876 } | 9956 } |
9877 DW_MUTEX_UNLOCK; | 9957 DW_MUTEX_UNLOCK; |
9878 #endif | 9958 #endif |
9879 } | 9959 } |
9890 int dw_html_raw(HWND handle, char *string) | 9970 int dw_html_raw(HWND handle, char *string) |
9891 { | 9971 { |
9892 #ifdef USE_GTKMOZEMBED | 9972 #ifdef USE_GTKMOZEMBED |
9893 int _locked_by_me = FALSE; | 9973 int _locked_by_me = FALSE; |
9894 | 9974 |
9895 DW_MUTEX_LOCK; | 9975 if(!_gtk_moz_embed_new) |
9896 gtk_moz_embed_render_data(GTK_MOZ_EMBED(handle), string, strlen(string), "", ""); | 9976 return -1; |
9977 | |
9978 DW_MUTEX_LOCK; | |
9979 _gtk_moz_embed_render_data(GTK_MOZ_EMBED(handle), string, strlen(string), "", ""); | |
9897 DW_MUTEX_UNLOCK; | 9980 DW_MUTEX_UNLOCK; |
9898 return 0; | 9981 return 0; |
9899 #endif | 9982 #endif |
9900 return -1; | 9983 return -1; |
9901 } | 9984 } |
9912 int dw_html_url(HWND handle, char *url) | 9995 int dw_html_url(HWND handle, char *url) |
9913 { | 9996 { |
9914 #ifdef USE_GTKMOZEMBED | 9997 #ifdef USE_GTKMOZEMBED |
9915 int _locked_by_me = FALSE; | 9998 int _locked_by_me = FALSE; |
9916 | 9999 |
9917 DW_MUTEX_LOCK; | 10000 if(!_gtk_moz_embed_new) |
9918 gtk_moz_embed_load_url(GTK_MOZ_EMBED(handle), url); | 10001 return -1; |
10002 | |
10003 DW_MUTEX_LOCK; | |
10004 _gtk_moz_embed_load_url(GTK_MOZ_EMBED(handle), url); | |
9919 DW_MUTEX_UNLOCK; | 10005 DW_MUTEX_UNLOCK; |
9920 return 0; | 10006 return 0; |
9921 #endif | 10007 #endif |
9922 return -1; | 10008 return -1; |
9923 } | 10009 } |
9932 { | 10018 { |
9933 #ifdef USE_GTKMOZEMBED | 10019 #ifdef USE_GTKMOZEMBED |
9934 GtkWidget *widget; | 10020 GtkWidget *widget; |
9935 int _locked_by_me = FALSE; | 10021 int _locked_by_me = FALSE; |
9936 | 10022 |
9937 DW_MUTEX_LOCK; | 10023 if(!_gtk_moz_embed_new) |
9938 widget = gtk_moz_embed_new(); | 10024 return NULL; |
10025 | |
10026 DW_MUTEX_LOCK; | |
10027 widget = _gtk_moz_embed_new(); | |
9939 DW_MUTEX_UNLOCK; | 10028 DW_MUTEX_UNLOCK; |
9940 return widget; | 10029 return widget; |
9941 #else | 10030 #else |
9942 return dw_box_new(DW_HORZ, 0); | 10031 return dw_box_new(DW_HORZ, 0); |
9943 #endif | 10032 #endif |