Add an example GTK based GUI that uses the shared memory interface
PATCH 4/4 Add an example GTK based GUI that uses the shared memory interface
To run from the subdirectory, first do a make and then run:
./gtk-qemu -qemu ../i386-softmmu/qemu <normal qemu args...>
Regards,
Anthony Liguori
# HG changeset patch
# User [email protected]
# Node ID 1f7d5a9d262388eb7ca22a0869f0bdddb104a0bd
# Parent 161ce66608016b77bb1889ce5bd046b26e942476
Add a sample GUI that uses the shared memory interface. This GUI is written in Python and uses a GTK widget.
gtk/Makefile new file +50 -0
@@ -0,0 +1,50 @@ +# Makefile -- QEMU GTK GUI +# +# Copyright (C) 2006 Anthony Liguori <[email protected]> +# +# This file is subject to the terms and conditions of the GNU General Public +# License. See the file COPYING in the main directory of this archive for more +# details. + +prefix ?= /usr + +CFLAGS = $(shell pkg-config --cflags gtk+-2.0 pygtk-2.0) +LDLIBS = $(shell pkg-config --libs gtk+-2.0 pygtk-2.0) + +CODEGENDIR = $(shell pkg-config --variable=codegendir pygtk-2.0) +DEFSDIR = $(shell pkg-config --variable=defsdir pygtk-2.0) + +PYVERSION = $(shell python -c "import sys; print sys.version[:3]") +PYLIBDIR = $(prefix)/lib/python$(PYVERSION)/site-packages + +CFLAGS += -I$(prefix)/include/python$(PYVERSION) + +CFLAGS += -Wall -g + +INSTALL_DIR = install -d +INSTALL_LIB = install -m755 +INSTALL_BIN = install -m755 + +all: qemu.so + +clean: + $(RM) *.o *~ qemu.defs gen-qemu.defs.c qemu.so + +qemu-screen.o: qemu-screen.c qemu-screen.h qemu-keys.h + +qemu.defs: qemu-screen.h + python $(CODEGENDIR)/h2def.py $< > $@ + +gen-qemu.defs.c: qemu.override qemu.defs + pygtk-codegen-2.0 --prefix qemu --register $(DEFSDIR)/gdk-types.defs \ + --register $(DEFSDIR)/gtk-types.defs \ + --override qemu.override qemu.defs > $@ + +qemu.so: gen-qemu.defs.o qemu-module.o qemu-screen.o + $(CC) $(LDLIBS) -shared $^ -o $@ + +install: qemu.so + $(INSTALL_DIR) $(DESTDIR)$(prefix)/bin + $(INSTALL_BIN) gtk-qemu $(DESTDIR)$(prefix)/bin/gtk-qemu + $(INSTALL_DIR) $(DESTDIR)$(PYLIBDIR) + $(INSTALL_LIB) qemu.so $(DESTDIR)$(PYLIBDIR)/qemu.so
gtk/README new file +23 -0
@@ -0,0 +1,23 @@ +QEMU GTK GUI + +This is a simple GUI that makes use of QEMU's new shared memory interface. +It uses a XShmImage so that there is virtually no performance overhead to +having the screen appear in an external application. + +Interacting with this GUI is very similar to interacting with the SDL GUI with +a few important exceptions. + + - There is currently no full screen mode so ctrl-alt-f and -fs do nothing. + + - Instead of switching virtual consoles with ctrl-alt-N, virtual consoles will + appear as tabs within a notebook. + + - There is an additional -qemu option which can be used to specify the + location of the QEMU executable that you want this GUI to use (normally + `qemu' is executed using whatever the current path is). + +The hope is that this will provide an example on constructing GUIs that use +QEMU and perhaps will grow in the future to a much more user friendly interface +to QEMU. + + aliguori
gtk/gtk-qemu new file +228 -0
228 lines not on this page · raw message
gtk/qemu-keys.h new file +252 -0
252 lines not on this page · raw message
gtk/qemu-module.c new file +36 -0
@@ -0,0 +1,36 @@ +/* +* qemu-module.c -- QEMU GTK Widget Python Bindings +* +* Copyright (C) 2006 Anthony Liguori <[email protected]> +* +* This file is subject to the terms and conditions of the GNU Lesser General +* Public License. See the file COPYING.lib in the main directory of this +* archive for more details. +*/ + +#include <pygobject.h> + +void qemu_register_classes (PyObject *d); +extern PyMethodDef qemu_functions[]; + +DL_EXPORT (void ) +initqemu (void ) +{ +PyObject *m, *d; + +init_pygobject (); + + m =Py_InitModule ("qemu" , qemu_functions); +if (PyErr_Occurred ()) +Py_FatalError ("can't init module" ); + + d =PyModule_GetDict (m); +if (PyErr_Occurred ()) +Py_FatalError ("can't get dict" ); + +qemu_register_classes (d); + +if (PyErr_Occurred ()) { +Py_FatalError ("can't initialise module qemu" ); + } +}
gtk/qemu-screen.c new file +592 -0
592 lines not on this page · raw message
gtk/qemu-screen.h new file +65 -0
65 lines not on this page · raw message
gtk/qemu.override new file +13 -0
@@ -0,0 +1,13 @@ +%% +headers +#include <Python.h> +#include "pygobject.h" +#include "qemu-screen.h" +%% +modulename qemu +%% +import gtk.DrawingArea as PyGtkDrawingArea_Type +%% +ignore-glob + *_get_type +%%