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 <mpgritti@gmail.com>2008-10-15 10:08:06 (GMT)
committer Marco Pesenti Gritti <mpgritti@gmail.com>2008-10-15 10:08:06 (GMT)
commitc0518123f7a236b2eef924aa4af85bbe92e58727 (patch)
treefe3534571f4456e5d54fc0b898c5b6a9d5a55e9c /src
parentfe68d402ad560edd6bdb265a14cbd80b5f281ca7 (diff)
Refactor initialization some more.
Diffstat (limited to 'src')
-rw-r--r--src/hulahop-web-view.cpp25
-rw-r--r--src/hulahop-web-view.h6
2 files changed, 22 insertions, 9 deletions
diff --git a/src/hulahop-web-view.cpp b/src/hulahop-web-view.cpp
index 2317823..9104b20 100644
--- a/src/hulahop-web-view.cpp
+++ b/src/hulahop-web-view.cpp
@@ -49,10 +49,6 @@ struct _HulahopWebView {
GtkWidget *mozilla_widget;
};
-struct _HulahopWebViewClass {
- GtkBinClass base_class;
-};
-
G_DEFINE_TYPE(HulahopWebView, hulahop_web_view, GTK_TYPE_BIN)
static GObjectClass *parent_class = NULL;
@@ -95,6 +91,13 @@ hulahop_web_view_unrealize(GtkWidget *widget)
GTK_WIDGET_CLASS(parent_class)->unrealize(widget);
}
+void
+hulahop_web_view_setup(HulahopWebView *web_view)
+{
+ web_view->base_window->Create();
+ web_view->mozilla_widget = GTK_BIN(web_view)->child;
+}
+
static void
hulahop_web_view_realize(GtkWidget *widget)
{
@@ -126,10 +129,11 @@ hulahop_web_view_realize(GtkWidget *widget)
if (web_view->mozilla_widget) {
gtk_widget_reparent(web_view->mozilla_widget, widget);
} else {
- web_view->base_window->Create();
- web_view->mozilla_widget = GTK_BIN(web_view)->child;
+ HULAHOP_WEB_VIEW_GET_CLASS(web_view)->setup(web_view);
}
+ g_assert(web_view->mozilla_widget);
+
g_signal_connect_object(web_view->mozilla_widget,
"focus-in-event",
G_CALLBACK(child_focus_in_cb),
@@ -231,7 +235,9 @@ hulahop_web_view_class_init(HulahopWebViewClass *web_view_class)
widget_class->unmap = hulahop_web_view_unmap;
widget_class->size_allocate = hulahop_web_view_size_allocate;
- gobject_class->dispose = hulahop_web_view_dispose;
+ gobject_class->dispose = hulahop_web_view_dispose;
+
+ web_view_class->setup = hulahop_web_view_setup;
}
static void
@@ -239,8 +245,6 @@ hulahop_web_view_init(HulahopWebView *web_view)
{
web_view->offscreen_window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_widget_realize(web_view->offscreen_window);
-
- nsresult rv;
web_view->browser = do_CreateInstance
("@mozilla.org/embedding/browser/nsWebBrowser;1");
@@ -250,8 +254,11 @@ hulahop_web_view_init(HulahopWebView *web_view)
item->SetItemType(nsIDocShellTreeItem::typeContentWrapper);
web_view->base_window = do_QueryInterface(web_view->browser);
+ g_assert(web_view->base_window);
+ nsresult rv;
rv = web_view->base_window->InitWindow(web_view, nsnull, 0, 0, 100, 100);
+ g_assert(NS_SUCCEEDED(rv));
GTK_WIDGET_UNSET_FLAGS(GTK_WIDGET(web_view), GTK_NO_WINDOW);
}
diff --git a/src/hulahop-web-view.h b/src/hulahop-web-view.h
index f54fecf..cd3b710 100644
--- a/src/hulahop-web-view.h
+++ b/src/hulahop-web-view.h
@@ -35,6 +35,12 @@ typedef struct _HulahopWebViewClass HulahopWebViewClass;
#define HULAHOP_IS_WEB_VIEW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), HULAHOP_TYPE_WEB_VIEW))
#define HULAHOP_WEB_VIEW_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), HULAHOP_TYPE_WEB_VIEW, HulahopWebViewClass))
+struct _HulahopWebViewClass {
+ GtkBinClass base_class;
+
+ void (* setup) (HulahopWebView *web_view);
+};
+
GType hulahop_web_view_get_type (void);
void hulahop_web_view_grab_focus (HulahopWebView *web_view);