diff options
| author | Joakim Verona | 2012-07-18 10:56:08 +0200 |
|---|---|---|
| committer | Joakim Verona | 2012-07-18 10:56:08 +0200 |
| commit | 82da003bbce9d1b93480ba20713432f7c27bf7de (patch) | |
| tree | 95577969ab2c9ab7774889b5f898e32f129fb8a4 | |
| parent | 7f914423eafcd40a7c2f394949d7bb5eeb5cdfff (diff) | |
| download | emacs-82da003bbce9d1b93480ba20713432f7c27bf7de.tar.gz emacs-82da003bbce9d1b93480ba20713432f7c27bf7de.zip | |
some experimental support for gobject introspection
| -rw-r--r-- | README.xwidget | 13 | ||||
| -rw-r--r-- | configure.in | 12 | ||||
| -rw-r--r-- | lisp/xwidget-test.el | 8 | ||||
| -rw-r--r-- | src/Makefile.in | 7 | ||||
| -rw-r--r-- | src/xwidget.c | 68 |
5 files changed, 104 insertions, 4 deletions
diff --git a/README.xwidget b/README.xwidget index c2359b6e8ae..3c9d8b91e9f 100644 --- a/README.xwidget +++ b/README.xwidget | |||
| @@ -1563,3 +1563,16 @@ special finalization would go into gc_sweep() | |||
| 1563 | http://developer.gnome.org/libevview/3.2/libevview-ev-view.html | 1563 | http://developer.gnome.org/libevview/3.2/libevview-ev-view.html |
| 1564 | would be useful for reading PDF:s and other document types. | 1564 | would be useful for reading PDF:s and other document types. |
| 1565 | it would work the same way webkit embedding works. | 1565 | it would work the same way webkit embedding works. |
| 1566 | |||
| 1567 | ** TODO support gobject introspection | ||
| 1568 | https://live.gnome.org/GObjectIntrospection/ | ||
| 1569 | supporting gobject introspection would mean that more gtk widgets | ||
| 1570 | could be tried out with less effort, and also that the build process | ||
| 1571 | and runtime support would be easier. The drawbacks are small: somewhat | ||
| 1572 | slower execution, and difficulty in providing elisp bindings for | ||
| 1573 | introspection. | ||
| 1574 | |||
| 1575 | https://live.gnome.org/GObjectIntrospection/HowToWriteALanguageBinding | ||
| 1576 | |||
| 1577 | http://developer.gnome.org/gi/unstable/gi-girepository.html | ||
| 1578 | http://developer.gnome.org/gi/unstable/gi-overview.html | ||
diff --git a/configure.in b/configure.in index fa2ed091b3a..c929b757bdd 100644 --- a/configure.in +++ b/configure.in | |||
| @@ -1960,6 +1960,8 @@ HAVE_XWIDGETS=no | |||
| 1960 | HAVE_WEBKIT=no | 1960 | HAVE_WEBKIT=no |
| 1961 | HAVE_GOOCANVAS=no | 1961 | HAVE_GOOCANVAS=no |
| 1962 | HAVE_CLUTTER=no | 1962 | HAVE_CLUTTER=no |
| 1963 | HAVE_GIR=no | ||
| 1964 | |||
| 1963 | if test "${with_xwidgets}" != "no"; then | 1965 | if test "${with_xwidgets}" != "no"; then |
| 1964 | echo "xwidgets enabled, checking webkit, and others" | 1966 | echo "xwidgets enabled, checking webkit, and others" |
| 1965 | HAVE_XWIDGETS=yes | 1967 | HAVE_XWIDGETS=yes |
| @@ -2000,6 +2002,15 @@ if test "${with_xwidgets}" != "no"; then | |||
| 2000 | AC_DEFINE(HAVE_GOOCANVAS, 1, [Define to 1 if you have goocanvas support.]) | 2002 | AC_DEFINE(HAVE_GOOCANVAS, 1, [Define to 1 if you have goocanvas support.]) |
| 2001 | fi | 2003 | fi |
| 2002 | fi | 2004 | fi |
| 2005 | |||
| 2006 | GIR_REQUIRED=1.32.1 | ||
| 2007 | GIR_MODULES="gobject-introspection-1.0 >= $GIR_REQUIRED" | ||
| 2008 | PKG_CHECK_MODULES(GIR, $GIR_MODULES, HAVE_GIR=yes, HAVE_GIR=no) | ||
| 2009 | if test $HAVE_GIR = yes; then | ||
| 2010 | AC_DEFINE(HAVE_GIR, 1, [Define to 1 if you have GIR support.]) | ||
| 2011 | fi | ||
| 2012 | |||
| 2013 | |||
| 2003 | fi | 2014 | fi |
| 2004 | 2015 | ||
| 2005 | 2016 | ||
| @@ -3761,6 +3772,7 @@ echo " Does Emacs use toolkit scroll bars? ${USE_TOOLKIT_SC | |||
| 3761 | 3772 | ||
| 3762 | echo " Does Emacs support Xwidgets? ${HAVE_XWIDGETS}" | 3773 | echo " Does Emacs support Xwidgets? ${HAVE_XWIDGETS}" |
| 3763 | echo " Does xwidgets support webkit(requires gtk3)? ${HAVE_WEBKIT}" | 3774 | echo " Does xwidgets support webkit(requires gtk3)? ${HAVE_WEBKIT}" |
| 3775 | echo " Does xwidgets support gobject introspection? ${HAVE_GIR}" | ||
| 3764 | echo " Does xwidgets support clutter(demo code)? ${HAVE_CLUTTER}" | 3776 | echo " Does xwidgets support clutter(demo code)? ${HAVE_CLUTTER}" |
| 3765 | echo " Does xwidgets support goocanvas(demo code)? ${HAVE_GOOCANVAS}" | 3777 | echo " Does xwidgets support goocanvas(demo code)? ${HAVE_GOOCANVAS}" |
| 3766 | echo | 3778 | echo |
diff --git a/lisp/xwidget-test.el b/lisp/xwidget-test.el index fd7ecfad43a..26e0dc0a5af 100644 --- a/lisp/xwidget-test.el +++ b/lisp/xwidget-test.el | |||
| @@ -72,6 +72,14 @@ | |||
| 72 | (xwidget-insert (point-min) 'webkit-osr "webkit-osr" 1000 1000) | 72 | (xwidget-insert (point-min) 'webkit-osr "webkit-osr" 1000 1000) |
| 73 | (define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-basic)) | 73 | (define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-basic)) |
| 74 | 74 | ||
| 75 | (xwidget-demo "a-xwgir" | ||
| 76 | (xwidget-insert (point-min) 'xwgir "xwgir" 1000 1000) | ||
| 77 | (define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-basic)) | ||
| 78 | |||
| 79 | (xwidget-demo "a-xwgir-button" | ||
| 80 | (xwidget-insert (point-min) 'ColorButton "xwgir-button" 1000 1000) | ||
| 81 | (define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-basic)) | ||
| 82 | |||
| 75 | 83 | ||
| 76 | 84 | ||
| 77 | (xwidget-demo "basic" | 85 | (xwidget-demo "basic" |
diff --git a/src/Makefile.in b/src/Makefile.in index b02d49ff5b0..2b0d095ad91 100644 --- a/src/Makefile.in +++ b/src/Makefile.in | |||
| @@ -238,6 +238,9 @@ CLUTTER_CFLAGS= @CLUTTER_CFLAGS@ | |||
| 238 | WEBKIT_LIBS= @WEBKIT_LIBS@ | 238 | WEBKIT_LIBS= @WEBKIT_LIBS@ |
| 239 | WEBKIT_CFLAGS= @WEBKIT_CFLAGS@ | 239 | WEBKIT_CFLAGS= @WEBKIT_CFLAGS@ |
| 240 | 240 | ||
| 241 | GIR_LIBS= @GIR_LIBS@ | ||
| 242 | GIR_CFLAGS= @GIR_CFLAGS@ | ||
| 243 | |||
| 241 | IMAGEMAGICK_LIBS= @IMAGEMAGICK_LIBS@ | 244 | IMAGEMAGICK_LIBS= @IMAGEMAGICK_LIBS@ |
| 242 | IMAGEMAGICK_CFLAGS= @IMAGEMAGICK_CFLAGS@ | 245 | IMAGEMAGICK_CFLAGS= @IMAGEMAGICK_CFLAGS@ |
| 243 | 246 | ||
| @@ -316,7 +319,7 @@ ALL_CFLAGS=-Demacs -DHAVE_CONFIG_H $(MYCPPFLAGS) -I. -I$(srcdir) \ | |||
| 316 | $(C_SWITCH_MACHINE) $(C_SWITCH_SYSTEM) $(C_SWITCH_X_SITE) \ | 319 | $(C_SWITCH_MACHINE) $(C_SWITCH_SYSTEM) $(C_SWITCH_X_SITE) \ |
| 317 | $(GNUSTEP_CFLAGS) $(CFLAGS_SOUND) $(RSVG_CFLAGS) $(IMAGEMAGICK_CFLAGS) \ | 320 | $(GNUSTEP_CFLAGS) $(CFLAGS_SOUND) $(RSVG_CFLAGS) $(IMAGEMAGICK_CFLAGS) \ |
| 318 | $(LIBXML2_CFLAGS) $(DBUS_CFLAGS) \ | 321 | $(LIBXML2_CFLAGS) $(DBUS_CFLAGS) \ |
| 319 | $(WEBKIT_CFLAGS) $(CLUTTER_CFLAGS) \ | 322 | $(WEBKIT_CFLAGS) $(CLUTTER_CFLAGS) $(GIR_CFLAGS) \ |
| 320 | $(SETTINGS_CFLAGS) $(FREETYPE_CFLAGS) $(FONTCONFIG_CFLAGS) \ | 323 | $(SETTINGS_CFLAGS) $(FREETYPE_CFLAGS) $(FONTCONFIG_CFLAGS) \ |
| 321 | $(LIBOTF_CFLAGS) $(M17N_FLT_CFLAGS) $(DEPFLAGS) $(PROFILING_CFLAGS) \ | 324 | $(LIBOTF_CFLAGS) $(M17N_FLT_CFLAGS) $(DEPFLAGS) $(PROFILING_CFLAGS) \ |
| 322 | $(LIBGNUTLS_CFLAGS) \ | 325 | $(LIBGNUTLS_CFLAGS) \ |
| @@ -394,7 +397,7 @@ otherobj= $(TERMCAP_OBJ) $(PRE_ALLOC_OBJ) $(GMALLOC_OBJ) $(RALLOC_OBJ) \ | |||
| 394 | ## with GCC, we might need LIB_GCC again after them. | 397 | ## with GCC, we might need LIB_GCC again after them. |
| 395 | LIBES = $(LIBS) $(LIBX_BASE) $(LIBX_OTHER) $(LIBSOUND) \ | 398 | LIBES = $(LIBS) $(LIBX_BASE) $(LIBX_OTHER) $(LIBSOUND) \ |
| 396 | $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(DBUS_LIBS) \ | 399 | $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(DBUS_LIBS) \ |
| 397 | $(WEBKIT_LIBS) $(CLUTTER_LIBS) \ | 400 | $(WEBKIT_LIBS) $(CLUTTER_LIBS) $(GIR_LIBS) \ |
| 398 | $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \ | 401 | $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \ |
| 399 | $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \ | 402 | $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \ |
| 400 | $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \ | 403 | $(FREETYPE_LIBS) $(FONTCONFIG_LIBS) $(LIBOTF_LIBS) $(M17N_FLT_LIBS) \ |
diff --git a/src/xwidget.c b/src/xwidget.c index f59f2f32d1e..a9e3477d103 100644 --- a/src/xwidget.c +++ b/src/xwidget.c | |||
| @@ -102,6 +102,9 @@ | |||
| 102 | #include <webkit/webkitdownload.h> | 102 | #include <webkit/webkitdownload.h> |
| 103 | #endif | 103 | #endif |
| 104 | 104 | ||
| 105 | //for GIR | ||
| 106 | #include <girepository.h> | ||
| 107 | |||
| 105 | #include "xwidget.h" | 108 | #include "xwidget.h" |
| 106 | 109 | ||
| 107 | //TODO should of course not be a hardcoded array but I can't be bothered atm | 110 | //TODO should of course not be a hardcoded array but I can't be bothered atm |
| @@ -137,7 +140,7 @@ Lisp_Object Qxwidget_info; | |||
| 137 | Lisp_Object Qxwidget_resize; | 140 | Lisp_Object Qxwidget_resize; |
| 138 | Lisp_Object Qxwidget_send_keyboard_event; | 141 | Lisp_Object Qxwidget_send_keyboard_event; |
| 139 | 142 | ||
| 140 | Lisp_Object Qbutton, Qtoggle, Qslider, Qsocket, Qsocket_osr, Qcairo, | 143 | Lisp_Object Qbutton, Qtoggle, Qslider, Qsocket, Qsocket_osr, Qcairo, Qxwgir, |
| 141 | Qwebkit_osr, QCplist; | 144 | Qwebkit_osr, QCplist; |
| 142 | 145 | ||
| 143 | 146 | ||
| @@ -601,6 +604,46 @@ xwidget_osr_button_callback (GtkWidget *widget, | |||
| 601 | return TRUE; //dont propagate this event furter | 604 | return TRUE; //dont propagate this event furter |
| 602 | } | 605 | } |
| 603 | 606 | ||
| 607 | |||
| 608 | GtkWidget* xwgir_create(char* class){ | ||
| 609 | //create a gtk widget, given its name | ||
| 610 | //find the constructor | ||
| 611 | //call it | ||
| 612 | //also figure out how to pass args | ||
| 613 | /* gboolean g_function_info_invoke (GIFunctionInfo *info, */ | ||
| 614 | /* const GIArgument *in_args, */ | ||
| 615 | /* int n_in_args, */ | ||
| 616 | /* const GIArgument *out_args, */ | ||
| 617 | /* int n_out_args, */ | ||
| 618 | /* GIArgument *return_value, */ | ||
| 619 | /* GError **error); */ | ||
| 620 | char* namespace = "Gtk"; | ||
| 621 | char* namespace_version = "3.0"; | ||
| 622 | GError *error = NULL; | ||
| 623 | GIRepository *repository; | ||
| 624 | GIArgument return_value; | ||
| 625 | /* GtkWidget* rv; */ | ||
| 626 | repository = g_irepository_get_default(); | ||
| 627 | g_irepository_require(repository, namespace, namespace_version, 0, &error); | ||
| 628 | if (error) { | ||
| 629 | g_error("ERROR: %s\n", error->message); | ||
| 630 | return NULL; | ||
| 631 | } | ||
| 632 | |||
| 633 | GIObjectInfo* obj_info = g_irepository_find_by_name(repository, namespace, class); | ||
| 634 | GIFunctionInfo* f_info = g_object_info_find_method (obj_info, "new"); | ||
| 635 | g_function_info_invoke(f_info, | ||
| 636 | 0, NULL, | ||
| 637 | 0, NULL, | ||
| 638 | &return_value, | ||
| 639 | NULL); | ||
| 640 | return return_value.v_pointer; | ||
| 641 | |||
| 642 | } | ||
| 643 | |||
| 644 | |||
| 645 | |||
| 646 | |||
| 604 | int xwidget_view_index=0; | 647 | int xwidget_view_index=0; |
| 605 | 648 | ||
| 606 | /* initializes and does initial placement of an xwidget view on screen */ | 649 | /* initializes and does initial placement of an xwidget view on screen */ |
| @@ -635,6 +678,9 @@ xwidget_init_view (struct xwidget *xww, | |||
| 635 | } else if (EQ(xww->type, Qtoggle)) { | 678 | } else if (EQ(xww->type, Qtoggle)) { |
| 636 | xv->widget = gtk_toggle_button_new_with_label (XSTRING(xww->title)->data); | 679 | xv->widget = gtk_toggle_button_new_with_label (XSTRING(xww->title)->data); |
| 637 | //xv->widget = gtk_entry_new ();//temp hack to experiment with key propagation TODO entry widget is useful for testing | 680 | //xv->widget = gtk_entry_new ();//temp hack to experiment with key propagation TODO entry widget is useful for testing |
| 681 | } else if (EQ(xww->type, Qxwgir)) { | ||
| 682 | //this is just a test for xwgir | ||
| 683 | xv->widget = xwgir_create ("Button"); | ||
| 638 | } else if (EQ(xww->type, Qsocket)) { | 684 | } else if (EQ(xww->type, Qsocket)) { |
| 639 | xv->widget = gtk_socket_new (); | 685 | xv->widget = gtk_socket_new (); |
| 640 | g_signal_connect_after(xv->widget, "plug-added", G_CALLBACK(xwidget_plug_added), "plug added"); | 686 | g_signal_connect_after(xv->widget, "plug-added", G_CALLBACK(xwidget_plug_added), "plug added"); |
| @@ -721,7 +767,21 @@ xwidget_init_view (struct xwidget *xww, | |||
| 721 | #endif | 767 | #endif |
| 722 | 768 | ||
| 723 | 769 | ||
| 724 | } else return NULL; | 770 | } else { |
| 771 | //here we have run out of hard coded symbols, we will now attempt to create | ||
| 772 | //a widget dynamically | ||
| 773 | //TODO | ||
| 774 | // - support OSR | ||
| 775 | // - support constructor args | ||
| 776 | // - support signals | ||
| 777 | // - check that the argument widget type actually exists | ||
| 778 | printf("xwgir symbol %s:\n",SDATA(SYMBOL_NAME(xww->type))); | ||
| 779 | //xv->widget = xwgir_create ("Button"); | ||
| 780 | xv->widget = xwgir_create(SDATA(SYMBOL_NAME(xww->type))); | ||
| 781 | |||
| 782 | } | ||
| 783 | |||
| 784 | //else return NULL; | ||
| 725 | 785 | ||
| 726 | //widget realization | 786 | //widget realization |
| 727 | //make container widget 1st, and put the actual widget inside the container | 787 | //make container widget 1st, and put the actual widget inside the container |
| @@ -1245,6 +1305,8 @@ syms_of_xwidget (void) | |||
| 1245 | DEFSYM (Qsocket_osr, "socket-osr"); | 1305 | DEFSYM (Qsocket_osr, "socket-osr"); |
| 1246 | DEFSYM (Qcairo, "cairo"); | 1306 | DEFSYM (Qcairo, "cairo"); |
| 1247 | 1307 | ||
| 1308 | DEFSYM (Qxwgir, "xwgir"); | ||
| 1309 | |||
| 1248 | DEFSYM (QCplist, ":plist"); | 1310 | DEFSYM (QCplist, ":plist"); |
| 1249 | 1311 | ||
| 1250 | DEFVAR_LISP ("xwidget-alist", Vxwidget_alist, doc: /*xwidgets list*/); | 1312 | DEFVAR_LISP ("xwidget-alist", Vxwidget_alist, doc: /*xwidgets list*/); |
| @@ -1471,4 +1533,6 @@ xwidget_end_redisplay (struct window *w, struct glyph_matrix *matrix) | |||
| 1471 | } | 1533 | } |
| 1472 | } | 1534 | } |
| 1473 | } | 1535 | } |
| 1536 | |||
| 1537 | |||
| 1474 | #endif | 1538 | #endif |