gtkieembed r195 - in trunk: . sample src
- From: hiikezoe svn gnome org
- To: svn-commits-list gnome org
- Subject: gtkieembed r195 - in trunk: . sample src
- Date: Wed, 28 Jan 2009 03:27:57 +0000 (UTC)
Author: hiikezoe
Date: Wed Jan 28 03:27:57 2009
New Revision: 195
URL: http://svn.gnome.org/viewvc/gtkieembed?rev=195&view=rev
Log:
* sample/samplebrowser.c: Use gtk_ie_embed_load_from_string in the
first tab.
* src/ie-bridge.cpp (_ie_bridge_load_html_from_string): Load
"about:blank" before loading html string. Use IHTMLDocument2::write
instead of IPersistStreamInit.
Modified:
trunk/ChangeLog
trunk/sample/samplebrowser.c
trunk/src/ie-bridge.cpp
Modified: trunk/sample/samplebrowser.c
==============================================================================
--- trunk/sample/samplebrowser.c (original)
+++ trunk/sample/samplebrowser.c Wed Jan 28 03:27:57 2009
@@ -4,7 +4,7 @@
static GtkWidget *entry;
static GtkActionGroup *action_group;
-static GtkIEEmbed *create_new_embed (GtkNotebook *notebook, const gchar *url);
+static GtkIEEmbed *create_new_embed (GtkNotebook *notebook);
static GtkIEEmbed *
get_current_embed (GtkNotebook *notebook)
@@ -16,7 +16,7 @@
static void
open_new_tab_action (GtkAction *action, GtkNotebook *notebook)
{
- create_new_embed (GTK_NOTEBOOK (notebook), NULL);
+ create_new_embed (GTK_NOTEBOOK (notebook));
}
static void
@@ -385,7 +385,7 @@
static gboolean
cb_new_window (GtkIEEmbed *ie, GtkIEEmbed **newie, GtkWidget *notebook)
{
- *newie = create_new_embed (GTK_NOTEBOOK (notebook), NULL);
+ *newie = create_new_embed (GTK_NOTEBOOK (notebook));
return FALSE;
}
@@ -454,7 +454,7 @@
}
static GtkIEEmbed *
-create_new_embed (GtkNotebook *notebook, const gchar *url)
+create_new_embed (GtkNotebook *notebook)
{
GtkWidget *embed, *label;
@@ -469,21 +469,39 @@
g_signal_connect (embed, "new-window", G_CALLBACK (cb_new_window), notebook);
g_signal_connect (embed, "close-window", G_CALLBACK (cb_close_window), notebook);
- gtk_ie_embed_load_url (GTK_IE_EMBED (embed), url);
-
return GTK_IE_EMBED (embed);
}
-int
-main (int argc, char *argv[])
+static void
+append_new_embed_with_url (GtkNotebook *notebook, const gchar *url)
+{
+ GtkIEEmbed *embed;
+
+ embed = create_new_embed (GTK_NOTEBOOK (notebook));
+ gtk_ie_embed_load_url (embed, url);
+}
+
+static void
+append_new_welcome_embed (GtkNotebook *notebook)
+{
+ GtkIEEmbed *embed;
+ gchar contents[] = "<html><title>Welcome</title>"
+ "<body>This page is rendered GtkIEEmbed.</body>"
+ "</html>";
+
+ embed = create_new_embed (GTK_NOTEBOOK (notebook));
+
+ gtk_ie_embed_load_html_from_string (embed, contents);
+}
+
+static void
+create_main_window (void)
{
GtkWidget *window;
- GtkWidget *vbox, *hbox;
GtkWidget *notebook;
+ GtkWidget *vbox, *hbox;
GtkUIManager *merge;
- gtk_init (&argc, &argv);
-
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_default_size (GTK_WINDOW (window), 600, 400);
g_signal_connect (window, "delete-event",
@@ -540,8 +558,17 @@
gtk_widget_show (window);
- create_new_embed (GTK_NOTEBOOK (notebook), "http://www.gnome.org/");
- create_new_embed (GTK_NOTEBOOK (notebook), "http://www.google.com/");
+ append_new_welcome_embed (GTK_NOTEBOOK (notebook));
+ append_new_embed_with_url (GTK_NOTEBOOK (notebook),
+ "http://www.gnome.org/");
+}
+
+int
+main (int argc, char *argv[])
+{
+ gtk_init (&argc, &argv);
+
+ create_main_window ();
gtk_main ();
Modified: trunk/src/ie-bridge.cpp
==============================================================================
--- trunk/src/ie-bridge.cpp (original)
+++ trunk/src/ie-bridge.cpp Wed Jan 28 03:27:57 2009
@@ -748,30 +748,38 @@
void
_ie_bridge_load_html_from_string (IEBridge *ie, const gchar *string)
{
- IStream *stream;
- IPersistStreamInit *persist_stream = NULL;
IHTMLDocument2 *doc = NULL;
IEBridgePriv *priv = IE_BRIDGE_GET_PRIVATE (ie);
+ BSTR bstr = NULL;
+ VARIANT *param;
+ SAFEARRAY *sfArray;
if (!priv->web_browser)
return;
+ _ie_bridge_load_url (ie, "about:blank");
priv->web_browser->get_Document ((IDispatch **) &doc);
if (!doc)
return;
- CreateStreamOnHGlobal ((HGLOBAL) string, TRUE, &stream);
- if (stream) {
- doc->QueryInterface (IID_IPersistStreamInit, (void **) &persist_stream);
- if (persist_stream) {
- persist_stream->InitNew ();
- persist_stream->Load (stream);
- persist_stream->Release ();
- }
- stream->Release ();
+ bstr = _ie_utils_utf8_to_BSTR (string);
+ if (!bstr)
+ return;
+
+ sfArray = SafeArrayCreateVector (VT_VARIANT, 0, 1);
+ if (!sfArray) {
+ SysFreeString (bstr);
+ return;
}
- doc->Release ();
+ SafeArrayAccessData (sfArray, (LPVOID*) & param);
+ param->vt = VT_BSTR;
+ param->bstrVal = bstr;
+ SafeArrayUnaccessData (sfArray);
+ doc->write (sfArray);
+
+ SysFreeString (bstr);
+ SafeArrayDestroy (sfArray);
}
void
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]