From: Joakim Verona Date: Wed, 18 Jul 2012 08:56:08 +0000 (+0200) Subject: some experimental support for gobject introspection X-Git-Tag: emacs-25.0.90~3296 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=82da003bbce9d1b93480ba20713432f7c27bf7de;p=emacs.git some experimental support for gobject introspection --- 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() http://developer.gnome.org/libevview/3.2/libevview-ev-view.html would be useful for reading PDF:s and other document types. it would work the same way webkit embedding works. + +** TODO support gobject introspection +https://live.gnome.org/GObjectIntrospection/ +supporting gobject introspection would mean that more gtk widgets +could be tried out with less effort, and also that the build process +and runtime support would be easier. The drawbacks are small: somewhat +slower execution, and difficulty in providing elisp bindings for +introspection. + +https://live.gnome.org/GObjectIntrospection/HowToWriteALanguageBinding + +http://developer.gnome.org/gi/unstable/gi-girepository.html +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 HAVE_WEBKIT=no HAVE_GOOCANVAS=no HAVE_CLUTTER=no +HAVE_GIR=no + if test "${with_xwidgets}" != "no"; then echo "xwidgets enabled, checking webkit, and others" HAVE_XWIDGETS=yes @@ -2000,6 +2002,15 @@ if test "${with_xwidgets}" != "no"; then AC_DEFINE(HAVE_GOOCANVAS, 1, [Define to 1 if you have goocanvas support.]) fi fi + + GIR_REQUIRED=1.32.1 + GIR_MODULES="gobject-introspection-1.0 >= $GIR_REQUIRED" + PKG_CHECK_MODULES(GIR, $GIR_MODULES, HAVE_GIR=yes, HAVE_GIR=no) + if test $HAVE_GIR = yes; then + AC_DEFINE(HAVE_GIR, 1, [Define to 1 if you have GIR support.]) + fi + + fi @@ -3761,6 +3772,7 @@ echo " Does Emacs use toolkit scroll bars? ${USE_TOOLKIT_SC echo " Does Emacs support Xwidgets? ${HAVE_XWIDGETS}" echo " Does xwidgets support webkit(requires gtk3)? ${HAVE_WEBKIT}" +echo " Does xwidgets support gobject introspection? ${HAVE_GIR}" echo " Does xwidgets support clutter(demo code)? ${HAVE_CLUTTER}" echo " Does xwidgets support goocanvas(demo code)? ${HAVE_GOOCANVAS}" 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 @@ (xwidget-insert (point-min) 'webkit-osr "webkit-osr" 1000 1000) (define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-basic)) +(xwidget-demo "a-xwgir" + (xwidget-insert (point-min) 'xwgir "xwgir" 1000 1000) + (define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-basic)) + +(xwidget-demo "a-xwgir-button" + (xwidget-insert (point-min) 'ColorButton "xwgir-button" 1000 1000) + (define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-basic)) + (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@ WEBKIT_LIBS= @WEBKIT_LIBS@ WEBKIT_CFLAGS= @WEBKIT_CFLAGS@ +GIR_LIBS= @GIR_LIBS@ +GIR_CFLAGS= @GIR_CFLAGS@ + IMAGEMAGICK_LIBS= @IMAGEMAGICK_LIBS@ IMAGEMAGICK_CFLAGS= @IMAGEMAGICK_CFLAGS@ @@ -316,7 +319,7 @@ ALL_CFLAGS=-Demacs -DHAVE_CONFIG_H $(MYCPPFLAGS) -I. -I$(srcdir) \ $(C_SWITCH_MACHINE) $(C_SWITCH_SYSTEM) $(C_SWITCH_X_SITE) \ $(GNUSTEP_CFLAGS) $(CFLAGS_SOUND) $(RSVG_CFLAGS) $(IMAGEMAGICK_CFLAGS) \ $(LIBXML2_CFLAGS) $(DBUS_CFLAGS) \ - $(WEBKIT_CFLAGS) $(CLUTTER_CFLAGS) \ + $(WEBKIT_CFLAGS) $(CLUTTER_CFLAGS) $(GIR_CFLAGS) \ $(SETTINGS_CFLAGS) $(FREETYPE_CFLAGS) $(FONTCONFIG_CFLAGS) \ $(LIBOTF_CFLAGS) $(M17N_FLT_CFLAGS) $(DEPFLAGS) $(PROFILING_CFLAGS) \ $(LIBGNUTLS_CFLAGS) \ @@ -394,7 +397,7 @@ otherobj= $(TERMCAP_OBJ) $(PRE_ALLOC_OBJ) $(GMALLOC_OBJ) $(RALLOC_OBJ) \ ## with GCC, we might need LIB_GCC again after them. LIBES = $(LIBS) $(LIBX_BASE) $(LIBX_OTHER) $(LIBSOUND) \ $(RSVG_LIBS) $(IMAGEMAGICK_LIBS) $(DBUS_LIBS) \ - $(WEBKIT_LIBS) $(CLUTTER_LIBS) \ + $(WEBKIT_LIBS) $(CLUTTER_LIBS) $(GIR_LIBS) \ $(LIBXML2_LIBS) $(LIBGPM) $(LIBRESOLV) $(LIBS_SYSTEM) \ $(LIBS_TERMCAP) $(GETLOADAVG_LIBS) $(SETTINGS_LIBS) $(LIBSELINUX_LIBS) \ $(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 @@ #include #endif +//for GIR +#include + #include "xwidget.h" //TODO should of course not be a hardcoded array but I can't be bothered atm @@ -137,7 +140,7 @@ Lisp_Object Qxwidget_info; Lisp_Object Qxwidget_resize; Lisp_Object Qxwidget_send_keyboard_event; -Lisp_Object Qbutton, Qtoggle, Qslider, Qsocket, Qsocket_osr, Qcairo, +Lisp_Object Qbutton, Qtoggle, Qslider, Qsocket, Qsocket_osr, Qcairo, Qxwgir, Qwebkit_osr, QCplist; @@ -601,6 +604,46 @@ xwidget_osr_button_callback (GtkWidget *widget, return TRUE; //dont propagate this event furter } + +GtkWidget* xwgir_create(char* class){ + //create a gtk widget, given its name + //find the constructor + //call it + //also figure out how to pass args + /* gboolean g_function_info_invoke (GIFunctionInfo *info, */ + /* const GIArgument *in_args, */ + /* int n_in_args, */ + /* const GIArgument *out_args, */ + /* int n_out_args, */ + /* GIArgument *return_value, */ + /* GError **error); */ + char* namespace = "Gtk"; + char* namespace_version = "3.0"; + GError *error = NULL; + GIRepository *repository; + GIArgument return_value; + /* GtkWidget* rv; */ + repository = g_irepository_get_default(); + g_irepository_require(repository, namespace, namespace_version, 0, &error); + if (error) { + g_error("ERROR: %s\n", error->message); + return NULL; + } + + GIObjectInfo* obj_info = g_irepository_find_by_name(repository, namespace, class); + GIFunctionInfo* f_info = g_object_info_find_method (obj_info, "new"); + g_function_info_invoke(f_info, + 0, NULL, + 0, NULL, + &return_value, + NULL); + return return_value.v_pointer; + +} + + + + int xwidget_view_index=0; /* initializes and does initial placement of an xwidget view on screen */ @@ -635,6 +678,9 @@ xwidget_init_view (struct xwidget *xww, } else if (EQ(xww->type, Qtoggle)) { xv->widget = gtk_toggle_button_new_with_label (XSTRING(xww->title)->data); //xv->widget = gtk_entry_new ();//temp hack to experiment with key propagation TODO entry widget is useful for testing + } else if (EQ(xww->type, Qxwgir)) { + //this is just a test for xwgir + xv->widget = xwgir_create ("Button"); } else if (EQ(xww->type, Qsocket)) { xv->widget = gtk_socket_new (); 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, #endif - } else return NULL; + } else { + //here we have run out of hard coded symbols, we will now attempt to create + //a widget dynamically + //TODO + // - support OSR + // - support constructor args + // - support signals + // - check that the argument widget type actually exists + printf("xwgir symbol %s:\n",SDATA(SYMBOL_NAME(xww->type))); + //xv->widget = xwgir_create ("Button"); + xv->widget = xwgir_create(SDATA(SYMBOL_NAME(xww->type))); + + } + + //else return NULL; //widget realization //make container widget 1st, and put the actual widget inside the container @@ -1245,6 +1305,8 @@ syms_of_xwidget (void) DEFSYM (Qsocket_osr, "socket-osr"); DEFSYM (Qcairo, "cairo"); + DEFSYM (Qxwgir, "xwgir"); + DEFSYM (QCplist, ":plist"); DEFVAR_LISP ("xwidget-alist", Vxwidget_alist, doc: /*xwidgets list*/); @@ -1471,4 +1533,6 @@ xwidget_end_redisplay (struct window *w, struct glyph_matrix *matrix) } } } + + #endif