From ec741a19c38e9be9455c917b4951f0e967583a51 Mon Sep 17 00:00:00 2001 From: Joakim Verona Date: Mon, 8 Apr 2013 22:02:38 +0200 Subject: [PATCH] xwgir work --- README.xwidget | 33 ++++++++++++++++++++++++++++++++- lisp/xwidget-test.el | 8 ++++---- src/xwidget.c | 40 ++++++++++++++++++++++++++++++++++++++-- 3 files changed, 74 insertions(+), 7 deletions(-) diff --git a/README.xwidget b/README.xwidget index e13834ba04c..1abc8f843e2 100644 --- a/README.xwidget +++ b/README.xwidget @@ -1627,8 +1627,39 @@ Current limitation: - next to no argument checking. If wrong type args are used with the xwgir methods, emacs crashes. +*** TODO xwgir create components with more advanced constructor +so this opens up an entire new can of beans. -** TODO investigate gdk_offscreen_window_set_embedder() +explain by example: +lets say we want to create agtkhscale on screen. its a slider. +https://developer.gnome.org/gtk3/stable/GtkHScale.html +we can already create buttons, so sliders shouldnt be much more +advanced right? wrong. + +the simplest slider constructor looks like: +GtkWidget * gtk_hscale_new +(GtkAdjustment *adjustment); + +so in order to call it, we must be able to forward arguments to the +constructor. this is almost already done, but we lack the ability to +pass object instances, only simple types atm. + +we need to be able to create GtkAdjustment +https://developer.gnome.org/gtk3/stable/GtkAdjustment.html + +this we can already almost do, because an xwidget is a gir object +with some decorations. we also store the decorated gir object in an +array, retrievable from lisp. + +In order for this to be usable in practice, we need some changes: +- lightweight objects should be stored un-decorated. they have no + need for the entire graphical machinery of xwidgets +- lightweight objects should be garbage collectable, but this is the + same for all the xwidget objects, and isnt really resolved atm. + + +** DONE investigate gdk_offscreen_window_set_embedder() + CLOSED: [2013-04-06 Sat 10:45] https://developer.gnome.org/gdk/unstable/gdk-Windows.html ,---- diff --git a/lisp/xwidget-test.el b/lisp/xwidget-test.el index 6d4953c0ae0..07b841bdc94 100644 --- a/lisp/xwidget-test.el +++ b/lisp/xwidget-test.el @@ -88,7 +88,7 @@ (put 'xwgirButton :xwgir-class '("Gtk" "Button")) (xwidget-insert (point-min) 'xwgirButton "xwgir label didnt work..." 700 700) - (xwgir-call-method (xwidget-at 1) "set_label" '( "xwgir label worked!")) + (xwgir-xwidget-call-method (xwidget-at 1) "set_label" '( "xwgir label worked!")) (define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-basic)) (xwidget-demo "a-xwgir-check-button" @@ -98,11 +98,11 @@ (xwidget-insert (point-min) 'xwgirCheckButton "xwgir label didnt work..." 700 700) (define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-basic)) -(xwidget-demo "a-xwgir-slider" +(xwidget-demo "a-xwgir-hscale" (xwgir-require-namespace "Gtk" "3.0") - (put 'xwgirSlider :xwgir-class '("Gtk" "Slider")) + (put 'xwgirHScale :xwgir-class '("Gtk" "HScale")) - (xwidget-insert (point-min) 'xwgirSlider "xwgir label didnt work..." 700 700) + (xwidget-insert (point-min) 'xwgirHScale "xwgir label didnt work..." 700 700) (define-key (current-local-map) [xwidget-event] 'xwidget-handler-demo-basic)) (xwidget-demo "a-xwgir-webkit" diff --git a/src/xwidget.c b/src/xwidget.c index 8a88a596163..77e3b00dae8 100644 --- a/src/xwidget.c +++ b/src/xwidget.c @@ -758,7 +758,43 @@ xwgir_convert_lisp_to_gir_arg(GIArgument* giarg, return 0; } -DEFUN ("xwgir-call-method", Fxwgir_call_method, Sxwgir_call_method, 3, 3, 0, + +void +refactor_attempt(){ + //this methhod should be called from xwgir-xwidget-call-method and from xwgir xwidget construction + char* class = SDATA(Fcar(Fcdr(Fget(xw->type, Qcxwgir_class)))); + + GIObjectInfo* obj_info = g_irepository_find_by_name(girepository, namespace, class); + GIFunctionInfo* f_info = g_object_info_find_method (obj_info, SDATA(method)); + + //loop over args, convert from lisp to primitive type, given arg introspection data + //TODO g_callable_info_get_n_args(f_info) should match + int argscount = XFASTINT(Flength(arguments)); + if(argscount != g_callable_info_get_n_args(f_info)){ + printf("xwgir call method arg count doesn match! \n"); + return Qnil; + } + int i; + for (i = 1; i < argscount + 1; ++i) + { + xwgir_convert_lisp_to_gir_arg(&in_args[i], g_callable_info_get_arg(f_info, i - 1), Fnth(i - 1, arguments)); + } + + in_args[0].v_pointer = widget; + if(g_function_info_invoke(f_info, + in_args, argscount + 1, + NULL, 0, + &return_value, + &error)) { + //g_error("ERROR: %s\n", error->message); + printf("invokation error\n"); + return Qnil; + } + return Qt; +} + + +DEFUN ("xwgir-xwidget-call-method", Fxwgir_xwidget_call_method, Sxwgir_xwidget_call_method, 3, 3, 0, doc: /* call xwidget object method.*/) (Lisp_Object xwidget, Lisp_Object method, Lisp_Object arguments) { @@ -1562,7 +1598,7 @@ syms_of_xwidget (void) DEFSYM (Qwebkit_osr ,"webkit-osr"); #endif - defsubr (&Sxwgir_call_method ); + defsubr (&Sxwgir_xwidget_call_method ); defsubr (&Sxwgir_require_namespace); defsubr (&Sxwidget_size_request ); defsubr (&Sxwidget_delete_zombies); -- 2.39.2