Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <marco@localhost.localdomain>2007-05-19 14:10:05 (GMT)
committer Marco Pesenti Gritti <marco@localhost.localdomain>2007-05-19 14:10:05 (GMT)
commite77e975333ac47677c48b57cea0ef6f785609941 (patch)
tree81490b4c694c490a115d67e7f07947672b5342c5 /src
Initial checkin
Diffstat (limited to 'src')
-rw-r--r--src/.gitignore1
-rw-r--r--src/HulahopDirectoryProvider.cpp51
-rw-r--r--src/HulahopDirectoryProvider.h29
-rw-r--r--src/Makefile.am48
-rw-r--r--src/__init__.py6
-rw-r--r--src/hulahop-browser.cpp135
-rw-r--r--src/hulahop-browser.h41
-rw-r--r--src/hulahop.defs9
-rw-r--r--src/hulahop.override17
-rw-r--r--src/hulahopmodule.c26
10 files changed, 363 insertions, 0 deletions
diff --git a/src/.gitignore b/src/.gitignore
new file mode 100644
index 0000000..39a0668
--- /dev/null
+++ b/src/.gitignore
@@ -0,0 +1 @@
+.deps
diff --git a/src/HulahopDirectoryProvider.cpp b/src/HulahopDirectoryProvider.cpp
new file mode 100644
index 0000000..dd7bf41
--- /dev/null
+++ b/src/HulahopDirectoryProvider.cpp
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2007, Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include "HulahopDirectoryProvider.h"
+
+NS_IMPL_QUERY_INTERFACE2(HulahopDirectoryProvider,
+ nsIDirectoryServiceProvider,
+ nsIDirectoryServiceProvider2)
+
+NS_IMETHODIMP_(nsrefcnt)
+HulahopDirectoryProvider::AddRef()
+{
+ return 1;
+}
+
+NS_IMETHODIMP_(nsrefcnt)
+HulahopDirectoryProvider::Release()
+{
+ return 1;
+}
+
+NS_IMETHODIMP
+HulahopDirectoryProvider::GetFile(const char *aKey,
+ PRBool *aPersist,
+ nsIFile **aResult)
+{
+ return NS_ERROR_FAILURE;
+}
+
+NS_IMETHODIMP
+HulahopDirectoryProvider::GetFiles(const char *aKey,
+ nsISimpleEnumerator **aResult)
+{
+ return NS_ERROR_FAILURE;
+}
diff --git a/src/HulahopDirectoryProvider.h b/src/HulahopDirectoryProvider.h
new file mode 100644
index 0000000..c6b5669
--- /dev/null
+++ b/src/HulahopDirectoryProvider.h
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2007, Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <nsIDirectoryService.h>
+
+class HulahopDirectoryProvider : public nsIDirectoryServiceProvider2
+{
+ public:
+ NS_DECL_ISUPPORTS_INHERITED
+ NS_DECL_NSIDIRECTORYSERVICEPROVIDER
+ NS_DECL_NSIDIRECTORYSERVICEPROVIDER2
+};
+
diff --git a/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..8abb20b
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,48 @@
+sugardir = $(pythondir)/hulahop
+sugar_PYTHON = \
+ __init__.py
+
+INCLUDES = \
+ $(DEPS_CFLAGS) \
+ $(PYTHON_INCLUDES) \
+ $(PYGTK_CFLAGS) \
+ $(MOZILLA_CFLAGS) \
+ -I$(MOZILLA_INCLUDE_ROOT)/docshell \
+ -I$(MOZILLA_INCLUDE_ROOT)/xulapp \
+ -I$(MOZILLA_INCLUDE_ROOT)/nspr \
+ -I$(MOZILLA_INCLUDE_ROOT)/string \
+ -I$(MOZILLA_INCLUDE_ROOT)/webbrwsr \
+ -I$(MOZILLA_INCLUDE_ROOT)/widget \
+ -I$(MOZILLA_INCLUDE_ROOT)/xpcom
+
+pkgpyexec_LTLIBRARIES = _hulahop.la
+
+_hulahop_la_LDFLAGS = -module -avoid-version -R$(MOZILLA_HOME) -dlopen self
+_hulahop_la_LIBADD = \
+ $(GECKO_LIBS) \
+ $(DEPS_LIBS) \
+ $(MOZILLA_EXTRA_LIBS) \
+ $(MOZILLA_GLUE_LIBS)
+
+_hulahop_la_SOURCES = \
+ HulahopDirectoryProvider.cpp \
+ HulahopDirectoryProvider.h \
+ hulahop-browser.cpp \
+ hulahop-browser.h \
+ hulahop.c \
+ hulahopmodule.c
+
+hulahop.c: hulahop.defs hulahop.override
+
+CLEANFILES = hulahop.c
+EXTRA_DIST = hulahop.override hulahop.defs
+
+.defs.c:
+ (cd $(srcdir)\
+ && $(PYGTK_CODEGEN) \
+ --register $(PYGTK_DEFSDIR)/gdk-types.defs \
+ --register $(PYGTK_DEFSDIR)/gtk-types.defs \
+ --override $*.override \
+ --prefix py$* $*.defs) > gen-$*.c \
+ && cp gen-$*.c $*.c \
+ && rm -f gen-$*.c
diff --git a/src/__init__.py b/src/__init__.py
new file mode 100644
index 0000000..9d9afbb
--- /dev/null
+++ b/src/__init__.py
@@ -0,0 +1,6 @@
+from hulahop import _hulahop
+
+class Browser(_hulahop.Browser):
+ def __init__(self):
+ _hulahop.Browser.__init__(self)
+
diff --git a/src/hulahop-browser.cpp b/src/hulahop-browser.cpp
new file mode 100644
index 0000000..b353765
--- /dev/null
+++ b/src/hulahop-browser.cpp
@@ -0,0 +1,135 @@
+/*
+ * Copyright (C) 2007, Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <nsIDocShellTreeItem.h>
+#include <nsComponentManagerUtils.h>
+#include <nsCOMPtr.h>
+#include <nsIWebBrowser.h>
+#include <nsIBaseWindow.h>
+#include <nsXULAppAPI.h>
+
+#include "hulahop-browser.h"
+#include "HulahopDirectoryProvider.h"
+
+struct _HulahopBrowser {
+ GtkBin base_instance;
+ nsCOMPtr<nsIWebBrowser> browser;
+ nsCOMPtr<nsIBaseWindow> base_window;
+};
+
+struct _HulahopBrowserClass {
+ GtkBinClass base_class;
+};
+
+G_DEFINE_TYPE(HulahopBrowser, hulahop_browser, GTK_TYPE_BIN)
+
+static GObjectClass *parent_class = NULL;
+
+static const HulahopDirectoryProvider kDirectoryProvider;
+
+static void
+hulahop_startup()
+{
+ XRE_InitEmbedding(nsnull, nsnull,
+ NS_CONST_CAST(HulahopDirectoryProvider *,
+ &kDirectoryProvider), nsnull, 0);
+}
+
+static void
+hulahop_browser_realize(GtkWidget *widget)
+{
+ HulahopBrowser *browser = HULAHOP_BROWSER(widget);
+ GdkWindowAttr attributes;
+ gint attributes_mask;
+
+ GTK_WIDGET_SET_FLAGS(widget, GTK_REALIZED);
+
+ attributes.window_type = GDK_WINDOW_CHILD;
+ attributes.x = widget->allocation.x;
+ attributes.y = widget->allocation.y;
+ attributes.width = widget->allocation.width;
+ attributes.height = widget->allocation.height;
+ attributes.wclass = GDK_INPUT_OUTPUT;
+ attributes.visual = gtk_widget_get_visual(widget);
+ attributes.colormap = gtk_widget_get_colormap(widget);
+ attributes.event_mask = gtk_widget_get_events(widget) | GDK_EXPOSURE_MASK;
+
+ attributes_mask = GDK_WA_X | GDK_WA_Y | GDK_WA_VISUAL | GDK_WA_COLORMAP;
+
+ widget->window = gdk_window_new(gtk_widget_get_parent_window(widget),
+ &attributes, attributes_mask);
+ gdk_window_set_user_data(widget->window, widget);
+
+ widget->style = gtk_style_attach (widget->style, widget->window);
+ gtk_style_set_background(widget->style, widget->window, GTK_STATE_NORMAL);
+
+ nsresult rv;
+
+ browser->browser = do_CreateInstance
+ ("@mozilla.org/embedding/browser/nsWebBrowser;1");
+ g_assert(browser->browser);
+
+ nsCOMPtr<nsIDocShellTreeItem> item = do_QueryInterface(browser->browser);
+ item->SetItemType(nsIDocShellTreeItem::typeContentWrapper);
+
+ browser->base_window = do_QueryInterface(browser->browser);
+
+ rv = browser->base_window->InitWindow(widget, nsnull, 0, 0,
+ widget->allocation.width,
+ widget->allocation.height);
+ g_assert(NS_SUCCEEDED(rv));
+
+ rv = browser->base_window->Create();
+ g_assert(NS_SUCCEEDED(rv));
+}
+
+static void
+hulahop_browser_map(GtkWidget *widget)
+{
+ HulahopBrowser *browser = HULAHOP_BROWSER(widget);
+
+ GTK_WIDGET_SET_FLAGS(widget, GTK_MAPPED);
+
+ nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(browser->browser);
+
+ // XXX hack around problem. probably widget/gtk2 window initialization.
+ baseWindow->SetVisibility(PR_FALSE);
+ baseWindow->SetVisibility(PR_TRUE);
+
+ gdk_window_show(widget->window);
+}
+
+static void
+hulahop_browser_class_init(HulahopBrowserClass *browser_class)
+{
+ GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(browser_class);
+
+ parent_class = (GObjectClass *) g_type_class_peek_parent(browser_class);
+
+ widget_class->realize = hulahop_browser_realize;
+ widget_class->map = hulahop_browser_map;
+}
+
+static void
+hulahop_browser_init(HulahopBrowser *browser)
+{
+ GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(browser), GTK_NO_WINDOW);
+
+ hulahop_startup();
+}
diff --git a/src/hulahop-browser.h b/src/hulahop-browser.h
new file mode 100644
index 0000000..d4d9215
--- /dev/null
+++ b/src/hulahop-browser.h
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2006, Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __HULAHOP_BROWSER_H__
+#define __HULAHOP_BROWSER_H__
+
+#include <gtk/gtkbin.h>
+
+G_BEGIN_DECLS
+
+typedef struct _HulahopBrowser HulahopBrowser;
+typedef struct _HulahopBrowserClass HulahopBrowserClass;
+
+#define HULAHOP_TYPE_BROWSER (hulahop_browser_get_type())
+#define HULAHOP_BROWSER(object) (G_TYPE_CHECK_INSTANCE_CAST((object), HULAHOP_TYPE_BROWSER, HulahopBrowser))
+#define HULAHOP_BROWSER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), HULAHOP_TYPE_BROWSER, HulahopBrowserClass))
+#define HULAHOP_IS_BROWSER(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), HULAHOP_TYPE_BROWSER))
+#define HULAHOP_IS_BROWSER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), HULAHOP_TYPE_BROWSER))
+#define HULAHOP_BROWSER_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), HULAHOP_TYPE_BROWSER, HulahopBrowserClass))
+
+GType hulahop_browser_get_type (void);
+
+G_END_DECLS
+
+#endif
diff --git a/src/hulahop.defs b/src/hulahop.defs
new file mode 100644
index 0000000..c3c2854
--- /dev/null
+++ b/src/hulahop.defs
@@ -0,0 +1,9 @@
+;; -*- scheme -*-
+; object definitions ...
+
+(define-object Browser
+ (in-module "Hulahop")
+ (parent "GtkBin")
+ (c-name "HulahopBrowser")
+ (gtype-id "HULAHOP_TYPE_BROWSER")
+)
diff --git a/src/hulahop.override b/src/hulahop.override
new file mode 100644
index 0000000..b232bcb
--- /dev/null
+++ b/src/hulahop.override
@@ -0,0 +1,17 @@
+/* -*- Mode: C; c-basic-offset: 4 -*- */
+%%
+headers
+#include <Python.h>
+#include <pygtk/pygtk.h>
+
+#include "hulahop-browser.h"
+
+%%
+modulename _hulahop
+%%
+import gtk.Bin as PyGtkBin_Type
+%%
+ignore-glob
+ *_get_type
+ _*
+%%
diff --git a/src/hulahopmodule.c b/src/hulahopmodule.c
new file mode 100644
index 0000000..ccbb773
--- /dev/null
+++ b/src/hulahopmodule.c
@@ -0,0 +1,26 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <pygobject.h>
+
+void py_hulahop_register_classes (PyObject *d);
+
+extern PyMethodDef pyhulahop_functions[];
+
+DL_EXPORT(void)
+init_hulahop(void)
+{
+ PyObject *m, *d;
+
+ init_pygobject ();
+
+ m = Py_InitModule ("_hulahop", pyhulahop_functions);
+ d = PyModule_GetDict (m);
+
+ pyhulahop_register_classes (d);
+
+ if (PyErr_Occurred ()) {
+ Py_FatalError ("can't initialise module hulahop");
+ }
+}