2009-07-01 00:39:22 +04:00
|
|
|
/* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 8; -*- */
|
|
|
|
|
|
|
|
#include "TabChild.h"
|
|
|
|
|
|
|
|
#include "nsIWebBrowser.h"
|
|
|
|
#include "nsEmbedCID.h"
|
|
|
|
#include "nsComponentManagerUtils.h"
|
|
|
|
#include "nsIBaseWindow.h"
|
|
|
|
#include "nsIDocShellTreeItem.h"
|
|
|
|
#include "nsThreadUtils.h"
|
|
|
|
#include <gdk/gdkx.h>
|
|
|
|
#include <gtk/gtk.h>
|
|
|
|
|
|
|
|
using namespace mozilla::tabs;
|
|
|
|
|
|
|
|
TabChild::TabChild()
|
|
|
|
: mWidget(0)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
TabChild::~TabChild()
|
|
|
|
{
|
|
|
|
// TODObsmedberg: destroy the window!
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
TabChild::Init(MessageLoop* aIOLoop, IPC::Channel* aChannel)
|
|
|
|
{
|
2009-07-03 04:24:02 +04:00
|
|
|
Open(aChannel, aIOLoop);
|
2009-07-01 00:39:22 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2009-07-03 04:24:02 +04:00
|
|
|
TabChild::Answerinit(const MagicWindowHandle& parentWidget)
|
2009-07-01 00:39:22 +04:00
|
|
|
{
|
|
|
|
printf("creating %d!\n", NS_IsMainThread());
|
|
|
|
|
|
|
|
gtk_init(NULL, NULL);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIWebBrowser> webBrowser(do_CreateInstance(NS_WEBBROWSER_CONTRACTID));
|
|
|
|
|
|
|
|
nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(webBrowser);
|
|
|
|
|
|
|
|
GtkWidget* win = gtk_plug_new((GdkNativeWindow)parentWidget);
|
|
|
|
gtk_widget_show(win);
|
|
|
|
baseWindow->InitWindow(win, 0, 0, 0, 0, 0);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDocShellTreeItem> docShellItem(do_QueryInterface(baseWindow));
|
|
|
|
docShellItem->SetItemType(nsIDocShellTreeItem::typeContentWrapper);
|
|
|
|
|
|
|
|
baseWindow->Create();
|
|
|
|
|
|
|
|
baseWindow->SetVisibility(PR_TRUE);
|
|
|
|
|
|
|
|
mWebNav = do_QueryInterface(webBrowser);
|
|
|
|
|
|
|
|
// TODObz: create and embed a window!
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2009-07-03 04:24:02 +04:00
|
|
|
TabChild::AnswerloadURL(const String& uri)
|
2009-07-01 00:39:22 +04:00
|
|
|
{
|
|
|
|
printf("loading %s, %d\n", uri.c_str(), NS_IsMainThread());
|
|
|
|
|
|
|
|
return mWebNav->LoadURI(NS_ConvertUTF8toUTF16(uri.c_str()).get(),
|
|
|
|
nsIWebNavigation::LOAD_FLAGS_NONE,
|
|
|
|
NULL, NULL, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
2009-07-03 04:24:02 +04:00
|
|
|
TabChild::Answermove(const uint32_t& x,
|
|
|
|
const uint32_t& y,
|
|
|
|
const uint32_t& width,
|
|
|
|
const uint32_t& height)
|
2009-07-01 00:39:22 +04:00
|
|
|
{
|
|
|
|
printf("[TabChild] MOVE to (x,y)=(%ud, %ud), (w,h)= (%ud, %ud)\n",
|
|
|
|
x, y, width, height);
|
|
|
|
|
|
|
|
nsCOMPtr<nsIBaseWindow> baseWin = do_QueryInterface(mWebNav);
|
|
|
|
baseWin->SetPositionAndSize(x, y, width, height, PR_TRUE);
|
|
|
|
return NS_OK;
|
|
|
|
}
|