gtkieembed r194 - in trunk: . src
- From: hiikezoe svn gnome org
- To: svn-commits-list gnome org
- Subject: gtkieembed r194 - in trunk: . src
- Date: Wed, 28 Jan 2009 01:56:53 +0000 (UTC)
Author: hiikezoe
Date: Wed Jan 28 01:56:52 2009
New Revision: 194
URL: http://svn.gnome.org/viewvc/gtkieembed?rev=194&view=rev
Log:
* src/ie-bridge.cpp: Use _ie_utils_BSTR_to_utf8 and
_ie_utils_utf8_to_BSTR since BSTR has also its length. Pointed out by
Ãngel GonzÃlez.
* src/ie-bridge.h: The second argument of title_changed,
location_changed, status_text_change is now a BSTR instead of
gunichar*.
Modified:
trunk/ChangeLog
trunk/src/ie-bridge.cpp
trunk/src/ie-bridge.h
trunk/src/ie-browser-event-dispatcher.cpp
Modified: trunk/src/ie-bridge.cpp
==============================================================================
--- trunk/src/ie-bridge.cpp (original)
+++ trunk/src/ie-bridge.cpp Wed Jan 28 01:56:52 2009
@@ -29,6 +29,7 @@
#include "gtk-ie-embed-private.h"
#include "ie-browser-event-dispatcher.h"
#include "ie-document-event-dispatcher.h"
+#include "ie-utils.h"
enum {
PROP_0,
@@ -303,19 +304,18 @@
_ie_bridge_load_url (IEBridge *ie, const gchar *url)
{
IEBridgePriv *priv = IE_BRIDGE_GET_PRIVATE (ie);
- gunichar2 *utf16_url;
+ BSTR bstrUrl;
if (!priv->web_browser)
return;
- utf16_url = g_utf8_to_utf16 (url, -1, NULL, NULL, NULL);
- if (utf16_url) {
- priv->web_browser->Navigate ((OLECHAR *) utf16_url, NULL, NULL, NULL, NULL);
- g_free (utf16_url);
+ bstrUrl = _ie_utils_utf8_to_BSTR (url);
+ if (bstrUrl) {
+ priv->web_browser->Navigate (bstrUrl, NULL, NULL, NULL, NULL);
+ SysFreeString (bstrUrl);
}
}
-
void
_ie_bridge_reload (IEBridge *ie, RefreshConstants flag)
{
@@ -383,7 +383,7 @@
BSTR URL;
priv->web_browser->get_LocationURL (&URL);
if (URL) {
- location = g_utf16_to_utf8 ((gunichar2 *) URL, -1, NULL, NULL, NULL);
+ location = _ie_utils_BSTR_to_utf8 (URL);
SysFreeString (URL);
}
}
@@ -401,7 +401,7 @@
BSTR Name;
priv->web_browser->get_LocationName (&Name);
if (Name) {
- title = g_utf16_to_utf8 ((gunichar2 *) Name, -1, NULL, NULL, NULL);
+ title = _ie_utils_BSTR_to_utf8 (Name);
SysFreeString (Name);
}
}
@@ -419,7 +419,7 @@
BSTR Charset = NULL;
priv->current_document->get_charset (&Charset);
if (Charset) {
- charset = g_utf16_to_utf8 ((gunichar2 *) Charset, -1, NULL, NULL, NULL);
+ charset = _ie_utils_BSTR_to_utf8 (Charset);
SysFreeString (Charset);
}
}
@@ -433,7 +433,7 @@
if (priv->web_browser) {
BSTR Charset;
- Charset = (BSTR) g_utf8_to_utf16 (charset, -1, NULL, NULL, NULL);
+ Charset = _ie_utils_utf8_to_BSTR (charset);
if (Charset) {
priv->current_document->put_charset (Charset);
SysFreeString (Charset);
@@ -607,7 +607,7 @@
return NULL;
doc->get_lastModified (&mTime);
if (mTime) {
- last_modified = g_utf16_to_utf8 ((gunichar2 *) mTime, -1, NULL, NULL, NULL);
+ last_modified = _ie_utils_BSTR_to_utf8 (mTime);
SysFreeString (mTime);
}
@@ -653,11 +653,11 @@
return NULL;
if (get_selected_text_range (priv->current_document, &text_range) &&
text_range) {
- BSTR selected_text;
- text_range->get_text (&selected_text);
- if (selected_text) {
- text = g_utf16_to_utf8 ((gunichar2 *) selected_text, -1, NULL, NULL, NULL);
- SysFreeString (selected_text);
+ BSTR selectedText = NULL;
+ text_range->get_text (&selectedText);
+ if (selectedText) {
+ text = _ie_utils_BSTR_to_utf8 (selectedText);
+ SysFreeString (selectedText);
}
text_range->Release();
}
@@ -698,41 +698,42 @@
if (get_selected_text_range (doc, &selected_range) && selected_range) {
long ActualCount;
gunichar2 *unit, *how;
- unit = g_utf8_to_utf16 ("character", -1, NULL, NULL, NULL);
+ BSTR Unit = NULL, How = NULL;
+ Unit = _ie_utils_utf8_to_BSTR ("character");
if (forward) {
- how = g_utf8_to_utf16 ("EndToEnd", -1, NULL, NULL, NULL);
- selected_range->moveStart ((OLECHAR *) unit, 1, &ActualCount);
+ How = _ie_utils_utf8_to_BSTR ("EndToEnd");
+ selected_range->moveStart (Unit, 1, &ActualCount);
} else {
- how = g_utf8_to_utf16 ("StartToStart", -1, NULL, NULL, NULL);
- selected_range->moveEnd ((OLECHAR *) unit, -1, &ActualCount);
+ How = _ie_utils_utf8_to_BSTR ("StartToStart");
+ selected_range->moveEnd (Unit, -1, &ActualCount);
}
- selected_range->setEndPoint ((OLECHAR *) how, text_range);
+ selected_range->setEndPoint (How, text_range);
text_range->Release ();
text_range = selected_range;
- g_free (unit);
- g_free (how);
+ SysFreeString (Unit);
+ SysFreeString (How);
}
if (text_range) {
- gunichar2 *utf16_string;
- utf16_string = g_utf8_to_utf16 (string, -1, NULL, NULL, NULL);
- if (utf16_string) {
+ BSTR bstr = NULL;
+ bstr = _ie_utils_utf8_to_BSTR (string);
+ if (bstr) {
VARIANT_BOOL vBool;
gint direction = forward ? 1 : -1;
- text_range->findText ((OLECHAR *) utf16_string, direction, 0, &vBool);
+ text_range->findText (bstr, direction, 0, &vBool);
if (vBool == VARIANT_TRUE) {
text_range->select ();
ret = TRUE;
} else if (selected_range && wrap) {
text_range->Release ();
body->createTextRange (&text_range);
- text_range->findText ((OLECHAR *) utf16_string, direction, 0, &vBool);
+ text_range->findText (bstr, direction, 0, &vBool);
if (vBool == VARIANT_TRUE) {
text_range->select ();
ret = TRUE;
}
}
- g_free (utf16_string);
+ SysFreeString (bstr);
}
text_range->Release ();
}
@@ -774,36 +775,39 @@
}
void
-_ie_bridge_title_changed (IEBridge *ie, gunichar2 *title)
+_ie_bridge_title_changed (IEBridge *ie, BSTR title)
{
gchar *utf8_title;
- IEBridgePriv *priv = IE_BRIDGE_GET_PRIVATE (ie);
- utf8_title = g_utf16_to_utf8 (title, -1, NULL, NULL, NULL);
+
+ utf8_title = _ie_utils_BSTR_to_utf8 (title);
if (utf8_title) {
+ IEBridgePriv *priv = IE_BRIDGE_GET_PRIVATE (ie);
g_signal_emit_by_name (priv->widget, "title", utf8_title);
g_free (utf8_title);
}
}
void
-_ie_bridge_location_changed (IEBridge *ie, gunichar2 *location)
+_ie_bridge_location_changed (IEBridge *ie, BSTR location)
{
gchar *utf8_location;
- IEBridgePriv *priv = IE_BRIDGE_GET_PRIVATE (ie);
- utf8_location = g_utf16_to_utf8 (location, -1, NULL, NULL, NULL);
+
+ utf8_location = _ie_utils_BSTR_to_utf8 (location);
if (utf8_location) {
+ IEBridgePriv *priv = IE_BRIDGE_GET_PRIVATE (ie);
g_signal_emit_by_name (priv->widget, "location", utf8_location);
g_free (utf8_location);
}
}
void
-_ie_bridge_status_text_change (IEBridge *ie, gunichar2 *text)
+_ie_bridge_status_text_change (IEBridge *ie, BSTR text)
{
gchar *utf8_text;
- IEBridgePriv *priv = IE_BRIDGE_GET_PRIVATE (ie);
- utf8_text = g_utf16_to_utf8 (text, -1, NULL, NULL, NULL);
+
+ utf8_text = _ie_utils_BSTR_to_utf8 (text);
if (utf8_text) {
+ IEBridgePriv *priv = IE_BRIDGE_GET_PRIVATE (ie);
g_signal_emit_by_name (priv->widget, "status-text", utf8_text);
g_free (utf8_text);
}
@@ -947,10 +951,10 @@
disp->QueryInterface (IID_IHTMLDOMAttribute, (IHTMLDOMAttribute **) &dom_attr);
dom_attr->get_nodeName (&nodeName);
dom_attr->get_nodeValue (&nodeValue);
- utf8_name = g_utf16_to_utf8 ((gunichar2 *) nodeName, -1, NULL, NULL, NULL);
- if (nodeValue.vt == VT_BSTR && nodeValue.bstrVal) {
- utf8_value = g_utf16_to_utf8 ((gunichar2 *) nodeValue.bstrVal, -1, NULL, NULL, NULL);
- }
+ utf8_name = _ie_utils_BSTR_to_utf8 (nodeName);
+ if (nodeValue.vt == VT_BSTR && nodeValue.bstrVal)
+ utf8_value = _ie_utils_BSTR_to_utf8 (nodeValue.bstrVal);
+
attr = g_slice_new0 (GtkIEEmbedDOMEventTargetAttribute);
attr->name = utf8_name;
attr->value = utf8_value;
@@ -964,21 +968,24 @@
node->Release ();
#else
/* workaround */
- VARIANT attr_value;
- gunichar2 *attr_name;
+ VARIANT attrValue;
+ BSTR attrName = NULL;
+
+ attrName = _ie_utils_utf8_to_BSTR ("href");
+ if (!attrName)
+ return;
- attr_name = g_utf8_to_utf16 ("href", -1, NULL, NULL, NULL);
- target_element->getAttribute ((OLECHAR *) attr_name, 0, &attr_value);
- if (attr_value.vt == VT_BSTR && attr_value.bstrVal) {
+ target_element->getAttribute (attrName, 0, &attrValue);
+ if (attrValue.vt == VT_BSTR && attrValue.bstrVal) {
gchar *value = NULL;
attr = g_slice_new0 (GtkIEEmbedDOMEventTargetAttribute);
attr->name = g_strdup ("href");
- value = g_utf16_to_utf8 ((gunichar2 *) attr_value.bstrVal, -1, NULL, NULL, NULL);
+ value = _ie_utils_BSTR_to_utf8 (attrValue.bstrVal);
if (value)
attr->value = value;
target->attribute_list = g_list_prepend (target->attribute_list, attr);
}
- g_free (attr_name);
+ SysFreeString (attrName);
#endif /* HAVE_IHTMLNODE */
}
@@ -986,16 +993,16 @@
_ie_bridge_create_dom_event_target (IHTMLElement *target_element)
{
GtkIEEmbedDOMEventTarget *target;
- BSTR tag_name = NULL;
+ BSTR tagName = NULL;
target = g_slice_new0 (GtkIEEmbedDOMEventTarget);
- target_element->get_tagName (&tag_name);
- if (tag_name) {
+ target_element->get_tagName (&tagName);
+ if (tagName) {
gchar *utf8_tag_name;
- utf8_tag_name = g_utf16_to_utf8 ((gunichar2 *) tag_name, -1, NULL, NULL, NULL);
+ utf8_tag_name = _ie_utils_BSTR_to_utf8 (tagName);
target->name = utf8_tag_name;
- SysFreeString (tag_name);
+ SysFreeString (tagName);
}
_set_dom_event_target_attributes (target, target_element);
@@ -1144,14 +1151,14 @@
continue;
link_element->get_rel (&relName);
if (relName) {
- utf8_name = g_utf16_to_utf8 ((gunichar2 *) relName, -1, NULL, NULL, NULL);
+ utf8_name = _ie_utils_BSTR_to_utf8 (relName);
if (!g_ascii_strcasecmp (utf8_name, "shortcut icon") ||
!g_ascii_strcasecmp (utf8_name, "icon")) {
BSTR href = NULL;
link_element->get_href (&href);
if (href) {
gchar *utf8_href;
- utf8_href = g_utf16_to_utf8 ((gunichar2 *) href, -1, NULL, NULL, NULL);
+ utf8_href = _ie_utils_BSTR_to_utf8 (href);
/* load a favicon */
SysFreeString (href);
g_free (utf8_href);
Modified: trunk/src/ie-bridge.h
==============================================================================
--- trunk/src/ie-bridge.h (original)
+++ trunk/src/ie-bridge.h Wed Jan 28 01:56:52 2009
@@ -23,6 +23,7 @@
#include <glib-object.h>
#include <gtk/gtkwidget.h>
#include "gtk-ie-embed.h"
+#include <windows.h>
G_BEGIN_DECLS
@@ -108,12 +109,12 @@
(IEBridge *ie,
const gchar *string);
void _ie_bridge_title_changed (IEBridge *ie,
- gunichar2 *title);
+ BSTR title);
void _ie_bridge_location_changed (IEBridge *ie,
- gunichar2 *location);
+ BSTR location);
void _ie_bridge_status_text_change
(IEBridge *ie,
- gunichar2 *text);
+ BSTR text);
void _ie_bridge_connect_document_event_dispatcher
(IEBridge *ie);
void _ie_bridge_disconnect_document_event_dispatcher
@@ -144,7 +145,7 @@
(IEBridge *ie);
void _ie_bridge_selection_changed
(IEBridge *ie);
-void _ie_bridge_load_favicon (IEBridge *ie);
+void _ie_bridge_load_favicon (IEBridge *ie);
G_END_DECLS
Modified: trunk/src/ie-browser-event-dispatcher.cpp
==============================================================================
--- trunk/src/ie-browser-event-dispatcher.cpp (original)
+++ trunk/src/ie-browser-event-dispatcher.cpp Wed Jan 28 01:56:52 2009
@@ -209,7 +209,7 @@
void
IEBrowserEventDispatcher::StatusTextChange (BSTR Text)
{
- _ie_bridge_status_text_change (mBridge, (gunichar2 *) Text);
+ _ie_bridge_status_text_change (mBridge, Text);
}
void
@@ -244,7 +244,7 @@
void
IEBrowserEventDispatcher::TitleChange (BSTR Title)
{
- _ie_bridge_title_changed (mBridge, (gunichar2 *) Title);
+ _ie_bridge_title_changed (mBridge, Title);
}
void
@@ -274,13 +274,12 @@
void
IEBrowserEventDispatcher::NavigateComplete2 (IDispatch *pDisp, VARIANT *URL)
{
- if (pDisp == _ie_bridge_get_browser_object (mBridge)) {
- _ie_bridge_location_changed (mBridge, (gunichar2 *) URL->pbstrVal);
- }
+ if (pDisp == _ie_bridge_get_browser_object (mBridge))
+ _ie_bridge_location_changed (mBridge, URL->bstrVal);
}
void
-IEBrowserEventDispatcher::DocumentComplete (IDispatch *wbDisp, VARIANT *url)
+IEBrowserEventDispatcher::DocumentComplete (IDispatch *wbDisp, VARIANT *URL)
{
/* Check wbDisp is not framed page */
if (wbDisp == _ie_bridge_get_browser_object (mBridge)) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]