Chris asked [2] if it's possible to embed GladeVCP panels in Axis like
video tabs [1] so moving discussion here.

If you don't want to read detailed description of process and just curious how
to run gladevcp in axis then skip to the last part of message.

Background:

Embeding programs into axis tabs is achieved with XEMBED protocol so either 
child
or parent program (Axis) must be aware of it. I'm not similar with Tkinter or 
Tcl
so on Axis side only empty frame is created. Reparenting relies on client.
Gtk provides special widget (GtkPlug [4]) that is able to reparent but it only 
works 
with gtk's counterpart named GtkSocket. Maybe with Qt's too but I have not 
tested.
Only possible way I've found is to use low-level X calls to reparent child 
window
manually. So how it's done:

 * Create popup GtkWindow. When it's created in program just give 
GTK_WINDOW_POPUP
   instead of GTK_WINDOW_TOPLEVEL (gtk.WINDOW_POPUP for python). With glade 
select
   window type as popup in properties. It's needed to suppress window 
decorations.

 * Get display and window id from gtk. Done with macros in C/C++:

        Window wid = GDK_WINDOW_XID (GTK_WIDGET(window)->window);
        Display *dpy = GDK_WINDOW_XDISPLAY(GTK_WIDGET(window)->window);

   In python window id is located in window->window->xid. I've not
   found way to get proper display object from gtk and use Xlib [5]:

        from Xlib import display
        from Xlib.xobject import drawable
        d = display.Display()
        w = drawable.Window(d.display, window.window.xid, 0)


 * Set _XEMBED_INFO property. Tests show that it's not very importat but to 
comply
   with protocol [3]. For C/C++ code is 

        long info[2] = { 0, 1 << 0 /*XEMBED_MAPPED*/ };
        Atom atom = XInternAtom(dpy, "_XEMBED_INFO", 1);
        XChangeProperty(dpy, xid, atom, atom, 32, PropModeReplace, (unsigned 
char *)&info, 2);

   For python (d is display, w is window objects):

        atom = d.get_atom('_XEMBED_INFO')
        w.change_property(atom, atom, 32, [0, 1])

 * Run reparent, map and sync X calls. For C/C++ it's 

        XReparentWindow(dpy, wid, parent, 0, 0)
        XMapWindow(dpy, wid)
        XSync(dpy)

    For python it's

        w.reparent(parent, 0, 0)
        w.map()
        d.sync()

 * Enjoy Gtk window reprented into non-gtk one.

Why so verbose? I've not found any explanation why GtkPlug is not working 
inside widgets
other then GtkSocket and why normal GtkWindow is not respecting XReparent. So 
let's hope
that google will find this message :)

Short version.
All you need is: 
 1. Small patch is needed for gladevcp (in following message). It uses python 
Xlib [5].
 2. Fix your glade file so it's toplevel window1 will be popup. With glade gui 
change 
    'Window type' property of top level window to 'popup'. Or edit .glade file 
and add 
    next line after <widget class='GtkWindow' id='window1'>

 <property name="type">popup</property>

 3. Add .axisrc from [1] to your local one.
 4. Comment loadusr string in hal file (since we don't know parent window in 
this stage).
 5. Add two variables in DISPLAY section of ini file:

    EMBED_TAB_NAME = GladeVCP
    EMBED_TAB_COMMAND = gladevcp -c COMPNAME -w {XID} path-to-glade-file

    Don't forget to add -w {XID} in command!

That's all.
                                Pavel

--
[1] http://wiki.linuxcnc.org/emcinfo.pl?Axis_Embed_Video
[2] 
http://www.linuxcnc.org/component/option,com_kunena/Itemid,20/func,view/catid,21/id,2198/limit,6/limitstart,18/lang,english/
[3] http://standards.freedesktop.org/xembed-spec/xembed-spec-latest.html
[4] http://library.gnome.org/devel/gtk/stable/GtkPlug.html
[5] http://python-xlib.sourceforge.net/

------------------------------------------------------------------------------
Beautiful is writing same markup. Internet Explorer 9 supports
standards for HTML5, CSS3, SVG 1.1,  ECMAScript5, and DOM L2 & L3.
Spend less time writing and  rewriting code and more time creating great
experiences on the web. Be a part of the beta today.
http://p.sf.net/sfu/beautyoftheweb
_______________________________________________
Emc-developers mailing list
Emc-developers@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/emc-developers

Reply via email to