gtkieembed r204 - in trunk: . src



Author: hiikezoe
Date: Tue Feb  3 00:16:43 2009
New Revision: 204
URL: http://svn.gnome.org/viewvc/gtkieembed?rev=204&view=rev

Log:
2009-02-03  Hiroyuki Ikezoe  <poincare ikezoe net>

	* src/gtk-ie-embed.[ch]: Added gtk_ie_embed_set_backward_history() and
	gtk_ie_embed_set_forward_history().
	* src/ie-bridge.[cpp|h]: Added ie_bridge_set_history().



Modified:
   trunk/ChangeLog
   trunk/src/gtk-ie-embed.c
   trunk/src/gtk-ie-embed.h
   trunk/src/gtkieembed.def
   trunk/src/ie-bridge.cpp
   trunk/src/ie-bridge.h
   trunk/src/ie-utils.h

Modified: trunk/src/gtk-ie-embed.c
==============================================================================
--- trunk/src/gtk-ie-embed.c	(original)
+++ trunk/src/gtk-ie-embed.c	Tue Feb  3 00:16:43 2009
@@ -756,6 +756,22 @@
     return priv->bridge ? _ie_bridge_get_history (priv->bridge, GTK_IE_EMBED_HISTORY_FORWARD) : NULL;
 }
 
+void
+gtk_ie_embed_set_backward_history (GtkIEEmbed *ie, const GList *history)
+{
+    GtkIEEmbedPriv *priv = GTK_IE_EMBED_GET_PRIVATE (ie);
+
+    return priv->bridge ? _ie_bridge_set_history (priv->bridge, GTK_IE_EMBED_HISTORY_BACKWARD, history) : NULL;
+}
+
+void
+gtk_ie_embed_set_forward_history (GtkIEEmbed *ie, const GList *history)
+{
+    GtkIEEmbedPriv *priv = GTK_IE_EMBED_GET_PRIVATE (ie);
+
+    return priv->bridge ? _ie_bridge_set_history (priv->bridge, GTK_IE_EMBED_HISTORY_FORWARD, history) : NULL;
+}
+
 const gchar *
 gtk_ie_embed_dom_event_target_get_name (GtkIEEmbedDOMEventTarget *target)
 {

Modified: trunk/src/gtk-ie-embed.h
==============================================================================
--- trunk/src/gtk-ie-embed.h	(original)
+++ trunk/src/gtk-ie-embed.h	Tue Feb  3 00:16:43 2009
@@ -158,6 +158,12 @@
                                          (GtkIEEmbed *ie);
 GList       *gtk_ie_embed_get_forward_history
                                          (GtkIEEmbed *ie);
+void         gtk_ie_embed_set_backward_history
+                                         (GtkIEEmbed *ie,
+                                          const GList *history);
+void         gtk_ie_embed_set_forward_history
+                                         (GtkIEEmbed *ie,
+                                          const GList *history);
 
 /* event target */
 const gchar *gtk_ie_embed_dom_event_target_get_name

Modified: trunk/src/gtkieembed.def
==============================================================================
--- trunk/src/gtkieembed.def	(original)
+++ trunk/src/gtkieembed.def	Tue Feb  3 00:16:43 2009
@@ -34,6 +34,8 @@
     gtk_ie_embed_find_string
     gtk_ie_embed_set_use_context_menu
     gtk_ie_embed_get_use_context_menu
+    gtk_ie_embed_get_backward_history
+    gtk_ie_embed_get_forward_history
     gtk_ie_embed_dom_event_target_get_name
     gtk_ie_embed_dom_event_target_get_attribute_value
     gtk_ie_embed_dom_event_target_get_attributes

Modified: trunk/src/ie-bridge.cpp
==============================================================================
--- trunk/src/ie-bridge.cpp	(original)
+++ trunk/src/ie-bridge.cpp	Tue Feb  3 00:16:43 2009
@@ -1194,17 +1194,13 @@
     collection->Release ();
 }
 
-GList *
-_ie_bridge_get_history (IEBridge *ie, GtkIEEmbedHistoryDirection direction)
-{
-    GList *history = NULL;
 #ifdef HAVE_TLOGSTG_H
+static ITravelLogStg *
+_get_travel_log (IEBridge *ie)
+{
     IServiceProvider *service_provider = NULL;    
     ITravelLogStg *travel_log = NULL;
-    IEnumTravelLogEntry *enum_entry = NULL;
-    ITravelLogEntry *entry = NULL;
     IEBridgePriv *priv = IE_BRIDGE_GET_PRIVATE (ie);
-    TLENUMF direction_flags = (direction == GTK_IE_EMBED_HISTORY_FORWARD) ? TLEF_RELATIVE_FORE : TLEF_RELATIVE_BACK;
 
     if (!priv->web_browser)
         return NULL;
@@ -1214,37 +1210,104 @@
         return NULL;
 
     service_provider->QueryService (SID_STravelLogCursor, IID_ITravelLogStg, (void**) &travel_log);
+    return travel_log;
+}
+#endif
+
+GList *
+_ie_bridge_get_history (IEBridge *ie, GtkIEEmbedHistoryDirection direction)
+{
+    GList *history = NULL;
+#ifdef HAVE_TLOGSTG_H
+    IServiceProvider *service_provider = NULL;    
+    ITravelLogStg *travel_log = NULL;
+    IEnumTravelLogEntry *enum_entry = NULL;
+    ITravelLogEntry *entry = NULL;
+    IEBridgePriv *priv = IE_BRIDGE_GET_PRIVATE (ie);
+    TLENUMF direction_flags = (direction == GTK_IE_EMBED_HISTORY_FORWARD) ? TLEF_RELATIVE_FORE : TLEF_RELATIVE_BACK;
+
+    travel_log = _get_travel_log (ie);
     if (!travel_log)
         return NULL;
 
     travel_log->EnumEntries (direction_flags, &enum_entry);
-    if (!enum_entry)
+    if (!enum_entry) {
+        travel_log->Release ();
         return NULL;
+    }
     
     while (enum_entry->Next (1, &entry, NULL) != S_FALSE) {
         LPOLESTR szURL, szTitle;
         gchar *uri, *title;
         GtkIEEmbedHistoryItem *history_item;
 
-        entry->GetURL(&szURL);
-        entry->GetTitle(&szTitle);
+        entry->GetURL (&szURL);
+        entry->GetTitle (&szTitle);
 
-        uri = g_utf16_to_utf8((gunichar2*) szURL, -1, NULL, NULL, NULL);
-        title = g_utf16_to_utf8((gunichar2*) szTitle, -1, NULL, NULL, NULL);
-        history_item = gtk_ie_embed_history_item_new(uri, title);
+        uri = g_utf16_to_utf8 ((gunichar2*) szURL, -1, NULL, NULL, NULL);
+        title = g_utf16_to_utf8 ((gunichar2*) szTitle, -1, NULL, NULL, NULL);
+        history_item = gtk_ie_embed_history_item_new (uri, title);
         history = g_list_append (history, history_item);
 
-        g_free(uri);
-        g_free(title);
-        CoTaskMemFree(szURL);
-        CoTaskMemFree(szTitle);
-        entry->Release();
+        g_free (uri);
+        g_free (title);
+        CoTaskMemFree (szURL);
+        CoTaskMemFree (szTitle);
+        entry->Release ();
         entry = NULL;
     }
+    travel_log->Release ();
+    enum_entry->Release ();
+
 #endif
     return history;
 }
 
+void
+_ie_bridge_set_history (IEBridge *ie, GtkIEEmbedHistoryDirection direction, const GList *history)
+{
+#ifdef HAVE_TLOGSTG_H
+    const GList *list;
+    ITravelLogStg *travel_log = NULL;
+    IEnumTravelLogEntry *enum_entry = NULL;
+    ITravelLogEntry *entry = NULL;
+    IEBridgePriv *priv = IE_BRIDGE_GET_PRIVATE (ie);
+    TLENUMF direction_flags = (direction == GTK_IE_EMBED_HISTORY_FORWARD) ? TLEF_RELATIVE_FORE : TLEF_RELATIVE_BACK;
+
+    travel_log = _get_travel_log (ie);
+    if (!travel_log)
+        return;
+
+    travel_log->EnumEntries (direction_flags, &enum_entry);
+    if (enum_entry) {
+        while (enum_entry->Next (1, &entry, NULL) != S_FALSE) {
+            travel_log->RemoveEntry (entry);
+            entry->Release ();
+            entry = NULL;
+        }
+    }
+    enum_entry->Release ();
+
+    for (list = history; list; list = g_list_next (list)) {
+        GtkIEEmbedHistoryItem *item = GTK_IE_EMBED_HISTORY_ITEM (list->data);
+        gunichar2 *utf16_uri, *utf16_title;
+
+        utf16_uri = g_utf8_to_utf16 (gtk_ie_embed_history_item_get_uri (item), -1,
+                                     NULL, NULL, NULL);
+        utf16_title = g_utf8_to_utf16 (gtk_ie_embed_history_item_get_title (item), -1,
+                                       NULL, NULL, NULL);
+        travel_log->CreateEntry ((LPOLESTR) utf16_uri, (LPOLESTR) utf16_title,
+                                 NULL, FALSE, &entry);
+
+        g_free (utf16_uri);
+        g_free (utf16_title);
+    }
+
+    travel_log->Release ();
+#endif
+}
+
+
 /*
 vi:ts=4:nowrap:ai:expandtab:sw=4
 */

Modified: trunk/src/ie-bridge.h
==============================================================================
--- trunk/src/ie-bridge.h	(original)
+++ trunk/src/ie-bridge.h	Tue Feb  3 00:16:43 2009
@@ -148,6 +148,9 @@
 void        _ie_bridge_load_favicon     (IEBridge *ie);
 GList      *_ie_bridge_get_history      (IEBridge *ie,
                                          GtkIEEmbedHistoryDirection direction);
+void        _ie_bridge_set_history      (IEBridge *ie,
+                                         GtkIEEmbedHistoryDirection direction,
+                                         const GList *history);
 
 G_END_DECLS
 

Modified: trunk/src/ie-utils.h
==============================================================================
--- trunk/src/ie-utils.h	(original)
+++ trunk/src/ie-utils.h	Tue Feb  3 00:16:43 2009
@@ -26,7 +26,6 @@
 G_BEGIN_DECLS
 
 gchar *_ie_utils_BSTR_to_utf8 (BSTR bstr);
-
 BSTR   _ie_utils_utf8_to_BSTR (const gchar *str);
 
 G_END_DECLS



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]