epiphany r8756 - in trunk: . src



Author: chpe
Date: Sat Feb  7 15:13:33 2009
New Revision: 8756
URL: http://svn.gnome.org/viewvc/epiphany?rev=8756&view=rev

Log:
Add seed support; use --enable-seed to check it out. Patch by Robert Carr.


Added:
   trunk/src/ephy-seed-extension.c
   trunk/src/ephy-seed-extension.h
   trunk/src/ephy-seed-loader.c
   trunk/src/ephy-seed-loader.h
Modified:
   trunk/configure.ac
   trunk/src/Makefile.am
   trunk/src/ephy-extensions-manager.c

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Sat Feb  7 15:13:33 2009
@@ -252,19 +252,44 @@
 
 AM_CONDITIONAL([ENABLE_INTROSPECTION],[test "$enable_introspection" = "yes"])
 
+# ****
+# Seed
+# ****
+
+AC_MSG_CHECKING([whether Seed support is requested])
+AC_ARG_ENABLE([seed],
+  [AS_HELP_STRING([--enable-seed],[Enable Seed support (default: disabled)]),
+  [],[enable_seed=no])
+AC_MSG_RESULT([$enable_seed])
+
+if test "$enable_seed" = "yes"; then
+  EPIPHANY_FEATURES="$EPIPHANY_FEATURES seed"
+
+  SEED_REQUIRED=0
+  PKG_CHECK_MODULES([SEED],[seed >= $SEED_REQUIRED])
+  AC_SUBST([SEED_CFLAGS])
+  AC_SUBST([SEED_LIBS])
+
+  AC_DEFINE([ENABLE_SEED],[1],[Define to compile with Seed support])
+fi
+
+AM_CONDITIONAL([ENABLE_SEED],[test "$enable_seed" = "yes"])
+
 # ******
 # Python
 # ******
 
 AC_MSG_CHECKING([whether Python support is requested])
-
 AC_ARG_ENABLE([python],
 	AS_HELP_STRING([--enable-python],[Enable python support]),
 	[enable_python=$enableval have_python=$enableval],
 	[enable_python=autodetect have_python=yes])
-
 AC_MSG_RESULT([$enable_python])
 
+if test "$enable_seed" = "yes" -a "$enable_python" = "yes"; then
+  AC_MSG_ERROR([cannot enable seed and python support at the same time])
+fi
+
 if test "$have_python" != "no"; then
 	AM_PATH_PYTHON([2.3],[],[no])
 
@@ -602,6 +627,7 @@
  	Zeroconf bookmarks support : $enable_zeroconf
  	NetworkManager support     : $enable_network_manager
  	GObject introspection      : $enable_introspection
+ 	Seed support               : $enable_seed
  	Python support             : $enable_python
  	Build tests                : $enable_tests
 "

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Sat Feb  7 15:13:33 2009
@@ -124,6 +124,21 @@
 	ephy-net-monitor.h
 endif
 
+if ENABLE_SEED
+NOINST_H_FILES += \
+	ephy-seed-extension.h \
+	ephy-seed-loader.h \
+	$(NULL)
+
+libephymain_la_SOURCES += \
+	ephy-seed-loader.c \
+	ephy-seed-extension.c \
+	$(NULL)
+
+libephymain_la_CFLAGS += $(SEED_CFLAGS)
+libephymain_la_LIBADD += $(SEED_LIBS)
+endif # ENABLE_SEED
+
 if ENABLE_PYTHON
 NOINST_H_FILES += \
 	ephy-python.h		\

Modified: trunk/src/ephy-extensions-manager.c
==============================================================================
--- trunk/src/ephy-extensions-manager.c	(original)
+++ trunk/src/ephy-extensions-manager.c	Sat Feb  7 15:13:33 2009
@@ -60,6 +60,10 @@
 #include "ephy-python-loader.h"
 #endif
 
+#ifdef ENABLE_SEED
+#include "ephy-seed-loader.h"
+#endif
+
 #define CONF_LOADED_EXTENSIONS	"/apps/epiphany/general/active_extensions"
 #define EE_GROUP		"Epiphany Extension"
 #define DOT_INI			".ephy-extension"
@@ -593,6 +597,20 @@
 #endif
 	}
 
+#ifdef ENABLE_SEED
+	if (strcmp (type, "seed") == 0)
+	{
+		info = g_new (LoaderInfo, 1);
+		info->type = g_strdup (type);
+		info->loader = g_object_new (EPHY_TYPE_SEED_LOADER, NULL);
+
+		manager->priv->factories =
+				g_list_append (manager->priv->factories, info);
+
+		return g_object_ref (info->loader);
+		return NULL;
+	}
+#endif
 	shlib_loader = get_loader_for_type (manager, "shlib");
 	g_return_val_if_fail (shlib_loader != NULL, NULL);
 

Added: trunk/src/ephy-seed-extension.c
==============================================================================
--- (empty file)
+++ trunk/src/ephy-seed-extension.c	Sat Feb  7 15:13:33 2009
@@ -0,0 +1,274 @@
+/*
+ *  Copyright  2009, Robert Carr
+ *
+ *  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, 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <seed.h>
+
+#include "config.h"
+
+#include "ephy-seed-extension.h"
+
+#include "ephy-extension.h"
+#include "ephy-window.h"
+#include "ephy-file-helpers.h"
+#include "ephy-debug.h"
+
+SeedEngine * global_eng = NULL;
+
+static void ephy_seed_extension_iface_init (EphyExtensionIface *iface);
+
+#define EPHY_SEED_EXTENSION_GET_PRIVATE(object) (G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_SEED_EXTENSION, EphySeedExtensionPrivate))
+
+struct _EphySeedExtensionPrivate
+{
+  char *filename;
+	
+  SeedContext ctx;
+  SeedObject obj;
+};
+
+enum
+  {
+    PROP_0,
+    PROP_FILENAME
+  };
+
+static void
+ephy_seed_extension_init (EphySeedExtension *extension)
+{
+  LOG ("EphySeedExtension initialising");
+
+  extension->priv = EPHY_SEED_EXTENSION_GET_PRIVATE (extension);
+}
+
+static void
+call_seed_func (EphyExtension *extension,
+		const char *func_name,
+		EphyWindow *window,
+		EphyEmbed *embed) /* HACK: tab may be NULL */
+{
+  EphySeedExtension *seed_ext;
+  EphySeedExtensionPrivate *priv;
+  SeedObject function;
+  SeedException exception = NULL;
+  SeedValue args[2];
+	
+  seed_ext = EPHY_SEED_EXTENSION (extension);
+  priv = seed_ext->priv;
+
+  if (priv->obj == NULL || seed_value_is_null(priv->ctx, priv->obj))
+    return;
+	
+  function = seed_object_get_property(priv->ctx, priv->obj, func_name);
+  
+  if (!seed_value_is_function(priv->ctx, function))
+    return;
+	
+  args[0] = seed_value_from_object(priv->ctx, G_OBJECT(window), exception);
+  if (embed != NULL)
+    args[1] = seed_value_from_object(priv->ctx, G_OBJECT(embed), exception);
+	
+  seed_object_call(global_eng->context, function, NULL, embed == NULL ? 1 : 2,
+		   args, &exception);
+  if (exception)
+    printf("seed_exception: %s \n", seed_exception_to_string(priv->ctx, exception));
+	
+}
+
+static void
+impl_attach_tab (EphyExtension *extension,
+		 EphyWindow *window,
+		 EphyEmbed *embed)
+{
+  call_seed_func (extension, "attach_tab", window, embed);
+}
+
+static void
+impl_detach_tab (EphyExtension *extension,
+		 EphyWindow *window,
+		 EphyEmbed *embed)
+{
+  call_seed_func (extension, "detach_tab", window, embed);
+}
+
+static void
+impl_attach_window (EphyExtension *extension,
+		    EphyWindow *window)
+{
+  call_seed_func (extension, "attach_window", window, NULL);
+}
+
+static void
+impl_detach_window (EphyExtension *extension,
+		    EphyWindow *window)
+{
+  call_seed_func (extension, "detach_window", window, NULL);
+}
+
+static void
+ephy_seed_extension_iface_init (EphyExtensionIface *iface)
+{
+  iface->attach_tab = impl_attach_tab;
+  iface->detach_tab = impl_detach_tab;
+  iface->attach_window = impl_attach_window;
+  iface->detach_window = impl_detach_window;
+}
+
+G_DEFINE_TYPE_WITH_CODE (EphySeedExtension, ephy_seed_extension, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (EPHY_TYPE_EXTENSION,
+                                                ephy_seed_extension_iface_init))
+static gchar *
+ephy_seed_extension_get_file (const gchar * name)
+{
+  gchar *dot_dir, *dot_path, *system_path, *absolute, *dirname;
+
+  dot_dir = g_strconcat (ephy_dot_dir (), "/extensions", NULL);
+  dot_path = g_strconcat (dot_dir, "/", name, ".js", NULL);  
+  if (g_file_test (dot_path, G_FILE_TEST_EXISTS))
+    {
+      g_free (dot_dir);
+      return dot_path;
+    }
+  g_free (dot_dir);
+  
+  system_path = g_strconcat (EXTENSIONS_DIR, name);
+  if (g_file_test (system_path, G_FILE_TEST_EXISTS))
+    {
+      return system_path;
+    }
+  g_free (system_path);
+  
+  dirname = g_path_get_dirname (name);
+  if (g_path_is_absolute (dirname))
+    {
+      g_free(dirname);
+      return name;
+    }
+  g_free(dirname);
+
+  return NULL;
+}
+
+static GObject *
+ephy_seed_extension_constructor (GType type,
+				 guint n_construct_properties,
+				 GObjectConstructParam *construct_params)
+{
+  SeedScript *script;
+  GObject *object;
+  EphySeedExtension *ext;
+
+  object =
+    G_OBJECT_CLASS (ephy_seed_extension_parent_class)->constructor (type,
+						  n_construct_properties,
+							construct_params);
+
+  ext = EPHY_SEED_EXTENSION (object);
+  
+  if (ext->priv->filename)
+    script = seed_script_new_from_file(global_eng->context,
+				       ext->priv->filename);
+	
+  ext->priv->ctx = seed_context_create(global_eng->group, NULL);
+  ext->priv->obj = seed_evaluate(global_eng->context,
+				 script,
+				 NULL);
+  
+  if (seed_script_exception(script))
+    g_warning("seed_exception: %s", 
+	      seed_exception_to_string(global_eng->context,
+				       seed_script_exception(script)));
+	
+
+  return object;
+}
+
+static void
+ephy_seed_extension_finalize (GObject *object)
+{
+  EphySeedExtension *extension =
+    EPHY_SEED_EXTENSION (object);
+
+  seed_value_unprotect(extension->priv->ctx,
+		       extension->priv->obj);
+  seed_context_unref(extension->priv->ctx);
+
+  G_OBJECT_CLASS (ephy_seed_extension_parent_class)->finalize (object);
+}
+
+static void
+ephy_seed_extension_get_property (GObject *object,
+				  guint prop_id,
+				  GValue *value,
+				  GParamSpec *pspec)
+{
+  /* no readable properties */
+  g_return_if_reached ();
+}
+
+static void
+ephy_seed_extension_set_property (GObject *object,
+				  guint prop_id,
+				  const GValue *value,
+				  GParamSpec *pspec)
+{
+  EphySeedExtension *ext = EPHY_SEED_EXTENSION (object);
+
+  switch (prop_id)
+    {
+    case PROP_FILENAME:
+      ext->priv->filename = 
+	ephy_seed_extension_get_file(g_value_get_string (value));
+      break;
+    default:
+      g_return_if_reached ();
+    }
+}
+
+static void
+ephy_seed_extension_class_init (EphySeedExtensionClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->finalize = ephy_seed_extension_finalize;
+  object_class->constructor = ephy_seed_extension_constructor;
+  object_class->get_property = ephy_seed_extension_get_property;
+  object_class->set_property = ephy_seed_extension_set_property;
+
+  g_object_class_install_property
+    (object_class,
+     PROP_FILENAME,
+     g_param_spec_string ("filename",
+			  "Filename",
+			  "Filename",
+			  NULL,
+			  G_PARAM_WRITABLE | G_PARAM_STATIC_NAME | 
+			  G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB |
+			  G_PARAM_CONSTRUCT_ONLY));
+
+  g_type_class_add_private (object_class, sizeof (EphySeedExtensionPrivate));
+
+  if (global_eng == NULL)
+    {
+      global_eng = seed_init(NULL, NULL);
+      seed_simple_evaluate(global_eng->context,
+			   "Seed.import_namespace('Gtk');"
+			   "Seed.import_namespace('Epiphany');");
+    }
+}
+

Added: trunk/src/ephy-seed-extension.h
==============================================================================
--- (empty file)
+++ trunk/src/ephy-seed-extension.h	Sat Feb  7 15:13:33 2009
@@ -0,0 +1,60 @@
+/*
+ *  Copyright  2009, Robert Carr <carrr rpi edu>
+ *
+ *  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, 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#if !defined (__EPHY_EPIPHANY_H_INSIDE__) && !defined (EPIPHANY_COMPILATION)
+#error "Only <epiphany/epiphany.h> can be included directly."
+#endif
+
+#ifndef EPHY_SEED_EXTENSION_H
+#define EPHY_SEED_EXTENSION_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define EPHY_TYPE_SEED_EXTENSION		(ephy_seed_extension_get_type ())
+#define EPHY_SEED_EXTENSION(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_SEED_EXTENSION, EphySeedExtension))
+#define EPHY_SEED_EXTENSION_CLASS(k)		(G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_SEED_EXTENSION, EphySeedExtensionClass))
+#define EPHY_IS_SEED_EXTENSION(o)		(G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_SEED_EXTENSION))
+#define EPHY_IS_SEED_EXTENSION_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_SEED_EXTENSION))
+#define EPHY_SEED_EXTENSION_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_SEED_EXTENSION, EphySeedExtensionClass))
+
+typedef struct _EphySeedExtension		EphySeedExtension;
+typedef struct _EphySeedExtensionClass	EphySeedExtensionClass;
+typedef struct _EphySeedExtensionPrivate	EphySeedExtensionPrivate;
+
+struct _EphySeedExtensionClass
+{
+	GObjectClass parent_class;
+};
+
+struct _EphySeedExtension
+{
+	GObject parent_instance;
+
+	/*< private >*/
+	EphySeedExtensionPrivate *priv;
+};
+
+GType	ephy_seed_extension_get_type		(void);
+
+G_END_DECLS
+
+#endif

Added: trunk/src/ephy-seed-loader.c
==============================================================================
--- (empty file)
+++ trunk/src/ephy-seed-loader.c	Sat Feb  7 15:13:33 2009
@@ -0,0 +1,108 @@
+/*
+ *  Copyright  2009, Robert Carr <carrr rpi edu>
+ *
+ *  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, 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+
+#include "ephy-seed-loader.h"
+#include "ephy-seed-extension.h"
+#include "ephy-loader.h"
+#include "ephy-debug.h"
+
+#include <seed.h>
+
+#define EPHY_SEED_LOADER_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_SEED_LOADER, EphySeedLoaderPrivate))
+
+struct _EphySeedLoaderPrivate
+{
+	gpointer dummy;
+};
+
+static GObject *
+impl_get_object (EphyLoader *eloader,
+		 GKeyFile *keyfile)
+{
+	char *filename;
+	GObject *object;
+
+	g_return_val_if_fail (keyfile != NULL, NULL);
+
+	filename = g_key_file_get_string (keyfile, "Loader", "Module", NULL);
+	if (filename == NULL)
+	{
+		g_warning ("NULL module name!\n");
+		return NULL;
+	}
+
+	object = g_object_new (EPHY_TYPE_SEED_EXTENSION,
+			       "filename", filename,
+			       NULL);
+
+	g_free (filename);
+
+	/* we own one ref */
+	return g_object_ref (object);
+}
+
+static void
+impl_release_object (EphyLoader *eloader,
+		     GObject *object)
+{
+	g_return_if_fail (object != NULL);
+
+	g_object_unref (object);
+}
+
+static void
+ephy_seed_loader_iface_init (EphyLoaderIface *iface)
+{
+	iface->type = "seed";
+	iface->get_object = impl_get_object;
+	iface->release_object = impl_release_object;
+}
+
+G_DEFINE_TYPE_WITH_CODE (EphySeedLoader, ephy_seed_loader, G_TYPE_OBJECT,
+                         G_IMPLEMENT_INTERFACE (EPHY_TYPE_LOADER, ephy_seed_loader_iface_init))
+
+static void
+ephy_seed_loader_init (EphySeedLoader *loader)
+{
+	loader->priv = EPHY_SEED_LOADER_GET_PRIVATE (loader);
+
+	LOG ("EphySeedLoader initialising");
+
+}
+
+static void
+ephy_seed_loader_finalize (GObject *object)
+{
+	LOG ("EphySeedLoader finalising");
+
+	G_OBJECT_CLASS (ephy_seed_loader_parent_class)->finalize (object);
+}
+
+static void
+ephy_seed_loader_class_init (EphySeedLoaderClass *klass)
+{
+	GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+	object_class->finalize = ephy_seed_loader_finalize;
+
+	g_type_class_add_private (object_class, sizeof (EphySeedLoaderPrivate));
+}
+

Added: trunk/src/ephy-seed-loader.h
==============================================================================
--- (empty file)
+++ trunk/src/ephy-seed-loader.h	Sat Feb  7 15:13:33 2009
@@ -0,0 +1,60 @@
+/*
+ *  Copyright Robert Carr, <carrr rpi edu> 2009
+ *
+ *  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, 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 Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#if !defined (__EPHY_EPIPHANY_H_INSIDE__) && !defined (EPIPHANY_COMPILATION)
+#error "Only <epiphany/epiphany.h> can be included directly."
+#endif
+
+#ifndef EPHY_SEED_LOADER_H
+#define EPHY_SEED_LOADER_H
+
+#include <glib.h>
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define EPHY_TYPE_SEED_LOADER		(ephy_seed_loader_get_type ())
+#define EPHY_SEED_LOADER(o)		(G_TYPE_CHECK_INSTANCE_CAST ((o), EPHY_TYPE_SEED_LOADER, EphySeedLoader))
+#define EPHY_SEED_LOADER_CLASS(k)	(G_TYPE_CHECK_CLASS_CAST((k), EPHY_TYPE_SEED_LOADER, EphySeedLoaderClass))
+#define EPHY_IS_SEED_LOADER(o)	(G_TYPE_CHECK_INSTANCE_TYPE ((o), EPHY_TYPE_SEED_LOADER))
+#define EPHY_IS_SEED_LOADER_CLASS(k)	(G_TYPE_CHECK_CLASS_TYPE ((k), EPHY_TYPE_SEED_LOADER))
+#define EPHY_SEED_LOADER_GET_CLASS(o)	(G_TYPE_INSTANCE_GET_CLASS ((o), EPHY_TYPE_SEED_LOADER, EphySeedLoaderClass))
+
+typedef struct _EphySeedLoader	EphySeedLoader;
+typedef struct _EphySeedLoaderClass	EphySeedLoaderClass;
+typedef struct _EphySeedLoaderPrivate	EphySeedLoaderPrivate;
+
+struct _EphySeedLoaderClass
+{
+	GObjectClass parent_class;
+};
+
+struct _EphySeedLoader
+{
+	GObject parent_instance;
+
+	/*< private >*/
+	EphySeedLoaderPrivate *priv;
+};
+
+GType	ephy_seed_loader_get_type		(void);
+
+G_END_DECLS
+
+#endif /* !EPHY_SEED_LOADER_H */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]