]> git.eshelyaron.com Git - emacs.git/commitdiff
some experimental support for gobject introspection
authorJoakim Verona <joakim@verona.se>
Wed, 18 Jul 2012 08:56:08 +0000 (10:56 +0200)
committerJoakim Verona <joakim@verona.se>
Wed, 18 Jul 2012 08:56:08 +0000 (10:56 +0200)
README.xwidget
configure.in
lisp/xwidget-test.el
src/Makefile.in
src/xwidget.c

index c2359b6e8ae434c977ef31e377fce7e4ffdebc19..3c9d8b91e9f0cce5a655fab05c8c61608363323e 100644 (file)
@@ -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
index fa2ed091b3a527e5016840be4dbb09ab96dab1f6..c929b757bdd4ddd0c9a7a4078d2b25c5e38a1379 100644 (file)
@@ -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
index fd7ecfad43ad7f802cb3ae7a998eba133243b897..26e0dc0a5af24c87b7b7f93e8fc531472ae68fb0 100644 (file)
               (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"
index b02d49ff5b0032dd35e0619e6d9819acfbc2eca1..2b0d095ad91bd15ef9133bc3115e7577ffd22493 100644 (file)
@@ -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) \
index f59f2f32d1ec343ce5e3f43236e7f807bd68cde0..a9e3477d103ea59790a5e43cef383f4690c19691 100644 (file)
 #include <webkit/webkitdownload.h>
 #endif
 
+//for GIR
+#include <girepository.h>
+
 #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