[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash configure.ac ChangeLog extensions/gtk2/Ma...
From: |
Rob Savoye |
Subject: |
[Gnash-commit] gnash configure.ac ChangeLog extensions/gtk2/Ma... |
Date: |
Thu, 15 Feb 2007 20:11:23 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Rob Savoye <rsavoye> 07/02/15 20:11:23
Modified files:
. : configure.ac ChangeLog
Added files:
extensions/gtk2: Makefile.am gtkext.cpp gtkext.h hello.as
Log message:
* extensions/gtk2: New directory for Gtk2 API extension.
* extensions/gtk2/hello.as: The well known Gtk "Hello" example
program written in ActionScript.
* extensions/gtk2/gtkext.{cpp,h}: Wrappers for the Gtk2 API to
export it into Gnash.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/configure.ac?cvsroot=gnash&r1=1.256&r2=1.257
http://cvs.savannah.gnu.org/viewcvs/gnash/ChangeLog?cvsroot=gnash&r1=1.2367&r2=1.2368
http://cvs.savannah.gnu.org/viewcvs/gnash/extensions/gtk2/Makefile.am?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/extensions/gtk2/gtkext.cpp?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/extensions/gtk2/gtkext.h?cvsroot=gnash&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/gnash/extensions/gtk2/hello.as?cvsroot=gnash&rev=1.1
Patches:
Index: configure.ac
===================================================================
RCS file: /sources/gnash/gnash/configure.ac,v
retrieving revision 1.256
retrieving revision 1.257
diff -u -b -r1.256 -r1.257
--- configure.ac 13 Feb 2007 19:39:46 -0000 1.256
+++ configure.ac 15 Feb 2007 20:11:23 -0000 1.257
@@ -15,7 +15,7 @@
dnl Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
dnl
-dnl $Id: configure.ac,v 1.256 2007/02/13 19:39:46 rsavoye Exp $
+dnl $Id: configure.ac,v 1.257 2007/02/15 20:11:23 rsavoye Exp $
AC_PREREQ(2.50)
AC_INIT(gnash, cvs)
@@ -828,11 +828,11 @@
extensions/dejagnu/Makefile
extensions/mysql/Makefile
extensions/fileio/Makefile
+extensions/gtk2/Makefile
plugin/Makefile
plugin/klash/Makefile
cygnal/Makefile
)
-dnl cygnal/Makefile
echo ""
echo "Configurable options are:"
Index: ChangeLog
===================================================================
RCS file: /sources/gnash/gnash/ChangeLog,v
retrieving revision 1.2367
retrieving revision 1.2368
diff -u -b -r1.2367 -r1.2368
--- ChangeLog 15 Feb 2007 17:51:42 -0000 1.2367
+++ ChangeLog 15 Feb 2007 20:11:23 -0000 1.2368
@@ -1,3 +1,11 @@
+2007-02-15 Rob Savoye <address@hidden>
+
+ * extensions/gtk2: New directory for Gtk2 API extension.
+ * extensions/gtk2/hello.as: The well known Gtk "Hello" example
+ program written in ActionScript.
+ * extensions/gtk2/gtkext.{cpp,h}: Wrappers for the Gtk2 API to
+ export it into Gnash.
+
2007-02-14 Udo Giacomozzi <address@hidden>
* server/BitmapMovieInstance.cpp, server/parser/BitmapMovieDefinition.cpp:
Index: extensions/gtk2/Makefile.am
===================================================================
RCS file: extensions/gtk2/Makefile.am
diff -N extensions/gtk2/Makefile.am
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ extensions/gtk2/Makefile.am 15 Feb 2007 20:11:23 -0000 1.1
@@ -0,0 +1,88 @@
+## Process this file with automake to generate Makefile.in
+#
+# Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+AUTOMAKE_OPTIONS =
+
+# this is where Gnash plugins get installed
+pluginsdir = $(libdir)/gnash/plugins
+
+plugins_LTLIBRARIES = gtkext.la
+DEF_MAKESWF_FLAGS = -I $(top_srcdir)/testsuite/actionscript.all
+
+INCLUDES = -I$(srcdir) \
+ -I$(top_srcdir)/libbase \
+ -I$(top_srcdir)/libgeometry \
+ -I$(top_srcdir)/server \
+ -I$(top_srcdir)/server/vm \
+ -I$(top_srcdir)/server/parser \
+ -I$(top_srcdir)/server/asobjs \
+ $(LIBXML_CFLAGS) \
+ $(SDL_CFLAGS) \
+ $(DMALLOC_CFLAGS) \
+ $(BOOST_CFLAGS) \
+ $(PTHREAD_CFLAGS) \
+ $(GTK2_CFLAGS) \
+ $(GLEXT_CFLAGS) \
+ $(GLIB_CFLAGS) \
+ $(PANGO_CFLAGS) \
+ $(ATK_CFLAGS) \
+ $(CAIRO_CFLAGS) \
+ $(INCLTDL)
+
+AM_LDFLAGS = \
+ $(top_builddir)/libbase/libgnashbase.la \
+ $(top_builddir)/server/vm/libgnashvm.la \
+ $(top_builddir)/backend/libgnashbackend.la \
+ $(top_builddir)/server/libgnashserver.la \
+ $(GTK2_LIBS) \
+ $(GLEXT_LIBS) \
+ $(CAIRO_LIBS) \
+ $(PANGO_LIBS) \
+ $(ATK_LIBS) \
+ $(GLIB_LIBS) \
+ $(EXPAT_LIBS) \
+ $(BOOST_LIBS) \
+ $(PTHREAD_LIBS) \
+ $(NULL)
+
+gtkext_la_SOURCES = gtkext.cpp gtkext.h
+gtkext_la_LDFLAGS = -module -avoid-version # -no-undefined
+gtkext_la_LIBDADD = $(LIBADD_DL) $(LIBLTDL) $(AM_LDFLAGS)
+
+
+check_PROGRAMS = hello
+CLEANFILES = \
+ gnash-dbg.log\
+ hello.swf.frame0.pp \
+ hello.swf \
+ logfile
+
+
+hello: hello.swf
+ ../../utilities/gprocessor hello.swf
+
+hello.swf: hello.as
+
+SUFFIXES = as swf
+.as.swf:
+ $(MAKESWF) $(DEF_MAKESWF_FLAGS) $(MAKESWF_FLAGS) -o $@ $<
+
+install-pluginsLTLIBRARIES: $(plugins_LTLIBRARIES)
+ test -d "$(DESTDIR)$(pluginsdir)" || $(mkinstalldirs)
"$(DESTDIR)$(pluginsdir)"
+ $(LIBTOOL) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG)
$(plugins_LTLIBRARIES) "$(DESTDIR)$(pluginsdir)/$(plugins_LTLIBRARIES)"
+ $(RM) $(DESTDIR)$(pluginsdir)/*.a
+
Index: extensions/gtk2/gtkext.cpp
===================================================================
RCS file: extensions/gtk2/gtkext.cpp
diff -N extensions/gtk2/gtkext.cpp
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ extensions/gtk2/gtkext.cpp 15 Feb 2007 20:11:23 -0000 1.1
@@ -0,0 +1,370 @@
+//
+// Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <map>
+#include <iostream>
+#include <string>
+#include <cstdio>
+#include <boost/algorithm/string/case_conv.hpp>
+
+#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
+#include <gdk/gdkkeysyms.h>
+
+#include "VM.h"
+#include "fn_call.h"
+#include "log.h"
+#include "fn_call.h"
+#include "as_object.h"
+#include "as_function.h"
+#include "builtin_function.h" // need builtin_function
+#include "debugger.h"
+#include "gtkext.h"
+
+using namespace std;
+
+namespace gnash
+{
+
+static LogFile& dbglogfile = LogFile::getDefaultInstance();
+#ifdef USE_DEBUGGER
+static Debugger& debugger = Debugger::getDefaultInstance();
+#endif
+
+// prototypes for the callbacks required by Gnash
+void gtkext_window_new(const fn_call& fn);
+void gtkext_signal_connect(const fn_call& fn);
+void gtkext_container_set_border_width(const fn_call& fn);
+void gtkext_button_new_with_label(const fn_call& fn);
+void gtkext_signal_connect_swapped(const fn_call& fn);
+void gtkext_container_add(const fn_call& fn);
+void gtkext_widget_show(const fn_call& fn);
+void gtkext_main(const fn_call& fn);
+
+// Sigh... We can't store the callbacks for the events in the GtkExt
+// class object because that data is inaccessible to a C symbol based
+// callback.
+static map<string, as_value> callbacks;
+
+void dump_callbacks(map<string, as_value> &calls)
+{
+// GNASH_REPORT_FUNCTION;
+ map<string, as_value>::const_iterator it;
+ dbglogfile << "# of callbacks is: " << calls.size() << endl;
+ for (it=calls.begin(); it != calls.end(); it++) {
+ string name = (*it).first;
+ as_value as = (*it).second;
+ dbglogfile << "Event \"" << name.c_str() << "\" has AS function" <<
as.to_string() << endl;
+ }
+
+}
+
+static void
+generic_callback(GtkWidget *widget, gpointer data)
+{
+// GNASH_REPORT_FUNCTION;
+// g_print ("Hello World - %d\n", *(int *)data;
+ const char *event = (const char *)data;
+
+ as_value handler = callbacks[event];
+ as_function *as_func = handler.to_as_function();
+
+// start the debugger when this callback is activated.
+// debugger.enabled(true);
+// debugger.console();
+
+ // FIXME: Delete events don't seem to pass in data in a form we
+ // can access it. So for now we just hack in a quit, since we know
+ // we're done, we hope...
+ if (*event == NULL) {
+ gtk_main_quit();
+ return;
+ } else {
+ cerr << "event is: \"" << event << "\"" << endl;
+ }
+
+ as_value val;
+ as_environment env;
+ env.push_val(handler.to_object());
+ env.push(event);
+ env.push(handler.to_string());
+
+ // Call the AS function defined in the source file using this extension
+ (*as_func)(fn_call(&val, handler.to_object(), &env, 2, 2));
+}
+
+static void
+attachInterface(as_object *obj)
+{
+// GNASH_REPORT_FUNCTION;
+
+ obj->set_member("window_new", >kext_window_new);
+ obj->set_member("signal_connect", >kext_signal_connect);
+ obj->set_member("container_set_border_width",
>kext_container_set_border_width);
+ obj->set_member("button_new_with_label", >kext_button_new_with_label);
+ obj->set_member("signal_connect_swapped", >kext_signal_connect_swapped);
+ obj->set_member("container_add", >kext_container_add);
+ obj->set_member("widget_show", >kext_widget_show);
+ obj->set_member("main", >kext_main);
+}
+
+static as_object*
+getInterface()
+{
+// GNASH_REPORT_FUNCTION;
+ static boost::intrusive_ptr<as_object> o;
+ if (o == NULL) {
+ o = new as_object();
+ }
+ return o.get();
+}
+
+static void
+gtkext_ctor(const fn_call& fn)
+{
+// GNASH_REPORT_FUNCTION;
+ GtkExt *obj = new GtkExt();
+
+ attachInterface(obj);
+ fn.result->set_as_object(obj); // will keep alive
+}
+
+
+GtkExt::GtkExt()
+{
+// GNASH_REPORT_FUNCTION;
+ int argc = 0;
+ char **argv;
+ gtk_init (&argc, &argv);
+}
+
+GtkExt::~GtkExt()
+{
+// GNASH_REPORT_FUNCTION;
+}
+
+void
+GtkExt::window_new()
+{
+ GNASH_REPORT_FUNCTION;
+ _window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
+}
+
+// void
+// GtkExt::signal_connect()
+// {
+// GNASH_REPORT_FUNCTION;
+// }
+
+// void gtk_container_set_border_width (GtkContainer *container, guint
border_width);
+void
+GtkExt::container_set_border_width(int width)
+{
+// GNASH_REPORT_FUNCTION;
+ if (_window) {
+ gtk_container_set_border_width (GTK_CONTAINER (_window), width);
+ }
+}
+
+// GtkWidget *gtk_button_new_with_label (const gchar *label);
+GtkWidget *
+GtkExt::button_new_with_label(const char *label)
+{
+// GNASH_REPORT_FUNCTION;
+ _window = gtk_button_new_with_label (label);
+ return _window;
+}
+
+void
+GtkExt::main()
+{
+// GNASH_REPORT_FUNCTION;
+}
+
+// this callback takes no arguments
+void gtkext_window_new(const fn_call& fn)
+{
+// GNASH_REPORT_FUNCTION;
+ GtkExt *ptr = dynamic_cast<GtkExt *>(fn.this_ptr);
+ assert(ptr);
+
+ GtkExt *obj = new GtkExt;
+ obj->window_new();
+ fn.result->set_as_object(obj);
+}
+
+// this callback takes 4 arguments, we only need two of them
+// g_signal_connect (instance, detailed_signal, c_handler, data)
+void gtkext_signal_connect(const fn_call& fn)
+{
+// GNASH_REPORT_FUNCTION;
+ GtkExt *ptr = dynamic_cast<GtkExt *>(fn.this_ptr);
+ assert(ptr);
+
+ if (fn.nargs > 0) {
+ GtkExt *window = dynamic_cast<GtkExt *>(fn.arg(0).to_object());
+ string name = fn.arg(1).to_std_string();
+ as_value func = fn.arg(2).to_as_function();
+ int data = fn.arg(3).to_number();
+
+ dbglogfile << "Adding callback " << func.to_string()
+ << " for event \"" << name << "\"" << endl;
+ callbacks[name] = func;
+ g_signal_connect (G_OBJECT (window->getWindow()), name.c_str(),
+ G_CALLBACK (generic_callback), (void *)name.c_str());
+ }
+}
+
+// this callback takes 2 arguments
+// void gtk_container_set_border_width (GtkContainer *container, guint
border_width);
+void gtkext_container_set_border_width(const fn_call& fn)
+{
+// GNASH_REPORT_FUNCTION;
+
+ GtkExt *ptr = dynamic_cast<GtkExt *>(fn.this_ptr);
+ assert(ptr);
+
+ if (fn.nargs > 0) {
+ GtkExt *window = dynamic_cast<GtkExt *>(fn.arg(0).to_object());
+ int width = fn.arg(1).to_number();
+ window->container_set_border_width(width);
+ dbglogfile << "set container border width to " << width << " !" << endl;
+ }
+}
+
+// Creates a new button with the label "Hello World".
+// GtkWidget *gtk_button_new_with_label (const gchar *label);
+void gtkext_button_new_with_label(const fn_call& fn)
+{
+// GNASH_REPORT_FUNCTION;
+ GtkExt *ptr = dynamic_cast<GtkExt *>(fn.this_ptr);
+ assert(ptr);
+
+ if (fn.nargs > 0) {
+ const char *label = fn.arg(0).to_string();
+ GtkExt *obj = new GtkExt;
+ obj->button_new_with_label(label);
+ fn.result->set_as_object(obj);
+ }
+}
+
+// g_signal_connect_swapped(instance, detailed_signal, c_handler, data)
+//
+// Connects a GCallback function to a signal for a particular object.
+//
+// The instance on which the signal is emitted and data will be swapped when
calling the handler.
+// instance : the instance to connect to.
+// detailed_signal : a string of the form "signal-name::detail".
+// c_handler : the GCallback to connect.
+// data : data to pass to c_handler calls.
+// Returns : the handler id
+void gtkext_signal_connect_swapped(const fn_call& fn)
+{
+ GNASH_REPORT_FUNCTION;
+ GtkExt *ptr = dynamic_cast<GtkExt *>(fn.this_ptr);
+ assert(ptr);
+
+
+ if (fn.nargs > 0) {
+ GtkExt *parent = dynamic_cast<GtkExt *>(fn.arg(0).to_object());
+ string name = (fn.arg(1).to_string());
+ GtkExt *child = dynamic_cast<GtkExt *>(fn.arg(3).to_object());
+ as_value *callback = dynamic_cast<as_value *>(fn.arg(2).to_object());
+
+ // FIXME: This seems to cause an Gobject warning
+ g_signal_connect_swapped (G_OBJECT (child->getWindow()), name.c_str(),
+ G_CALLBACK (gtk_widget_destroy),
+ G_OBJECT (parent->getWindow()));
+ }
+}
+
+// this takes two arguments
+void gtkext_container_add(const fn_call& fn)
+{
+// GNASH_REPORT_FUNCTION;
+ GtkExt *ptr = dynamic_cast<GtkExt *>(fn.this_ptr);
+ assert(ptr);
+
+ if (fn.nargs > 0) {
+ GtkExt *parent = dynamic_cast<GtkExt *>(fn.arg(0).to_object());
+ GtkExt *child = dynamic_cast<GtkExt *>(fn.arg(1).to_object());
+ gtk_container_add (GTK_CONTAINER (parent->getWindow()),
child->getWindow());
+ fn.result->set_bool(true);
+ }
+}
+
+void gtkext_widget_show(const fn_call& fn)
+{
+// GNASH_REPORT_FUNCTION;
+ GtkExt *ptr = dynamic_cast<GtkExt *>(fn.this_ptr);
+ assert(ptr);
+
+ if (fn.nargs > 0) {
+ GtkExt *window = dynamic_cast<GtkExt *>(fn.arg(0).to_object());
+ gtk_widget_show(window->getWindow());
+ }
+}
+
+// gtk_main taks no arguments.
+void gtkext_main(const fn_call& fn)
+{
+// GNASH_REPORT_FUNCTION;
+ GtkExt *ptr = dynamic_cast<GtkExt *>(fn.this_ptr);
+ assert(ptr);
+
+ gtk_main();
+}
+
+std::auto_ptr<as_object>
+init_gtkext_instance()
+{
+ return std::auto_ptr<as_object>(new GtkExt());
+}
+
+extern "C" {
+ void
+ gtkext_class_init(as_object &obj)
+ {
+// GNASH_REPORT_FUNCTION;
+ // This is going to be the global "class"/"function"
+ static boost::intrusive_ptr<builtin_function> cl;
+ if (cl == NULL) {
+ cl = new builtin_function(>kext_ctor, getInterface());
+// // replicate all interface to class, to be able to access
+// // all methods as static functions
+ attachInterface(cl.get());
+ }
+
+ VM& vm = VM::get(); // cache this ?
+ std::string name = "GtkExt";
+ if ( vm.getSWFVersion() < 7 ) {
+ boost::to_lower(name, vm.getLocale());
+ }
+ obj.init_member(name, cl.get());
+ }
+} // end of extern C
+
+
+} // end of gnash namespace
+
+// Local Variables:
+// mode: C++
+// indent-tabs-mode: t
+// End:
Index: extensions/gtk2/gtkext.h
===================================================================
RCS file: extensions/gtk2/gtkext.h
diff -N extensions/gtk2/gtkext.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ extensions/gtk2/gtkext.h 15 Feb 2007 20:11:23 -0000 1.1
@@ -0,0 +1,79 @@
+//
+// Copyright (C) 2005, 2006 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+#ifndef __GTKEXT_PLUGIN_H__
+#define __GTKEXT_PLUGIN_H__
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <memory> // for auto_ptr
+#include "as_object.h"
+
+#include <cstdio>
+#include <string>
+#include <map>
+#include <gtk/gtk.h>
+#include <gdk/gdkx.h>
+
+namespace gnash
+{
+
+class GtkExt : public as_object {
+public:
+ GtkExt();
+ ~GtkExt();
+
+ typedef void (*gtk_callback_t)(GtkWidget *widget, gpointer data);
+
+ // Gtk2 API
+ void window_new();
+ void signal_connect();
+ void container_set_border_width(int width);
+ GtkWidget *button_new_with_label(const char *label);
+ void signal_connect_swapped();
+ void container_add();
+ void widget_show();
+ void main();
+
+ // internal methods
+ GtkWidget *getWindow() { return _window; };
+ void setWindow(GtkWidget *x) { _window = x; };
+// void addCallback(std::string &event, as_value *func) {
_callbacks[event] = func; };
+// as_value *getCallback(std::string &event) { return _callbacks[event]; };
+// std::map<std::string, as_value *> _callbacks;
+
+private:
+ GtkWidget *_window;
+};
+
+extern "C" {
+ void gtkext_class_init(as_object &obj);
+ /// Return an instance
+}
+
+std::auto_ptr<as_object> init_gtkext_instance();
+
+} // end of gnash namespace
+
+// __GTKEXT_PLUGIN_H__
+#endif
+
+// Local Variables:
+// mode: C++
+// indent-tabs-mode: t
+// End:
Index: extensions/gtk2/hello.as
===================================================================
RCS file: extensions/gtk2/hello.as
diff -N extensions/gtk2/hello.as
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ extensions/gtk2/hello.as 15 Feb 2007 20:11:23 -0000 1.1
@@ -0,0 +1,94 @@
+// Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+// You should have received a copy of the GNU General Public License
+
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+// Test case for XML ActionScript class
+// compile this test case with Ming makeswf, and then
+// execute it like this gnash -1 -r 0 -v out.swf
+
+rcsid="$Id: hello.as,v 1.1 2007/02/15 20:11:23 rsavoye Exp $";
+
+#include "dejagnu.as"
+
+file = new FileIO();
+
+var gtk = new GtkExt();
+
+function hello (Gtk2, data)
+{
+ file.puts("hello");
+ file.puts(data);
+}
+
+function delete (Gtk2, event, data)
+{
+ file.puts("delete");
+ trace(data);
+}
+
+function destroy (Gtk2, data)
+{
+ file.puts("destroy");
+ trace(data);
+ gtk.main_quit();
+}
+
+// create a new window
+var window = gtk.window_new();
+
+// When the window is given the "delete_event" signal (this is given
+// by the window manager, usually by the "close" option, or on the
+// titlebar), we ask it to call the delete_event () function
+// as defined above. The data passed to the callback
+// function is NULL and is ignored in the callback function.
+gtk.signal_connect(window, "delete_event", delete, 0);
+
+// Here we connect the "destroy" event to a signal handler.
+// This event occurs when we call gtk_widget_destroy() on the window,
+// or if we return FALSE in the "delete_event" callback.
+gtk.signal_connect(window, "destroy_event", destroy, 0);
+
+// Sets the border width of the window.
+gtk.container_set_border_width (window, 5);
+
+// Creates a new button with the label "Hello World".
+var button = gtk.button_new_with_label ("Hello World");
+
+// When the button receives the "clicked" signal, it will call the
+// function hello() passing it NULL as its argument. The hello()
+// function is defined above.
+gtk.signal_connect (button, "clicked", hello, 222);
+
+// This will cause the window to be destroyed by calling
+// gtk_widget_destroy(window) when "clicked". Again, the destroy
+// signal could come from here, or the window manager.
+gtk.signal_connect_swapped (button, "clicked", gtk_widget_destroy, window);
+
+// This packs the button into the window (a gtk container).
+gtk.container_add (window, button);
+
+// The final step is to display this newly created widget.
+gtk.widget_show (button);
+
+// and the window
+gtk.widget_show (window);
+
+// All GTK applications must have a gtk_main(). Control ends here
+// and waits for an event to occur (like a key press or mouse event).
+
+gtk.main ();
+
+// totals();
- [Gnash-commit] gnash configure.ac ChangeLog extensions/gtk2/Ma...,
Rob Savoye <=